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 1999-2001 (C) Intalio, Inc. All Rights Reserved. 32 * 33 * $Id$ 34 */ 35 36 package org.exolab.castor.xml.schema; 37 38 // -- we should change this to SchemaValidationException 39 // -- and localize the package 40 import org.exolab.castor.xml.ValidationException; 41 42 /** 43 * The base class for all XML Schema stuctures. 44 * 45 * @author <a href="mailto:kvisco@intalio.com">Keith Visco</a> 46 * @version $Revision$ $Date: 2003-03-03 00:05:44 -0700 (Mon, 03 Mar 2003) $ 47 **/ 48 public abstract class Structure implements java.io.Serializable { 49 50 public static final short ANYTYPE = 0; 51 public static final short ANNOTATION = 1; 52 public static final short APPINFO = 2; 53 public static final short ATTRIBUTE = 3; 54 public static final short ATTRIBUTE_GROUP = 4; 55 public static final short COMPLEX_CONTENT = 5; 56 public static final short COMPLEX_TYPE = 6; 57 public static final short DOCUMENTATION = 7; 58 public static final short ELEMENT = 8; 59 public static final short FACET = 9; 60 public static final short GROUP = 10; 61 public static final short IDENTITY_FIELD = 11; 62 public static final short IDENTITY_SELECTOR = 12; 63 public static final short KEY = 13; 64 public static final short KEYREF = 14; 65 public static final short LIST = 15; 66 public static final short MODELGROUP = 16; 67 public static final short MODELGROUP_REF = 17; 68 public static final short REDEFINE = 18; 69 public static final short SCHEMA = 19; 70 public static final short SIMPLE_CONTENT = 20; 71 public static final short SIMPLE_TYPE = 21; 72 public static final short UNION = 22; 73 public static final short UNIQUE = 23; 74 public static final short WILDCARD = 24; 75 76 // -- should be removed eventually 77 public static final short UNKNOWN = -1; 78 79 80 /** 81 * Creates a new XML Schema Structure 82 **/ 83 protected Structure() { 84 super(); 85 } // -- Structure 86 87 /** 88 * Calls validate() to determine if this Schema Definition is valid. 89 * 90 * @return true if this Schema definition is valid, otherwise false. 91 **/ 92 public boolean isValid() { 93 try { 94 validate(); 95 } catch (ValidationException ex) { 96 return false; 97 } 98 return true; 99 } // -- isValid 100 101 /** 102 * Returns the type of this Schema Structure. 103 * 104 * @return the type of this Schema Structure. 105 **/ 106 public abstract short getStructureType(); 107 108 /** 109 * Checks the validity of this Schema defintion. 110 * 111 * @exception ValidationException when this Schema definition is invalid. 112 **/ 113 public abstract void validate() throws ValidationException; 114 115 } // -- Structure