Frames | No Frames |
1: /* ======================================================================== 2: * JCommon : a free general purpose class library for the Java(tm) platform 3: * ======================================================================== 4: * 5: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. 6: * 7: * Project Info: http://www.jfree.org/jcommon/index.html 8: * 9: * This library is free software; you can redistribute it and/or modify it 10: * under the terms of the GNU Lesser General Public License as published by 11: * the Free Software Foundation; either version 2.1 of the License, or 12: * (at your option) any later version. 13: * 14: * This library is distributed in the hope that it will be useful, but 15: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17: * License for more details. 18: * 19: * You should have received a copy of the GNU Lesser General Public 20: * License along with this library; if not, write to the Free Software 21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 22: * USA. 23: * 24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 25: * in the United States and other countries.] 26: * 27: * --------------------- 28: * ClassDescription.java 29: * --------------------- 30: * (C)opyright 2003, 2004, by Thomas Morgner and Contributors. 31: * 32: * Original Author: Thomas Morgner; 33: * Contributor(s): David Gilbert (for Object Refinery Limited); 34: * 35: * $Id: ClassDescription.java,v 1.2 2005/10/18 13:32:37 mungady Exp $ 36: * 37: * Changes 38: * ------- 39: * 21-Jun-2003 : Initial version (TM); 40: * 26-Nov-2003 : Updated header and Javadocs (DG); 41: * 42: */ 43: 44: package org.jfree.xml.generator.model; 45: 46: /** 47: * A description of a Java class. 48: */ 49: public class ClassDescription { 50: 51: /** Storage for info about properties. */ 52: private PropertyInfo[] properties; 53: 54: /** Constructor descriptions. */ 55: private TypeInfo[] constructorDescription; 56: 57: /** The class. */ 58: private Class objectClass; 59: 60: /** A description. */ 61: private String description; 62: 63: /** The register key. */ 64: private String registerKey; 65: 66: /** The super class. */ 67: private Class superClass; 68: 69: /** ??. */ 70: private boolean preserve; 71: 72: /** The comments. */ 73: private Comments comments; 74: 75: /** The source. */ 76: private String source; 77: 78: /** 79: * Creates a new class description. 80: * 81: * @param objectClass the class. 82: */ 83: public ClassDescription(final Class objectClass) { 84: if (objectClass == null) { 85: throw new NullPointerException(); 86: } 87: this.objectClass = objectClass; 88: } 89: 90: /** 91: * Returns the info about properties. 92: * 93: * @return the info about properties. 94: */ 95: public PropertyInfo[] getProperties() { 96: return this.properties; 97: } 98: 99: /** 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.superClass; 154: } 155: 156: /** 157: * Sets the super class. 158: * 159: * @param superClass the super class. 160: */ 161: public void setSuperClass(final Class superClass) { 162: this.superClass = superClass; 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(final TypeInfo[] constructorDescription) { 216: this.constructorDescription = constructorDescription; 217: } 218: 219: /** 220: * Returns a property. 221: * 222: * @param name the property name. 223: * 224: * @return a property. 225: */ 226: public PropertyInfo getProperty (final String name) { 227: if (this.properties == null) { 228: return null; 229: } 230: for (int i = 0; i < this.properties.length; i++) { 231: if (this.properties[i].getName().equals(name)) { 232: return this.properties[i]; 233: } 234: } 235: return null; 236: } 237: 238: /** 239: * Returns <code>true</code> if the description is undefined. 240: * 241: * @return a boolean. 242: */ 243: public boolean isUndefined() { 244: if (this.properties != null) { 245: if (this.properties.length > 0) { 246: return false; 247: } 248: } 249: if (isPreserve()) { 250: return false; 251: } 252: if (getRegisterKey() != null) { 253: return false; 254: } 255: if (getConstructorDescription() != null) { 256: if (getConstructorDescription().length > 0) { 257: return false; 258: } 259: } 260: return true; 261: } 262: 263: /** 264: * Returns the comments for the class description. 265: * 266: * @return The comments. 267: */ 268: public Comments getComments() { 269: return this.comments; 270: } 271: 272: /** 273: * Sets the comments for the class description. 274: * 275: * @param comments the comments. 276: */ 277: public void setComments(final Comments comments) { 278: this.comments = comments; 279: } 280: 281: /** 282: * Returns the source for the class description. 283: * 284: * @return The source. 285: */ 286: public String getSource() { 287: return this.source; 288: } 289: 290: /** 291: * Sets the source for the class description. 292: * 293: * @param source the source. 294: */ 295: public void setSource(final String source) { 296: this.source = source; 297: } 298: 299: }