KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > codegen > JavaVariable


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: JavaVariable.java,v 1.1.1.1 2003/03/10 16:36:19 taweili Exp $
22  */

23
24 package org.enhydra.xml.xmlc.codegen;
25
26 import java.io.PrintWriter JavaDoc;
27
28 /**
29  * Base class for classes that describe variables.
30  * Objects of this class are immutable.
31  */

32 abstract public class JavaVariable {
33     /** Attributes of the variable */
34     protected String JavaDoc fName;
35     protected String JavaDoc fType;
36     protected int fModifiers;
37     protected String JavaDoc[] fDoc;
38
39     /**
40      * Constructor with doc array.
41      * @param name The variable name.
42      * @param type The variable type.
43      * @param modifiers The variable modifier bit set.
44      * @param doc The variable documentation, where each row is a line of the
45      * document. If null, no documention is created.
46      * @see JavaModifiers
47      */

48     public JavaVariable(String JavaDoc name,
49                         String JavaDoc type,
50                         int modifiers,
51                         String JavaDoc[] doc) {
52         fName = name;
53         fType = type;
54         fModifiers = modifiers;
55         if ((doc != null) && (doc.length > 0)) {
56             fDoc = (String JavaDoc[])doc.clone();
57         }
58     }
59
60     /**
61      * Constructor with doc string.
62      * @param name The variable name.
63      * @param type The variable type.
64      * @param modifiers The variable modifier bit set.
65      * @param doc The variable documentation.
66      * If null, no documention is created.
67      * @see JavaModifiers
68      */

69     public JavaVariable(String JavaDoc name,
70                         String JavaDoc type,
71                         int modifiers,
72                         String JavaDoc doc) {
73         this(name, type, modifiers,
74              (doc == null) ? null : new String JavaDoc[] {doc});
75     }
76
77     /**
78      * Get the name.
79      */

80     public String JavaDoc getName() {
81         return fName;
82     }
83
84     /**
85      * Get the type.
86      */

87     public String JavaDoc getType() {
88         return fType;
89     }
90
91     /**
92      * Get the modifiers.
93      */

94     public int getModifiers() {
95         return fModifiers;
96     }
97
98     /**
99      * Get the documentation, or null if there is none.
100      */

101     protected String JavaDoc[] getDoc() {
102         return fDoc;
103     }
104
105     /**
106      * Output the variable definition without a `;' terminator.
107      */

108     public void printDefinition(PrintWriter JavaDoc out) {
109         out.print(JavaModifiers.toDecl(fModifiers));
110         out.print(fType);
111         out.print(' ');
112         out.print(fName);
113     }
114 }
115
Popular Tags