KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javacore > jmiimpl > javamodel > JavaDocImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.javacore.jmiimpl.javamodel;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.List JavaDoc;
23 import org.netbeans.jmi.javamodel.Element;
24 import org.netbeans.jmi.javamodel.JavaDoc;
25 import org.netbeans.jmi.javamodel.JavaModelPackage;
26 import org.netbeans.lib.java.parser.Token;
27 import org.netbeans.mdr.storagemodel.StorableObject;
28 import org.netbeans.modules.javacore.parser.ASTProvider;
29 import org.netbeans.modules.javacore.parser.MDRParser;
30 import org.openide.text.PositionBounds;
31
32 /**
33  * Implementation of JavaDoc object instance interface.
34  *
35  * @author Vladimir Hudec
36  */

37 public abstract class JavaDocImpl extends MetadataElement implements JavaDoc {
38
39     protected String JavaDoc text = null;
40     protected List JavaDoc tags = null;
41
42     private boolean isNew = false;
43     protected boolean childrenInited = false;
44
45
46     protected JavaDocImpl(StorableObject s) {
47         super(s);
48     }
49
50     protected final boolean isInitialized() {
51         return isNew;
52     }
53
54     /** Overriding methods must call super.setNew() */
55     protected void setNew() {
56         setChanged();
57         isNew = true;
58         childrenInited = true;
59     }
60
61     protected final boolean isNew() {
62         return isNew;
63     }
64
65     public List JavaDoc getChildren() {
66         return new ArrayList JavaDoc(getTags());
67     }
68     
69     public PositionBounds getPosition(boolean inclDoc) {
70         testResourceChange();
71         FeatureImpl feature=(FeatureImpl)refImmediateComposite();
72         ASTProvider p=feature.getParser();
73         Token javadocToken=p.getComment(feature.getASTree());
74
75         return p.createBounds(javadocToken.getStartOffset(), javadocToken.getEndOffset());
76     }
77     
78     /**
79      * Returns the value of attribute text.
80      * @return Value of attribute text.
81      */

82     public String JavaDoc getText() {
83         return text;
84     }
85
86     /**
87      * Sets the value of text attribute. See {@link #getText} for description
88      * on the attribute.
89      * @param newValue New value to be set.
90      */

91     public void setText(String JavaDoc newValue) {
92         objectChanged(CHANGED_JAVADOC);
93         this.text = newValue;
94     }
95
96     /**
97      * Returns the value of attribute tags.
98      * @return Value of tags attribute.
99      */

100     public List JavaDoc getTags() {
101         return tags;
102     }
103
104     void setData(String JavaDoc text, List JavaDoc tags) {
105         this.text = text;
106         this.tags = createChildrenList("tags", tags, CHANGED_JAVADOC); // NOI18N
107
}
108
109     protected java.lang.Object JavaDoc getInternalForm() {
110         return text;
111     }
112
113     /** Part ot the rollback mechanism.
114      *
115      * In the case of any rollback, all classes should be rebuilt from ASTrees.
116      * The layout for method is the next one:
117      * protected void reset() {
118      * .. do your own job...
119      * super.reset()
120      * }
121      */

122     protected final void rollback() {
123         // TODO: implement me
124
}
125     
126     public MDRParser getParser() {
127         return null;
128     }
129     
130     public Element duplicate(JavaModelPackage targetExtent) {
131         return targetExtent.getJavaDoc().createJavaDoc(getText(), duplicateList(getTags(), targetExtent));
132     }
133 }
134
Popular Tags