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 2002 (C) Intalio Inc. All Rights Reserved.
042: *
043: * $Id: AnyType.java 6230 2006-09-19 07:56:07Z wguttmn $
044: */package org.exolab.castor.xml.schema;
045:
046: import org.exolab.castor.xml.ValidationException;
047:
048: /**
049: * A Class which represents the XML Schema AnyType.
050: * <BR />
051: *
052: * @author <a href="mailto:kvisco@intalio.com">Keith Visco</a>
053: * @version $Revision: 6230 $ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $
054: **/
055: public final class AnyType extends XMLType {
056: /** SerialVersionUID */
057: private static final long serialVersionUID = 7670252205849057981L;
058:
059: /**
060: * The name of this type
061: */
062: private String name = "anyType";
063:
064: /**
065: * The parent Schema for this AnyType
066: */
067: private Schema _parent = null;
068:
069: //------------------/
070: //- Constructor(s) -/
071: //------------------/
072:
073: /**
074: * Creates a new AnyType for the given Schema.
075: */
076: public AnyType(Schema schema) {
077: super ();
078: if (schema == null) {
079: String error = "The 'schema' argument must not be null.";
080: throw new IllegalArgumentException(error);
081: }
082: _parent = schema;
083: setSchema(schema);
084: } //-- AnyType
085:
086: //-------------------/
087: //-- Public Methods -/
088: //-------------------/
089:
090: /**
091: * Returns the name of this type. This method
092: * always returns 'anyType'.
093: *
094: * @return the name of this type.
095: */
096: public String getName() {
097: return name;
098: } //-- getName
099:
100: /**
101: * Returns the type of this Schema Structure. This
102: * method returns Structure.ANYTYPE.
103: *
104: * @return the type of this Schema Structure.
105: */
106: public short getStructureType() {
107: return Structure.ANYTYPE;
108: } //-- getStructureType
109:
110: /**
111: * Overrides XMLType#setName. The Name of anyType cannot be changed.
112: *
113: * @param name of the type
114: */
115: public synchronized void setName(String name) {
116: String error = "The name of 'anyType' cannot be changed.";
117: throw new IllegalStateException(error);
118: } //-- setName
119:
120: /**
121: * Overrides XMLType#setBaseType(), anyType cannot have a Base type.
122: *
123: * @param baseType the base type which this datatype inherits from
124: */
125: public void setBaseType(XMLType baseType) {
126: String error = "'anyType' cannot have a base type";
127: throw new IllegalStateException(error);
128: } //-- setBaseType
129:
130: /**
131: * Overrides XMLType#setDerivationMethod, anyType cannot
132: * be derived from any other type.
133: *
134: * @param derivationMethod the derivation method.
135: */
136: public void setDerivationMethod(String derivationMethod) {
137: String error = "'anyType' cannot be derived from other types.";
138: throw new IllegalStateException(error);
139: }
140:
141: /**
142: * Sets the Id for this XMLType. The Id must be globally unique
143: * within the Schema. Use a null value to remove the Id.
144: *
145: * @param id the unique Id for this XMLType
146: **/
147: public void setId(String id) {
148: //-- ignore
149: } //-- setId
150:
151: /**
152: * Checks the validity of this Schema defintion.
153: *
154: * @exception ValidationException when this Schema definition
155: * is invalid.
156: */
157: public void validate() throws ValidationException {
158: //-- do nothing, this type is always valid.
159: } //-- validate
160:
161: //----------------------/
162: //-- Protected Methods -/
163: //----------------------/
164:
165: /**
166: * Sets the parent for this XMLType
167: *
168: * @param parent the parent Structure for this XMLType
169: **/
170: protected void setParent(Structure parent) {
171: if (parent != _parent) {
172: String error = "The parent of 'anyType' cannot be changed.";
173: throw new IllegalArgumentException(error);
174: }
175: } //-- setParent
176:
177: } //-- AnyType
|