/plugins/JavaSideKick/tags/javasidekick-2-4-0/src/sidekick/java/node/NameNode.java

# · Java · 64 lines · 20 code · 8 blank · 36 comment · 3 complexity · 419be840bf3f6ea161d10013c4a914e3 MD5 · raw file

  1. /*
  2. Copyright (c) 2005, Dale Anson
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without modification,
  5. are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright notice,
  7. this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright notice,
  9. this list of conditions and the following disclaimer in the documentation
  10. and/or other materials provided with the distribution.
  11. * Neither the name of the <ORGANIZATION> nor the names of its contributors
  12. may be used to endorse or promote products derived from this software without
  13. specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  18. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  21. ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. package sidekick.java.node;
  26. /**
  27. * Represents some sort of named object in the sense of JLS 6.5.6. This could
  28. * represent a package name in an import statement, e.g. the 'java.util.*' part
  29. * of 'import java.util.*;' or a static method in a class, e.g. 'GUIUtilities.centerOnScreen'.
  30. * To help differentiate these names in the proper context, everything from the
  31. * start of the name to the last '.' is used as the Type of this node, everything
  32. * after the last '.' is the name of this node. The dot is lost. Note that the
  33. * Type may be null, but the name should never be null.
  34. */
  35. public class NameNode extends TigerNode {
  36. public NameNode() {
  37. }
  38. public NameNode(String name, Type type) {
  39. setName(name);
  40. setType(type);
  41. }
  42. public String getFullyQualifiedTypeName() {
  43. String type = getType();
  44. String rtn = getName();
  45. if (type != null && type.length() > 0) {
  46. rtn = type + "." + rtn;
  47. }
  48. return rtn;
  49. }
  50. public String toString() {
  51. return getFullyQualifiedTypeName();
  52. }
  53. }