001: /**
002: * Redistribution and use of this software and associated documentation
003: * ("Software"), with or without modification, are permitted provided
004: * that the following conditions are met:
005: *
006: * 1. Redistributions of source code must retain copyright
007: * statements and notices. Redistributions must also contain a
008: * copy of this document.
009: *
010: * 2. Redistributions in binary form must reproduce the
011: * above copyright notice, this list of conditions and the
012: * following disclaimer in the documentation and/or other
013: * materials provided with the distribution.
014: *
015: * 3. The name "Exolab" must not be used to endorse or promote
016: * products derived from this Software without prior written
017: * permission of Intalio, Inc. For written permission,
018: * please contact info@exolab.org.
019: *
020: * 4. Products derived from this Software may not be called "Exolab"
021: * nor may "Exolab" appear in their names without prior written
022: * permission of Intalio, Inc. Exolab is a registered
023: * trademark of Intalio, Inc.
024: *
025: * 5. Due credit should be given to the Exolab Project
026: * (http://www.exolab.org/).
027: *
028: * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS
029: * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
030: * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
031: * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
032: * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
033: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
034: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
035: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
036: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
037: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
038: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
039: * OF THE POSSIBILITY OF SUCH DAMAGE.
040: *
041: * Copyright 1999 (C) Intalio, Inc. All Rights Reserved.
042: *
043: * $Id: ClassDescriptorImpl.java 6907 2007-03-28 21:24:52Z rjoachim $
044: */package org.exolab.castor.mapping.loader;
045:
046: import java.util.Collection;
047: import java.util.LinkedList;
048:
049: import org.exolab.castor.mapping.ClassDescriptor;
050: import org.exolab.castor.mapping.FieldDescriptor;
051: import org.exolab.castor.mapping.xml.ClassMapping;
052:
053: /**
054: * A basic class descriptor implementation. Engines will extend this class to provide
055: * additional functionality.
056: *
057: * @author <a href="mailto:arkin AT intalio DOT com">Assaf Arkin</a>
058: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
059: * @version $Revision: 6907 $ $Date: 2006-01-07 15:48:31 -0700 (Sat, 07 Jan 2006) $
060: */
061: public class ClassDescriptorImpl implements ClassDescriptor {
062: //-----------------------------------------------------------------------------------
063:
064: private ClassMapping _mapping;
065:
066: /** The Java class for this descriptor. */
067: private Class _javaClass;
068:
069: /** The descriptor of the class which this class extends,
070: * or null if this is a top-level class. */
071: private ClassDescriptor _extends;
072:
073: /** A collection of class descriptors that extend this class, or
074: * an empty collection if this is a leaf class. */
075: private final Collection _extended = new LinkedList();
076:
077: private ClassDescriptor _depends;
078:
079: /** The fields described for this class. */
080: private FieldDescriptor[] _fields;
081:
082: /** The field of the identity for this class. */
083: private FieldDescriptor[] _identities;
084:
085: //-----------------------------------------------------------------------------------
086:
087: public void setMapping(final ClassMapping mapping) {
088: _mapping = mapping;
089: }
090:
091: public ClassMapping getMapping() {
092: return _mapping;
093: }
094:
095: public void setJavaClass(final Class javaClass) {
096: _javaClass = javaClass;
097: }
098:
099: public Class getJavaClass() {
100: return _javaClass;
101: }
102:
103: public void setExtends(final ClassDescriptor extend) {
104: _extends = extend;
105: }
106:
107: public ClassDescriptor getExtends() {
108: return _extends;
109: }
110:
111: public void addExtended(final ClassDescriptor classDesc) {
112: _extended.add(classDesc);
113: }
114:
115: /**
116: * Returns a collection of class descriptors that extend this class descriptor.
117: *
118: * @return A collection of class descriptors.
119: */
120: public Collection getExtended() {
121: return _extended;
122: }
123:
124: public void setDepends(final ClassDescriptor depends) {
125: _depends = depends;
126: }
127:
128: public ClassDescriptor getDepends() {
129: return _depends;
130: }
131:
132: public void setFields(final FieldDescriptor[] fields) {
133: _fields = fields;
134: }
135:
136: public FieldDescriptor[] getFields() {
137: return _fields;
138: }
139:
140: public void setIdentities(final FieldDescriptor[] identities) {
141: _identities = identities;
142: }
143:
144: public FieldDescriptor[] getIdentities() {
145: return _identities;
146: }
147:
148: public FieldDescriptor getIdentity() {
149: return (_identities == null) ? null : _identities[0];
150: }
151:
152: //-----------------------------------------------------------------------------------
153:
154: /**
155: * {@inheritDoc}
156: */
157: public String toString() {
158: return _javaClass.getName();
159: }
160:
161: //-----------------------------------------------------------------------------------
162: }
|