You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FieldDocImpl.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * This file is part of the debugger and core tools for the AspectJ(tm)
  4. * programming language; see http://aspectj.org
  5. *
  6. * The contents of this file are subject to the Mozilla Public License
  7. * Version 1.1 (the "License"); you may not use this file except in
  8. * compliance with the License. You may obtain a copy of the License at
  9. * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is AspectJ.
  17. *
  18. * The Initial Developer of the Original Code is Xerox Corporation. Portions
  19. * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
  20. * All Rights Reserved.
  21. */
  22. package org.aspectj.tools.ajdoc;
  23. import org.aspectj.compiler.base.ast.Dec;
  24. import org.aspectj.compiler.base.ast.FieldDec;
  25. import com.sun.javadoc.ClassDoc;
  26. import com.sun.javadoc.SerialFieldTag;
  27. import java.lang.reflect.Modifier;
  28. public class FieldDocImpl
  29. extends MemberDocImpl
  30. implements org.aspectj.ajdoc.FieldDoc {
  31. /** The FieldDec that corresponds to this FieldDoc. */
  32. private final FieldDec field;
  33. /**
  34. * The type of this field. This can't be set initially
  35. * because the compiler doesn't resolve the types for
  36. * introductions, yet, so we have to allow others to set it.
  37. */
  38. private org.aspectj.compiler.base.ast.Type type;
  39. /**
  40. * Sets the org.apectj.compiler.base.ast.Type used to return
  41. * the com.sun.javadoc.Type.
  42. *
  43. * @param type the new org.aspectj.compiler.base.ast.Type used
  44. * to find the com.sun.javadoc.Type.
  45. * @hack This is only needed because of unresolved
  46. * introduced fields.
  47. */
  48. public void setType(org.aspectj.compiler.base.ast.Type type) {
  49. this.type = type;
  50. }
  51. public FieldDocImpl(ClassDoc containingClass, FieldDec field) {
  52. super(containingClass);
  53. this.field = field;
  54. setType(field.getType());
  55. }
  56. protected Dec dec() {
  57. return field;
  58. }
  59. protected FieldDec fieldDec() {
  60. return field;
  61. }
  62. /**
  63. * Returns <code>true</code>.
  64. *
  65. * @return <code>true</code>.
  66. */
  67. public boolean isField() {
  68. return true;
  69. }
  70. /**
  71. * Returns the type of this field.
  72. *
  73. * @return the type of this field.
  74. */
  75. public com.sun.javadoc.Type type() {
  76. return TypeImpl.getInstance(type);
  77. }
  78. /**
  79. * Return <code>true</code> is this field is <code>volatile</code>.
  80. *
  81. * @return <code>true</code> is this field is <code>volatile</code>.
  82. */
  83. public boolean isVolatile() {
  84. return Modifier.isVolatile(modifierSpecifier());
  85. }
  86. /**
  87. * Return <code>true</code> is this field is <code>transient</code>.
  88. *
  89. * @return <code>true</code> is this field is <code>transient</code>.
  90. */
  91. public boolean isTransient() {
  92. return Modifier.isTransient(modifierSpecifier());
  93. }
  94. /**
  95. * Returns the serial field tags for this field.
  96. *
  97. * @return an array of SerialFieldTag representing the
  98. * serial field tags for this field.
  99. */
  100. public SerialFieldTag[] serialFieldTags() {
  101. return getComment().serialFieldTags();
  102. }
  103. /**
  104. * Returns the name of the field.
  105. *
  106. * @return the name of the field.
  107. */
  108. public String toString() {
  109. return name();
  110. }
  111. /**
  112. * Returns <code>true</code> is <code>md</code> is a
  113. * FieldDocImpl and has the same name.
  114. *
  115. * @return <code>true</code> is <code>md</code> is a
  116. * FieldDocImpl and has the same name.
  117. */
  118. public boolean weakEquals(Object md) {
  119. if (!(md instanceof FieldDocImpl)) return false;
  120. return name().equals(((FieldDocImpl)md).name());
  121. }
  122. }