1 /** 2 * Redistribution and use of this software and associated documentation ("Software"), with or 3 * without modification, are permitted provided that the following conditions are met: 4 * 5 * 1. Redistributions of source code must retain copyright statements and notices. Redistributions 6 * must also contain a copy of this document. 7 * 8 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 9 * conditions and the following disclaimer in the documentation and/or other materials provided with 10 * the distribution. 11 * 12 * 3. The name "Exolab" must not be used to endorse or promote products derived from this Software 13 * without prior written permission of Intalio, Inc. For written permission, please contact 14 * info@exolab.org. 15 * 16 * 4. Products derived from this Software may not be called "Exolab" nor may "Exolab" appear in 17 * their names without prior written permission of Intalio, Inc. Exolab is a registered trademark of 18 * Intalio, Inc. 19 * 20 * 5. Due credit should be given to the Exolab Project (http://www.exolab.org/). 21 * 22 * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTALIO, INC. OR ITS 25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 29 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * Copyright 2002 (C) Intalio Inc. All Rights Reserved. 32 * 33 * $Id$ 34 */ 35 36 package org.exolab.castor.xml.schema; 37 38 39 import org.exolab.castor.xml.ValidationException; 40 41 /** 42 * A Class which represents the XML Schema AnyType. <BR /> 43 * 44 * @author <a href="mailto:kvisco@intalio.com">Keith Visco</a> 45 * @version $Revision$ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $ 46 **/ 47 public final class AnyType extends XMLType { 48 /** SerialVersionUID */ 49 private static final long serialVersionUID = 7670252205849057981L; 50 51 /** 52 * The name of this type 53 */ 54 private String name = "anyType"; 55 56 57 /** 58 * The parent Schema for this AnyType 59 */ 60 private Schema _parent = null; 61 62 // ------------------/ 63 // - Constructor(s) -/ 64 // ------------------/ 65 66 67 /** 68 * Creates a new AnyType for the given Schema. 69 */ 70 public AnyType(Schema schema) { 71 super(); 72 if (schema == null) { 73 String error = "The 'schema' argument must not be null."; 74 throw new IllegalArgumentException(error); 75 } 76 _parent = schema; 77 setSchema(schema); 78 } // -- AnyType 79 80 // -------------------/ 81 // -- Public Methods -/ 82 // -------------------/ 83 84 /** 85 * Returns the name of this type. This method always returns 'anyType'. 86 * 87 * @return the name of this type. 88 */ 89 public String getName() { 90 return name; 91 } // -- getName 92 93 94 /** 95 * Returns the type of this Schema Structure. This method returns Structure.ANYTYPE. 96 * 97 * @return the type of this Schema Structure. 98 */ 99 public short getStructureType() { 100 return Structure.ANYTYPE; 101 } // -- getStructureType 102 103 /** 104 * Overrides XMLType#setName. The Name of anyType cannot be changed. 105 * 106 * @param name of the type 107 */ 108 public synchronized void setName(String name) { 109 String error = "The name of 'anyType' cannot be changed."; 110 throw new IllegalStateException(error); 111 } // -- setName 112 113 114 /** 115 * Overrides XMLType#setBaseType(), anyType cannot have a Base type. 116 * 117 * @param baseType the base type which this datatype inherits from 118 */ 119 public void setBaseType(XMLType baseType) { 120 String error = "'anyType' cannot have a base type"; 121 throw new IllegalStateException(error); 122 } // -- setBaseType 123 124 125 /** 126 * Overrides XMLType#setDerivationMethod, anyType cannot be derived from any other type. 127 * 128 * @param derivationMethod the derivation method. 129 */ 130 public void setDerivationMethod(String derivationMethod) { 131 String error = "'anyType' cannot be derived from other types."; 132 throw new IllegalStateException(error); 133 } 134 135 /** 136 * Sets the Id for this XMLType. The Id must be globally unique within the Schema. Use a null 137 * value to remove the Id. 138 * 139 * @param id the unique Id for this XMLType 140 **/ 141 public void setId(String id) { 142 // -- ignore 143 } // -- setId 144 145 /** 146 * Checks the validity of this Schema defintion. 147 * 148 * @exception ValidationException when this Schema definition is invalid. 149 */ 150 public void validate() throws ValidationException { 151 // -- do nothing, this type is always valid. 152 } // -- validate 153 154 // ----------------------/ 155 // -- Protected Methods -/ 156 // ----------------------/ 157 158 /** 159 * Sets the parent for this XMLType 160 * 161 * @param parent the parent Structure for this XMLType 162 **/ 163 protected void setParent(Structure parent) { 164 if (parent != _parent) { 165 String error = "The parent of 'anyType' cannot be changed."; 166 throw new IllegalArgumentException(error); 167 } 168 } // -- setParent 169 170 171 } // -- AnyType