KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > tools > ajdoc > SerialFieldTagImpl


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
24 import com.sun.javadoc.ClassDoc;
25 import com.sun.javadoc.Doc;
26 import com.sun.javadoc.SerialFieldTag;
27
28 import java.util.Locale JavaDoc;
29
30 /**
31  * Represents a serial field tag in the aspectj-world.
32  *
33  * @author Jeff Palm
34  */

35 public class SerialFieldTagImpl
36     extends TagImpl implements SerialFieldTag,
37                                Comparable JavaDoc {
38
39     private String JavaDoc description;
40     private String JavaDoc fieldName;
41     private String JavaDoc fieldType;
42     private ClassDoc fieldTypeDoc;
43
44     /**
45      * Constructs the new tag with given parameters and
46      * then tries to resolve the names of the text.
47      *
48      * @param doc the new value for <code>doc</code>.
49      * @param name the new value for <code>name</code>.
50      * @param text the new value for <code>text</code>.
51      * @param locale the new value for <code>locale</code>.
52      * @param err the new value for <code>err</code>.
53      */

54     public SerialFieldTagImpl(Doc doc,
55                               String JavaDoc name,
56                               String JavaDoc text,
57                               Locale JavaDoc loc,
58                               ErrPrinter err) {
59         super(doc, name, text, loc, err);
60         resolveNames(text);
61     }
62
63     /**
64      * Returns the description.
65      *
66      * @return the description.
67      */

68     public String JavaDoc description() {
69         return description;
70     }
71
72     /**
73      * Returns the field name.
74      *
75      * @return the field name.
76      */

77     public String JavaDoc fieldName() {
78         return fieldName;
79     }
80
81     /**
82      * Returns the field type.
83      *
84      * @return the field type.
85      */

86     public String JavaDoc fieldType() {
87         return fieldType;
88     }
89
90     /**
91      * Returns the class of the field type.
92      *
93      * @return a ClassDoc with type name fieldType.
94      */

95     public ClassDoc fieldTypeDoc() {
96         return fieldTypeDoc;
97     }
98
99     //XXX
100
//TODO: implement
101
public int compareTo(Object JavaDoc other) {
102         return -1;
103     }
104     
105     /**
106      * Returns <code>serialField</code>.
107      *
108      * @return <code>serialField</code>.
109      */

110     public String JavaDoc kind() {
111         return "@serialField";
112     }
113     
114     
115     private void resolveNames(String JavaDoc str) {
116         //
117
// @serialField field-name field-type field-description
118
//
119
if (str == null || (str = str.trim()).length() < 1) return;
120         final int N = str.length();
121         
122         int i = 0;
123         int start;
124
125         // Find the first char in the field-name
126
start = i;
127         if (i < N && !start(str.charAt(i++))) {
128             err().error("serialField_tag_invalid_field_name_start",
129                         ""+str.charAt(i));
130             return;
131         }
132
133         // Find the rest of the field-name
134
while (i < N && !space(str.charAt(i))) {
135             if (!ident(str.charAt(i))) {
136                 err().error("serialField_tag_invalid_field_name_part",
137                             ""+str.charAt(i));
138                 return;
139             }
140             i++;
141         }
142
143         // Found the field-name
144
fieldName = str.substring(start, i).trim();
145
146         // Find the first char in the field-type
147
start = i;
148         if (i < N && !start(str.charAt(i++))) {
149             err().error("serialField_tag_invalid_type_name_start",
150                         ""+str.charAt(i));
151             return;
152         }
153
154         // Find the rest of the field-name
155
while (i < N && !space(str.charAt(i))) {
156             if (!(str.charAt(i) == '[' ||
157                   str.charAt(i) == ']' ||
158                   ident(str.charAt(i)))) {
159                 err().error("serialField_tag_invalid_type_name_part",
160                             ""+str.charAt(i));
161                 return;
162             }
163         }
164
165         // Found the field-type
166
fieldType = str.substring(start, i).trim();
167
168         // The rest is the field-description
169
if (i < N) {
170             description = str.substring(i).trim();
171         }
172     }
173 }
174
Popular Tags