spotbugs fixes
git-svn-id: https://svn.apache.org/repos/asf/xmlbeans/trunk@1881967 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/xmlbeans/SchemaParticle.java b/src/main/java/org/apache/xmlbeans/SchemaParticle.java
index 22dbd21..741dea6 100644
--- a/src/main/java/org/apache/xmlbeans/SchemaParticle.java
+++ b/src/main/java/org/apache/xmlbeans/SchemaParticle.java
@@ -15,9 +15,8 @@
package org.apache.xmlbeans;
-import java.math.BigInteger;
-
import javax.xml.namespace.QName;
+import java.math.BigInteger;
/**
* Represents a Schema particle definition.
@@ -33,44 +32,43 @@
* sequences, nonrepeating sequences with only one item, and so on.
* (<a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#cos-particle-restrict">Pointless particles</a>
* are defined precisely in the XML Schema specification.)
- *
+ *
* @see SchemaType#getContentModel
*/
-public interface SchemaParticle
-{
+public interface SchemaParticle {
/**
* Returns the particle type ({@link #ALL}, {@link #CHOICE},
- * {@link #SEQUENCE}, {@link #ELEMENT}, or {@link #WILDCARD}).
- */
+ * {@link #SEQUENCE}, {@link #ELEMENT}, or {@link #WILDCARD}).
+ */
int getParticleType();
-
+
/**
* An <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#declare-contentModel">xs:all</a> group.
* See {@link #getParticleType}.
- */
- static final int ALL = 1;
+ */
+ int ALL = 1;
/**
* A <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#declare-contentModel">xs:choice</a> group.
* See {@link #getParticleType}.
- */
- static final int CHOICE = 2;
+ */
+ int CHOICE = 2;
/**
* A <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#declare-contentModel">xs:sequence</a> group.
* See {@link #getParticleType}.
- */
- static final int SEQUENCE = 3;
+ */
+ int SEQUENCE = 3;
/**
* An <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#declare-element">xs:element</a> particle.
* This code means the particle can be coerced to {@link SchemaLocalElement}.
* See {@link #getParticleType}.
- */
- static final int ELEMENT = 4;
+ */
+ int ELEMENT = 4;
/**
* An <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#declare-openness">xs:any</a> particle,
* also known as an element wildcard.
* See {@link #getParticleType}.
- */
- static final int WILDCARD = 5;
+ */
+ int WILDCARD = 5;
/**
* Returns the minOccurs value for this particle.
@@ -90,14 +88,14 @@
* convenience of a validating state machine that doesn't count
* higher than MAX_INT anyway.
*/
- public int getIntMinOccurs();
+ int getIntMinOccurs();
/**
* Returns the maxOccurs value, pegged to a 32-bit int for
* convenience of a validating state machine that doesn't count
* higher than MAX_INT anyway. Unbounded is given as MAX_INT.
*/
- public int getIntMaxOccurs();
+ int getIntMaxOccurs();
/**
@@ -151,19 +149,25 @@
*/
int getWildcardProcess();
- /** <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#Wildcard_details">Strict wildcard</a> processing. See {@link #getWildcardProcess} */
- static final int STRICT = 1;
- /** <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#Wildcard_details">Lax wildcard</a> processing. See {@link #getWildcardProcess} */
- static final int LAX = 2;
- /** <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#Wildcard_details">Skip wildcard</a> processing. See {@link #getWildcardProcess} */
- static final int SKIP = 3;
+ /**
+ * <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#Wildcard_details">Strict wildcard</a> processing. See {@link #getWildcardProcess}
+ */
+ int STRICT = 1;
+ /**
+ * <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#Wildcard_details">Lax wildcard</a> processing. See {@link #getWildcardProcess}
+ */
+ int LAX = 2;
+ /**
+ * <a target="_blank" href="http://www.w3.org/TR/xmlschema-1/#Wildcard_details">Skip wildcard</a> processing. See {@link #getWildcardProcess}
+ */
+ int SKIP = 3;
/**
* For elements only: the QName for the element use.
* May be unqualified version of referenced element's name.
*/
QName getName();
-
+
/**
* For elements only: returns the type of the element.
*/
@@ -178,7 +182,7 @@
* For elements only: returns the default (or fixed) text value
*/
String getDefaultText();
-
+
/**
* For elements only: returns the default (or fixed) strongly-typed value
*/
@@ -193,5 +197,5 @@
* For elements only: true if is fixed value.
*/
boolean isFixed();
-
+
}
diff --git a/src/main/java/org/apache/xmlbeans/SchemaType.java b/src/main/java/org/apache/xmlbeans/SchemaType.java
index fc10375..8c55dc7 100644
--- a/src/main/java/org/apache/xmlbeans/SchemaType.java
+++ b/src/main/java/org/apache/xmlbeans/SchemaType.java
@@ -44,10 +44,10 @@
* {@link SchemaGlobalElement Global Elements}, {@link SchemaGlobalAttribute Global Attributes},
* {@link SchemaModelGroup Named Model Groups}, or {@link SchemaAttributeGroup Attribute Groups}.
* SchemaType represents a Type component, not any of the other kinds of components.
- * There are different kinds of metadata objects for the different Schema components.
+ * There are different kinds of metadata objects for the different Schema components.
* <p>
* The space of SchemaTypes is divided as follows:
- *
+ *
* <ul>
* <li>First, there is the universal base type and the universal
* subtype. These are {@link XmlObject#type}
@@ -109,7 +109,7 @@
* <li>If a complex type has {@link #EMPTY_CONTENT}, the content model will be null.
* <li>If a complex type has {@link #SIMPLE_CONTENT}, then it will extend the
* simple type that describes the content. In addition, the type
- * may impose additional simple type facet restrictions; these can
+ * may impose additional simple type facet restrictions; these can
* be determined in the same way they are for a simple type.
* <li>If a complex type has {@link #ELEMENT_CONTENT} or {@link #MIXED_CONTENT}, then
* the detailed content model can be determined by examining
@@ -121,24 +121,23 @@
* {@link #getAttributeProperties}, and related methods rather than
* examining the particle tree and attribute model directly.
* </ul>
- *
+ *
* @see SchemaTypeLoader
* @see XmlObject#schemaType
* @see SimpleValue#instanceType
- */
-public interface SchemaType extends SchemaComponent, SchemaAnnotated
-{
+ */
+public interface SchemaType extends SchemaComponent, SchemaAnnotated {
/**
* The name used to describe the type in the schema.
* Null if the type is anonymous (nested), or if it is a document type.
*/
- public abstract QName getName();
+ QName getName();
/**
* The parent schema element.
* Null for top-level (named) types and document types.
*/
- public abstract SchemaField getContainerField();
+ SchemaField getContainerField();
/**
* True if this is a document type.
@@ -149,7 +148,7 @@
* which contain the defined global elements, and they all turn into
* Java types. (Named ElementnameDocument.)
*/
- public boolean isDocumentType();
+ boolean isDocumentType();
/**
* True if this is a attribute type.
@@ -160,252 +159,357 @@
* which contain the defined global attribute, and they all turn into
* Java types. (Named AttributenameAttribute.)
*/
- public boolean isAttributeType();
+ boolean isAttributeType();
/**
* Returns the document element name if this is a document type,
* or null otherwise.
*/
- public QName getDocumentElementName();
+ QName getDocumentElementName();
/**
* Returns the attribute qname if this is a attribute type,
* or null otherwise.
*/
- public QName getAttributeTypeAttributeName();
+ QName getAttributeTypeAttributeName();
/**
* The outer schema type.
* Null for top-level (named) types.
*/
- public abstract SchemaType getOuterType();
+ SchemaType getOuterType();
/**
* True if this anonymous type has no corresponding Java type. True for
* anonymous types nested within simple type restrictions.
*/
- public abstract boolean isSkippedAnonymousType();
+ boolean isSkippedAnonymousType();
/**
* True if this schema type was compiled to have a corresponding
* Java class.
*/
- public abstract boolean isCompiled();
+ boolean isCompiled();
/**
* The fully-qualified Java type name of the class.
*/
- public abstract String getFullJavaName();
+ String getFullJavaName();
/**
* The short unqualfiied Java name for the class.
*/
- public abstract String getShortJavaName();
+ String getShortJavaName();
/**
* The fully-qualified Java type name of the implementation class.
*/
- public abstract String getFullJavaImplName();
+ String getFullJavaImplName();
/**
* The short unqualfiied Java name for the implementation class.
*/
- public abstract String getShortJavaImplName();
+ String getShortJavaImplName();
/**
* The Java class corresponding to this schema type.
*/
- public abstract Class getJavaClass();
+ Class<? extends XmlObject> getJavaClass();
/**
* The Java class corresponding to the enumeration type for this schema type,
* if applicable (or null if not an enumeration).
*/
- public abstract Class getEnumJavaClass();
+ Class<? extends StringEnumAbstractBase> getEnumJavaClass();
/**
* Returns user-specific information.
+ *
* @see SchemaBookmark
*/
- public Object getUserData();
+ Object getUserData();
/**
* True if the Xsd type is anonymous (i.e., not top-level).
*/
- public abstract boolean isAnonymousType();
+ boolean isAnonymousType();
/**
* True for any of the 40+ built-in types.
*/
- public abstract boolean isBuiltinType();
+ boolean isBuiltinType();
/**
* True for the anySimpleType and any restrictions/unions/lists.
*/
- public abstract boolean isSimpleType();
+ boolean isSimpleType();
/**
* Returns base restriction or extension type. Unions and lists
* return the anySimpleType.
*/
- public abstract SchemaType getBaseType();
+ SchemaType getBaseType();
/**
* Returns common base type with the given type. The returned
* type is the most specific declared base type of both types.
*/
- public abstract SchemaType getCommonBaseType(SchemaType type);
+ SchemaType getCommonBaseType(SchemaType type);
/**
* True if the specified type derives from this type (or if
* it is the same type).
- *
+ * <p>
* Note that XmlObject.type (the anyType) is assignable
* from all type, and the XmlBeans.noType (the absence of
* a type) is assignable to all types.
*/
- public abstract boolean isAssignableFrom(SchemaType type);
+ boolean isAssignableFrom(SchemaType type);
/**
- * Returns an integer for the derivation type, either
+ * Returns an integer for the derivation type, either
* {@link #DT_EXTENSION}, {@link #DT_RESTRICTION}, {@link #DT_NOT_DERIVED}.
*/
- public int getDerivationType();
-
- /** Not derived. True for XmlObject.type only. See {@link #getDerivationType}. */
- public static final int DT_NOT_DERIVED = 0;
- /** Derived by restriction. See {@link #getDerivationType}. */
- public static final int DT_RESTRICTION = 1;
- /** Derived by extension. See {@link #getDerivationType}. */
- public static final int DT_EXTENSION = 2;
+ int getDerivationType();
+
+ /**
+ * Not derived. True for XmlObject.type only. See {@link #getDerivationType}.
+ */
+ int DT_NOT_DERIVED = 0;
+ /**
+ * Derived by restriction. See {@link #getDerivationType}.
+ */
+ int DT_RESTRICTION = 1;
+ /**
+ * Derived by extension. See {@link #getDerivationType}.
+ */
+ int DT_EXTENSION = 2;
/**
* Returns an integer for builtin types that can be used
* for quick comparison.
*/
- public abstract int getBuiltinTypeCode();
+ int getBuiltinTypeCode();
- /** Not a builtin type */
- public static final int BTC_NOT_BUILTIN = 0;
- /** xs:anyType, aka {@link XmlObject#type} */
- public static final int BTC_ANY_TYPE = 1;
-
- /** The primitive types have codes between BTC_FIRST_PRIMITIVE and BTC_LAST_PRIMITIVE inclusive */
- public static final int BTC_FIRST_PRIMITIVE = 2;
+ /**
+ * Not a builtin type
+ */
+ int BTC_NOT_BUILTIN = 0;
+ /**
+ * xs:anyType, aka {@link XmlObject#type}
+ */
+ int BTC_ANY_TYPE = 1;
- /** xs:anySimpleType, aka {@link XmlAnySimpleType#type} */
- public static final int BTC_ANY_SIMPLE = 2;
+ /**
+ * The primitive types have codes between BTC_FIRST_PRIMITIVE and BTC_LAST_PRIMITIVE inclusive
+ */
+ int BTC_FIRST_PRIMITIVE = 2;
- /** xs:boolean, aka {@link XmlBoolean#type} */
- public static final int BTC_BOOLEAN = 3;
- /** xs:base64Binary, aka {@link XmlBase64Binary#type} */
- public static final int BTC_BASE_64_BINARY = 4;
- /** xs:hexBinary, aka {@link XmlBase64Binary#type} */
- public static final int BTC_HEX_BINARY = 5;
- /** xs:anyURI, aka {@link XmlAnyURI#type} */
- public static final int BTC_ANY_URI = 6;
- /** xs:QName, aka {@link XmlQName#type} */
- public static final int BTC_QNAME = 7;
- /** xs:NOTATION, aka {@link XmlNOTATION#type} */
- public static final int BTC_NOTATION = 8;
- /** xs:float, aka {@link XmlFloat#type} */
- public static final int BTC_FLOAT = 9;
- /** xs:double, aka {@link XmlDouble#type} */
- public static final int BTC_DOUBLE = 10;
- /** xs:decimal, aka {@link XmlDecimal#type} */
- public static final int BTC_DECIMAL = 11;
- /** xs:string, aka {@link XmlString#type} */
- public static final int BTC_STRING = 12;
+ /**
+ * xs:anySimpleType, aka {@link XmlAnySimpleType#type}
+ */
+ int BTC_ANY_SIMPLE = 2;
- /** xs:duration, aka {@link XmlDuration#type} */
- public static final int BTC_DURATION = 13;
- /** xs:dateTime, aka {@link XmlDateTime#type} */
- public static final int BTC_DATE_TIME = 14;
- /** xs:time, aka {@link XmlTime#type} */
- public static final int BTC_TIME = 15;
- /** xs:date, aka {@link XmlDate#type} */
- public static final int BTC_DATE = 16;
- /** xs:gYearMonth, aka {@link XmlGYearMonth#type} */
- public static final int BTC_G_YEAR_MONTH = 17;
- /** xs:gYear, aka {@link XmlGYear#type} */
- public static final int BTC_G_YEAR = 18;
- /** xs:gMonthDay, aka {@link XmlGMonthDay#type} */
- public static final int BTC_G_MONTH_DAY = 19;
- /** xs:gDay, aka {@link XmlGDay#type} */
- public static final int BTC_G_DAY = 20;
- /** xs:gMonth, aka {@link XmlGMonth#type} */
- public static final int BTC_G_MONTH = 21;
+ /**
+ * xs:boolean, aka {@link XmlBoolean#type}
+ */
+ int BTC_BOOLEAN = 3;
+ /**
+ * xs:base64Binary, aka {@link XmlBase64Binary#type}
+ */
+ int BTC_BASE_64_BINARY = 4;
+ /**
+ * xs:hexBinary, aka {@link XmlBase64Binary#type}
+ */
+ int BTC_HEX_BINARY = 5;
+ /**
+ * xs:anyURI, aka {@link XmlAnyURI#type}
+ */
+ int BTC_ANY_URI = 6;
+ /**
+ * xs:QName, aka {@link XmlQName#type}
+ */
+ int BTC_QNAME = 7;
+ /**
+ * xs:NOTATION, aka {@link XmlNOTATION#type}
+ */
+ int BTC_NOTATION = 8;
+ /**
+ * xs:float, aka {@link XmlFloat#type}
+ */
+ int BTC_FLOAT = 9;
+ /**
+ * xs:double, aka {@link XmlDouble#type}
+ */
+ int BTC_DOUBLE = 10;
+ /**
+ * xs:decimal, aka {@link XmlDecimal#type}
+ */
+ int BTC_DECIMAL = 11;
+ /**
+ * xs:string, aka {@link XmlString#type}
+ */
+ int BTC_STRING = 12;
- /** The primitive types have codes between BTC_FIRST_PRIMITIVE and BTC_LAST_PRIMITIVE inclusive */
- public static final int BTC_LAST_PRIMITIVE = 21;
+ /**
+ * xs:duration, aka {@link XmlDuration#type}
+ */
+ int BTC_DURATION = 13;
+ /**
+ * xs:dateTime, aka {@link XmlDateTime#type}
+ */
+ int BTC_DATE_TIME = 14;
+ /**
+ * xs:time, aka {@link XmlTime#type}
+ */
+ int BTC_TIME = 15;
+ /**
+ * xs:date, aka {@link XmlDate#type}
+ */
+ int BTC_DATE = 16;
+ /**
+ * xs:gYearMonth, aka {@link XmlGYearMonth#type}
+ */
+ int BTC_G_YEAR_MONTH = 17;
+ /**
+ * xs:gYear, aka {@link XmlGYear#type}
+ */
+ int BTC_G_YEAR = 18;
+ /**
+ * xs:gMonthDay, aka {@link XmlGMonthDay#type}
+ */
+ int BTC_G_MONTH_DAY = 19;
+ /**
+ * xs:gDay, aka {@link XmlGDay#type}
+ */
+ int BTC_G_DAY = 20;
+ /**
+ * xs:gMonth, aka {@link XmlGMonth#type}
+ */
+ int BTC_G_MONTH = 21;
+
+ /**
+ * The primitive types have codes between BTC_FIRST_PRIMITIVE and BTC_LAST_PRIMITIVE inclusive
+ */
+ int BTC_LAST_PRIMITIVE = 21;
// derived numerics
- /** xs:integer, aka {@link XmlInteger#type} */
- public static final int BTC_INTEGER = 22;
- /** xs:long, aka {@link XmlLong#type} */
- public static final int BTC_LONG = 23;
- /** xs:int, aka {@link XmlInt#type} */
- public static final int BTC_INT = 24;
- /** xs:short, aka {@link XmlShort#type} */
- public static final int BTC_SHORT = 25;
- /** xs:byte, aka {@link XmlByte#type} */
- public static final int BTC_BYTE = 26;
- /** xs:nonPositiveInteger, aka {@link XmlNonPositiveInteger#type} */
- public static final int BTC_NON_POSITIVE_INTEGER = 27;
- /** xs:NegativeInteger, aka {@link XmlNegativeInteger#type} */
- public static final int BTC_NEGATIVE_INTEGER = 28;
- /** xs:nonNegativeInteger, aka {@link XmlNonNegativeInteger#type} */
- public static final int BTC_NON_NEGATIVE_INTEGER = 29;
- /** xs:positiveInteger, aka {@link XmlPositiveInteger#type} */
- public static final int BTC_POSITIVE_INTEGER = 30;
- /** xs:unsignedLong, aka {@link XmlUnsignedLong#type} */
- public static final int BTC_UNSIGNED_LONG = 31;
- /** xs:unsignedInt, aka {@link XmlUnsignedInt#type} */
- public static final int BTC_UNSIGNED_INT = 32;
- /** xs:unsignedShort, aka {@link XmlUnsignedShort#type} */
- public static final int BTC_UNSIGNED_SHORT = 33;
- /** xs:unsignedByte, aka {@link XmlUnsignedByte#type} */
- public static final int BTC_UNSIGNED_BYTE = 34;
+ /**
+ * xs:integer, aka {@link XmlInteger#type}
+ */
+ int BTC_INTEGER = 22;
+ /**
+ * xs:long, aka {@link XmlLong#type}
+ */
+ int BTC_LONG = 23;
+ /**
+ * xs:int, aka {@link XmlInt#type}
+ */
+ int BTC_INT = 24;
+ /**
+ * xs:short, aka {@link XmlShort#type}
+ */
+ int BTC_SHORT = 25;
+ /**
+ * xs:byte, aka {@link XmlByte#type}
+ */
+ int BTC_BYTE = 26;
+ /**
+ * xs:nonPositiveInteger, aka {@link XmlNonPositiveInteger#type}
+ */
+ int BTC_NON_POSITIVE_INTEGER = 27;
+ /**
+ * xs:NegativeInteger, aka {@link XmlNegativeInteger#type}
+ */
+ int BTC_NEGATIVE_INTEGER = 28;
+ /**
+ * xs:nonNegativeInteger, aka {@link XmlNonNegativeInteger#type}
+ */
+ int BTC_NON_NEGATIVE_INTEGER = 29;
+ /**
+ * xs:positiveInteger, aka {@link XmlPositiveInteger#type}
+ */
+ int BTC_POSITIVE_INTEGER = 30;
+ /**
+ * xs:unsignedLong, aka {@link XmlUnsignedLong#type}
+ */
+ int BTC_UNSIGNED_LONG = 31;
+ /**
+ * xs:unsignedInt, aka {@link XmlUnsignedInt#type}
+ */
+ int BTC_UNSIGNED_INT = 32;
+ /**
+ * xs:unsignedShort, aka {@link XmlUnsignedShort#type}
+ */
+ int BTC_UNSIGNED_SHORT = 33;
+ /**
+ * xs:unsignedByte, aka {@link XmlUnsignedByte#type}
+ */
+ int BTC_UNSIGNED_BYTE = 34;
// derived strings
- /** xs:normalizedString, aka {@link XmlNormalizedString#type} */
- public static final int BTC_NORMALIZED_STRING = 35;
- /** xs:token, aka {@link XmlToken#type} */
- public static final int BTC_TOKEN = 36;
- /** xs:Name, aka {@link XmlName#type} */
- public static final int BTC_NAME = 37;
- /** xs:NCName, aka {@link XmlNCName#type} */
- public static final int BTC_NCNAME = 38;
- /** xs:language, aka {@link XmlLanguage#type} */
- public static final int BTC_LANGUAGE = 39;
- /** xs:ID, aka {@link XmlID#type} */
- public static final int BTC_ID = 40;
- /** xs:IDREF, aka {@link XmlIDREF#type} */
- public static final int BTC_IDREF = 41;
- /** xs:IDREFS, aka {@link XmlIDREFS#type} */
- public static final int BTC_IDREFS = 42;
- /** xs:ENTITY, aka {@link XmlENTITY#type} */
- public static final int BTC_ENTITY = 43;
- /** xs:ENTITIES, aka {@link XmlENTITIES#type} */
- public static final int BTC_ENTITIES = 44;
- /** xs:NMTOKEN, aka {@link XmlNMTOKEN#type} */
- public static final int BTC_NMTOKEN = 45;
- /** xs:NMTOKENS, aka {@link XmlNMTOKENS#type} */
- public static final int BTC_NMTOKENS = 46;
+ /**
+ * xs:normalizedString, aka {@link XmlNormalizedString#type}
+ */
+ int BTC_NORMALIZED_STRING = 35;
+ /**
+ * xs:token, aka {@link XmlToken#type}
+ */
+ int BTC_TOKEN = 36;
+ /**
+ * xs:Name, aka {@link XmlName#type}
+ */
+ int BTC_NAME = 37;
+ /**
+ * xs:NCName, aka {@link XmlNCName#type}
+ */
+ int BTC_NCNAME = 38;
+ /**
+ * xs:language, aka {@link XmlLanguage#type}
+ */
+ int BTC_LANGUAGE = 39;
+ /**
+ * xs:ID, aka {@link XmlID#type}
+ */
+ int BTC_ID = 40;
+ /**
+ * xs:IDREF, aka {@link XmlIDREF#type}
+ */
+ int BTC_IDREF = 41;
+ /**
+ * xs:IDREFS, aka {@link XmlIDREFS#type}
+ */
+ int BTC_IDREFS = 42;
+ /**
+ * xs:ENTITY, aka {@link XmlENTITY#type}
+ */
+ int BTC_ENTITY = 43;
+ /**
+ * xs:ENTITIES, aka {@link XmlENTITIES#type}
+ */
+ int BTC_ENTITIES = 44;
+ /**
+ * xs:NMTOKEN, aka {@link XmlNMTOKEN#type}
+ */
+ int BTC_NMTOKEN = 45;
+ /**
+ * xs:NMTOKENS, aka {@link XmlNMTOKENS#type}
+ */
+ int BTC_NMTOKENS = 46;
- public static final int BTC_LAST_BUILTIN = 46;
+ int BTC_LAST_BUILTIN = 46;
/**
* True for anyType and anySimpleType.
*/
- public boolean isURType();
+ boolean isURType();
/**
* True for the type object that represents a the absence of a determined type.
* XML Objects whose type isNoType() are never valid.
*/
- public boolean isNoType();
+ boolean isNoType();
/**
* Returns the SchemaTypeLoader in which this type was defined.
@@ -415,46 +519,70 @@
* the builtin types, which are defined in the builtin type system
* and used elsewhere.
*/
- public SchemaTypeSystem getTypeSystem();
+ SchemaTypeSystem getTypeSystem();
- /** True if this type cannot be used directly in instances */
- public boolean isAbstract();
+ /**
+ * True if this type cannot be used directly in instances
+ */
+ boolean isAbstract();
- /** True if other types cannot extend this type (only for complex types) */
- public boolean finalExtension();
+ /**
+ * True if other types cannot extend this type (only for complex types)
+ */
+ boolean finalExtension();
- /** True if other types cannot restrict this type */
- public boolean finalRestriction();
+ /**
+ * True if other types cannot restrict this type
+ */
+ boolean finalRestriction();
- /** True if list derivation of this type is prohibited (only for simple types) */
- public boolean finalList();
+ /**
+ * True if list derivation of this type is prohibited (only for simple types)
+ */
+ boolean finalList();
- /** True if union derivation of this type is prohibited (only for simple types) */
- public boolean finalUnion();
+ /**
+ * True if union derivation of this type is prohibited (only for simple types)
+ */
+ boolean finalUnion();
- /** True if extensions of this type cannot be substituted for this type */
- public boolean blockExtension();
+ /**
+ * True if extensions of this type cannot be substituted for this type
+ */
+ boolean blockExtension();
- /** True if restrictions of this type cannot be substituted for this type */
- public boolean blockRestriction();
+ /**
+ * True if restrictions of this type cannot be substituted for this type
+ */
+ boolean blockRestriction();
/**
* Returns {@link #EMPTY_CONTENT}, {@link #SIMPLE_CONTENT}, {@link #ELEMENT_CONTENT}, or
* {@link #MIXED_CONTENT} for complex types. For noncomplex types, returns
* {@link #NOT_COMPLEX_TYPE}.
*/
- public abstract int getContentType();
-
- /** Not a complex type. See {@link #getContentType()}. */
- public static final int NOT_COMPLEX_TYPE = 0;
- /** Empty content. See {@link #getContentType()}. */
- public static final int EMPTY_CONTENT = 1;
- /** Simple content. See {@link #getContentType()}. */
- public static final int SIMPLE_CONTENT = 2;
- /** Element-only content. See {@link #getContentType()}. */
- public static final int ELEMENT_CONTENT = 3;
- /** Mixed content. See {@link #getContentType()}. */
- public static final int MIXED_CONTENT = 4;
+ int getContentType();
+
+ /**
+ * Not a complex type. See {@link #getContentType()}.
+ */
+ int NOT_COMPLEX_TYPE = 0;
+ /**
+ * Empty content. See {@link #getContentType()}.
+ */
+ int EMPTY_CONTENT = 1;
+ /**
+ * Simple content. See {@link #getContentType()}.
+ */
+ int SIMPLE_CONTENT = 2;
+ /**
+ * Element-only content. See {@link #getContentType()}.
+ */
+ int ELEMENT_CONTENT = 3;
+ /**
+ * Mixed content. See {@link #getContentType()}.
+ */
+ int MIXED_CONTENT = 4;
/**
@@ -476,35 +604,35 @@
* The array of inner (anonymous) types defined
* within this type.
*/
- public abstract SchemaType[] getAnonymousTypes();
+ SchemaType[] getAnonymousTypes();
/**
* Returns a SchemaProperty corresponding to an element within this
* complex type by looking up the element name.
*/
- public abstract SchemaProperty getElementProperty(QName eltName);
+ SchemaProperty getElementProperty(QName eltName);
/**
* Returns all the SchemaProperties corresponding to elements.
*/
- public abstract SchemaProperty[] getElementProperties();
+ SchemaProperty[] getElementProperties();
/**
* Returns a SchemaProperty corresponding to an attribute within this
* complex type by looking up the attribute name.
*/
- public abstract SchemaProperty getAttributeProperty(QName attrName);
+ SchemaProperty getAttributeProperty(QName attrName);
/**
* Returns all the SchemaProperties corresponding to attributes.
*/
- public abstract SchemaProperty[] getAttributeProperties();
+ SchemaProperty[] getAttributeProperties();
/**
* Returns all the SchemaProperties within this complex type,
* elements followed by attributes.
*/
- public abstract SchemaProperty[] getProperties();
+ SchemaProperty[] getProperties();
/**
* Returns the SchemaProperties defined by this complex type,
@@ -515,224 +643,274 @@
/**
* Returns the attribute model for this complex type (with simple or complex content).
*/
- public abstract SchemaAttributeModel getAttributeModel();
+ SchemaAttributeModel getAttributeModel();
/**
* True if this type permits wildcard attributes. See the attribute model for
* more information about which wildcards are allowed.
*/
- public abstract boolean hasAttributeWildcards();
+ boolean hasAttributeWildcards();
/**
* Returns the complex content model for this complex type (with complex content).
*/
- public abstract SchemaParticle getContentModel();
+ SchemaParticle getContentModel();
/**
* True if this type permits element wildcards. See the content model for
* more information about which wildcards are allowed, and where.
*/
- public abstract boolean hasElementWildcards();
+ boolean hasElementWildcards();
/**
* For document types, true if the given name can be substituted for the
* document element name.
*/
- public boolean isValidSubstitution(QName name);
+ boolean isValidSubstitution(QName name);
/**
* True if the complex content model for this complex type is an "all" group.
*/
- public abstract boolean hasAllContent();
+ boolean hasAllContent();
/**
* True if particles have same defaults, nillability, etc, that are
* invariant when order changes. Computed only for Javaized types.
*/
- public abstract boolean isOrderSensitive();
+ boolean isOrderSensitive();
/**
* Returns the type of a child element based on the element name and
* an xsi:type attribute (and the type system within which names are
* resolved).
*/
- public abstract SchemaType getElementType(QName eltName, QName xsiType, SchemaTypeLoader wildcardTypeLoader);
+ SchemaType getElementType(QName eltName, QName xsiType, SchemaTypeLoader wildcardTypeLoader);
/**
* Returns the type of an attribute based on the attribute name and
* the type system within which (wildcard) names are resolved.
*/
- public abstract SchemaType getAttributeType(QName eltName, SchemaTypeLoader wildcardTypeLoader);
+ SchemaType getAttributeType(QName eltName, SchemaTypeLoader wildcardTypeLoader);
- /*************************************************************/
- /* SIMPLE TYPE MODEL BELOW */
- /*************************************************************/
+ /* *********************************************************** */
+ /* SIMPLE TYPE MODEL BELOW */
+ /* *********************************************************** */
- /** xs:length facet */
- public static final int FACET_LENGTH = 0;
- /** xs:minLength facet */
- public static final int FACET_MIN_LENGTH = 1;
- /** xs:maxLength facet */
- public static final int FACET_MAX_LENGTH = 2;
- /** xs:minExclusive facet */
- public static final int FACET_MIN_EXCLUSIVE = 3;
- /** xs:minInclusive facet */
- public static final int FACET_MIN_INCLUSIVE = 4;
- /** xs:maxInclusive facet */
- public static final int FACET_MAX_INCLUSIVE = 5;
- /** xs:maxExclusive facet */
- public static final int FACET_MAX_EXCLUSIVE = 6;
- /** xs:totalDigits facet */
- public static final int FACET_TOTAL_DIGITS = 7;
- /** xs:fractionDigits facet */
- public static final int FACET_FRACTION_DIGITS = 8;
+ /**
+ * xs:length facet
+ */
+ int FACET_LENGTH = 0;
+ /**
+ * xs:minLength facet
+ */
+ int FACET_MIN_LENGTH = 1;
+ /**
+ * xs:maxLength facet
+ */
+ int FACET_MAX_LENGTH = 2;
+ /**
+ * xs:minExclusive facet
+ */
+ int FACET_MIN_EXCLUSIVE = 3;
+ /**
+ * xs:minInclusive facet
+ */
+ int FACET_MIN_INCLUSIVE = 4;
+ /**
+ * xs:maxInclusive facet
+ */
+ int FACET_MAX_INCLUSIVE = 5;
+ /**
+ * xs:maxExclusive facet
+ */
+ int FACET_MAX_EXCLUSIVE = 6;
+ /**
+ * xs:totalDigits facet
+ */
+ int FACET_TOTAL_DIGITS = 7;
+ /**
+ * xs:fractionDigits facet
+ */
+ int FACET_FRACTION_DIGITS = 8;
- public static final int LAST_BASIC_FACET = 8;
+ int LAST_BASIC_FACET = 8;
- /** xs:whiteSpace facet - use {@link #getWhiteSpaceRule} instead */
- public static final int FACET_WHITE_SPACE = 9;
- /** xs:pattern facet - use {@link #matchPatternFacet} instead */
- public static final int FACET_PATTERN = 10;
- /** xs:enumeration facet - use {@link #getEnumerationValues} instead */
- public static final int FACET_ENUMERATION = 11;
+ /**
+ * xs:whiteSpace facet - use {@link #getWhiteSpaceRule} instead
+ */
+ int FACET_WHITE_SPACE = 9;
+ /**
+ * xs:pattern facet - use {@link #matchPatternFacet} instead
+ */
+ int FACET_PATTERN = 10;
+ /**
+ * xs:enumeration facet - use {@link #getEnumerationValues} instead
+ */
+ int FACET_ENUMERATION = 11;
- /** The last ordinary facet code */
- public static final int LAST_FACET = 11;
-
- /** @see #ordered */
- public static final int PROPERTY_ORDERED = 12;
- /** @see #isBounded */
- public static final int PROPERTY_BOUNDED = 13;
- /** @see #isFinite */
- public static final int PROPERTY_CARDINALITY = 14;
- /** @see #isNumeric */
- public static final int PROPERTY_NUMERIC = 15;
-
- /** The last property code */
- public static final int LAST_PROPERTY = 15;
+ /**
+ * The last ordinary facet code
+ */
+ int LAST_FACET = 11;
+
+ /**
+ * @see #ordered
+ */
+ int PROPERTY_ORDERED = 12;
+ /**
+ * @see #isBounded
+ */
+ int PROPERTY_BOUNDED = 13;
+ /**
+ * @see #isFinite
+ */
+ int PROPERTY_CARDINALITY = 14;
+ /**
+ * @see #isNumeric
+ */
+ int PROPERTY_NUMERIC = 15;
+
+ /**
+ * The last property code
+ */
+ int LAST_PROPERTY = 15;
/**
* Returns the value of the given facet, or null if
* none is set.
*/
- public abstract XmlAnySimpleType getFacet(int facetCode);
+ XmlAnySimpleType getFacet(int facetCode);
/**
* True if the given facet is fixed.
*/
- public abstract boolean isFacetFixed(int facetCode);
+ boolean isFacetFixed(int facetCode);
/**
* True if ordered. Returns either {@link #UNORDERED},
* {@link #PARTIAL_ORDER}, or {@link #TOTAL_ORDER}.
*/
- public abstract int ordered();
+ int ordered();
- /** Unordered. See {@link #ordered}. */
- public static int UNORDERED = 0;
- /** Partially ordered. See {@link #ordered}. */
- public static int PARTIAL_ORDER = 1;
- /** Totally ordered. See {@link #ordered}. */
- public static int TOTAL_ORDER = 2;
+ /**
+ * Unordered. See {@link #ordered}.
+ */
+ int UNORDERED = 0;
+ /**
+ * Partially ordered. See {@link #ordered}.
+ */
+ int PARTIAL_ORDER = 1;
+ /**
+ * Totally ordered. See {@link #ordered}.
+ */
+ int TOTAL_ORDER = 2;
/**
* True if bounded.
*/
- public abstract boolean isBounded();
+ boolean isBounded();
/**
* True if finite.
*/
- public abstract boolean isFinite();
+ boolean isFinite();
/**
* True if numeric.
*/
- public abstract boolean isNumeric();
+ boolean isNumeric();
/**
* True if there are regex pattern facents
*/
- public abstract boolean hasPatternFacet();
-
+ boolean hasPatternFacet();
+
/**
- * True
+ * True
*/
- public abstract String[] getPatterns();
+ String[] getPatterns();
/**
* True if the given string matches the pattern facets.
* Always true if there are no pattern facets.
*/
- public abstract boolean matchPatternFacet(String s);
+ boolean matchPatternFacet(String s);
/**
* Returns the array of valid objects from the
* enumeration facet, null if no enumeration defined.
*/
- public abstract XmlAnySimpleType[] getEnumerationValues();
+ XmlAnySimpleType[] getEnumerationValues();
/**
* True if this is a string enum where an integer
* is assigned to each enumerated value.
*/
- public abstract boolean hasStringEnumValues();
+ boolean hasStringEnumValues();
/**
* If this is a string enumeration, returns the most basic base schema
* type that this enuemration is based on. Otherwise returns null.
*/
- public abstract SchemaType getBaseEnumType();
+ SchemaType getBaseEnumType();
/**
* Returns the array of SchemaStringEnumEntries for this type: this
* array includes information about the java constant names used for
* each string enum entry.
*/
- public SchemaStringEnumEntry[] getStringEnumEntries();
+ SchemaStringEnumEntry[] getStringEnumEntries();
/**
* Returns the string enum entry corresponding to the given enumerated
* string, or null if there is no match or this type is not
* a string enumeration.
*/
- public SchemaStringEnumEntry enumEntryForString(String s);
+ SchemaStringEnumEntry enumEntryForString(String s);
/**
* Returns the string enum value corresponding to the given enumerated
* string, or null if there is no match or this type is not
* a string enumeration.
*/
- public abstract StringEnumAbstractBase enumForString(String s);
+ StringEnumAbstractBase enumForString(String s);
/**
* Returns the string enum value corresponding to the given enumerated
* string, or null if there is no match or this type is not
* a string enumeration.
*/
- public abstract StringEnumAbstractBase enumForInt(int i);
+ StringEnumAbstractBase enumForInt(int i);
/**
* True for any of the 20 primitive types (plus anySimpleType)
*/
- public abstract boolean isPrimitiveType();
+ boolean isPrimitiveType();
/**
* Returns whether the simple type is ATOMIC, UNION, or LIST.
* Returns {@link #NOT_SIMPLE}, {@link #ATOMIC}, {@link #UNION},
* or {@link #LIST}.
*/
- public abstract int getSimpleVariety();
-
- /** Not a simple type or simple content. See {@link #getSimpleVariety}. */
- public static final int NOT_SIMPLE = 0;
- /** Atomic type. See {@link #getSimpleVariety} */
- public static final int ATOMIC = 1;
- /** Union type. See {@link #getSimpleVariety} */
- public static final int UNION = 2;
- /** Simple list type. See {@link #getSimpleVariety} */
- public static final int LIST = 3;
+ int getSimpleVariety();
+
+ /**
+ * Not a simple type or simple content. See {@link #getSimpleVariety}.
+ */
+ int NOT_SIMPLE = 0;
+ /**
+ * Atomic type. See {@link #getSimpleVariety}
+ */
+ int ATOMIC = 1;
+ /**
+ * Union type. See {@link #getSimpleVariety}
+ */
+ int UNION = 2;
+ /**
+ * Simple list type. See {@link #getSimpleVariety}
+ */
+ int LIST = 3;
/**
@@ -740,7 +918,7 @@
* <p>
* Returns null if this is not an atomic type.
*/
- public abstract SchemaType getPrimitiveType();
+ SchemaType getPrimitiveType();
/**
* For atomic numeric restrictions of decimal only: the
@@ -753,22 +931,36 @@
* {@link #SIZE_LONG}, {@link #SIZE_BIG_INTEGER}, or
* {@link #SIZE_BIG_DECIMAL}.
*/
- public abstract int getDecimalSize();
+ int getDecimalSize();
- /** Not a decimal restriction. See {@link #getDecimalSize}. */
- public static final int NOT_DECIMAL = 0;
- /** Fits in a byte. See {@link #getDecimalSize}. */
- public static final int SIZE_BYTE = 8;
- /** Fits in a short. See {@link #getDecimalSize}. */
- public static final int SIZE_SHORT = 16;
- /** Fits in an int. See {@link #getDecimalSize}. */
- public static final int SIZE_INT = 32;
- /** Fits in a long. See {@link #getDecimalSize}. */
- public static final int SIZE_LONG = 64;
- /** Fits in a {@link java.math.BigInteger}. See {@link #getDecimalSize}. */
- public static final int SIZE_BIG_INTEGER = 1000000; // "millions"
- /** Fits in a {@link java.math.BigDecimal}. See {@link #getDecimalSize}. */
- public static final int SIZE_BIG_DECIMAL = 1000001; // "even more"
+ /**
+ * Not a decimal restriction. See {@link #getDecimalSize}.
+ */
+ int NOT_DECIMAL = 0;
+ /**
+ * Fits in a byte. See {@link #getDecimalSize}.
+ */
+ int SIZE_BYTE = 8;
+ /**
+ * Fits in a short. See {@link #getDecimalSize}.
+ */
+ int SIZE_SHORT = 16;
+ /**
+ * Fits in an int. See {@link #getDecimalSize}.
+ */
+ int SIZE_INT = 32;
+ /**
+ * Fits in a long. See {@link #getDecimalSize}.
+ */
+ int SIZE_LONG = 64;
+ /**
+ * Fits in a {@link java.math.BigInteger}. See {@link #getDecimalSize}.
+ */
+ int SIZE_BIG_INTEGER = 1000000; // "millions"
+ /**
+ * Fits in a {@link java.math.BigDecimal}. See {@link #getDecimalSize}.
+ */
+ int SIZE_BIG_DECIMAL = 1000001; // "even more"
/**
* For union types only: get the shallow member types. This
@@ -778,7 +970,7 @@
* <p>
* Returns null if this type is not a union.
*/
- public abstract SchemaType[] getUnionMemberTypes();
+ SchemaType[] getUnionMemberTypes();
/**
* For union types only: gets the full tree of member types.
@@ -791,7 +983,7 @@
* <p>
* Returns null if this type is not a union.
*/
- public abstract SchemaType[] getUnionSubTypes();
+ SchemaType[] getUnionSubTypes();
/**
* For union types only: get the constituent member types. This
@@ -801,7 +993,7 @@
* <p>
* Returns null if this type is not a union.
*/
- public abstract SchemaType[] getUnionConstituentTypes();
+ SchemaType[] getUnionConstituentTypes();
/**
* For union types only: get the most specific common base
@@ -809,7 +1001,7 @@
* <p>
* Returns null if this type is not a union.
*/
- public abstract SchemaType getUnionCommonBaseType();
+ SchemaType getUnionCommonBaseType();
/**
* For anonymous types defined inside a union only: gets
@@ -819,7 +1011,7 @@
* a union type is numbered "1". Used to differentiate
* between different anonymous types.
*/
- public abstract int getAnonymousUnionMemberOrdinal();
+ int getAnonymousUnionMemberOrdinal();
/**
* For list types only: get the item type. This is the atomic
@@ -827,7 +1019,7 @@
* <p>
* Returns null if this type is not a list.
*/
- public abstract SchemaType getListItemType();
+ SchemaType getListItemType();
/**
* For nonunion simple types: get the whitespace rule. This is
@@ -835,74 +1027,85 @@
* {@link #WS_COLLAPSE}. Returns {@link #WS_UNSPECIFIED}
* for unions and complex types.
*/
- public abstract int getWhiteSpaceRule();
+ int getWhiteSpaceRule();
- /** Whitespace rule unspecified. See {@link #getWhiteSpaceRule}. */
- public static final int WS_UNSPECIFIED = 0;
- /** Whitespace preserved. See {@link #getWhiteSpaceRule}. */
- public static final int WS_PRESERVE = 1;
- /** Whitespace replaced by ordinary space. See {@link #getWhiteSpaceRule}. */
- public static final int WS_REPLACE = 2;
- /** Whitespace collapsed and trimmed. See {@link #getWhiteSpaceRule}. */
- public static final int WS_COLLAPSE = 3;
+ /**
+ * Whitespace rule unspecified. See {@link #getWhiteSpaceRule}.
+ */
+ int WS_UNSPECIFIED = 0;
+ /**
+ * Whitespace preserved. See {@link #getWhiteSpaceRule}.
+ */
+ int WS_PRESERVE = 1;
+ /**
+ * Whitespace replaced by ordinary space. See {@link #getWhiteSpaceRule}.
+ */
+ int WS_REPLACE = 2;
+ /**
+ * Whitespace collapsed and trimmed. See {@link #getWhiteSpaceRule}.
+ */
+ int WS_COLLAPSE = 3;
/**
* Creates an immutable simple type value that does not reside in a tree.
*/
- public abstract XmlAnySimpleType newValue(Object v);
-
+ XmlAnySimpleType newValue(Object v);
+
/**
* Used to allow on-demand loading of types.
- *
- * @exclude
*/
- public final static class Ref extends SchemaComponent.Ref
- {
- public Ref(SchemaType type)
- { super(type); }
+ final class Ref extends SchemaComponent.Ref {
+ public Ref(SchemaType type) {
+ super(type);
+ }
- public Ref(SchemaTypeSystem system, String handle)
- { super(system, handle); }
+ public Ref(SchemaTypeSystem system, String handle) {
+ super(system, handle);
+ }
- public final int getComponentType()
- { return SchemaComponent.TYPE; }
+ public final int getComponentType() {
+ return SchemaComponent.TYPE;
+ }
- public final SchemaType get()
- { return (SchemaType)getComponent(); }
+ public final SchemaType get() {
+ return (SchemaType) getComponent();
+ }
}
/**
* Retruns a SchemaType.Ref pointing to this schema type itself.
*/
- public Ref getRef();
+ Ref getRef();
/**
* Returns a QNameSet of elements that may exist in wildcard
* buchets and are not explicitly defined in this schema type.
* Note: In this example:
- * <xs:complexType name="exampleType">
- * <xs:sequence>
- * <xs:element name="someElement" type='xs:string' />
- * <xs:any namespace="##targetNamespace" />
- * </xs:sequence>
- * </xs:complexType>
- * the returned QNameSet will not contain the qname of 'someElement'.
+ * <xs:complexType name="exampleType">
+ * <xs:sequence>
+ * <xs:element name="someElement" type='xs:string' />
+ * <xs:any namespace="##targetNamespace" />
+ * </xs:sequence>
+ * </xs:complexType>
+ * the returned QNameSet will not contain the qname of 'someElement'.
+ *
* @return the constructed QNameSet
*/
- public QNameSet qnameSetForWildcardElements();
+ QNameSet qnameSetForWildcardElements();
/**
* Returns a QNameSet of attributes that may exist in wildcard
* buchets and are not explicitly defined in this schema type.
* Note: In this example:
- * <xs:complexType name="exampleType">
- * ...
- * <xs:attribute name='someAttribute' type='xs:string' />
- * <xs:anyAttribute namespace="##targetNamespace" />
- * </xs:complexType>
- * the returned QNameSet will not contain the qname of 'someAttribute'.
+ * <xs:complexType name="exampleType">
+ * ...
+ * <xs:attribute name='someAttribute' type='xs:string' />
+ * <xs:anyAttribute namespace="##targetNamespace" />
+ * </xs:complexType>
+ * the returned QNameSet will not contain the qname of 'someAttribute'.
+ *
* @return the constructed QNameSet
*/
- public QNameSet qnameSetForWildcardAttributes();
+ QNameSet qnameSetForWildcardAttributes();
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
index f06c544..076a29a 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
@@ -23,7 +23,7 @@
import java.util.Map;
public class SchemaIdentityConstraintImpl implements SchemaIdentityConstraint {
- private SchemaContainer _container;
+ private final SchemaContainer _container;
private String _selector;
private String[] _fields;
private SchemaIdentityConstraint.Ref _key;
@@ -32,7 +32,7 @@
private XmlObject _parse;
private Object _userData;
private SchemaAnnotation _annotation;
- private Map _nsMap = Collections.EMPTY_MAP;
+ private Map<String,String> _nsMap = Collections.emptyMap();
private String _parseTNS;
private boolean _chameleon;
private String _filename;
@@ -80,11 +80,11 @@
return _annotation;
}
- public void setNSMap(Map nsMap) {
+ public void setNSMap(Map<String,String> nsMap) {
_nsMap = nsMap;
}
- public Map getNSMap() {
+ public Map<String,String> getNSMap() {
return Collections.unmodifiableMap(_nsMap);
}
@@ -95,7 +95,7 @@
public void setFields(String[] fields) {
assert fields != null && fields.length > 0;
- _fields = fields;
+ _fields = fields.clone();
}
public String[] getFields() {
@@ -192,7 +192,7 @@
return getConstraintCategory() != CC_KEYREF || _key != null;
}
- private SchemaIdentityConstraint.Ref _selfref = new SchemaIdentityConstraint.Ref(this);
+ private final SchemaIdentityConstraint.Ref _selfref = new SchemaIdentityConstraint.Ref(this);
public SchemaIdentityConstraint.Ref getRef() {
return _selfref;
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaLocalElementImpl.java b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaLocalElementImpl.java
index 4aa51f5..1f664ec 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaLocalElementImpl.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaLocalElementImpl.java
@@ -16,15 +16,14 @@
package org.apache.xmlbeans.impl.schema;
import org.apache.xmlbeans.SchemaAnnotation;
+import org.apache.xmlbeans.SchemaIdentityConstraint;
import org.apache.xmlbeans.SchemaLocalElement;
import org.apache.xmlbeans.SchemaParticle;
-import org.apache.xmlbeans.SchemaIdentityConstraint;
import org.apache.xmlbeans.soap.SOAPArrayType;
import org.apache.xmlbeans.soap.SchemaWSDLArrayType;
public class SchemaLocalElementImpl extends SchemaParticleImpl
- implements SchemaLocalElement, SchemaWSDLArrayType
-{
+ implements SchemaLocalElement, SchemaWSDLArrayType {
private boolean _blockExt;
private boolean _blockRest;
private boolean _blockSubst;
@@ -34,73 +33,63 @@
private SchemaIdentityConstraint.Ref[] _constraints = new SchemaIdentityConstraint.Ref[0];
- public SchemaLocalElementImpl()
- {
+ public SchemaLocalElementImpl() {
setParticleType(SchemaParticle.ELEMENT);
}
- public boolean blockExtension()
- {
+ public boolean blockExtension() {
return _blockExt;
}
- public boolean blockRestriction()
- {
+ public boolean blockRestriction() {
return _blockRest;
}
- public boolean blockSubstitution()
- {
+ public boolean blockSubstitution() {
return _blockSubst;
}
- public boolean isAbstract()
- {
+ public boolean isAbstract() {
return _abs;
}
- public void setAbstract(boolean abs)
- {
+ public void setAbstract(boolean abs) {
_abs = abs;
}
- public void setBlock(boolean extension, boolean restriction, boolean substitution)
- {
+ public void setBlock(boolean extension, boolean restriction, boolean substitution) {
mutate();
_blockExt = extension;
_blockRest = restriction;
_blockSubst = substitution;
}
- public void setAnnotation(SchemaAnnotation ann)
- {
+ public void setAnnotation(SchemaAnnotation ann) {
_annotation = ann;
}
- public void setWsdlArrayType(SOAPArrayType arrayType)
- {
+ public void setWsdlArrayType(SOAPArrayType arrayType) {
_wsdlArrayType = arrayType;
}
- public SchemaAnnotation getAnnotation()
- {
+ public SchemaAnnotation getAnnotation() {
return _annotation;
}
- public SOAPArrayType getWSDLArrayType()
- {
+ public SOAPArrayType getWSDLArrayType() {
return _wsdlArrayType;
}
public void setIdentityConstraints(SchemaIdentityConstraint.Ref[] constraints) {
mutate();
- _constraints = constraints;
+ _constraints = (constraints == null) ? null : constraints.clone();
}
public SchemaIdentityConstraint[] getIdentityConstraints() {
SchemaIdentityConstraint[] result = new SchemaIdentityConstraint[_constraints.length];
- for (int i = 0 ; i < result.length ; i++)
+ for (int i = 0; i < result.length; i++) {
result[i] = _constraints[i].get();
+ }
return result;
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java
index 047d95f..6752e8b 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java
@@ -15,20 +15,13 @@
package org.apache.xmlbeans.impl.schema;
-import org.apache.xmlbeans.SchemaParticle;
-import org.apache.xmlbeans.QNameSet;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlAnySimpleType;
-import org.apache.xmlbeans.XmlQName;
+import org.apache.xmlbeans.*;
import org.apache.xmlbeans.impl.values.NamespaceContext;
+import javax.xml.namespace.QName;
import java.math.BigInteger;
-import javax.xml.namespace.QName;
-
-public class SchemaParticleImpl implements SchemaParticle
-{
+public class SchemaParticleImpl implements SchemaParticle {
private int _particleType;
private BigInteger _minOccurs;
private BigInteger _maxOccurs;
@@ -52,82 +45,104 @@
private Object _userData;
private XmlValueRef _defaultValue;
- protected void mutate()
- { if (_isImmutable) throw new IllegalStateException(); }
+ protected void mutate() {
+ if (_isImmutable) {
+ throw new IllegalStateException();
+ }
+ }
- public void setImmutable()
- { mutate(); _isImmutable = true; }
+ public void setImmutable() {
+ mutate();
+ _isImmutable = true;
+ }
- public boolean hasTransitionRules()
- { return (_startSet != null); }
+ public boolean hasTransitionRules() {
+ return (_startSet != null);
+ }
- public boolean hasTransitionNotes()
- { return (_excludeNextSet != null); }
+ public boolean hasTransitionNotes() {
+ return (_excludeNextSet != null);
+ }
public void setTransitionRules(QNameSet start,
- boolean isSkippable)
- {
+ boolean isSkippable) {
_startSet = start;
_isSkippable = isSkippable;
}
- public void setTransitionNotes(QNameSet excludeNext, boolean isDeterministic)
- {
+ public void setTransitionNotes(QNameSet excludeNext, boolean isDeterministic) {
_excludeNextSet = excludeNext;
_isDeterministic = isDeterministic;
}
- public boolean canStartWithElement(QName name)
- { return name != null && _startSet.contains(name); }
+ public boolean canStartWithElement(QName name) {
+ return name != null && _startSet.contains(name);
+ }
- public QNameSet acceptedStartNames()
- { return _startSet; }
+ public QNameSet acceptedStartNames() {
+ return _startSet;
+ }
- public QNameSet getExcludeNextSet()
- { return _excludeNextSet; }
+ public QNameSet getExcludeNextSet() {
+ return _excludeNextSet;
+ }
- public boolean isSkippable()
- { return _isSkippable; }
+ public boolean isSkippable() {
+ return _isSkippable;
+ }
- public boolean isDeterministic()
- { return _isDeterministic; }
+ public boolean isDeterministic() {
+ return _isDeterministic;
+ }
- public int getParticleType()
- { return _particleType; }
+ public int getParticleType() {
+ return _particleType;
+ }
- public void setParticleType(int pType)
- { mutate(); _particleType = pType; }
+ public void setParticleType(int pType) {
+ mutate();
+ _particleType = pType;
+ }
- public boolean isSingleton()
- { return _maxOccurs != null &&
- _maxOccurs.compareTo(BigInteger.ONE) == 0 &&
- _minOccurs.compareTo(BigInteger.ONE) == 0; }
+ public boolean isSingleton() {
+ return _maxOccurs != null &&
+ _maxOccurs.compareTo(BigInteger.ONE) == 0 &&
+ _minOccurs.compareTo(BigInteger.ONE) == 0;
+ }
- public BigInteger getMinOccurs()
- { return _minOccurs; }
+ public BigInteger getMinOccurs() {
+ return _minOccurs;
+ }
- public void setMinOccurs(BigInteger min)
- { mutate(); _minOccurs = min; _intMinOccurs = pegBigInteger(min); }
+ public void setMinOccurs(BigInteger min) {
+ mutate();
+ _minOccurs = min;
+ _intMinOccurs = pegBigInteger(min);
+ }
- public int getIntMinOccurs()
- { return _intMinOccurs; }
+ public int getIntMinOccurs() {
+ return _intMinOccurs;
+ }
- public BigInteger getMaxOccurs()
- { return _maxOccurs; }
+ public BigInteger getMaxOccurs() {
+ return _maxOccurs;
+ }
- public int getIntMaxOccurs()
- { return _intMaxOccurs; }
+ public int getIntMaxOccurs() {
+ return _intMaxOccurs;
+ }
- public void setMaxOccurs(BigInteger max)
- { mutate(); _maxOccurs = max; _intMaxOccurs = pegBigInteger(max); }
+ public void setMaxOccurs(BigInteger max) {
+ mutate();
+ _maxOccurs = max;
+ _intMaxOccurs = pegBigInteger(max);
+ }
- public SchemaParticle[] getParticleChildren()
- {
- if (_particleChildren == null)
- {
+ public SchemaParticle[] getParticleChildren() {
+ if (_particleChildren == null) {
assert _particleType != SchemaParticle.ALL &&
- _particleType != SchemaParticle.SEQUENCE &&
- _particleType != SchemaParticle.CHOICE;
+ _particleType != SchemaParticle.SEQUENCE &&
+ _particleType != SchemaParticle.CHOICE;
return null;
}
SchemaParticle[] result = new SchemaParticle[_particleChildren.length];
@@ -135,75 +150,97 @@
return result;
}
- public void setParticleChildren(SchemaParticle[] children)
- { mutate(); _particleChildren = children; }
+ public void setParticleChildren(SchemaParticle[] children) {
+ mutate();
+ _particleChildren = (children == null) ? null : children.clone();
+ }
- public SchemaParticle getParticleChild(int i)
- { return _particleChildren[i]; }
+ public SchemaParticle getParticleChild(int i) {
+ return _particleChildren[i];
+ }
- public int countOfParticleChild()
- { return _particleChildren == null ? 0 : _particleChildren.length; }
+ public int countOfParticleChild() {
+ return _particleChildren == null ? 0 : _particleChildren.length;
+ }
- public void setWildcardSet(QNameSet set)
- { mutate(); _wildcardSet = set; }
+ public void setWildcardSet(QNameSet set) {
+ mutate();
+ _wildcardSet = set;
+ }
- public QNameSet getWildcardSet()
- { return _wildcardSet; }
+ public QNameSet getWildcardSet() {
+ return _wildcardSet;
+ }
- public void setWildcardProcess(int process)
- { mutate(); _wildcardProcess = process; }
+ public void setWildcardProcess(int process) {
+ mutate();
+ _wildcardProcess = process;
+ }
- public int getWildcardProcess()
- { return _wildcardProcess; }
+ public int getWildcardProcess() {
+ return _wildcardProcess;
+ }
private static final BigInteger _maxint = BigInteger.valueOf(Integer.MAX_VALUE);
- private static final int pegBigInteger(BigInteger bi)
- {
- if (bi == null)
+ private static int pegBigInteger(BigInteger bi) {
+ if (bi == null) {
return Integer.MAX_VALUE;
- if (bi.signum() <= 0)
+ }
+ if (bi.signum() <= 0) {
return 0;
- if (bi.compareTo(_maxint) >= 0)
+ }
+ if (bi.compareTo(_maxint) >= 0) {
return Integer.MAX_VALUE;
+ }
return bi.intValue();
}
- public QName getName()
- { return _qName; }
-
- public void setNameAndTypeRef(QName formname, SchemaType.Ref typeref)
- { mutate(); _qName = formname; _typeref = typeref; }
-
- public boolean isTypeResolved()
- {
- return (_typeref != null);
+ public QName getName() {
+ return _qName;
}
- public void resolveTypeRef(SchemaType.Ref typeref)
- {
- if (_typeref != null)
- throw new IllegalStateException();
+ public void setNameAndTypeRef(QName formname, SchemaType.Ref typeref) {
+ mutate();
+ _qName = formname;
_typeref = typeref;
}
- public boolean isAttribute()
- { return false; }
+ public boolean isTypeResolved() {
+ return (_typeref != null);
+ }
- public SchemaType getType()
- { if (_typeref == null) return null; return _typeref.get(); }
+ public void resolveTypeRef(SchemaType.Ref typeref) {
+ if (_typeref != null) {
+ throw new IllegalStateException();
+ }
+ _typeref = typeref;
+ }
- public String getDefaultText()
- { return _defaultText; }
+ public boolean isAttribute() {
+ return false;
+ }
- public boolean isDefault()
- { return _isDefault; }
+ public SchemaType getType() {
+ if (_typeref == null) {
+ return null;
+ }
+ return _typeref.get();
+ }
- public boolean isFixed()
- { return _isFixed; }
+ public String getDefaultText() {
+ return _defaultText;
+ }
- public void setDefault(String deftext, boolean isFixed, XmlObject parseObject)
- {
+ public boolean isDefault() {
+ return _isDefault;
+ }
+
+ public boolean isFixed() {
+ return _isFixed;
+ }
+
+ public void setDefault(String deftext, boolean isFixed, XmlObject parseObject) {
mutate();
_defaultText = deftext;
_isDefault = (deftext != null);
@@ -211,27 +248,25 @@
_parseObject = parseObject;
}
- public boolean isNillable()
- { return _isNillable; }
+ public boolean isNillable() {
+ return _isNillable;
+ }
- public void setNillable(boolean nillable)
- { mutate(); _isNillable = nillable; }
+ public void setNillable(boolean nillable) {
+ mutate();
+ _isNillable = nillable;
+ }
- public XmlAnySimpleType getDefaultValue()
- {
- if (_defaultValue != null)
+ public XmlAnySimpleType getDefaultValue() {
+ if (_defaultValue != null) {
return _defaultValue.get();
- if (_defaultText != null && XmlAnySimpleType.type.isAssignableFrom(getType()))
- {
- if (_parseObject != null && XmlQName.type.isAssignableFrom(getType()))
- {
- try
- {
+ }
+ if (_defaultText != null && XmlAnySimpleType.type.isAssignableFrom(getType())) {
+ if (_parseObject != null && XmlQName.type.isAssignableFrom(getType())) {
+ try {
NamespaceContext.push(new NamespaceContext(_parseObject));
return getType().newValue(_defaultText);
- }
- finally
- {
+ } finally {
NamespaceContext.pop();
}
}
@@ -239,20 +274,17 @@
}
return null;
}
-
- public void setDefaultValue(XmlValueRef defaultRef)
- {
+
+ public void setDefaultValue(XmlValueRef defaultRef) {
mutate();
_defaultValue = defaultRef;
}
- public Object getUserData()
- {
+ public Object getUserData() {
return _userData;
}
- public void setUserData(Object data)
- {
+ public void setUserData(Object data) {
_userData = data;
}
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
index 44a7550..904edca 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
@@ -63,14 +63,12 @@
private PrePostExtension _prepost;
// runtime java type support: volatile because they're cached
- private volatile Class _javaClass;
- private volatile Class _javaEnumClass;
- private volatile Class _javaImplClass;
- private volatile Constructor _javaImplConstructor;
- private volatile Constructor _javaImplConstructor2;
+ private volatile Class<? extends XmlObject> _javaClass;
+ private volatile Class<? extends StringEnumAbstractBase> _javaEnumClass;
+ private volatile Class<? extends XmlObjectBase> _javaImplClass;
+ private volatile Constructor<? extends XmlObjectBase> _javaImplConstructor;
+ private volatile Constructor<? extends XmlObjectBase> _javaImplConstructor2;
private volatile boolean _implNotAvailable;
- private volatile Class _userTypeClass;
- private volatile Class _userTypeHandlerClass;
// user data objects not persisted
private volatile Object _userData;
@@ -84,10 +82,10 @@
// complex content support
private SchemaParticle _contentModel;
private volatile SchemaLocalElement[] _localElts; // lazily computed
- private volatile Map _eltToIndexMap; // lazily computed
- private volatile Map _attrToIndexMap; // lazily computed
- private Map _propertyModelByElementName;
- private Map _propertyModelByAttributeName;
+ private volatile Map<SchemaLocalElement, Integer> _eltToIndexMap; // lazily computed
+ private volatile Map<SchemaLocalAttribute, Integer> _attrToIndexMap; // lazily computed
+ private Map<QName, SchemaProperty> _propertyModelByElementName;
+ private Map<QName, SchemaProperty> _propertyModelByAttributeName;
private boolean _hasAllContent;
private boolean _orderSensitive;
private QNameSet _typedWildcardElements;
@@ -95,7 +93,7 @@
private boolean _hasWildcardElements;
private boolean _hasWildcardAttributes;
// set of valid QNames that can be substituted for a property
- private Set _validSubstitutions = Collections.EMPTY_SET;
+ private Set<QName> _validSubstitutions = Collections.emptySet();
// simple content support
private int _complexTypeVariety;
@@ -147,9 +145,9 @@
private XmlValueRef[] _enumerationValues;
private SchemaType.Ref _baseEnumTyperef;
private boolean _stringEnumEnsured;
- private volatile Map _lookupStringEnum;
- private volatile List _listOfStringEnum;
- private volatile Map _lookupStringEnumEntry;
+ private volatile Map<String, StringEnumAbstractBase> _lookupStringEnum;
+ private volatile List<StringEnumAbstractBase> _listOfStringEnum;
+ private volatile Map<String, SchemaStringEnumEntry> _lookupStringEnumEntry;
private SchemaStringEnumEntry[] _stringEnumEntries;
// for lists only
@@ -174,7 +172,7 @@
// for document types only - only valid during compilation
private QName _sg;
- private List _sgMembers = new ArrayList();
+ private final List<QName> _sgMembers = new ArrayList<>();
public boolean isUnloaded() {
return _unloaded;
@@ -479,8 +477,10 @@
if (_containerFieldCode == 0) {
_containerField = _containerFieldRef == null ? null : (SchemaField) _containerFieldRef.getComponent();
} else if (_containerFieldCode == 1) {
+ assert (outer != null);
_containerField = outer.getAttributeModel().getAttributes()[_containerFieldIndex];
} else {
+ assert (outer != null);
_containerField = ((SchemaTypeImpl) outer).getLocalElementByIndex(_containerFieldIndex);
}
_containerFieldCode = -1;
@@ -535,9 +535,8 @@
public boolean isSkippedAnonymousType() {
SchemaType outerType = getOuterType();
- return ((outerType == null) ? false :
- (outerType.getBaseType() == this ||
- outerType.getContentBasedOnType() == this));
+ return (outerType != null && (outerType.getBaseType() == this ||
+ outerType.getContentBasedOnType() == this));
}
public String getShortJavaName() {
@@ -612,7 +611,7 @@
public void setInterfaceExtensions(InterfaceExtension[] interfaces) {
assertResolved();
- _interfaces = interfaces;
+ _interfaces = (interfaces == null) ? null : interfaces.clone();
}
public InterfaceExtension[] getInterfaceExtensions() {
@@ -653,31 +652,31 @@
return _contentModel;
}
- private static void buildEltList(List eltList, SchemaParticle contentModel) {
+ private static void buildEltList(List<SchemaLocalElement> eltList, SchemaParticle contentModel) {
if (contentModel == null) {
return;
}
switch (contentModel.getParticleType()) {
case SchemaParticle.ELEMENT:
- eltList.add(contentModel);
- return;
+ eltList.add((SchemaLocalElement) contentModel);
+ break;
case SchemaParticle.ALL:
case SchemaParticle.CHOICE:
case SchemaParticle.SEQUENCE:
for (int i = 0; i < contentModel.countOfParticleChild(); i++) {
buildEltList(eltList, contentModel.getParticleChild(i));
}
- return;
+ break;
default:
- return;
+ break;
}
}
private void buildLocalElts() {
- List eltList = new ArrayList();
+ List<SchemaLocalElement> eltList = new ArrayList<>();
buildEltList(eltList, _contentModel);
- _localElts = (SchemaLocalElement[]) eltList.toArray(new SchemaLocalElement[eltList.size()]);
+ _localElts = eltList.toArray(new SchemaLocalElement[0]);
}
public SchemaLocalElement getLocalElementByIndex(int i) {
@@ -690,31 +689,31 @@
}
public int getIndexForLocalElement(SchemaLocalElement elt) {
- Map localEltMap = _eltToIndexMap;
+ Map<SchemaLocalElement, Integer> localEltMap = _eltToIndexMap;
if (localEltMap == null) {
if (_localElts == null) {
buildLocalElts();
}
- localEltMap = new HashMap();
+ localEltMap = new HashMap<>();
for (int i = 0; i < _localElts.length; i++) {
- localEltMap.put(_localElts[i], new Integer(i));
+ localEltMap.put(_localElts[i], i);
}
_eltToIndexMap = localEltMap;
}
- return ((Integer) localEltMap.get(elt)).intValue();
+ return localEltMap.get(elt);
}
public int getIndexForLocalAttribute(SchemaLocalAttribute attr) {
- Map localAttrMap = _attrToIndexMap;
+ Map<SchemaLocalAttribute, Integer> localAttrMap = _attrToIndexMap;
if (localAttrMap == null) {
- localAttrMap = new HashMap();
+ localAttrMap = new HashMap<>();
SchemaLocalAttribute[] attrs = this._attributeModel.getAttributes();
for (int i = 0; i < attrs.length; i++) {
- localAttrMap.put(attrs[i], new Integer(i));
+ localAttrMap.put(attrs[i], i);
}
_attrToIndexMap = localAttrMap;
}
- return ((Integer) localAttrMap.get(attr)).intValue();
+ return localAttrMap.get(attr);
}
public SchemaAttributeModel getAttributeModel() {
@@ -730,10 +729,10 @@
return getElementProperties();
}
- List list = new ArrayList();
+ List<SchemaProperty> list = new ArrayList<>();
list.addAll(_propertyModelByElementName.values());
list.addAll(_propertyModelByAttributeName.values());
- return (SchemaProperty[]) list.toArray(new SchemaProperty[list.size()]);
+ return list.toArray(new SchemaProperty[0]);
}
private static final SchemaProperty[] NO_PROPERTIES = new SchemaProperty[0];
@@ -744,7 +743,7 @@
return getProperties();
}
- List results = new ArrayList();
+ List<SchemaProperty> results = new ArrayList<>();
if (_propertyModelByElementName != null) {
results.addAll(_propertyModelByElementName.values());
@@ -754,8 +753,8 @@
results.addAll(_propertyModelByAttributeName.values());
}
- for (Iterator it = results.iterator(); it.hasNext(); ) {
- SchemaProperty prop = (SchemaProperty) it.next();
+ for (Iterator<SchemaProperty> it = results.iterator(); it.hasNext(); ) {
+ SchemaProperty prop = it.next();
SchemaProperty baseProp = prop.isAttribute() ?
baseType.getAttributeProperty(prop.getName()) :
baseType.getElementProperty(prop.getName());
@@ -777,7 +776,7 @@
}
- return (SchemaProperty[]) results.toArray(new SchemaProperty[results.size()]);
+ return results.toArray(new SchemaProperty[0]);
}
private static boolean eq(BigInteger a, BigInteger b) {
@@ -805,8 +804,7 @@
return NO_PROPERTIES;
}
- return (SchemaProperty[])
- _propertyModelByElementName.values().toArray(new SchemaProperty[_propertyModelByElementName.size()]);
+ return _propertyModelByElementName.values().toArray(new SchemaProperty[0]);
}
public SchemaProperty[] getAttributeProperties() {
@@ -814,16 +812,15 @@
return NO_PROPERTIES;
}
- return (SchemaProperty[])
- _propertyModelByAttributeName.values().toArray(new SchemaProperty[_propertyModelByAttributeName.size()]);
+ return _propertyModelByAttributeName.values().toArray(new SchemaProperty[0]);
}
public SchemaProperty getElementProperty(QName eltName) {
- return _propertyModelByElementName == null ? null : (SchemaProperty) _propertyModelByElementName.get(eltName);
+ return _propertyModelByElementName == null ? null : _propertyModelByElementName.get(eltName);
}
public SchemaProperty getAttributeProperty(QName attrName) {
- return _propertyModelByAttributeName == null ? null : (SchemaProperty) _propertyModelByAttributeName.get(attrName);
+ return _propertyModelByAttributeName == null ? null : _propertyModelByAttributeName.get(attrName);
}
public boolean hasAllContent() {
@@ -842,8 +839,8 @@
public void setContentModel(
SchemaParticle contentModel,
SchemaAttributeModel attrModel,
- Map propertyModelByElementName,
- Map propertyModelByAttributeName,
+ Map<QName, SchemaProperty> propertyModelByElementName,
+ Map<QName, SchemaProperty> propertyModelByAttributeName,
boolean isAll) {
assertResolving();
_contentModel = contentModel;
@@ -855,14 +852,13 @@
// Add entries for each element property for substitution group members
if (_propertyModelByElementName != null) {
- _validSubstitutions = new LinkedHashSet();
- Collection eltProps = _propertyModelByElementName.values();
- for (Iterator it = eltProps.iterator(); it.hasNext(); ) {
- SchemaProperty prop = (SchemaProperty) it.next();
+ _validSubstitutions = new LinkedHashSet<>();
+ Collection<SchemaProperty> eltProps = _propertyModelByElementName.values();
+ for (SchemaProperty prop : eltProps) {
QName[] names = prop.acceptedNames();
- for (int i = 0; i < names.length; i++) {
- if (!_propertyModelByElementName.containsKey(names[i])) {
- _validSubstitutions.add(names[i]);
+ for (QName name : names) {
+ if (!_propertyModelByElementName.containsKey(name)) {
+ _validSubstitutions.add(name);
}
}
}
@@ -891,8 +887,8 @@
return BuiltinSchemaTypeSystem.ST_NO_TYPE;
}
- SchemaType type = null;
- SchemaProperty prop = (SchemaProperty) _propertyModelByElementName.get(eltName);
+ SchemaType type;
+ SchemaProperty prop = _propertyModelByElementName.get(eltName);
if (prop != null) {
type = prop.getType();
} else {
@@ -925,9 +921,7 @@
sghead = sghead.substitutionGroup();
}
*/
- if (type == null) {
- return BuiltinSchemaTypeSystem.ST_NO_TYPE;
- }
+ return BuiltinSchemaTypeSystem.ST_NO_TYPE;
}
}
@@ -955,7 +949,7 @@
return BuiltinSchemaTypeSystem.ST_ANY_SIMPLE;
}
- SchemaProperty prop = (SchemaProperty) _propertyModelByAttributeName.get(attrName);
+ SchemaProperty prop = _propertyModelByAttributeName.get(attrName);
if (prop != null) {
return prop.getType();
}
@@ -979,12 +973,12 @@
* things, they can't be refactored to share code, so exercise caution
*/
public XmlObject createElementType(QName eltName, QName xsiType, SchemaTypeLoader wildcardTypeLoader) {
- SchemaType type = null;
+ SchemaType type;
SchemaProperty prop = null;
if (isSimpleType() || !containsElements() || isNoType()) {
type = BuiltinSchemaTypeSystem.ST_NO_TYPE;
} else {
- prop = (SchemaProperty) _propertyModelByElementName.get(eltName);
+ prop = _propertyModelByElementName.get(eltName);
if (prop != null) {
type = prop.getType();
} else if (_typedWildcardElements.contains(eltName) ||
@@ -1019,9 +1013,7 @@
sghead = sghead.substitutionGroup();
}
*/
- if (type == null) {
- type = BuiltinSchemaTypeSystem.ST_NO_TYPE;
- }
+ type = BuiltinSchemaTypeSystem.ST_NO_TYPE;
}
if (xsiType != null) {
@@ -1044,14 +1036,14 @@
}
public XmlObject createAttributeType(QName attrName, SchemaTypeLoader wildcardTypeLoader) {
- SchemaTypeImpl type = null;
+ SchemaTypeImpl type;
SchemaProperty prop = null;
if (isSimpleType() || isNoType()) {
type = BuiltinSchemaTypeSystem.ST_NO_TYPE;
} else if (isURType()) {
type = BuiltinSchemaTypeSystem.ST_ANY_SIMPLE;
} else {
- prop = (SchemaProperty) _propertyModelByAttributeName.get(attrName);
+ prop = _propertyModelByAttributeName.get(attrName);
if (prop != null) {
type = (SchemaTypeImpl) prop.getType();
} else if (!_typedWildcardAttributes.contains(attrName)) {
@@ -1090,7 +1082,7 @@
}
public void setAnonymousTypeRefs(SchemaType.Ref[] anonymousTyperefs) {
- _anonymousTyperefs = anonymousTyperefs;
+ _anonymousTyperefs = anonymousTyperefs == null ? null : anonymousTyperefs.clone();
}
@@ -1223,7 +1215,7 @@
public void setUnionMemberTypeRefs(SchemaType.Ref[] typerefs) {
assertResolving();
- _unionMemberTyperefs = typerefs;
+ _unionMemberTyperefs = typerefs == null ? null : typerefs.clone();
}
public int getAnonymousUnionMemberOrdinal() {
@@ -1272,14 +1264,14 @@
if (getSimpleVariety() != SchemaType.UNION) {
throw new IllegalStateException("Operation is only supported on union types");
}
- Set constituentMemberTypes = new LinkedHashSet();
- Set allSubTypes = new LinkedHashSet();
+ Set<SchemaType> constituentMemberTypes = new LinkedHashSet<>();
+ Set<SchemaType> allSubTypes = new LinkedHashSet<>();
SchemaType commonBaseType = null;
allSubTypes.add(this);
- for (int i = 0; i < _unionMemberTyperefs.length; i++) {
- SchemaTypeImpl mImpl = (SchemaTypeImpl) _unionMemberTyperefs[i].get();
+ for (Ref unionMemberTyperef : _unionMemberTyperefs) {
+ SchemaTypeImpl mImpl = (SchemaTypeImpl) unionMemberTyperef.get();
switch (mImpl.getSimpleVariety()) {
case SchemaType.LIST:
@@ -1305,10 +1297,8 @@
}
}
- setUnionConstituentTypes((SchemaType[])
- constituentMemberTypes.toArray(StscState.EMPTY_ST_ARRAY));
- setUnionSubTypes((SchemaType[])
- allSubTypes.toArray(StscState.EMPTY_ST_ARRAY));
+ setUnionConstituentTypes(constituentMemberTypes.toArray(StscState.EMPTY_ST_ARRAY));
+ setUnionSubTypes(allSubTypes.toArray(StscState.EMPTY_ST_ARRAY));
setUnionCommonBaseType(commonBaseType);
}
@@ -1327,8 +1317,7 @@
}
public QName[] getSubstitutionGroupMembers() {
- QName[] result = new QName[_sgMembers.size()];
- return (QName[]) _sgMembers.toArray(result);
+ return _sgMembers.toArray(new QName[0]);
}
public int getWhiteSpaceRule() {
@@ -1369,8 +1358,8 @@
public void setBasicFacets(XmlValueRef[] values, boolean[] fixed) {
assertResolving();
- _facetArray = values;
- _fixedFacetArray = fixed;
+ _facetArray = values == null ? null : values.clone();
+ _fixedFacetArray = fixed == null ? null : fixed.clone();
}
public int ordered() {
@@ -1461,7 +1450,7 @@
public void setPatterns(org.apache.xmlbeans.impl.regex.RegularExpression[] list) {
assertResolving();
- _patterns = list;
+ _patterns = list == null ? null : list.clone();
}
public XmlAnySimpleType[] getEnumerationValues() {
@@ -1479,7 +1468,7 @@
public void setEnumerationValues(XmlValueRef[] a) {
assertResolving();
- _enumerationValues = a;
+ _enumerationValues = a == null ? null : a.clone();
}
public StringEnumAbstractBase enumForString(String s) {
@@ -1487,7 +1476,7 @@
if (_lookupStringEnum == null) {
return null;
}
- return (StringEnumAbstractBase) _lookupStringEnum.get(s);
+ return _lookupStringEnum.get(s);
}
public StringEnumAbstractBase enumForInt(int i) {
@@ -1495,7 +1484,7 @@
if (_listOfStringEnum == null || i < 0 || i >= _listOfStringEnum.size()) {
return null;
}
- return (StringEnumAbstractBase) _listOfStringEnum.get(i);
+ return _listOfStringEnum.get(i);
}
public SchemaStringEnumEntry enumEntryForString(String s) {
@@ -1503,7 +1492,7 @@
if (_lookupStringEnumEntry == null) {
return null;
}
- return (SchemaStringEnumEntry) _lookupStringEnumEntry.get(s);
+ return _lookupStringEnumEntry.get(s);
}
public SchemaType getBaseEnumType() {
@@ -1523,9 +1512,9 @@
return result;
}
- public void setStringEnumEntries(SchemaStringEnumEntry sEnums[]) {
+ public void setStringEnumEntries(SchemaStringEnumEntry[] sEnums) {
assertJavaizing();
- _stringEnumEntries = sEnums;
+ _stringEnumEntries = sEnums == null ? null : sEnums.clone();
}
private void ensureStringEnumInfo() {
@@ -1539,22 +1528,22 @@
return;
}
- Map lookupStringEnum = new HashMap(sEnums.length);
- List listOfStringEnum = new ArrayList(sEnums.length + 1);
- Map lookupStringEnumEntry = new HashMap(sEnums.length);
+ Map<String, StringEnumAbstractBase> lookupStringEnum = new HashMap<>(sEnums.length);
+ List<StringEnumAbstractBase> listOfStringEnum = new ArrayList<>(sEnums.length + 1);
+ Map<String, SchemaStringEnumEntry> lookupStringEnumEntry = new HashMap<>(sEnums.length);
- for (int i = 0; i < sEnums.length; i++) {
- lookupStringEnumEntry.put(sEnums[i].getString(), sEnums[i]);
+ for (SchemaStringEnumEntry sEnum : sEnums) {
+ lookupStringEnumEntry.put(sEnum.getString(), sEnum);
}
- Class jc = _baseEnumTyperef.get().getEnumJavaClass();
+ Class<? extends StringEnumAbstractBase> jc = _baseEnumTyperef.get().getEnumJavaClass();
if (jc != null) {
try {
StringEnumAbstractBase.Table table = (StringEnumAbstractBase.Table) jc.getField("table").get(null);
- for (int i = 0; i < sEnums.length; i++) {
- int j = sEnums[i].getIntValue();
+ for (SchemaStringEnumEntry sEnum : sEnums) {
+ int j = sEnum.getIntValue();
StringEnumAbstractBase enumVal = table.forInt(j);
- lookupStringEnum.put(sEnums[i].getString(), enumVal);
+ lookupStringEnum.put(sEnum.getString(), enumVal);
while (listOfStringEnum.size() <= j) {
listOfStringEnum.add(null);
}
@@ -1569,9 +1558,9 @@
}
if (jc == null) {
- for (int i = 0; i < sEnums.length; i++) {
- int j = sEnums[i].getIntValue();
- String s = sEnums[i].getString();
+ for (SchemaStringEnumEntry sEnum : sEnums) {
+ int j = sEnum.getIntValue();
+ String s = sEnum.getString();
StringEnumAbstractBase enumVal = new StringEnumValue(s, j);
lookupStringEnum.put(s, enumVal);
while (listOfStringEnum.size() <= j) {
@@ -1620,11 +1609,11 @@
SchemaProperty[] eltProps = getElementProperties();
SchemaParticle contentModel = getContentModel();
- Map state = new HashMap();
+ Map<SchemaParticle, QNameSet> state = new HashMap<>();
QNameSet allContents = computeAllContainedElements(contentModel, state);
- for (int i = 0; i < eltProps.length; i++) {
- SchemaPropertyImpl sImpl = (SchemaPropertyImpl) eltProps[i];
+ for (SchemaProperty eltProp : eltProps) {
+ SchemaPropertyImpl sImpl = (SchemaPropertyImpl) eltProp;
QNameSet nde = computeNondelimitingElements(sImpl.getName(), contentModel, state);
QNameSetBuilder builder = new QNameSetBuilder(allContents);
builder.removeAll(nde);
@@ -1640,7 +1629,7 @@
* contentModel. When appending an element, it comes before the first
* one that is not in this set.
*/
- private static QNameSet computeNondelimitingElements(QName target, SchemaParticle contentModel, Map state) {
+ private static QNameSet computeNondelimitingElements(QName target, SchemaParticle contentModel, Map<SchemaParticle, QNameSet> state) {
QNameSet allContents = computeAllContainedElements(contentModel, state);
if (!allContents.contains(target)) {
return QNameSet.EMPTY;
@@ -1698,9 +1687,9 @@
* to record the results, so that if they are needed again later,
* they do not need to be recomputed.
*/
- private static QNameSet computeAllContainedElements(SchemaParticle contentModel, Map state) {
+ private static QNameSet computeAllContainedElements(SchemaParticle contentModel, Map<SchemaParticle, QNameSet> state) {
// Remember previously computed results to avoid complexity explosion
- QNameSet result = (QNameSet) state.get(contentModel);
+ QNameSet result = state.get(contentModel);
if (result != null) {
return result;
}
@@ -1725,23 +1714,21 @@
case SchemaParticle.ELEMENT:
// Fix for XMLBEANS-228
- result = ((SchemaLocalElementImpl) contentModel).acceptedStartNames();
+ result = contentModel.acceptedStartNames();
break;
}
state.put(contentModel, result);
return result;
}
- public Class getJavaClass() {
+ @SuppressWarnings("unchecked")
+ public Class<? extends XmlObject> getJavaClass() {
// This field is declared volatile and Class is immutable so this is allowed.
if (_javaClass == null && getFullJavaName() != null) {
try {
- _javaClass = Class.forName(getFullJavaName(), false, getTypeSystem().getClassLoader());
+ _javaClass = (Class<? extends XmlObject>) Class.forName(getFullJavaName(), false, getTypeSystem().getClassLoader());
} catch (ClassNotFoundException e) {
-// This is a legitimate use, when users get a SchemaTypeSystem without compiling classes
-// System.err.println("Could not find class name " + getFullJavaName());
-// System.err.println("Searched in classloader " + getTypeSystem().getClassLoader());
-// e.printStackTrace(System.err);
+ // This is a legitimate use, when users get a SchemaTypeSystem without compiling classes
_javaClass = null;
}
}
@@ -1749,7 +1736,8 @@
return _javaClass;
}
- public Class getJavaImplClass() {
+ @SuppressWarnings("unchecked")
+ public Class<? extends XmlObjectBase> getJavaImplClass() {
if (_implNotAvailable) {
return null;
}
@@ -1757,7 +1745,7 @@
if (_javaImplClass == null) {
try {
if (getFullJavaImplName() != null) {
- _javaImplClass = Class.forName(getFullJavaImplName(), false, getTypeSystem().getClassLoader());
+ _javaImplClass = (Class<? extends XmlObjectBase>) Class.forName(getFullJavaImplName(), false, getTypeSystem().getClassLoader());
} else {
_implNotAvailable = true;
}
@@ -1769,42 +1757,14 @@
return _javaImplClass;
}
- public Class getUserTypeClass() {
- // This field is declared volatile and Class is immutable so this is allowed.
- if (_userTypeClass == null && getUserTypeName() != null) {
- try {
- _userTypeClass = Class.forName(_userTypeName, false,
- getTypeSystem().getClassLoader());
- } catch (ClassNotFoundException e) {
- _userTypeClass = null;
- }
- }
-
- return _userTypeClass;
- }
-
- public Class getUserTypeHandlerClass() {
- // This field is declared volatile and Class is immutable so this is allowed.
- if (_userTypeHandlerClass == null && getUserTypeHandlerName() != null) {
- try {
- _userTypeHandlerClass = Class.forName(_userTypeHandler, false,
- getTypeSystem().getClassLoader());
- } catch (ClassNotFoundException e) {
- _userTypeHandlerClass = null;
- }
- }
-
- return _userTypeHandlerClass;
- }
-
- public Constructor getJavaImplConstructor() {
+ public Constructor<? extends XmlObjectBase> getJavaImplConstructor() {
if (_javaImplConstructor == null && !_implNotAvailable) {
- final Class impl = getJavaImplClass();
+ final Class<? extends XmlObjectBase> impl = getJavaImplClass();
if (impl == null) {
return null;
}
try {
- _javaImplConstructor = impl.getConstructor(new Class[]{SchemaType.class});
+ _javaImplConstructor = impl.getConstructor(SchemaType.class);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
@@ -1814,14 +1774,14 @@
}
- public Constructor getJavaImplConstructor2() {
+ public Constructor<? extends XmlObjectBase> getJavaImplConstructor2() {
if (_javaImplConstructor2 == null && !_implNotAvailable) {
- final Class impl = getJavaImplClass();
+ final Class<? extends XmlObjectBase> impl = getJavaImplClass();
if (impl == null) {
return null;
}
try {
- _javaImplConstructor2 = impl.getDeclaredConstructor(new Class[]{SchemaType.class, boolean.class});
+ _javaImplConstructor2 = impl.getDeclaredConstructor(SchemaType.class, boolean.class);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
@@ -1831,12 +1791,14 @@
}
- public Class getEnumJavaClass() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<? extends StringEnumAbstractBase> getEnumJavaClass() {
// This field is declared volatile and Class is immutable so this is allowed.
if (_javaEnumClass == null) {
if (getBaseEnumType() != null) {
try {
- _javaEnumClass = Class.forName(getBaseEnumType().getFullJavaName() + "$Enum", false, getTypeSystem().getClassLoader());
+ _javaEnumClass = (Class<? extends StringEnumAbstractBase>) Class.forName(getBaseEnumType().getFullJavaName() + "$Enum", false, getTypeSystem().getClassLoader());
} catch (ClassNotFoundException e) {
_javaEnumClass = null;
}
@@ -1846,7 +1808,7 @@
return _javaEnumClass;
}
- public void setJavaClass(Class javaClass) {
+ public void setJavaClass(Class<? extends XmlObject> javaClass) {
assertResolved();
_javaClass = javaClass;
setFullJavaName(javaClass.getName());
@@ -1863,8 +1825,7 @@
public XmlObject createUnwrappedNode() {
// Todo: attach a new xml store!
- XmlObject result = createUnattachedNode(null);
- return result;
+ return createUnattachedNode(null);
}
/**
@@ -1918,11 +1879,10 @@
if (!isBuiltinType() && !isNoType()) {
// System.out.println("Attempting to load impl class: " + getFullJavaImplName());
- Constructor ctr = getJavaImplConstructor();
+ Constructor<? extends XmlObjectBase> ctr = getJavaImplConstructor();
if (ctr != null) {
try {
- // System.out.println("Succeeded!");
- return (XmlObject) ctr.newInstance(_ctrArgs);
+ return ctr.newInstance(_ctrArgs);
} catch (Exception e) {
System.out.println("Exception trying to instantiate impl class.");
e.printStackTrace();
@@ -1944,14 +1904,13 @@
private XmlObject createUnattachedSubclass(SchemaType sType) {
if (!isBuiltinType() && !isNoType()) {
// System.out.println("Attempting to load impl class: " + getFullJavaImplName());
- Constructor ctr = getJavaImplConstructor2();
+ Constructor<? extends XmlObjectBase> ctr = getJavaImplConstructor2();
if (ctr != null) {
boolean accessible = ctr.isAccessible();
try {
ctr.setAccessible(true);
- // System.out.println("Succeeded!");
try {
- return (XmlObject) ctr.newInstance(new Object[]{sType, sType.isSimpleType() ? Boolean.FALSE : Boolean.TRUE});
+ return ctr.newInstance(sType, !sType.isSimpleType());
} catch (Exception e) {
System.out.println("Exception trying to instantiate impl class.");
e.printStackTrace();
@@ -1959,7 +1918,7 @@
// Make a best-effort try to set the accessibility back to what it was
try {
ctr.setAccessible(accessible);
- } catch (SecurityException se) {
+ } catch (SecurityException ignored) {
}
}
} catch (Exception e) {
@@ -2210,10 +2169,7 @@
while (sImpl2.getBaseDepth() > sImpl1.getBaseDepth()) {
sImpl2 = (SchemaTypeImpl) sImpl2.getBaseType();
}
- for (; ; ) {
- if (sImpl1.equals(sImpl2)) {
- break;
- }
+ while (!sImpl1.equals(sImpl2)) {
sImpl1 = (SchemaTypeImpl) sImpl1.getBaseType();
sImpl2 = (SchemaTypeImpl) sImpl2.getBaseType();
assert (sImpl1 != null && sImpl2 != null); // must meet at anyType
@@ -2232,8 +2188,8 @@
if (getSimpleVariety() == UNION) {
SchemaType[] members = getUnionMemberTypes();
- for (int i = 0; i < members.length; i++) {
- if (members[i].isAssignableFrom(type)) {
+ for (SchemaType member : members) {
+ if (member.isAssignableFrom(type)) {
return true;
}
}
@@ -2337,7 +2293,7 @@
return _redefinition;
}
- private SchemaType.Ref _selfref = new SchemaType.Ref(this);
+ private final SchemaType.Ref _selfref = new SchemaType.Ref(this);
public SchemaType.Ref getRef() {
return _selfref;
@@ -2351,7 +2307,7 @@
* Gives access to the internals of element validation
*/
private static class SequencerImpl implements SchemaTypeElementSequencer {
- private SchemaTypeVisitorImpl _visitor;
+ private final SchemaTypeVisitorImpl _visitor;
private SequencerImpl(SchemaTypeVisitorImpl visitor) {
_visitor = visitor;
@@ -2396,8 +2352,7 @@
QNameSetBuilder qnsb = new QNameSetBuilder(wildcardSet);
SchemaProperty[] props = this.getElementProperties();
- for (int i = 0; i < props.length; i++) {
- SchemaProperty prop = props[i];
+ for (SchemaProperty prop : props) {
qnsb.remove(prop.getName());
}
@@ -2441,8 +2396,7 @@
SchemaProperty[] props = this.getAttributeProperties();
- for (int i = 0; i < props.length; i++) {
- SchemaProperty prop = props[i];
+ for (SchemaProperty prop : props) {
qnsb.remove(prop.getName());
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
index a6673cd..3a512be 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
@@ -61,7 +61,7 @@
}
public void setSchemas(SchemaDocument.Schema[] schemas) {
- this.schemas = schemas;
+ this.schemas = (schemas == null) ? null : schemas.clone();
}
public BindingConfig getConfig() {
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/StscChecker.java b/src/main/java/org/apache/xmlbeans/impl/schema/StscChecker.java
index 9f056a7..338f21f 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/StscChecker.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/StscChecker.java
@@ -158,10 +158,6 @@
* Checks the default values of elements.<p/>
* Also checks that the type of elements is not one of ID, IDREF, IDREFS, ENTITY, ENTITIES or
* NOTATION as per XMLSchema part 2.
- *
- * @param model
- * @param location
- * @param parentType
*/
private static void checkElementDefaults(SchemaParticle model, XmlObject location, SchemaType parentType) {
if (model == null) {
@@ -317,6 +313,7 @@
XmlObject location = sType.getParseObject();
SchemaType baseType = sType.getBaseType();
+ assert (baseType != null);
if (baseType.isSimpleType()) {
state.error(XmlErrorCodes.SCHEMA_COMPLEX_TYPE$COMPLEX_CONTENT,
new Object[]{QNameHelper.pretty(baseType.getName())},
@@ -448,7 +445,7 @@
* @param baseModel - The base schema particle
* @param derivedModel - The derived (restricted) schema particle
* @param errors - Invalid restriction errors are put into this collection
- * @param context
+ * @param context . the context
* @return boolean, true if valid restruction, false if invalid restriction
* @
*/
@@ -487,11 +484,7 @@
restrictionValid = nsSubset(baseModel, derivedModel, errors, context);
break;
case SchemaParticle.ALL:
- restrictionValid = nsRecurseCheckCardinality(baseModel, derivedModel, errors, context);
- break;
case SchemaParticle.CHOICE:
- restrictionValid = nsRecurseCheckCardinality(baseModel, derivedModel, errors, context);
- break;
case SchemaParticle.SEQUENCE:
restrictionValid = nsRecurseCheckCardinality(baseModel, derivedModel, errors, context);
break;
@@ -573,7 +566,6 @@
// mapAndSum is call if base: CHOICE, derived: SEQUENCE
assert baseModel.getParticleType() == SchemaParticle.CHOICE;
assert derivedModel.getParticleType() == SchemaParticle.SEQUENCE;
- boolean mapAndSumValid = true;
// Schema Component Constraint: Particle Derivation OK (Sequence:Choice -- MapAndSum)
// For a sequence group particle to be a �valid restriction� of a choice group particle all of the following
// must be true:
@@ -604,13 +596,11 @@
}
}
if (!foundMatch) {
- mapAndSumValid = false;
errors.add(XmlError.forObject(XmlErrorCodes.PARTICLE_DERIVATION_MAP_AND_SUM$MAP,
new Object[]{printParticle(derivedParticle)},
context));
// KHK: if we don't return false now, this error may get swallowed by an error produced below
return false;
- //break;
}
}
@@ -631,6 +621,7 @@
// 2.1 The other's {max occurs} is unbounded.
// 2.2 Both {max occurs} are numbers, and the particle's is less than or equal to the other's.
+ boolean mapAndSumValid = true;
if (derivedRangeMin.compareTo(baseModel.getMinOccurs()) < 0) {
mapAndSumValid = false;
errors.add(XmlError.forObject(XmlErrorCodes.PARTICLE_DERIVATION_MAP_AND_SUM$SUM_MIN_OCCURS_GTE_MIN_OCCURS,
@@ -960,6 +951,8 @@
// Check for valid Wildcard/Group derivation
nsRecurseCheckCardinality = nsRecurseCheckCardinality(asIfPart, particle, errors, context);
break;
+ default:
+ break;
}
// If any particle is invalid then break the loop
if (!nsRecurseCheckCardinality) {
@@ -992,6 +985,8 @@
minRange = getEffectiveMinRangeChoice(derivedModel);
maxRange = getEffectiveMaxRangeChoice(derivedModel);
break;
+ default:
+ break;
}
// Check min occurs for validity
@@ -1080,6 +1075,8 @@
}
}
break;
+ default:
+ break;
}
// if an unbounded has been found then we are done
if (maxRange == null) {
@@ -1156,6 +1153,8 @@
}
}
break;
+ default:
+ break;
}
// if an unbounded has been found then we are done
if (maxRange == null) {
@@ -1219,6 +1218,8 @@
minRange = mrc;
}
break;
+ default:
+ break;
}
}
if (minRange == null) {
@@ -1256,6 +1257,8 @@
case SchemaParticle.CHOICE:
particleTotalMinOccurs = particleTotalMinOccurs.add(getEffectiveMinRangeChoice(particle));
break;
+ default:
+ break;
}
}
@@ -1300,13 +1303,7 @@
// as defined by Wildcard allows Namespace Name (�3.10.4).
if (baseModel.getWildcardSet().contains(derivedElement.getName())) {
// 2 R's occurrence range is a valid restriction of B's occurrence range as defined by Occurrence Range OK (�3.9.6).
- if (occurrenceRangeOK(baseModel, (SchemaParticle) derivedElement, errors, context)) {
- nsCompat = true;
- } else {
- nsCompat = false;
- // error already produced by occurrenceRangeOK
- //errors.add(XmlError.forObject(formatOccurenceRangeMinError(baseModel, (SchemaParticle) derivedElement), context));
- }
+ nsCompat = occurrenceRangeOK(baseModel, (SchemaParticle) derivedElement, errors, context);
} else {
nsCompat = false;
errors.add(XmlError.forObject(XmlErrorCodes.PARTICLE_DERIVATION_NS_COMPAT$WILDCARD_VALID,
diff --git a/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java b/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java
index 8e7e1b0..18efbd7 100644
--- a/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java
+++ b/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java
@@ -461,7 +461,7 @@
return input;
}
}
- Class<?> desiredClass = commonType.getJavaClass();
+ Class<? extends XmlObject> desiredClass = commonType.getJavaClass();
while (desiredClass == null) {
commonType = commonType.getBaseType();
if (XmlObject.type.equals(commonType)) {
@@ -1549,12 +1549,12 @@
new Object[]{getPrimitiveTypeName(), "QName"});
}
- public List getListValue() {
+ public List<?> getListValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[]{getPrimitiveTypeName(), "List"});
}
- public List xgetListValue() {
+ public List<?> xgetListValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[]{getPrimitiveTypeName(), "List"});
}
@@ -2836,7 +2836,7 @@
private static class SerializedRootObject implements Serializable {
private static final long serialVersionUID = 1;
- transient Class<?> _xbeanClass;
+ transient Class<? extends XmlObject> _xbeanClass;
transient XmlObject _impl;
private SerializedRootObject(XmlObject impl) {
@@ -2861,13 +2861,14 @@
out.writeBoolean(false);
}
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException {
try {
// read class object first - this is
// first just for historical reasons - really
// it would be better to have the version numbers
// first
- _xbeanClass = (Class<?>) in.readObject();
+ _xbeanClass = (Class<? extends XmlObject>) in.readObject();
int utfBytes = in.readUnsignedShort();
@@ -2891,16 +2892,13 @@
break;
case 1:
- switch (minorVersionNum) {
- case 1:
- xmlText = (String) in.readObject();
- in.readBoolean(); // ignored
- break;
-
- default:
- throw new IOException("Deserialization error: " +
- "version number " + majorVersionNum + "." +
- minorVersionNum + " not supported.");
+ if (minorVersionNum == 1) {
+ xmlText = (String) in.readObject();
+ in.readBoolean(); // ignored
+ } else {
+ throw new IOException("Deserialization error: " +
+ "version number " + majorVersionNum + "." +
+ minorVersionNum + " not supported.");
}
break;