You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2004/05/16 00:13:13 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/util XSNamedMapImpl.java
mrglavas 2004/05/15 15:13:12
Modified: java/src/org/apache/xerces/impl/xs SchemaGrammar.java
XSModelImpl.java
java/src/org/apache/xerces/impl/xs/util XSNamedMapImpl.java
Log:
Fixing Jira Bug #960:
http://nagoya.apache.org/jira/browse/XERCESJ-960
Two new kinds of components (XSFacet & XSMultiValueFacet)
were added to the XML Schema API some time ago, but the
array in SchemaGrammar was't updated to reflect such change.
Fixing another bug where we returned null where an empty
XSNamedMap is expected for getComponents and
getComponentsByNamespace. This wasn't updated when
the spec changed.
Revision Changes Path
1.37 +28 -25 xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- SchemaGrammar.java 24 Feb 2004 22:59:11 -0000 1.36
+++ SchemaGrammar.java 15 May 2004 22:13:12 -0000 1.37
@@ -18,10 +18,23 @@
import java.util.Vector;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.dv.SchemaDVFactory;
import org.apache.xerces.impl.dv.ValidatedInfo;
import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.impl.xs.identity.IdentityConstraint;
+import org.apache.xerces.impl.xs.util.SimpleLocator;
+import org.apache.xerces.impl.xs.util.StringListImpl;
+import org.apache.xerces.impl.xs.util.XSNamedMap4Types;
+import org.apache.xerces.impl.xs.util.XSNamedMapImpl;
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;
+import org.apache.xerces.parsers.DOMParser;
+import org.apache.xerces.parsers.IntegratedParserConfiguration;
+import org.apache.xerces.parsers.SAXParser;
+import org.apache.xerces.util.SymbolHash;
+import org.apache.xerces.util.SymbolTable;
+import org.apache.xerces.xni.grammars.XMLGrammarDescription;
+import org.apache.xerces.xni.grammars.XSGrammar;
import org.apache.xerces.xs.StringList;
import org.apache.xerces.xs.XSAnnotation;
import org.apache.xerces.xs.XSAttributeDeclaration;
@@ -37,19 +50,6 @@
import org.apache.xerces.xs.XSParticle;
import org.apache.xerces.xs.XSTypeDefinition;
import org.apache.xerces.xs.XSWildcard;
-import org.apache.xerces.impl.xs.util.SimpleLocator;
-import org.apache.xerces.impl.xs.util.StringListImpl;
-import org.apache.xerces.impl.xs.util.XSNamedMap4Types;
-import org.apache.xerces.impl.xs.util.XSNamedMapImpl;
-import org.apache.xerces.impl.xs.util.XSObjectListImpl;
-import org.apache.xerces.impl.Constants;
-import org.apache.xerces.parsers.DOMParser;
-import org.apache.xerces.parsers.SAXParser;
-import org.apache.xerces.parsers.IntegratedParserConfiguration;
-import org.apache.xerces.util.SymbolHash;
-import org.apache.xerces.util.SymbolTable;
-import org.apache.xerces.xni.grammars.XMLGrammarDescription;
-import org.apache.xerces.xni.grammars.XSGrammar;
/**
* This class is to hold all schema component declaration that are declared
@@ -695,6 +695,8 @@
false, // idc
true, // notation
false, // annotation
+ false, // facet
+ false, // multi value facet
true, // complex type
true // simple type
};
@@ -755,21 +757,22 @@
}
/**
- * Returns a list of top-level components, i.e. element declarations,
- * attribute declarations, etc.<p>
- * Note that <code>XSTypeDefinition#SIMPLE_TYPE</code> and
- * <code>XSTypeDefinition#COMPLEX_TYPE</code> can also be used as the
- * <code>objectType</code> to retrieve only complex types or simple types,
- * instead of all types.
- * @param objectType The type of the declaration, i.e.
- * ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, etc.
- * @return A list of top-level definition of the specified type in
- * <code>objectType</code> or <code>null</code>.
+ * [schema components]: a list of top-level components, i.e. element
+ * declarations, attribute declarations, etc.
+ * @param objectType The type of the declaration, i.e.
+ * <code>ELEMENT_DECLARATION</code>. Note that
+ * <code>XSTypeDefinition.SIMPLE_TYPE</code> and
+ * <code>XSTypeDefinition.COMPLEX_TYPE</code> can also be used as the
+ * <code>objectType</code> to retrieve only complex types or simple
+ * types, instead of all types.
+ * @return A list of top-level definition of the specified type in
+ * <code>objectType</code> or an empty <code>XSNamedMap</code> if no
+ * such definitions exist.
*/
public synchronized XSNamedMap getComponents(short objectType) {
if (objectType <= 0 || objectType > MAX_COMP_IDX ||
!GLOBAL_COMP[objectType]) {
- return null;
+ return XSNamedMapImpl.EMPTY_MAP;
}
if (fComponents == null)
1.14 +24 -19 xml-xerces/java/src/org/apache/xerces/impl/xs/XSModelImpl.java
Index: XSModelImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSModelImpl.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XSModelImpl.java 24 Feb 2004 22:59:12 -0000 1.13
+++ XSModelImpl.java 15 May 2004 22:13:12 -0000 1.14
@@ -219,17 +219,22 @@
}
/**
- * Returns a list of top-level components, i.e. element declarations,
- * attribute declarations, etc.
- * @param objectType The type of the declaration, i.e.
- * ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, etc.
- * @return A list of top-level definition of the specified type in
- * <code>objectType</code> or <code>null</code>.
+ * Returns a list of top-level components, i.e. element declarations,
+ * attribute declarations, etc.
+ * @param objectType The type of the declaration, i.e.
+ * <code>ELEMENT_DECLARATION</code>. Note that
+ * <code>XSTypeDefinition.SIMPLE_TYPE</code> and
+ * <code>XSTypeDefinition.COMPLEX_TYPE</code> can also be used as the
+ * <code>objectType</code> to retrieve only complex types or simple
+ * types, instead of all types.
+ * @return A list of top-level definitions of the specified type in
+ * <code>objectType</code> or an empty <code>XSNamedMap</code> if no
+ * such definitions exist.
*/
public synchronized XSNamedMap getComponents(short objectType) {
if (objectType <= 0 || objectType > MAX_COMP_IDX ||
!GLOBAL_COMP[objectType]) {
- return null;
+ return XSNamedMapImpl.EMPTY_MAP;
}
SymbolHash[] tables = new SymbolHash[fGrammarCount];
@@ -274,22 +279,22 @@
}
/**
- * Convenience method. Returns a list of top-level component declarations
- * that are defined within the specified namespace, i.e. element
- * declarations, attribute declarations, etc.
- * @param objectType The type of the declaration, i.e.
- * ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, etc.
- * @param namespace The namespace to which declaration belong or
- * <code>null</code> (for components with no targetNamespace).
- * @return A list of top-level definition of the specified type in
- * <code>objectType</code> and defined in the specified
- * <code>namespace</code> or <code>null</code>.
+ * Convenience method. Returns a list of top-level component declarations
+ * that are defined within the specified namespace, i.e. element
+ * declarations, attribute declarations, etc.
+ * @param objectType The type of the declaration, i.e.
+ * <code>ELEMENT_DECLARATION</code>.
+ * @param namespace The namespace to which the declaration belongs or
+ * <code>null</code> (for components with no target namespace).
+ * @return A list of top-level definitions of the specified type in
+ * <code>objectType</code> and defined in the specified
+ * <code>namespace</code> or an empty <code>XSNamedMap</code>.
*/
public synchronized XSNamedMap getComponentsByNamespace(short objectType,
String namespace) {
if (objectType <= 0 || objectType > MAX_COMP_IDX ||
!GLOBAL_COMP[objectType]) {
- return null;
+ return XSNamedMapImpl.EMPTY_MAP;
}
// try to find the grammar
1.7 +16 -1 xml-xerces/java/src/org/apache/xerces/impl/xs/util/XSNamedMapImpl.java
Index: XSNamedMapImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/util/XSNamedMapImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSNamedMapImpl.java 24 Feb 2004 22:59:13 -0000 1.6
+++ XSNamedMapImpl.java 15 May 2004 22:13:12 -0000 1.7
@@ -29,6 +29,21 @@
*/
public class XSNamedMapImpl implements XSNamedMap {
+ /**
+ * An immutable empty map.
+ */
+ public static final XSNamedMap EMPTY_MAP = new XSNamedMap () {
+ public int getLength() {
+ return 0;
+ }
+ public XSObject itemByName(String namespace, String localName) {
+ return null;
+ }
+ public XSObject item(int index) {
+ return null;
+ }
+ };
+
// components of these namespaces are stored in this map
String[] fNamespaces;
// number of namespaces
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org