001: /* ========================================================================
002: * JCommon : a free general purpose class library for the Java(tm) platform
003: * ========================================================================
004: *
005: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006: *
007: * Project Info: http://www.jfree.org/jcommon/index.html
008: *
009: * This library is free software; you can redistribute it and/or modify it
010: * under the terms of the GNU Lesser General Public License as published by
011: * the Free Software Foundation; either version 2.1 of the License, or
012: * (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but
015: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017: * License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022: * USA.
023: *
024: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025: * in the United States and other countries.]
026: *
027: * ---------------------
028: * ClassDescription.java
029: * ---------------------
030: * (C)opyright 2003, 2004, by Thomas Morgner and Contributors.
031: *
032: * Original Author: Thomas Morgner;
033: * Contributor(s): David Gilbert (for Object Refinery Limited);
034: *
035: * $Id: ClassDescription.java,v 1.2 2005/10/18 13:32:37 mungady Exp $
036: *
037: * Changes
038: * -------
039: * 21-Jun-2003 : Initial version (TM);
040: * 26-Nov-2003 : Updated header and Javadocs (DG);
041: *
042: */
043:
044: package org.jfree.xml.generator.model;
045:
046: /**
047: * A description of a Java class.
048: */
049: public class ClassDescription {
050:
051: /** Storage for info about properties. */
052: private PropertyInfo[] properties;
053:
054: /** Constructor descriptions. */
055: private TypeInfo[] constructorDescription;
056:
057: /** The class. */
058: private Class objectClass;
059:
060: /** A description. */
061: private String description;
062:
063: /** The register key. */
064: private String registerKey;
065:
066: /** The super class. */
067: private Class super Class;
068:
069: /** ??. */
070: private boolean preserve;
071:
072: /** The comments. */
073: private Comments comments;
074:
075: /** The source. */
076: private String source;
077:
078: /**
079: * Creates a new class description.
080: *
081: * @param objectClass the class.
082: */
083: public ClassDescription(final Class objectClass) {
084: if (objectClass == null) {
085: throw new NullPointerException();
086: }
087: this .objectClass = objectClass;
088: }
089:
090: /**
091: * Returns the info about properties.
092: *
093: * @return the info about properties.
094: */
095: public PropertyInfo[] getProperties() {
096: return this .properties;
097: }
098:
099: /**
100: * Sets the info about the class properties.
101: *
102: * @param properties the properties.
103: */
104: public void setProperties(final PropertyInfo[] properties) {
105: this .properties = properties;
106: }
107:
108: /**
109: * Returns the object's class.
110: *
111: * @return the object's class.
112: */
113: public Class getObjectClass() {
114: return this .objectClass;
115: }
116:
117: /**
118: * Returns the description.
119: *
120: * @return the description.
121: */
122: public String getDescription() {
123: return this .description;
124: }
125:
126: /**
127: * Sets the description for the object.
128: *
129: * @param description the description.
130: */
131: public void setDescription(final String description) {
132: this .description = description;
133: }
134:
135: /**
136: * Returns the class name.
137: *
138: * @return the class name.
139: */
140: public String getName() {
141: if (getObjectClass() == null) {
142: return null;
143: }
144: return getObjectClass().getName();
145: }
146:
147: /**
148: * Returns the super class.
149: *
150: * @return the super class.
151: */
152: public Class getSuperClass() {
153: return this .super Class;
154: }
155:
156: /**
157: * Sets the super class.
158: *
159: * @param superClass the super class.
160: */
161: public void setSuperClass(final Class super Class) {
162: this .super Class = super Class;
163: }
164:
165: /**
166: * Returns the preserve flag.
167: *
168: * @return a boolean.
169: */
170: public boolean isPreserve() {
171: return this .preserve;
172: }
173:
174: /**
175: * Sets the preserve flag.
176: *
177: * @param preserve the new value of the flag.
178: */
179: public void setPreserve(final boolean preserve) {
180: this .preserve = preserve;
181: }
182:
183: /**
184: * Returns the register key.
185: *
186: * @return the register key.
187: */
188: public String getRegisterKey() {
189: return this .registerKey;
190: }
191:
192: /**
193: * Sets the register key.
194: *
195: * @param registerKey the register key.
196: */
197: public void setRegisterKey(final String registerKey) {
198: this .registerKey = registerKey;
199: }
200:
201: /**
202: * Returns the constructor descriptions.
203: *
204: * @return the constructor descriptions.
205: */
206: public TypeInfo[] getConstructorDescription() {
207: return this .constructorDescription;
208: }
209:
210: /**
211: * Sets the constructor description.
212: *
213: * @param constructorDescription the constructor description.
214: */
215: public void setConstructorDescription(
216: final TypeInfo[] constructorDescription) {
217: this .constructorDescription = constructorDescription;
218: }
219:
220: /**
221: * Returns a property.
222: *
223: * @param name the property name.
224: *
225: * @return a property.
226: */
227: public PropertyInfo getProperty(final String name) {
228: if (this .properties == null) {
229: return null;
230: }
231: for (int i = 0; i < this .properties.length; i++) {
232: if (this .properties[i].getName().equals(name)) {
233: return this .properties[i];
234: }
235: }
236: return null;
237: }
238:
239: /**
240: * Returns <code>true</code> if the description is undefined.
241: *
242: * @return a boolean.
243: */
244: public boolean isUndefined() {
245: if (this .properties != null) {
246: if (this .properties.length > 0) {
247: return false;
248: }
249: }
250: if (isPreserve()) {
251: return false;
252: }
253: if (getRegisterKey() != null) {
254: return false;
255: }
256: if (getConstructorDescription() != null) {
257: if (getConstructorDescription().length > 0) {
258: return false;
259: }
260: }
261: return true;
262: }
263:
264: /**
265: * Returns the comments for the class description.
266: *
267: * @return The comments.
268: */
269: public Comments getComments() {
270: return this .comments;
271: }
272:
273: /**
274: * Sets the comments for the class description.
275: *
276: * @param comments the comments.
277: */
278: public void setComments(final Comments comments) {
279: this .comments = comments;
280: }
281:
282: /**
283: * Returns the source for the class description.
284: *
285: * @return The source.
286: */
287: public String getSource() {
288: return this .source;
289: }
290:
291: /**
292: * Sets the source for the class description.
293: *
294: * @param source the source.
295: */
296: public void setSource(final String source) {
297: this.source = source;
298: }
299:
300: }
|