Home » xmlbeans-2.5.0-src » org.apache » xmlbeans » [javadoc | source]

    1   /*   Copyright 2004 The Apache Software Foundation
    2    *
    3    *   Licensed under the Apache License, Version 2.0 (the "License");
    4    *   you may not use this file except in compliance with the License.
    5    *   You may obtain a copy of the License at
    6    *
    7    *       http://www.apache.org/licenses/LICENSE-2.0
    8    *
    9    *   Unless required by applicable law or agreed to in writing, software
   10    *   distributed under the License is distributed on an "AS IS" BASIS,
   11    *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12    *   See the License for the specific language governing permissions and
   13    *  limitations under the License.
   14    */
   15   
   16   package org.apache.xmlbeans;
   17   
   18   import javax.xml.namespace.QName;
   19   
   20   /**
   21    * Represents a schema type.
   22    * <p>
   23    * SchemaType is the metadata "type" class for {@link XmlObject}, and it plays the
   24    * analogous role for {@link XmlObject} that {@link java.lang.Class} plays for
   25    * {@link java.lang.Object}.
   26    * <p>
   27    * Every XML Bean class corresponds to a singleton SchemaType object
   28    * obtainable by ClassName.type (e.g., {@link XmlNonPositiveInteger#type}), and
   29    * every XML Bean instance has an actual SchemaType, obtainable by
   30    * {@link XmlObject#schemaType}.  The ClassName.type and schemaType() mechanisms are
   31    * analogous to the ordinary Java ClassName.class and obj.getClass() mechanisms.
   32    * <p>
   33    * All schema types are represented by a SchemaType, this includes all types
   34    * regardless of whether they are built-in or user-defined, compiled or
   35    * uncompiled, simple or complex.
   36    * <p>
   37    * In addition, a compiled XML Bean type system includes special "document" schema types
   38    * each representing a document containing nothing but a single element for each
   39    * global element, and special "attribute" schema types each representing
   40    * a fragment containing nothing but a single global attribute for global
   41    * attribute.
   42    * <p>
   43    * Do not confuse Schema Types with other types of Schema Components such as
   44    * {@link SchemaGlobalElement Global Elements}, {@link SchemaGlobalAttribute Global Attributes},
   45    * {@link SchemaModelGroup Named Model Groups}, or {@link SchemaAttributeGroup Attribute Groups}.
   46    * SchemaType represents a Type component, not any of the other kinds of components.
   47    * There are different kinds of metadata objects for the different Schema components. 
   48    * <p>
   49    * The space of SchemaTypes is divided as follows:
   50    * 
   51    * <ul>
   52    * <li>First, there is the universal base type and the universal
   53    *     subtype.  These are {@link XmlObject#type}
   54    *     (corresponding to xs:anyType) and {@link XmlBeans#NO_TYPE},
   55    *     respectively.  The first type is a base type of all other
   56    *     types.  The other type indicates the absence of type information
   57    *     and, at least in set-theoretic terms, is a subtype of all other types.
   58    * <li>There is another universal base type that is the base type
   59    *     for all simple types.  This is the {@link XmlAnySimpleType#type},
   60    *     corresponding to xs:anySimpleType.   Only XmlObject.type and
   61    *     XmlAnySimpleType.type return <code>true</code> for {@link #isURType}, and
   62    *     only XmlBeans.NO_TYPE returns <code>true</code> for {@link #isNoType}.
   63    * <li>The two "special" kinds of types that are generated that
   64    *     do not formally exist in the actual Schema specification are
   65    *     document types and global attribute types (corresponding to
   66    *     documents that contain a global element, or fragments that
   67    *     contain a global attribute).  They can be detected using
   68    *     {@link #isDocumentType} and {@link #isAttributeType}. Other
   69    *     than their anonymity (lack of a type name) and their appearance
   70    *     only at the root of an instance, they are otherwise just like
   71    *     ordinary complex types.
   72    * <li>Simple types can be detected using {@link #isSimpleType}.
   73    *     Complex types are consdered to be all the types that are
   74    *     not simple.
   75    * <li>Simple types are divided into three varieties: atomic types,
   76    *     list types, and union types.  Which variety of simple type
   77    *     you have can be discoverd using {@link #getSimpleVariety}.
   78    *     It will return either {@link #ATOMIC}, {@link #LIST}, or
   79    *     {@link #UNION}.
   80    * <li>An {@link #ATOMIC} simple type is always based on one of the
   81    *     20 built-in primitive schema types.  You can determine
   82    *     the underlying primitive type for an atomic simple type
   83    *     by calling {@link #getPrimitiveType}.  An atomic type
   84    *     may add facet restrictions on top of the primitive type,
   85    *     and these facets can be explored using {@link #getFacet},
   86    *     {@link #getWhiteSpaceRule}, {@link #matchPatternFacet},
   87    *     {@link #getEnumerationValues}, and related methods.
   88    * <li>A {@link #LIST} simple type is always based on another non-list
   89    *     simple type.  The underlying list item type can be obtained
   90    *     by using {@link #getListItemType}.
   91    * <li>A {@link #UNION} simple type is always composed out of a number of
   92    *     other simple types.  The direct members of the union can
   93    *     be obtained by {@link #getUnionMemberTypes}.  When unions
   94    *     consist of other unions, it is useful to know useful to know
   95    *     the "leaves of the union tree", so the
   96    *     set of non-union types making up the union can be obtained
   97    *     by {@link #getUnionConstituentTypes}.  The closure of the
   98    *     entire "union tree" is {@link #getUnionSubTypes} (this includes
   99    *     the type itself).  For
  100    *     simple unions that do not consist of other unions, all three
  101    *     of these sets are the same.
  102    * <li>Complex types have nested structure.  They are divided into
  103    *     four content types: empty content, simple content, element-only
  104    *     content, and mixed content.  All kinds of complex types may
  105    *     have attributes.  The content type for a complex type can
  106    *     be dermined using {@link #getContentType}.  This will return
  107    *     {@link #EMPTY_CONTENT}, {@link #SIMPLE_CONTENT},
  108    *     {@link #ELEMENT_CONTENT}, or {@link #MIXED_CONTENT}.
  109    * <li>If a complex type has {@link #EMPTY_CONTENT}, the content model will be null.
  110    * <li>If a complex type has {@link #SIMPLE_CONTENT}, then it will extend the
  111    *     simple type that describes the content.  In addition, the type
  112    *     may impose additional simple type facet restrictions; these can 
  113    *     be determined in the same way they are for a simple type.
  114    * <li>If a complex type has {@link #ELEMENT_CONTENT} or {@link #MIXED_CONTENT}, then
  115    *     the detailed content model can be determined by examining
  116    *     the particle tree (which may be null for MIXED_CONTENT).
  117    *     The particle tree can be obtained via {@link #getContentModel}.
  118    * <li>When working with a complex type, most users will find it
  119    *     sufficient to discover the summarized shape of the content model
  120    *     and attribute model using {@link #getElementProperties},
  121    *     {@link #getAttributeProperties}, and related methods rather than
  122    *     examining the particle tree and attribute model directly.
  123    * </ul>
  124    * 
  125    * @see SchemaTypeLoader
  126    * @see XmlObject#schemaType
  127    * @see SimpleValue#instanceType
  128    */ 
  129   public interface SchemaType extends SchemaComponent, SchemaAnnotated
  130   {
  131       /**
  132        * The name used to describe the type in the schema.
  133        * Null if the type is anonymous (nested), or if it is a document type.
  134        */
  135       public abstract QName getName();
  136   
  137       /**
  138        * The parent schema element.
  139        * Null for top-level (named) types and document types.
  140        */
  141       public abstract SchemaField getContainerField();
  142   
  143       /**
  144        * True if this is a document type.
  145        * <p>
  146        * Document types are generated for every global element. A document
  147        * type is an unnamed complex type that contains exactly one element:
  148        * we define these types, because they are the types of the "documents"
  149        * which contain the defined global elements, and they all turn into
  150        * Java types. (Named ElementnameDocument.)
  151        */
  152       public boolean isDocumentType();
  153   
  154       /**
  155        * True if this is a attribute type.
  156        * <p>
  157        * Attribute types are generated for every global attribute. An attribute
  158        * type is an unnamed complex type that contains exactly one attribute:
  159        * we define these types, because they are the types of the "attribute documents"
  160        * which contain the defined global attribute, and they all turn into
  161        * Java types. (Named AttributenameAttribute.)
  162        */
  163       public boolean isAttributeType();
  164   
  165   
  166       /**
  167        * Returns the document element name if this is a document type,
  168        * or null otherwise.
  169        */
  170       public QName getDocumentElementName();
  171   
  172       /**
  173        * Returns the attribute qname if this is a attribute type,
  174        * or null otherwise.
  175        */
  176       public QName getAttributeTypeAttributeName();
  177   
  178       /**
  179        * The outer schema type.
  180        * Null for top-level (named) types.
  181        */
  182       public abstract SchemaType getOuterType();
  183   
  184       /**
  185        * True if this anonymous type has no corresponding Java type. True for
  186        * anonymous types nested within simple type restrictions.
  187        */
  188       public abstract boolean isSkippedAnonymousType();
  189   
  190       /**
  191        * True if this schema type was compiled to have a corresponding
  192        * Java class.
  193        */
  194       public abstract boolean isCompiled();
  195   
  196       /**
  197        * The fully-qualified Java type name of the class.
  198        */
  199       public abstract String getFullJavaName();
  200   
  201       /**
  202        * The short unqualfiied Java name for the class.
  203        */
  204       public abstract String getShortJavaName();
  205   
  206       /**
  207        * The fully-qualified Java type name of the implementation class.
  208        */
  209       public abstract String getFullJavaImplName();
  210   
  211       /**
  212        * The short unqualfiied Java name for the implementation class.
  213        */
  214       public abstract String getShortJavaImplName();
  215   
  216       /**
  217        * The Java class corresponding to this schema type.
  218        */
  219       public abstract Class getJavaClass();
  220   
  221       /**
  222        * The Java class corresponding to the enumeration type for this schema type,
  223        * if applicable (or null if not an enumeration).
  224        */
  225       public abstract Class getEnumJavaClass();
  226   
  227       /**
  228        * Returns user-specific information.
  229        * @see SchemaBookmark
  230        */
  231       public Object getUserData();
  232   
  233       /**
  234        * True if the Xsd type is anonymous (i.e., not top-level).
  235        */
  236       public abstract boolean isAnonymousType();
  237   
  238       /**
  239        * True for any of the 40+ built-in types.
  240        */
  241       public abstract boolean isBuiltinType();
  242   
  243       /**
  244        * True for the anySimpleType and any restrictions/unions/lists.
  245        */
  246       public abstract boolean isSimpleType();
  247   
  248       /**
  249        * Returns base restriction or extension type. Unions and lists
  250        * return the anySimpleType.
  251        */
  252       public abstract SchemaType getBaseType();
  253   
  254       /**
  255        * Returns common base type with the given type. The returned
  256        * type is the most specific declared base type of both types.
  257        */
  258       public abstract SchemaType getCommonBaseType(SchemaType type);
  259   
  260       /**
  261        * True if the specified type derives from this type (or if
  262        * it is the same type).
  263        *
  264        * Note that XmlObject.type (the anyType) is assignable
  265        * from all type, and the XmlBeans.noType (the absence of
  266        * a type) is assignable to all types.
  267        */
  268       public abstract boolean isAssignableFrom(SchemaType type);
  269   
  270       /**
  271        * Returns an integer for the derivation type, either 
  272        * {@link #DT_EXTENSION}, {@link #DT_RESTRICTION}, {@link #DT_NOT_DERIVED}.
  273        */
  274       public int getDerivationType();
  275       
  276       /** Not derived.  True for XmlObject.type only. See {@link #getDerivationType}. */
  277       public static final int DT_NOT_DERIVED = 0;
  278       /** Derived by restriction. See {@link #getDerivationType}. */
  279       public static final int DT_RESTRICTION = 1;
  280       /** Derived by extension. See {@link #getDerivationType}. */
  281       public static final int DT_EXTENSION = 2;
  282   
  283       /**
  284        * Returns an integer for builtin types that can be used
  285        * for quick comparison.
  286        */
  287       public abstract int getBuiltinTypeCode();
  288   
  289       /** Not a builtin type */ 
  290       public static final int BTC_NOT_BUILTIN = 0;
  291       /** xs:anyType, aka {@link XmlObject#type} */ 
  292       public static final int BTC_ANY_TYPE = 1;
  293       
  294       /** The primitive types have codes between BTC_FIRST_PRIMITIVE and BTC_LAST_PRIMITIVE inclusive */
  295       public static final int BTC_FIRST_PRIMITIVE = 2;
  296   
  297       /** xs:anySimpleType, aka {@link XmlAnySimpleType#type} */ 
  298       public static final int BTC_ANY_SIMPLE = 2;
  299   
  300       /** xs:boolean, aka {@link XmlBoolean#type} */ 
  301       public static final int BTC_BOOLEAN = 3;
  302       /** xs:base64Binary, aka {@link XmlBase64Binary#type} */ 
  303       public static final int BTC_BASE_64_BINARY = 4;
  304       /** xs:hexBinary, aka {@link XmlBase64Binary#type} */ 
  305       public static final int BTC_HEX_BINARY = 5;
  306       /** xs:anyURI, aka {@link XmlAnyURI#type} */ 
  307       public static final int BTC_ANY_URI = 6;
  308       /** xs:QName, aka {@link XmlQName#type} */ 
  309       public static final int BTC_QNAME = 7;
  310       /** xs:NOTATION, aka {@link XmlNOTATION#type} */ 
  311       public static final int BTC_NOTATION = 8;
  312       /** xs:float, aka {@link XmlFloat#type} */ 
  313       public static final int BTC_FLOAT = 9;
  314       /** xs:double, aka {@link XmlDouble#type} */ 
  315       public static final int BTC_DOUBLE = 10;
  316       /** xs:decimal, aka {@link XmlDecimal#type} */ 
  317       public static final int BTC_DECIMAL = 11;
  318       /** xs:string, aka {@link XmlString#type} */ 
  319       public static final int BTC_STRING = 12;
  320   
  321       /** xs:duration, aka {@link XmlDuration#type} */ 
  322       public static final int BTC_DURATION = 13;
  323       /** xs:dateTime, aka {@link XmlDateTime#type} */ 
  324       public static final int BTC_DATE_TIME = 14;
  325       /** xs:time, aka {@link XmlTime#type} */ 
  326       public static final int BTC_TIME = 15;
  327       /** xs:date, aka {@link XmlDate#type} */ 
  328       public static final int BTC_DATE = 16;
  329       /** xs:gYearMonth, aka {@link XmlGYearMonth#type} */ 
  330       public static final int BTC_G_YEAR_MONTH = 17;
  331       /** xs:gYear, aka {@link XmlGYear#type} */ 
  332       public static final int BTC_G_YEAR = 18;
  333       /** xs:gMonthDay, aka {@link XmlGMonthDay#type} */ 
  334       public static final int BTC_G_MONTH_DAY = 19;
  335       /** xs:gDay, aka {@link XmlGDay#type} */ 
  336       public static final int BTC_G_DAY = 20;
  337       /** xs:gMonth, aka {@link XmlGMonth#type} */ 
  338       public static final int BTC_G_MONTH = 21;
  339   
  340       /** The primitive types have codes between BTC_FIRST_PRIMITIVE and BTC_LAST_PRIMITIVE inclusive */
  341       public static final int BTC_LAST_PRIMITIVE = 21;
  342   
  343       // derived numerics
  344       /** xs:integer, aka {@link XmlInteger#type} */ 
  345       public static final int BTC_INTEGER = 22;
  346       /** xs:long, aka {@link XmlLong#type} */ 
  347       public static final int BTC_LONG = 23;
  348       /** xs:int, aka {@link XmlInt#type} */ 
  349       public static final int BTC_INT = 24;
  350       /** xs:short, aka {@link XmlShort#type} */ 
  351       public static final int BTC_SHORT = 25;
  352       /** xs:byte, aka {@link XmlByte#type} */ 
  353       public static final int BTC_BYTE = 26;
  354       /** xs:nonPositiveInteger, aka {@link XmlNonPositiveInteger#type} */ 
  355       public static final int BTC_NON_POSITIVE_INTEGER = 27;
  356       /** xs:NegativeInteger, aka {@link XmlNegativeInteger#type} */ 
  357       public static final int BTC_NEGATIVE_INTEGER = 28;
  358       /** xs:nonNegativeInteger, aka {@link XmlNonNegativeInteger#type} */ 
  359       public static final int BTC_NON_NEGATIVE_INTEGER = 29;
  360       /** xs:positiveInteger, aka {@link XmlPositiveInteger#type} */ 
  361       public static final int BTC_POSITIVE_INTEGER = 30;
  362       /** xs:unsignedLong, aka {@link XmlUnsignedLong#type} */
  363       public static final int BTC_UNSIGNED_LONG = 31;
  364       /** xs:unsignedInt, aka {@link XmlUnsignedInt#type} */
  365       public static final int BTC_UNSIGNED_INT = 32;
  366       /** xs:unsignedShort, aka {@link XmlUnsignedShort#type} */
  367       public static final int BTC_UNSIGNED_SHORT = 33;
  368       /** xs:unsignedByte, aka {@link XmlUnsignedByte#type} */
  369       public static final int BTC_UNSIGNED_BYTE = 34;
  370   
  371       // derived strings
  372       /** xs:normalizedString, aka {@link XmlNormalizedString#type} */
  373       public static final int BTC_NORMALIZED_STRING = 35;
  374       /** xs:token, aka {@link XmlToken#type} */
  375       public static final int BTC_TOKEN = 36;
  376       /** xs:Name, aka {@link XmlName#type} */
  377       public static final int BTC_NAME = 37;
  378       /** xs:NCName, aka {@link XmlNCName#type} */
  379       public static final int BTC_NCNAME = 38;
  380       /** xs:language, aka {@link XmlLanguage#type} */
  381       public static final int BTC_LANGUAGE = 39;
  382       /** xs:ID, aka {@link XmlID#type} */
  383       public static final int BTC_ID = 40;
  384       /** xs:IDREF, aka {@link XmlIDREF#type} */
  385       public static final int BTC_IDREF = 41;
  386       /** xs:IDREFS, aka {@link XmlIDREFS#type} */
  387       public static final int BTC_IDREFS = 42;
  388       /** xs:ENTITY, aka {@link XmlENTITY#type} */
  389       public static final int BTC_ENTITY = 43;
  390       /** xs:ENTITIES, aka {@link XmlENTITIES#type} */
  391       public static final int BTC_ENTITIES = 44;
  392       /** xs:NMTOKEN, aka {@link XmlNMTOKEN#type} */
  393       public static final int BTC_NMTOKEN = 45;
  394       /** xs:NMTOKENS, aka {@link XmlNMTOKENS#type} */
  395       public static final int BTC_NMTOKENS = 46;
  396   
  397       public static final int BTC_LAST_BUILTIN = 46;
  398   
  399       /**
  400        * True for anyType and anySimpleType.
  401        */
  402       public boolean isURType();
  403   
  404       /**
  405        * True for the type object that represents a the absence of a determined type.
  406        * XML Objects whose type isNoType() are never valid.
  407        */
  408       public boolean isNoType();
  409   
  410       /**
  411        * Returns the SchemaTypeLoader in which this type was defined.
  412        * Complex types are defined and used in exactly one schema type
  413        * system, but simple types are defined in one type system and can
  414        * be used in any number of type systems. The most common case is
  415        * the builtin types, which are defined in the builtin type system
  416        * and used elsewhere.
  417        */
  418       public SchemaTypeSystem getTypeSystem();
  419   
  420       /** True if this type cannot be used directly in instances */
  421       public boolean isAbstract();
  422   
  423       /** True if other types cannot extend this type (only for complex types) */
  424       public boolean finalExtension();
  425   
  426       /** True if other types cannot restrict this type */
  427       public boolean finalRestriction();
  428   
  429       /** True if list derivation of this type is prohibited (only for simple types) */
  430       public boolean finalList();
  431   
  432       /** True if union derivation of this type is prohibited (only for simple types) */
  433       public boolean finalUnion();
  434   
  435       /** True if extensions of this type cannot be substituted for this type */
  436       public boolean blockExtension();
  437   
  438       /** True if restrictions of this type cannot be substituted for this type */
  439       public boolean blockRestriction();
  440   
  441       /**
  442        * Returns {@link #EMPTY_CONTENT}, {@link #SIMPLE_CONTENT}, {@link #ELEMENT_CONTENT}, or
  443        * {@link #MIXED_CONTENT} for complex types. For noncomplex types, returns
  444        * {@link #NOT_COMPLEX_TYPE}.
  445        */
  446       public abstract int getContentType();
  447       
  448       /** Not a complex type.  See {@link #getContentType()}. */
  449       public static final int NOT_COMPLEX_TYPE = 0;
  450       /** Empty content.  See {@link #getContentType()}. */
  451       public static final int EMPTY_CONTENT = 1;
  452       /** Simple content.  See {@link #getContentType()}. */
  453       public static final int SIMPLE_CONTENT = 2;
  454       /** Element-only content.  See {@link #getContentType()}. */
  455       public static final int ELEMENT_CONTENT = 3;
  456       /** Mixed content.  See {@link #getContentType()}. */
  457       public static final int MIXED_CONTENT = 4;
  458   
  459   
  460       /**
  461        * For complex types with simple content returns the base type for this
  462        * type's content. In most cases, this is the same as the base type, but
  463        * it can also be an anonymous type.
  464        */
  465       SchemaType getContentBasedOnType();
  466   
  467       /**
  468        * Returns a {@link SchemaTypeElementSequencer} object, which can then
  469        * be used to validate complex content inside this element. This is useful
  470        * for example for trying out different names and see which one would be
  471        * valid as a child of this element.
  472        */
  473       SchemaTypeElementSequencer getElementSequencer();
  474   
  475       /**
  476        * The array of inner (anonymous) types defined
  477        * within this type.
  478        */
  479       public abstract SchemaType[] getAnonymousTypes();
  480   
  481       /**
  482        * Returns a SchemaProperty corresponding to an element within this
  483        * complex type by looking up the element name.
  484        */
  485       public abstract SchemaProperty getElementProperty(QName eltName);
  486   
  487       /**
  488        * Returns all the SchemaProperties corresponding to elements.
  489        */
  490       public abstract SchemaProperty[] getElementProperties();
  491   
  492       /**
  493        * Returns a SchemaProperty corresponding to an attribute within this
  494        * complex type by looking up the attribute name.
  495        */
  496       public abstract SchemaProperty getAttributeProperty(QName attrName);
  497   
  498       /**
  499        * Returns all the SchemaProperties corresponding to attributes.
  500        */
  501       public abstract SchemaProperty[] getAttributeProperties();
  502   
  503       /**
  504        * Returns all the SchemaProperties within this complex type,
  505        * elements followed by attributes.
  506        */
  507       public abstract SchemaProperty[] getProperties();
  508   
  509       /**
  510        * Returns the SchemaProperties defined by this complex type,
  511        * exclusive of the base type (if any).
  512        */
  513       SchemaProperty[] getDerivedProperties();
  514   
  515       /**
  516        * Returns the attribute model for this complex type (with simple or complex content).
  517        */
  518       public abstract SchemaAttributeModel getAttributeModel();
  519   
  520       /**
  521        * True if this type permits wildcard attributes. See the attribute model for
  522        * more information about which wildcards are allowed.
  523        */
  524       public abstract boolean hasAttributeWildcards();
  525   
  526       /**
  527        * Returns the complex content model for this complex type (with complex content).
  528        */
  529       public abstract SchemaParticle getContentModel();
  530   
  531       /**
  532        * True if this type permits element wildcards. See the content model for
  533        * more information about which wildcards are allowed, and where.
  534        */
  535       public abstract boolean hasElementWildcards();
  536   
  537       /**
  538        * For document types, true if the given name can be substituted for the
  539        * document element name.
  540        */
  541       public boolean isValidSubstitution(QName name);
  542   
  543       /**
  544        * True if the complex content model for this complex type is an "all" group.
  545        */
  546       public abstract boolean hasAllContent();
  547   
  548       /**
  549        * True if particles have same defaults, nillability, etc, that are
  550        * invariant when order changes. Computed only for Javaized types.
  551        */
  552       public abstract boolean isOrderSensitive();
  553   
  554       /**
  555        * Returns the type of a child element based on the element name and
  556        * an xsi:type attribute (and the type system within which names are
  557        * resolved).
  558        */
  559       public abstract SchemaType getElementType(QName eltName, QName xsiType, SchemaTypeLoader wildcardTypeLoader);
  560   
  561       /**
  562        * Returns the type of an attribute based on the attribute name and
  563        * the type system within which (wildcard) names are resolved.
  564        */
  565       public abstract SchemaType getAttributeType(QName eltName, SchemaTypeLoader wildcardTypeLoader);
  566   
  567       /*************************************************************/
  568       /* SIMPLE TYPE MODEL BELOW                                   */
  569       /*************************************************************/
  570   
  571       /** xs:length facet */
  572       public static final int FACET_LENGTH = 0;
  573       /** xs:minLength facet */
  574       public static final int FACET_MIN_LENGTH = 1;
  575       /** xs:maxLength facet */
  576       public static final int FACET_MAX_LENGTH = 2;
  577       /** xs:minExclusive facet */
  578       public static final int FACET_MIN_EXCLUSIVE = 3;
  579       /** xs:minInclusive facet */
  580       public static final int FACET_MIN_INCLUSIVE = 4;
  581       /** xs:maxInclusive facet */
  582       public static final int FACET_MAX_INCLUSIVE = 5;
  583       /** xs:maxExclusive facet */
  584       public static final int FACET_MAX_EXCLUSIVE = 6;
  585       /** xs:totalDigits facet */
  586       public static final int FACET_TOTAL_DIGITS = 7;
  587       /** xs:fractionDigits facet */
  588       public static final int FACET_FRACTION_DIGITS = 8;
  589   
  590       public static final int LAST_BASIC_FACET = 8;
  591   
  592       /** xs:whiteSpace facet - use {@link #getWhiteSpaceRule} instead */
  593       public static final int FACET_WHITE_SPACE = 9;
  594       /** xs:pattern facet - use {@link #matchPatternFacet} instead */
  595       public static final int FACET_PATTERN = 10;
  596       /** xs:enumeration facet - use {@link #getEnumerationValues} instead */
  597       public static final int FACET_ENUMERATION = 11;
  598   
  599       /** The last ordinary facet code */ 
  600       public static final int LAST_FACET = 11;
  601       
  602       /** @see #ordered */
  603       public static final int PROPERTY_ORDERED = 12;
  604       /** @see #isBounded */
  605       public static final int PROPERTY_BOUNDED = 13;
  606       /** @see #isFinite */
  607       public static final int PROPERTY_CARDINALITY = 14;
  608       /** @see #isNumeric */
  609       public static final int PROPERTY_NUMERIC = 15;
  610       
  611       /** The last property code */
  612       public static final int LAST_PROPERTY = 15;
  613   
  614   
  615       /**
  616        * Returns the value of the given facet, or null if
  617        * none is set.
  618        */
  619       public abstract XmlAnySimpleType getFacet(int facetCode);
  620   
  621       /**
  622        * True if the given facet is fixed.
  623        */
  624       public abstract boolean isFacetFixed(int facetCode);
  625   
  626       /**
  627        * True if ordered.  Returns either {@link #UNORDERED},
  628        * {@link #PARTIAL_ORDER}, or {@link #TOTAL_ORDER}.
  629        */
  630       public abstract int ordered();
  631   
  632       /** Unordered. See {@link #ordered}. */
  633       public static int UNORDERED = 0;
  634       /** Partially ordered. See {@link #ordered}. */
  635       public static int PARTIAL_ORDER = 1;
  636       /** Totally ordered. See {@link #ordered}. */
  637       public static int TOTAL_ORDER = 2;
  638   
  639       /**
  640        * True if bounded.
  641        */
  642       public abstract boolean isBounded();
  643   
  644       /**
  645        * True if finite.
  646        */
  647       public abstract boolean isFinite();
  648   
  649       /**
  650        * True if numeric.
  651        */
  652       public abstract boolean isNumeric();
  653   
  654       /**
  655        * True if there are regex pattern facents
  656        */
  657       public abstract boolean hasPatternFacet();
  658       
  659       /**
  660        * True 
  661        */
  662       public abstract String[] getPatterns();
  663   
  664       /**
  665        * True if the given string matches the pattern facets.
  666        * Always true if there are no pattern facets.
  667        */
  668       public abstract boolean matchPatternFacet(String s);
  669   
  670       /**
  671        * Returns the array of valid objects from the
  672        * enumeration facet, null if no enumeration defined.
  673        */
  674       public abstract XmlAnySimpleType[] getEnumerationValues();
  675   
  676       /**
  677        * True if this is a string enum where an integer
  678        * is assigned to each enumerated value.
  679        */
  680       public abstract boolean hasStringEnumValues();
  681   
  682       /**
  683        * If this is a string enumeration, returns the most basic base schema
  684        * type that this enuemration is based on. Otherwise returns null.
  685        */
  686       public abstract SchemaType getBaseEnumType();
  687   
  688       /**
  689        * Returns the array of SchemaStringEnumEntries for this type: this
  690        * array includes information about the java constant names used for
  691        * each string enum entry.
  692        */
  693       public SchemaStringEnumEntry[] getStringEnumEntries();
  694   
  695       /**
  696        * Returns the string enum entry corresponding to the given enumerated
  697        * string, or null if there is no match or this type is not
  698        * a string enumeration.
  699        */
  700       public SchemaStringEnumEntry enumEntryForString(String s);
  701   
  702       /**
  703        * Returns the string enum value corresponding to the given enumerated
  704        * string, or null if there is no match or this type is not
  705        * a string enumeration.
  706        */
  707       public abstract StringEnumAbstractBase enumForString(String s);
  708   
  709       /**
  710        * Returns the string enum value corresponding to the given enumerated
  711        * string, or null if there is no match or this type is not
  712        * a string enumeration.
  713        */
  714       public abstract StringEnumAbstractBase enumForInt(int i);
  715   
  716       /**
  717        * True for any of the 20 primitive types (plus anySimpleType)
  718        */
  719       public abstract boolean isPrimitiveType();
  720   
  721       /**
  722        * Returns whether the simple type is ATOMIC, UNION, or LIST.
  723        * Returns {@link #NOT_SIMPLE}, {@link #ATOMIC}, {@link #UNION},
  724        * or {@link #LIST}.
  725        */
  726       public abstract int getSimpleVariety();
  727       
  728       /** Not a simple type or simple content. See {@link #getSimpleVariety}. */
  729       public static final int NOT_SIMPLE = 0;
  730       /** Atomic type.  See {@link #getSimpleVariety} */
  731       public static final int ATOMIC = 1;
  732       /** Union type.  See {@link #getSimpleVariety} */
  733       public static final int UNION = 2;
  734       /** Simple list type.  See {@link #getSimpleVariety} */
  735       public static final int LIST = 3;
  736   
  737   
  738       /**
  739        * For atomic types only: get the primitive type underlying this one.
  740        * <p>
  741        * Returns null if this is not an atomic type.
  742        */
  743       public abstract SchemaType getPrimitiveType();
  744   
  745       /**
  746        * For atomic numeric restrictions of decimal only: the
  747        * numeric size category. Takes into account min and max
  748        * restrictions as well as totalDigits and fractionDigits
  749        * facets.
  750        * <p>
  751        * Returns either {@link #NOT_DECIMAL},
  752        * {@link #SIZE_BYTE}, {@link #SIZE_SHORT}, {@link #SIZE_INT},
  753        * {@link #SIZE_LONG}, {@link #SIZE_BIG_INTEGER}, or
  754        * {@link #SIZE_BIG_DECIMAL}.
  755        */
  756       public abstract int getDecimalSize();
  757   
  758       /** Not a decimal restriction. See {@link #getDecimalSize}. */
  759       public static final int NOT_DECIMAL = 0;
  760       /** Fits in a byte. See {@link #getDecimalSize}. */
  761       public static final int SIZE_BYTE = 8;
  762       /** Fits in a short. See {@link #getDecimalSize}. */
  763       public static final int SIZE_SHORT = 16;
  764       /** Fits in an int. See {@link #getDecimalSize}. */
  765       public static final int SIZE_INT = 32;
  766       /** Fits in a long. See {@link #getDecimalSize}. */
  767       public static final int SIZE_LONG = 64;
  768       /** Fits in a {@link java.math.BigInteger}. See {@link #getDecimalSize}. */
  769       public static final int SIZE_BIG_INTEGER = 1000000; // "millions"
  770       /** Fits in a {@link java.math.BigDecimal}. See {@link #getDecimalSize}. */
  771       public static final int SIZE_BIG_DECIMAL = 1000001; // "even more"
  772   
  773       /**
  774        * For union types only: get the shallow member types. This
  775        * returns the declared member types of the union, so, for
  776        * example if the type contains another union, the nested
  777        * members of that union are NOT returned here.
  778        * <p>
  779        * Returns null if this type is not a union.
  780        */
  781       public abstract SchemaType[] getUnionMemberTypes();
  782   
  783       /**
  784        * For union types only: gets the full tree of member types.
  785        * This computes the closure of the set returned by
  786        * getUnionMemberTypes(), so, for example, it returns
  787        * all the types nested within unions of unions as well
  788        * as the top-level members; the set also includes the
  789        * type itself. If you are seeking only the basic
  790        * non-union consituents, use getUnionConstituentTypes.
  791        * <p>
  792        * Returns null if this type is not a union.
  793        */
  794       public abstract SchemaType[] getUnionSubTypes();
  795   
  796       /**
  797        * For union types only: get the constituent member types. This
  798        * returns only non-union types, so, for example, for unions of
  799        * unions, this returns the flattened list of individual member
  800        * types within the innermost unions.
  801        * <p>
  802        * Returns null if this type is not a union.
  803        */
  804       public abstract SchemaType[] getUnionConstituentTypes();
  805   
  806       /**
  807        * For union types only: get the most specific common base
  808        * type of the constituent member types. May return a UR type.
  809        * <p>
  810        * Returns null if this type is not a union.
  811        */
  812       public abstract SchemaType getUnionCommonBaseType();
  813   
  814       /**
  815        * For anonymous types defined inside a union only: gets
  816        * the integer indicating the declaration order of this
  817        * type within the outer union type, or zero if this is
  818        * not applicable. The first anonymous union member within
  819        * a union type is numbered "1". Used to differentiate
  820        * between different anonymous types.
  821        */
  822       public abstract int getAnonymousUnionMemberOrdinal();
  823   
  824       /**
  825        * For list types only: get the item type. This is the atomic
  826        * or union type that is the type of every entry in the list.
  827        * <p>
  828        * Returns null if this type is not a list.
  829        */
  830       public abstract SchemaType getListItemType();
  831   
  832       /**
  833        * For nonunion simple types: get the whitespace rule. This is
  834        * either {@link #WS_PRESERVE}, {@link #WS_REPLACE}, or
  835        * {@link #WS_COLLAPSE}. Returns {@link #WS_UNSPECIFIED}
  836        * for unions and complex types.
  837        */
  838       public abstract int getWhiteSpaceRule();
  839   
  840       /** Whitespace rule unspecified.  See {@link #getWhiteSpaceRule}. */
  841       public static final int WS_UNSPECIFIED = 0;
  842       /** Whitespace preserved.  See {@link #getWhiteSpaceRule}. */
  843       public static final int WS_PRESERVE = 1;
  844       /** Whitespace replaced by ordinary space.  See {@link #getWhiteSpaceRule}. */
  845       public static final int WS_REPLACE = 2;
  846       /** Whitespace collapsed and trimmed.  See {@link #getWhiteSpaceRule}. */
  847       public static final int WS_COLLAPSE = 3;
  848   
  849       /**
  850        * Creates an immutable simple type value that does not reside in a tree.
  851        */
  852       public abstract XmlAnySimpleType newValue(Object v);
  853       
  854   
  855       /**
  856        * Used to allow on-demand loading of types.
  857        * 
  858        * @exclude
  859        */
  860       public final static class Ref extends SchemaComponent.Ref
  861       {
  862           public Ref(SchemaType type)
  863               { super(type); }
  864   
  865           public Ref(SchemaTypeSystem system, String handle)
  866               { super(system, handle); }
  867   
  868           public final int getComponentType()
  869               { return SchemaComponent.TYPE; }
  870   
  871           public final SchemaType get()
  872               { return (SchemaType)getComponent(); }
  873       }
  874   
  875       /**
  876        * Retruns a SchemaType.Ref pointing to this schema type itself.
  877        */
  878       public Ref getRef();
  879   
  880       /**
  881        * Returns a QNameSet of elements that may exist in wildcard
  882        * buchets and are not explicitly defined in this schema type.
  883        * Note: In this example:
  884        *  <xs:complexType name="exampleType">
  885        *    <xs:sequence>
  886        *      <xs:element name="someElement" type='xs:string' />
  887        *      <xs:any namespace="##targetNamespace" />
  888        *    </xs:sequence>
  889        *  </xs:complexType>
  890        *  the returned QNameSet will not contain the qname of 'someElement'.
  891        * @return the constructed QNameSet
  892        */
  893       public QNameSet qnameSetForWildcardElements();
  894   
  895       /**
  896        * Returns a QNameSet of attributes that may exist in wildcard
  897        * buchets and are not explicitly defined in this schema type.
  898        * Note: In this example:
  899        *  <xs:complexType name="exampleType">
  900        *    ...
  901        *    <xs:attribute name='someAttribute' type='xs:string' />
  902        *    <xs:anyAttribute namespace="##targetNamespace" />
  903        *  </xs:complexType>
  904        *  the returned QNameSet will not contain the qname of 'someAttribute'.
  905        * @return the constructed QNameSet
  906        */
  907       public QNameSet qnameSetForWildcardAttributes();
  908   }

Home » xmlbeans-2.5.0-src » org.apache » xmlbeans » [javadoc | source]