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 2008/09/19 08:59:47 UTC

svn commit: r696945 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs: XSSimpleTypeDecl.java XSSimpleTypeDelegate.java

Author: mrglavas
Date: Thu Sep 18 23:59:47 2008
New Revision: 696945

URL: http://svn.apache.org/viewvc?rev=696945&view=rev
Log:
Adding a class which allows one to extend or modify the behaviour of an existing XSSimpleType.

Added:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java   (with props)
Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java?rev=696945&r1=696944&r2=696945&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java Thu Sep 18 23:59:47 2008
@@ -2506,20 +2506,25 @@
     public boolean derivedFromType(XSTypeDefinition ancestor, short derivation) {
         // REVISIT: implement according to derivation
 
-        // ancestor is null, retur false
-        if (ancestor == null)
+        // ancestor is null, return false
+        if (ancestor == null) {
             return false;
+        }
+        // extract the actual XSTypeDefinition if the given ancestor is a delegate.
+        while (ancestor instanceof XSSimpleTypeDelegate) {
+            ancestor = ((XSSimpleTypeDelegate) ancestor).type;
+        }
         // ancestor is anyType, return true
         // anyType is the only type whose base type is itself
-        if (ancestor.getBaseType() == ancestor)
+        if (ancestor.getBaseType() == ancestor) {
             return true;
+        }
         // recursively get base, and compare it with ancestor
         XSTypeDefinition type = this;
         while (type != ancestor &&                      // compare with ancestor
                 type != fAnySimpleType) {  // reached anySimpleType
             type = type.getBaseType();
         }
-
         return type == ancestor;
     }
 

Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java?rev=696945&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java Thu Sep 18 23:59:47 2008
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.impl.dv.xs;
+
+import org.apache.xerces.impl.dv.DatatypeException;
+import org.apache.xerces.impl.dv.InvalidDatatypeFacetException;
+import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.xerces.impl.dv.ValidatedInfo;
+import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.impl.dv.XSFacets;
+import org.apache.xerces.impl.dv.XSSimpleType;
+import org.apache.xerces.xs.StringList;
+import org.apache.xerces.xs.XSNamespaceItem;
+import org.apache.xerces.xs.XSObjectList;
+import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.apache.xerces.xs.XSTypeDefinition;
+
+/**
+ * Base class for XSSimpleType wrapper implementations.
+ * 
+ * @xerces.internal
+ * 
+ * @version $Id$
+ */
+public class XSSimpleTypeDelegate
+    implements XSSimpleType {
+
+    protected final XSSimpleType type;
+    
+    public XSSimpleTypeDelegate(XSSimpleType type) {
+        if (type == null) {
+            throw new NullPointerException();
+        }
+        this.type = type;
+    }
+
+    public XSObjectList getAnnotations() {
+        return type.getAnnotations();
+    }
+
+    public boolean getBounded() {
+        return type.getBounded();
+    }
+
+    public short getBuiltInKind() {
+        return type.getBuiltInKind();
+    }
+
+    public short getDefinedFacets() {
+        return type.getDefinedFacets();
+    }
+
+    public XSObjectList getFacets() {
+        return type.getFacets();
+    }
+
+    public boolean getFinite() {
+        return type.getFinite();
+    }
+
+    public short getFixedFacets() {
+        return type.getFixedFacets();
+    }
+
+    public XSSimpleTypeDefinition getItemType() {
+        return type.getItemType();
+    }
+
+    public StringList getLexicalEnumeration() {
+        return type.getLexicalEnumeration();
+    }
+
+    public String getLexicalFacetValue(short facetName) {
+        return type.getLexicalFacetValue(facetName);
+    }
+
+    public StringList getLexicalPattern() {
+        return type.getLexicalPattern();
+    }
+
+    public XSObjectList getMemberTypes() {
+        return type.getMemberTypes();
+    }
+
+    public XSObjectList getMultiValueFacets() {
+        return type.getMultiValueFacets();
+    }
+
+    public boolean getNumeric() {
+        return type.getNumeric();
+    }
+
+    public short getOrdered() {
+        return type.getOrdered();
+    }
+
+    public XSSimpleTypeDefinition getPrimitiveType() {
+        return type.getPrimitiveType();
+    }
+
+    public short getVariety() {
+        return type.getVariety();
+    }
+
+    public boolean isDefinedFacet(short facetName) {
+        return type.isDefinedFacet(facetName);
+    }
+
+    public boolean isFixedFacet(short facetName) {
+        return type.isFixedFacet(facetName);
+    }
+
+    public boolean derivedFrom(String namespace, String name, short derivationMethod) {
+        return type.derivedFrom(namespace, name, derivationMethod);
+    }
+
+    public boolean derivedFromType(XSTypeDefinition ancestorType, short derivationMethod) {
+        return type.derivedFromType(ancestorType, derivationMethod);
+    }
+
+    public boolean getAnonymous() {
+        return type.getAnonymous();
+    }
+
+    public XSTypeDefinition getBaseType() {
+        return type.getBaseType();
+    }
+
+    public short getFinal() {
+        return type.getFinal();
+    }
+
+    public short getTypeCategory() {
+        return type.getTypeCategory();
+    }
+
+    public boolean isFinal(short restriction) {
+        return type.isFinal(restriction);
+    }
+
+    public String getName() {
+        return type.getName();
+    }
+
+    public String getNamespace() {
+        return type.getNamespace();
+    }
+
+    public XSNamespaceItem getNamespaceItem() {
+        return type.getNamespaceItem();
+    }
+
+    public short getType() {
+        return type.getType();
+    }
+
+    public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context) 
+        throws InvalidDatatypeFacetException {
+        type.applyFacets(facets, presentFacet, fixedFacet, context);
+    }
+
+    public short getPrimitiveKind() {
+        return type.getPrimitiveKind();
+    }
+
+    public short getWhitespace() throws DatatypeException {
+        return type.getWhitespace();
+    }
+
+    public boolean isEqual(Object value1, Object value2) {
+        return type.isEqual(value1, value2);
+    }
+
+    public boolean isIDType() {
+        return type.isIDType();
+    }
+
+    public void validate(ValidationContext context, ValidatedInfo validatedInfo) 
+        throws InvalidDatatypeValueException {
+        type.validate(context, validatedInfo);
+    }
+
+    public Object validate(String content, ValidationContext context, ValidatedInfo validatedInfo) 
+        throws InvalidDatatypeValueException {
+        return type.validate(content, context, validatedInfo);
+    }
+
+    public Object validate(Object content, ValidationContext context, ValidatedInfo validatedInfo) 
+        throws InvalidDatatypeValueException {
+        return type.validate(content, context, validatedInfo);
+    }
+}

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org