Clover coverage report - XJavaDoc - 1.1 Coverage timestamp: Sun Oct 3 2004 19:56:54 BST FRAMES NO FRAMES |
file stats: | LOC: | 271 |  | Methods: | 23
| NCLOC: | 191 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
AbstractProgramElement.java | 82.1% | 78.3% | 65.2% | 76.7% |

1 |  |
     /*
2 |  |
      * Copyright (c) 2001-2003 The XDoclet team
3 |  |
      * All rights reserved.
4 |  |
      */
5 |  |
     package xjavadoc;
6 |  |
7 |  |
     import java.lang.reflect.Modifier;
8 |  |
     import java.util.*;
9 |  |
10 |  |
     /**
11 |  |
      * Describe what this class does
12 |  |
      *
13 |  |
      * @author    Ara Abrahamian
14 |  |
      * @author    Aslak Hellesøy
15 |  |
      * @created   7. mars 2003
16 |  |
      */
17 |  |
     public abstract class AbstractProgramElement implements XProgramElement
18 |  |
     {
19 |  |
         final static List  EMPTY_LIST = Collections.unmodifiableList( new LinkedList() );
20 |  |
21 |  |
         private XJavaDoc _xJavaDoc;
22 |  |
         private AbstractClass _containingClass;
23 |  |
         private int        _modifiers = 0;
24 |  |
         private String     _modifierString;
25 |  |
         private XDoc       _doc;
26 |  |
         private Token      _token;
27 |  |
         private Token      _javadocToken;
28 |  |
         private final XTagFactory _tagFactory;
29 |  |
30 | 11616 |
         protected AbstractProgramElement( AbstractClass containingClass, XTagFactory tagFactory )
31 |  |
         {
32 | 11616 |
             _xJavaDoc = containingClass.getXJavaDoc();
33 | 11616 |
             _containingClass = containingClass;
34 | 11616 |
             _tagFactory = tagFactory;
35 |  |
         }
36 |  |
37 | 3308 |
         protected AbstractProgramElement( XJavaDoc xJavaDoc,  XTagFactory tagFactory )
38 |  |
         {
39 | 3308 |
             _xJavaDoc = xJavaDoc;
40 | 3308 |
             _containingClass = null;
41 | 3308 |
             _tagFactory = tagFactory;
42 |  |
         }
43 |  |
44 | 21696 |
         public XJavaDoc getXJavaDoc() {
45 | 21696 |
             return _xJavaDoc;
46 |  |
         }
47 |  |
48 | 0 |
         public final boolean isFinal()
49 |  |
         {
50 | 0 |
             return ( _modifiers & Modifier.FINAL ) != 0;
51 |  |
         }
52 |  |
53 | 0 |
         public final boolean isAbstract()
54 |  |
         {
55 | 0 |
             return ( _modifiers & Modifier.ABSTRACT ) != 0;
56 |  |
         }
57 |  |
58 | 0 |
         public final boolean isPackagePrivate()
59 |  |
         {
60 | 0 |
             return !isPrivate() && !isProtected() && !isPublic();
61 |  |
         }
62 |  |
63 | 36 |
         public final boolean isPrivate()
64 |  |
         {
65 | 36 |
             return ( _modifiers & Modifier.PRIVATE ) != 0;
66 |  |
         }
67 |  |
68 | 0 |
         public final boolean isProtected()
69 |  |
         {
70 | 0 |
             return ( _modifiers & Modifier.PROTECTED ) != 0;
71 |  |
         }
72 |  |
73 | 18 |
         public final boolean isPublic()
74 |  |
         {
75 | 18 |
             return ( _modifiers & Modifier.PUBLIC ) != 0;
76 |  |
         }
77 |  |
78 | 0 |
         public final boolean isStatic()
79 |  |
         {
80 | 0 |
             return ( _modifiers & Modifier.STATIC ) != 0;
81 |  |
         }
82 |  |
83 |  |
         /**
84 |  |
          * Get the doc. If this is a binary, primitive or unknown, null is returned.
85 |  |
          *
86 |  |
          * @return   the class level doc
87 |  |
          */
88 | 710 |
         public final XDoc getDoc()
89 |  |
         {
90 | 710 |
             if( _doc == null )
91 |  |
             {
92 | 698 |
                 if( _token == null )
93 |  |
                 {
94 |  |
                     // We're not from source (we're binary, primitive or unknown)
95 | 0 |
                     _doc = new XDoc( null, this, _tagFactory );
96 |  |
                 }
97 |  |
                 else
98 |  |
                 {
99 | 698 |
                     if( _javadocToken != null )
100 |  |
                     {
101 | 450 |
                         _doc = new XDoc( _javadocToken, this, _tagFactory );
102 |  |
                     }
103 |  |
                     else
104 |  |
                     {
105 |  |
                         // there was no doc in the original source. Create it.
106 |  |
                         // We have to create a new token and attach it to _token as specialToken
107 |  |
                         // The pre and post tokens are only to ensure proper line breaks before and after
108 | 248 |
                         Token preJavadocToken = Token.newToken( NodeParserConstants.DEFAULT );
109 |  |
110 | 248 |
                         preJavadocToken.image = "\n\n";
111 |  |
112 | 248 |
                         _javadocToken = Token.newToken( NodeParserConstants.FORMAL_COMMENT );
113 | 248 |
                         _javadocToken.image = "";
114 |  |
115 | 248 |
                         Token postJavadocToken = Token.newToken( NodeParserConstants.DEFAULT );
116 |  |
117 | 248 |
                         postJavadocToken.image = "\n";
118 |  |
119 |  |
                         // Link the new tokens properly
120 | 248 |
                         preJavadocToken.next = _javadocToken;
121 | 248 |
                         _javadocToken.next = postJavadocToken;
122 |  |
123 | 248 |
                         _token.specialToken = preJavadocToken;
124 | 248 |
                         _doc = new XDoc( _javadocToken, this, _tagFactory );
125 |  |
                     }
126 |  |
                 }
127 |  |
                 // Help the GC. We don't need the tokens anymore.
128 | 698 |
                 _token = null;
129 | 698 |
                 _javadocToken = null;
130 |  |
             }
131 | 710 |
             return _doc;
132 |  |
         }
133 |  |
134 |  |
         /**
135 |  |
          * Get modifiers string.
136 |  |
          *
137 |  |
          * @return
138 |  |
          */
139 | 16 |
         public final String getModifiers()
140 |  |
         {
141 | 16 |
             if( _modifierString == null )
142 |  |
             {
143 | 16 |
                 _modifierString = Modifier.toString( _modifiers );
144 |  |
             }
145 | 16 |
             return _modifierString;
146 |  |
         }
147 |  |
148 |  |
         /**
149 |  |
          * Get the modifier specifier integer.
150 |  |
          *
151 |  |
          * @return
152 |  |
          */
153 | 0 |
         public final int getModifierSpecifier()
154 |  |
         {
155 | 0 |
             return _modifiers;
156 |  |
         }
157 |  |
158 | 12942 |
         public final XClass getContainingClass()
159 |  |
         {
160 | 12942 |
             return getContainingAbstractClass();
161 |  |
         }
162 |  |
163 | 15862 |
         public final AbstractClass getContainingAbstractClass()
164 |  |
         {
165 | 15862 |
             return _containingClass;
166 |  |
         }
167 |  |
168 | 0 |
         public XPackage getContainingPackage()
169 |  |
         {
170 | 0 |
             if( _containingClass != null )
171 |  |
             {
172 | 0 |
                 return getContainingClass().getContainingPackage();
173 |  |
             }
174 |  |
             else
175 |  |
             {
176 | 0 |
                 return null;
177 |  |
             }
178 |  |
         }
179 |  |
180 |  |
         /**
181 |  |
          * Sets the Token where we start. Useful for doc mutation.
182 |  |
          *
183 |  |
          * @param token  The new Token value
184 |  |
          */
185 | 22268 |
         public final void setToken( Token token )
186 |  |
         {
187 | 22268 |
             if( _token == null && token != null )
188 |  |
             {
189 | 11760 |
                 _token = token;
190 | 11760 |
                 setJavaDoc();
191 |  |
             }
192 |  |
         }
193 |  |
194 | 16476 |
         public final void addModifier( int modifier )
195 |  |
         {
196 | 16476 |
             _modifiers |= modifier;
197 |  |
         }
198 |  |
199 | 2664 |
         public int compareTo( Object o )
200 |  |
         {
201 | 2664 |
             XProgramElement other = ( XProgramElement ) o;
202 |  |
203 | 2664 |
             return getName().compareTo( other.getName() );
204 |  |
         }
205 |  |
206 |  |
         /**
207 |  |
          * update javadoc
208 |  |
          */
209 | 152 |
         public void updateDoc()
210 |  |
         {
211 | 152 |
             if( _doc != null )
212 |  |
             {
213 | 8 |
                 _doc.updateToken();
214 |  |
             }
215 |  |
         }
216 |  |
217 | 684 |
         protected XTagFactory getTagFactory() {
218 | 684 |
             return _tagFactory;
219 |  |
         }
220 |  |
221 | 0 |
         void reset()
222 |  |
         {
223 | 0 |
             _doc = null;
224 | 0 |
             _containingClass = null;
225 | 0 |
             _token = null;
226 | 0 |
             _javadocToken = null;
227 |  |
         }
228 |  |
229 | 11760 |
         private final void setJavaDoc()
230 |  |
         {
231 | 11760 |
             Token javadoc = null;
232 |  |
233 | 11760 |
             Token tt = _token.specialToken;
234 |  |
235 | 11760 |
             if( tt != null )
236 |  |
             {
237 | 11754 |
                 while( tt.specialToken != null )
238 |  |
                 {
239 | 69224 |
                     tt = tt.specialToken;
240 |  |
                 }
241 | 11754 |
                 while( tt != null )
242 |  |
                 {
243 | 80978 |
                     if( tt.kind == NodeParserConstants.FORMAL_COMMENT )
244 |  |
                     {
245 |  |
                         // it's JavaDoc
246 | 5610 |
                         javadoc = tt;
247 |  |
                     }
248 | 75368 |
                     else if( tt.kind == NodeParserConstants.SINGLE_LINE_COMMENT || tt.kind == NodeParserConstants.MULTI_LINE_COMMENT )
249 |  |
                     {
250 |  |
                         // reset it. some other comment is standalone or followed what could have been a javadoc comment
251 | 128 |
                         javadoc = null;
252 |  |
                     }
253 | 80978 |
                     tt = tt.next;
254 |  |
                 }
255 |  |
             }
256 | 11760 |
             if( javadoc != null )
257 |  |
             {
258 |  |
                 // There was javadoc here!
259 | 5610 |
                 if( _doc != null )
260 |  |
                 {
261 | 0 |
                     throw new IllegalStateException( "Doc has already been set!!" );
262 |  |
                 }
263 |  |
                 else
264 |  |
                 {
265 | 5610 |
                     _javadocToken = javadoc;
266 |  |
                 }
267 |  |
             }
268 |  |
         }
269 |  |
270 |  |
     }
271 |  |