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.

SerialFieldTagImpl.java 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 com.sun.javadoc.ClassDoc;
  24. import com.sun.javadoc.Doc;
  25. import com.sun.javadoc.SerialFieldTag;
  26. import java.util.Locale;
  27. /**
  28. * Represents a serial field tag in the aspectj-world.
  29. *
  30. * @author Jeff Palm
  31. */
  32. public class SerialFieldTagImpl
  33. extends TagImpl implements SerialFieldTag,
  34. Comparable {
  35. private String description;
  36. private String fieldName;
  37. private String fieldType;
  38. private ClassDoc fieldTypeDoc;
  39. /**
  40. * Constructs the new tag with given parameters and
  41. * then tries to resolve the names of the text.
  42. *
  43. * @param doc the new value for <code>doc</code>.
  44. * @param name the new value for <code>name</code>.
  45. * @param text the new value for <code>text</code>.
  46. * @param locale the new value for <code>locale</code>.
  47. * @param err the new value for <code>err</code>.
  48. */
  49. public SerialFieldTagImpl(Doc doc,
  50. String name,
  51. String text,
  52. Locale loc,
  53. ErrPrinter err) {
  54. super(doc, name, text, loc, err);
  55. resolveNames(text);
  56. }
  57. /**
  58. * Returns the description.
  59. *
  60. * @return the description.
  61. */
  62. public String description() {
  63. return description;
  64. }
  65. /**
  66. * Returns the field name.
  67. *
  68. * @return the field name.
  69. */
  70. public String fieldName() {
  71. return fieldName;
  72. }
  73. /**
  74. * Returns the field type.
  75. *
  76. * @return the field type.
  77. */
  78. public String fieldType() {
  79. return fieldType;
  80. }
  81. /**
  82. * Returns the class of the field type.
  83. *
  84. * @return a ClassDoc with type name fieldType.
  85. */
  86. public ClassDoc fieldTypeDoc() {
  87. return fieldTypeDoc;
  88. }
  89. //XXX
  90. //TODO: implement
  91. public int compareTo(Object other) {
  92. return -1;
  93. }
  94. /**
  95. * Returns <code>serialField</code>.
  96. *
  97. * @return <code>serialField</code>.
  98. */
  99. public String kind() {
  100. return "@serialField";
  101. }
  102. private void resolveNames(String str) {
  103. //
  104. // @serialField field-name field-type field-description
  105. //
  106. if (str == null || (str = str.trim()).length() < 1) return;
  107. final int N = str.length();
  108. int i = 0;
  109. int start;
  110. // Find the first char in the field-name
  111. start = i;
  112. if (i < N && !start(str.charAt(i++))) {
  113. err().error("serialField_tag_invalid_field_name_start",
  114. ""+str.charAt(i));
  115. return;
  116. }
  117. // Find the rest of the field-name
  118. while (i < N && !space(str.charAt(i))) {
  119. if (!ident(str.charAt(i))) {
  120. err().error("serialField_tag_invalid_field_name_part",
  121. ""+str.charAt(i));
  122. return;
  123. }
  124. i++;
  125. }
  126. // Found the field-name
  127. fieldName = str.substring(start, i).trim();
  128. // Find the first char in the field-type
  129. start = i;
  130. if (i < N && !start(str.charAt(i++))) {
  131. err().error("serialField_tag_invalid_type_name_start",
  132. ""+str.charAt(i));
  133. return;
  134. }
  135. // Find the rest of the field-name
  136. while (i < N && !space(str.charAt(i))) {
  137. if (!(str.charAt(i) == '[' ||
  138. str.charAt(i) == ']' ||
  139. ident(str.charAt(i)))) {
  140. err().error("serialField_tag_invalid_type_name_part",
  141. ""+str.charAt(i));
  142. return;
  143. }
  144. }
  145. // Found the field-type
  146. fieldType = str.substring(start, i).trim();
  147. // The rest is the field-description
  148. if (i < N) {
  149. description = str.substring(i).trim();
  150. }
  151. }
  152. }