KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > js > JavaSourceObject


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.ws.jaxme.js;
17
18
19 /** This class implements a generic JavaSource object.
20  */

21 public abstract class JavaSourceObject extends IndentationEngineImpl {
22   protected JavaSourceObject(String JavaDoc pName, JavaQName pType, JavaSource.Protection pProtection) {
23     setName(pName);
24     setType(pType);
25     setProtection(pProtection);
26   }
27
28   protected JavaSourceObject(String JavaDoc pName, JavaQName pType) {
29     this(pName, pType, null);
30   }
31
32   protected JavaSourceObject(String JavaDoc pName, String JavaDoc pType, JavaSource.Protection pProtection) {
33     setName(pName);
34     if (pType == null) {
35       throw new NullPointerException JavaDoc("Type must not be null");
36     }
37     setType(JavaQNameImpl.getInstance(pType, true));
38     setProtection(pProtection);
39   }
40
41   protected JavaSourceObject(String JavaDoc pName, String JavaDoc pType) {
42     this(pName, pType, null);
43   }
44
45   private String JavaDoc name;
46   /** Returns this JavaSource objects name.
47    * @see #setName
48    */

49   public String JavaDoc getName() { return name; }
50   /** Sets this JavaSource objects name.
51    * @see #getName
52    */

53   public void setName(String JavaDoc n) { name = n; }
54
55   private boolean isFinal = false;
56   /** Returns whether this is a final JavaSource object.
57    *
58    * @see #setFinal
59    */

60   public boolean isFinal() { return isFinal; }
61   /** Sets whether this is a final JavaSource object.
62    *
63    * @see #isFinal
64    */

65   public void setFinal(boolean pFinal) { isFinal = pFinal; }
66
67   private boolean isStatic = false;
68   /** Returns whether this is a static JavaSource object.
69    * @see #setStatic
70    */

71   public boolean isStatic() { return isStatic; }
72   /** Sets whether this is a static JavaSource object.
73    * @see #isStatic
74    */

75   public void setStatic(boolean pStatic) { isStatic = pStatic; }
76
77   private JavaQName type;
78   /** Returns this JavaSource objects type.
79    * @see #setType
80    */

81   public JavaQName getType() { return type; }
82   /** Sets this JavaSource objects type.
83    * @see #getType
84    */

85   public void setType(JavaQName t) { type = t; }
86
87   private JavaSource.Protection protection = JavaSource.DEFAULT_PROTECTION;
88   /** Returns this JavaSource objects protection.
89    * @see #setProtection
90    */

91   public JavaSource.Protection getProtection() { return protection; }
92   /** Sets this JavaSource objects protection.
93    * @param p null, "public", "protected" or "private"
94    * @see #getProtection
95    */

96   public void setProtection(JavaSource.Protection p) {
97      protection = (p == null) ? JavaSource.DEFAULT_PROTECTION : p;
98   }
99
100   private JavaComment comment;
101   /** Returns a comment describing this JavaSource object.
102    * @see #newComment
103    */

104   public JavaComment getComment() { return comment; }
105   /** Creates a new Javadoc comment describing this JavaSource object.
106    * @see #getComment
107    */

108   public JavaComment newComment() {
109     if (comment == null) {
110        comment = new JavaComment();
111        return comment;
112      } else {
113        throw new IllegalStateException JavaDoc("A Javadoc comment has already been created for this object.");
114      }
115   }
116
117   private boolean bAbstract = false;
118   /** Returns whether this JavaSource object is abstract.
119    */

120   public boolean isAbstract() {
121     return bAbstract;
122   }
123   /** Sets whether this JavaSource object is abstract.
124    */

125   public void setAbstract(boolean isAbstract) {
126     this.bAbstract = isAbstract;
127   }
128
129   private JavaSource javaSource;
130   protected void setJavaSource(JavaSource pSource) {
131     javaSource = pSource;
132   }
133   /** Returns the class, to which this JavaSource object belongs.
134    */

135   public JavaSource getJavaSource() {
136     return javaSource;
137   }
138 }
Popular Tags