KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > doc > javadoc > JavadocItem


1 /*
2  * Copyright (c) 1998-2003 Caucho Technology -- all rights reserved
3  *
4  * Caucho Technology permits redistribution, modification and use
5  * of this file in source and binary form ("the Software") under the
6  * Caucho Developer Source License ("the License"). The following
7  * conditions must be met:
8  *
9  * 1. Each copy or derived work of the Software must preserve the copyright
10  * notice and this notice unmodified.
11  *
12  * 2. Redistributions of the Software in source or binary form must include
13  * an unmodified copy of the License, normally in a plain ASCII text
14  *
15  * 3. The names "Resin" or "Caucho" are trademarks of Caucho Technology and
16  * may not be used to endorse products derived from this software.
17  * "Resin" or "Caucho" may not appear in the names of products derived
18  * from this software.
19  *
20  * This Software is provided "AS IS," without a warranty of any kind.
21  * ALL EXPRESS OR IMPLIED REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
22  * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
23  * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
24  *
25  * CAUCHO TECHNOLOGY AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
26  * SUFFERED BY LICENSEE OR ANY THIRD PARTY AS A RESULT OF USING OR
27  * DISTRIBUTING SOFTWARE. IN NO EVENT WILL CAUCHO OR ITS LICENSORS BE LIABLE
28  * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
29  * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
30  * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
31  * INABILITY TO USE SOFTWARE, EVEN IF HE HAS BEEN ADVISED OF THE POSSIBILITY
32  * OF SUCH DAMAGES.
33  *
34  * @author Sam
35  */

36
37 package com.caucho.doc.javadoc;
38
39 import com.caucho.log.Log;
40 import com.caucho.util.CharBuffer;
41 import com.caucho.util.L10N;
42
43 import java.util.logging.Logger JavaDoc;
44
45 /**
46  * A single javadoc item, a package, class, member, or method.
47  */

48 public class JavadocItem {
49   static protected final Logger JavaDoc log = Log.open(JavadocItem.class);
50   static final L10N L = new L10N(JavadocItem.class);
51
52   public final static int PACKAGE=0x01;
53   public final static int CLASS=0x02;
54   public final static int METHOD=0x04;
55   public final static int VARIABLE=0x08;
56   public final static int ANY=PACKAGE | CLASS | METHOD | VARIABLE;
57
58   String JavaDoc _name;
59   String JavaDoc _fullName;
60   int _type;
61   JavadocFile _file;
62   String JavaDoc _anchor;
63   String JavaDoc _description;
64
65   boolean _exact = false;
66
67   public JavadocItem(String JavaDoc name, String JavaDoc fullName, int type, String JavaDoc anchor, String JavaDoc description, JavadocFile file)
68   {
69     _name = name;
70     _fullName = fullName;
71     _type = type;
72     _file = file;
73     _anchor = anchor;
74     _description = description;
75   }
76
77   public String JavaDoc getName()
78   {
79     return _name;
80   }
81
82   public String JavaDoc getFullName()
83   {
84     return _fullName;
85   }
86
87   public int getType()
88   {
89     return _type;
90   }
91
92   public String JavaDoc getTypeString()
93   {
94     switch (_type) {
95       case PACKAGE:
96         return "package";
97       case CLASS:
98         return "class";
99       case METHOD:
100         return "method";
101       case VARIABLE:
102         return "var";
103     }
104     return "unknown";
105   }
106
107   public JavadocFile getFile()
108   {
109     return _file;
110   }
111
112   public String JavaDoc getAnchor()
113   {
114     return _anchor;
115   }
116
117   public String JavaDoc getDescription()
118   {
119     return _description;
120   }
121
122   void setExact(boolean exact)
123   {
124     _exact = exact;
125   }
126
127   /**
128    * If this JavadocItem is generated as a result of a query, it may be flagged
129    * as exact to indicate that it would be appropriate for this item to be
130    * displayed automatically.
131    */

132   public boolean getExact()
133   {
134     return _exact;
135   }
136
137   public String JavaDoc getHref()
138   {
139     CharBuffer cb = CharBuffer.allocate();
140     cb.append(_file.getHref());
141     if (_anchor != null) {
142       cb.append('#');
143       cb.append(_anchor);
144     }
145     return cb.close();
146   }
147 }
148
149
Popular Tags