You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2003/06/24 23:37:13 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/psvi XSFacet.java XSConstants.java XSSimpleTypeDefinition.java
elena 2003/06/24 14:37:13
Modified: java/src/org/apache/xerces/impl/dv/xs XSSimpleTypeDecl.java
java/src/org/apache/xerces/impl/xs/psvi XSConstants.java
XSSimpleTypeDefinition.java
Added: java/src/org/apache/xerces/impl/xs/psvi XSFacet.java
Log:
Change to PSVI API -- adding a way to retrieve facets as objects, to allow users access to annotations
Revision Changes Path
1.40 +168 -1 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
Index: XSSimpleTypeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- XSSimpleTypeDecl.java 23 Jun 2003 17:11:02 -0000 1.39
+++ XSSimpleTypeDecl.java 24 Jun 2003 21:37:12 -0000 1.40
@@ -70,7 +70,9 @@
import org.apache.xerces.impl.xpath.regex.RegularExpression;
import org.apache.xerces.impl.xs.psvi.StringList;
import org.apache.xerces.impl.xs.XSAnnotationImpl;
+import org.apache.xerces.impl.xs.psvi.XSAnnotation;
import org.apache.xerces.impl.xs.psvi.XSConstants;
+import org.apache.xerces.impl.xs.psvi.XSFacet;
import org.apache.xerces.impl.xs.psvi.XSNamespaceItem;
import org.apache.xerces.impl.xs.psvi.XSObjectList;
import org.apache.xerces.impl.xs.psvi.XSSimpleTypeDefinition;
@@ -259,6 +261,9 @@
private Object fMaxExclusive;
private Object fMinExclusive;
private Object fMinInclusive;
+
+ // facets as objects
+ private XSObjectListImpl fFacets;
// optional annotations
private XSObjectList fAnnotations = null;
@@ -2293,6 +2298,7 @@
fPatternType = SPECIAL_PATTERN_NONE;
fAnnotations = null;
+ fFacets = null;
// REVISIT: reset for fundamental facets
}
@@ -2309,6 +2315,167 @@
*/
public String toString() {
return this.fTargetNamespace+"," +this.fTypeName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSSimpleTypeDefinition#getFacets()
+ */
+ public XSObjectList getFacets() {
+ if (fFacets != null){
+ return fFacets;
+ }
+ int pattern = 0;
+ int enum = 0;
+ if (fPatternStr != null){
+ pattern = fPatternStr.size();
+ }
+ if (fEnumeration != null){
+ enum = fEnumeration.size();
+ }
+ int count = 12 + pattern + enum;
+
+ XSFacetImpl[] facets = new XSFacetImpl[count];
+
+ count = 0;
+ if ((fFacetsDefined & FACET_WHITESPACE) != 0){
+ facets[count] = new XSFacetImpl(FACET_WHITESPACE,
+ WS_FACET_STRING[fWhiteSpace] ,(fFixedFacet & FACET_WHITESPACE) != 0, null);
+ count++;
+ }
+ if (fLength != -1){
+ facets[count] = new XSFacetImpl(FACET_LENGTH,
+ Integer.toString(fLength) ,(fFixedFacet & FACET_LENGTH) != 0, null);
+ count++;
+ }
+ if (fMinLength != -1){
+ facets[count] = new XSFacetImpl(FACET_MINLENGTH,
+ Integer.toString(fMinLength) ,(fFixedFacet & FACET_MINLENGTH) != 0, null);
+ count++;
+ }
+ if (fMaxLength != -1){
+ facets[count] = new XSFacetImpl(FACET_MAXLENGTH,
+ Integer.toString(fMaxLength) ,(fFixedFacet & FACET_MAXLENGTH) != 0, null);
+ count++;
+ }
+ if (fTotalDigits != -1){
+ facets[count] = new XSFacetImpl(FACET_TOTALDIGITS,
+ Integer.toString(fTotalDigits) ,(fFixedFacet & FACET_TOTALDIGITS) != 0, null);
+ count++;
+ }
+ if (fFractionDigits != -1){
+ facets[count] = new XSFacetImpl(FACET_FRACTIONDIGITS,
+ Integer.toString(fFractionDigits) ,(fFixedFacet & FACET_FRACTIONDIGITS) != 0, null);
+ count++;
+ }
+ if (fPatternStr != null){
+ for (int i = 0; i < pattern; i++){
+ facets[count] = new XSFacetImpl(FACET_PATTERN,
+ fPatternStr.elementAt(i).toString(), false, null);
+ count++;
+ }
+ }
+ if (fEnumeration !=null){
+ for (int i = 0; i < enum; i++){
+ facets[count] = new XSFacetImpl(FACET_ENUMERATION,
+ fEnumeration.elementAt(i).toString(), false, null);
+ count++;
+ }
+ }
+ if (fMaxInclusive != null){
+ facets[count] = new XSFacetImpl(FACET_MAXINCLUSIVE,
+ fMaxInclusive.toString() ,(fFixedFacet & FACET_MAXINCLUSIVE) != 0, null);
+ count++;
+ }
+ if (fMaxExclusive != null){
+ facets[count] = new XSFacetImpl(FACET_MAXEXCLUSIVE,
+ fMaxExclusive.toString() ,(fFixedFacet & FACET_MAXEXCLUSIVE) != 0, null);
+ count++;
+ }
+ if (fMinExclusive != null){
+ facets[count] = new XSFacetImpl(FACET_MINEXCLUSIVE,
+ fMinExclusive.toString() ,(fFixedFacet & FACET_MINEXCLUSIVE) != 0, null);
+ count++;
+ }
+ if (fMinInclusive != null){
+ facets[count] = new XSFacetImpl(FACET_MININCLUSIVE,
+ fMinInclusive.toString() ,(fFixedFacet & FACET_MININCLUSIVE) != 0, null);
+ count++;
+ }
+ fFacets = new XSObjectListImpl(facets, count);
+ return fFacets;
+ }
+
+
+ private static final class XSFacetImpl implements XSFacet {
+ final short kind;
+ final String value;
+ final boolean fixed;
+ final XSAnnotation annotation;
+
+ public XSFacetImpl(short kind, String value, boolean fixed, XSAnnotation annotation) {
+ this.kind = kind;
+ this.value = value;
+ this.fixed = fixed;
+ this.annotation = annotation;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSFacet#getAnnotation()
+ */
+ public XSAnnotation getAnnotation() {
+ // TODO: implement annotation support
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSFacet#getFacetKind()
+ */
+ public short getFacetKind() {
+ return kind;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSFacet#getLexicalFacetValue()
+ */
+ public String getLexicalFacetValue() {
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSFacet#isFixed()
+ */
+ public boolean isFixed() {
+ return fixed;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSObject#getName()
+ */
+ public String getName() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSObject#getNamespace()
+ */
+ public String getNamespace() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ // REVISIT: implement
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSObject#getType()
+ */
+ public short getType() {
+ return XSConstants.FACET;
+ }
+
}
} // class XSSimpleTypeDecl
1.5 +4 -0 xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSConstants.java
Index: XSConstants.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSConstants.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSConstants.java 20 Feb 2003 23:10:41 -0000 1.4
+++ XSConstants.java 24 Jun 2003 21:37:13 -0000 1.5
@@ -111,6 +111,10 @@
* The object describes an annotation.
*/
public static final short ANNOTATION = 12;
+ /**
+ * The object describes a facet.
+ */
+ public static final short FACET = 13;
// Derivation constants
/**
1.7 +4 -0 xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSSimpleTypeDefinition.java
Index: XSSimpleTypeDefinition.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSSimpleTypeDefinition.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSSimpleTypeDefinition.java 23 Jun 2003 16:34:29 -0000 1.6
+++ XSSimpleTypeDefinition.java 24 Jun 2003 21:37:13 -0000 1.7
@@ -247,5 +247,9 @@
* Optional. A set of [annotation]s.
*/
public XSObjectList getAnnotations();
+ /**
+ * @return list of constraining facets.
+ */
+ public XSObjectList getFacets();
}
1.1 xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSFacet.java
Index: XSFacet.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001, 2002, 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2003, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xerces.impl.xs.psvi;
/**
* Describes a constraining facet.
* TODO: how should we represent enumerations and patterns?
* Currently the implementation will expose each enumeration/pattern as an
* XSObject.
* TODO: we should also expose actual values
*/
public interface XSFacet extends XSObject{
/**
* @return The name of the facet: e.i. <code>length</code>,
* <code>whiteSpace</code>, <code>pattern</code>, etc.
*/
public short getFacetKind();
/**
* @return Returns a value of a constraining facet.
*/
public String getLexicalFacetValue();
/**
* Check whether a facet value is fixed.
*/
public boolean isFixed();
/**
* @return an annotation
*/
public XSAnnotation getAnnotation();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org