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: * MultiplexMappingInfo.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: MultiplexMappingInfo.java,v 1.2 2005/10/18 13:32:37 mungady Exp $
036: *
037: * Changes
038: * -------
039: * 16-Nov-2003 : Initial version
040: *
041: */
042:
043: package org.jfree.xml.generator.model;
044:
045: import java.util.Arrays;
046:
047: /**
048: * Defines the multiplex entries for a certain base class. Multiplexers are
049: * used to select a specific handler if more than one class will match the
050: * property type.
051: * <p>
052: * Multiplexers override automatic mappings and can be redefined using manual
053: * mappings.
054: */
055: public class MultiplexMappingInfo {
056:
057: /** The base class. */
058: private Class baseClass;
059:
060: /** The type attribute. */
061: private String typeAttribute;
062:
063: /** The child classes. */
064: private TypeInfo[] childClasses;
065:
066: /** The comments. */
067: private Comments comments;
068:
069: /** The source. */
070: private String source;
071:
072: /**
073: * Creates a new instance for the specified class.
074: *
075: * @param baseClass the base class.
076: */
077: public MultiplexMappingInfo(final Class baseClass) {
078: this (baseClass, "type");
079: }
080:
081: /**
082: * Creates a new instance for the specified class.
083: *
084: * @param baseClass the base class (<code>null</code> not permitted).
085: * @param typeAttribute the type attribute (<code>null</code> not permitted).
086: */
087: public MultiplexMappingInfo(final Class baseClass,
088: final String typeAttribute) {
089: if (baseClass == null) {
090: throw new NullPointerException("BaseClass");
091: }
092: if (typeAttribute == null) {
093: throw new NullPointerException("TypeAttribute");
094: }
095: this .baseClass = baseClass;
096: this .typeAttribute = typeAttribute;
097: }
098:
099: /**
100: * Returns the base class.
101: *
102: * @return The base class.
103: */
104: public Class getBaseClass() {
105: return this .baseClass;
106: }
107:
108: /**
109: * Returns the type attribute.
110: *
111: * @return The type attribute.
112: */
113: public String getTypeAttribute() {
114: return this .typeAttribute;
115: }
116:
117: /**
118: * Returns the child classes.
119: *
120: * @return The child classes.
121: */
122: public TypeInfo[] getChildClasses() {
123: return this .childClasses;
124: }
125:
126: /**
127: * Sets the child classes.
128: *
129: * @param childClasses the child classes.
130: */
131: public void setChildClasses(final TypeInfo[] childClasses) {
132: this .childClasses = childClasses;
133: }
134:
135: /**
136: * Returns the comments.
137: *
138: * @return The comments.
139: */
140: public Comments getComments() {
141: return this .comments;
142: }
143:
144: /**
145: * Sets the comments.
146: *
147: * @param comments the comments.
148: */
149: public void setComments(final Comments comments) {
150: this .comments = comments;
151: }
152:
153: /**
154: * Returns the source.
155: *
156: * @return The source.
157: */
158: public String getSource() {
159: return this .source;
160: }
161:
162: /**
163: * Sets the source.
164: *
165: * @param source the source.
166: */
167: public void setSource(final String source) {
168: this .source = source;
169: }
170:
171: /**
172: * Tests this object for equality with another object.
173: *
174: * @param o the other object.
175: *
176: * @return A boolean.
177: */
178: public boolean equals(final Object o) {
179: if (this == o) {
180: return true;
181: }
182: if (!(o instanceof MultiplexMappingInfo)) {
183: return false;
184: }
185:
186: final MultiplexMappingInfo multiplexMappingInfo = (MultiplexMappingInfo) o;
187:
188: if (!this .baseClass.equals(multiplexMappingInfo.baseClass)) {
189: return false;
190: }
191: if (!Arrays.equals(this .childClasses,
192: multiplexMappingInfo.childClasses)) {
193: return false;
194: }
195: if (!this .typeAttribute
196: .equals(multiplexMappingInfo.typeAttribute)) {
197: return false;
198: }
199:
200: return true;
201: }
202:
203: /**
204: * Returns a hash code for this object.
205: *
206: * @return A hash code.
207: */
208: public int hashCode() {
209: int result;
210: result = this .baseClass.hashCode();
211: result = 29 * result + this.typeAttribute.hashCode();
212: return result;
213: }
214:
215: }
|