You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2006/11/24 13:15:06 UTC

svn commit: r478855 [3/21] - in /webservices/jaxme/branches/MAVEN/jaxme-xs: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/ws/ src/main/java/org/apache/ws/jaxme/ src/main/java/org/apache/ws/jaxme/...

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAppinfoImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAppinfoImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAppinfoImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAppinfoImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import org.apache.ws.jaxme.xs.XSAppinfo;
+import org.apache.ws.jaxme.xs.XSObject;
+import org.apache.ws.jaxme.xs.xml.XsAnyURI;
+import org.apache.ws.jaxme.xs.xml.XsEAppinfo;
+
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSAppinfoImpl extends XSObjectImpl implements XSAppinfo {
+  /** <p>Creates a new instance of XSAppinfoImpl.</p>
+   */
+  protected XSAppinfoImpl(XSObject pParent, XsEAppinfo pBaseObject) {
+    super(pParent, pBaseObject);
+  }
+
+  public XsAnyURI getSource() {
+    return ((XsEAppinfo) getXsObject()).getSource();
+  }
+
+  public Object[] getChilds() {
+    return ((XsEAppinfo) getXsObject()).getChilds();
+  }
+
+  public String getText() {
+    StringBuffer sb = new StringBuffer();
+    Object[] childs = ((XsEAppinfo) getXsObject()).getChilds();
+    for (int i = 0;  i < childs.length;  i++) {
+      if (childs[i] instanceof String) {
+        sb.append((String) childs[i]);
+      }
+    }
+    return sb.toString();
+  }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAtomicTypeRestrictionImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAtomicTypeRestrictionImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAtomicTypeRestrictionImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAtomicTypeRestrictionImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import org.apache.ws.jaxme.xs.XSAtomicType;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.xml.XsEFractionDigits;
+import org.apache.ws.jaxme.xs.xml.XsELength;
+import org.apache.ws.jaxme.xs.xml.XsEMaxExclusive;
+import org.apache.ws.jaxme.xs.xml.XsEMaxInclusive;
+import org.apache.ws.jaxme.xs.xml.XsEMaxLength;
+import org.apache.ws.jaxme.xs.xml.XsEMinExclusive;
+import org.apache.ws.jaxme.xs.xml.XsEMinInclusive;
+import org.apache.ws.jaxme.xs.xml.XsEMinLength;
+import org.apache.ws.jaxme.xs.xml.XsEPattern;
+import org.apache.ws.jaxme.xs.xml.XsETotalDigits;
+import org.apache.ws.jaxme.xs.xml.XsEWhiteSpace;
+import org.apache.ws.jaxme.xs.xml.XsGSimpleRestrictionModel;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSAtomicTypeRestrictionImpl extends XSSimpleTypeRestrictionImpl implements XSAtomicType {
+	private static final String[] ZERO_PATTERNS = new String[0];
+	private final XSAtomicType atomicBaseType;
+
+  /** Creates a new atomic type restricting <code>pBaseType</code>
+   * with the constraints <code>pRestriction</code>.
+   */
+  public XSAtomicTypeRestrictionImpl(XSType pParent,
+                                     XSType pBaseType, XsGSimpleRestrictionModel pRestriction)
+      throws SAXException {
+    super(pParent, pBaseType, pRestriction);
+    atomicBaseType = pBaseType.getSimpleType().getAtomicType();
+  }
+
+  public boolean isAtomic() { return true; }
+
+  public XSAtomicType getAtomicType() {
+    return this;
+  }
+
+  public Long getFractionDigits() {
+    XsEFractionDigits fractionDigits = getRestriction().getFractionDigits();
+    if (fractionDigits == null) {
+      return atomicBaseType.getFractionDigits();
+    } else {
+      return new Long(fractionDigits.getValue());
+    }
+  }
+
+  public Long getLength() {
+    XsELength length = getRestriction().getLength();
+    if (length == null) {
+      return atomicBaseType.getLength();
+    } else {
+      return new Long(length.getValue());
+    }
+  }
+
+  public String getMaxExclusive() {
+    XsEMaxExclusive maxExclusive = getRestriction().getMaxExclusive();
+    if (maxExclusive == null) {
+      return atomicBaseType.getMaxExclusive();
+    } else {
+      return maxExclusive.getValue();
+    }
+  }
+
+  public String getMaxInclusive() {
+    XsEMaxInclusive maxInclusive = getRestriction().getMaxInclusive();
+    if (maxInclusive == null) {
+      return atomicBaseType.getMaxInclusive();
+    } else {
+      return maxInclusive.getValue();
+    }
+  }
+
+  public Long getMaxLength() {
+    XsEMaxLength length = getRestriction().getMaxLength();
+    if (length == null) {
+      return atomicBaseType.getMaxLength();
+    } else {
+      return new Long(length.getValue());
+    }
+  }
+
+  public String getMinExclusive() {
+    XsEMinExclusive minExclusive = getRestriction().getMinExclusive();
+    if (minExclusive == null) {
+      return atomicBaseType.getMinExclusive();
+    } else {
+      return minExclusive.getValue();
+    }
+  }
+
+  public String getMinInclusive() {
+    XsEMinInclusive minInclusive = getRestriction().getMinInclusive();
+    if (minInclusive == null) {
+      return atomicBaseType.getMinInclusive();
+    } else {
+      return minInclusive.getValue();
+    }
+  }
+
+  public Long getMinLength() {
+    XsEMinLength length = getRestriction().getMinLength();
+    if (length == null) {
+      return atomicBaseType.getMinLength();
+    } else {
+      return new Long(length.getValue());
+    }
+  }
+
+  public Long getTotalDigits() {
+    XsETotalDigits totalDigits = getRestriction().getTotalDigits();
+    if (totalDigits == null) {
+      return atomicBaseType.getTotalDigits();
+    } else {
+      return new Long(totalDigits.getValue());
+    }
+  }
+
+  public boolean isReplacing() {
+    XsEWhiteSpace whiteSpace = getRestriction().getWhiteSpace();
+    if (whiteSpace == null) {
+      return atomicBaseType.isReplacing();
+    } else {
+      return whiteSpace.isReplacing() || whiteSpace.isCollapsing();
+    }
+  }
+
+  public boolean isCollapsing() {
+    XsEWhiteSpace whiteSpace = getRestriction().getWhiteSpace();
+    if (whiteSpace == null) {
+      return atomicBaseType.isReplacing();
+    } else {
+      return whiteSpace.isCollapsing();
+    }
+  }
+
+  public String[] getPatterns() {
+	  XsEPattern[] patterns = getRestriction().getPatterns();
+	  if (patterns == null  ||  patterns.length == 0) {
+		  return ZERO_PATTERNS;
+	  } else {
+		  String[] result = new String[patterns.length];
+		  for (int i = 0;  i < patterns.length;  i++) {
+			  result[i] = patterns[i].getValue();
+		  }
+		  return result;
+	  }
+  }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAttributeGroupImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAttributeGroupImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAttributeGroupImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAttributeGroupImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ws.jaxme.xs.XSAttributable;
+import org.apache.ws.jaxme.xs.XSAttribute;
+import org.apache.ws.jaxme.xs.XSAttributeGroup;
+import org.apache.ws.jaxme.xs.XSObject;
+import org.apache.ws.jaxme.xs.XSWildcard;
+import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
+import org.apache.ws.jaxme.xs.xml.XsESchema;
+import org.apache.ws.jaxme.xs.xml.XsGAttrDecls;
+import org.apache.ws.jaxme.xs.xml.XsNCName;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+import org.apache.ws.jaxme.xs.xml.XsTAttribute;
+import org.apache.ws.jaxme.xs.xml.XsTAttributeGroup;
+import org.apache.ws.jaxme.xs.xml.XsTAttributeGroupRef;
+import org.apache.ws.jaxme.xs.xml.XsTWildcard;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSAttributeGroupImpl extends XSOpenAttrsImpl implements XSAttributeGroup {
+  private final XsQName name;
+  private boolean isValidated;
+  private XSAttributable[] attributes;
+
+  protected XsTAttributeGroup getXsTAttributeGroup() {
+    return (XsTAttributeGroup) getXsObject();
+  }
+
+  protected boolean isReference() {
+    return getXsTAttributeGroup().getRef() != null;
+  }
+
+  protected XSAttributeGroupImpl(XSObject pParent, XsTAttributeGroup pBaseGroup)
+      throws SAXException {
+    super(pParent, pBaseGroup);
+    XsQName qName;
+    if (isReference()) {
+      qName = getXsTAttributeGroup().getRef();
+    } else {
+      XsNCName myName = pBaseGroup.getName();
+      if (myName == null) {
+        throw new LocSAXException("Invalid attribute group: Neither of its 'name' or 'ref' attributes are set.",
+                                     pBaseGroup.getLocator());
+      } else {
+        XsESchema schema = pBaseGroup.getXsESchema();
+        qName = new XsQName(schema.getTargetNamespace(), myName.toString(), schema.getTargetNamespacePrefix());
+      }
+    }
+    name = qName;
+  }
+
+  public XsQName getName() {
+    return name;
+  }
+
+  public void validate() throws SAXException {
+    if (isValidated) {
+      return;
+    } else {
+      isValidated = true;
+    }
+
+    if (isReference()) {
+      XSAttributeGroup referencedGroup = getXSSchema().getAttributeGroup(getName());
+      if (referencedGroup == null) {
+        throw new LocSAXException("Invalid attribute group: Unknown attribute group " + name + " referenced",
+                                   getLocator());
+      }
+      referencedGroup.validate();
+      attributes = referencedGroup.getAttributes();
+    } else {
+      XsTAttributeGroup attributeGroup = (XsTAttributeGroup) getXsObject();
+      attributes = getAttributes(this, attributeGroup);
+    }
+  }
+
+  public XSAttributable[] getAttributes() {
+    return attributes;
+  }
+
+  protected static XSAttributable[] getAttributes(XSObjectImpl pObject,
+                                                  XsGAttrDecls pAttrDecls) throws SAXException {
+    List attributes = new ArrayList();
+    Object[] allAttributes = pAttrDecls.getAllAttributes();
+    for (int i = 0;  i < allAttributes.length;  i++) {
+      Object o = allAttributes[i];
+      if (o == null) {
+        throw new NullPointerException("Null attribute detected.");
+      } else if (o instanceof XsTAttribute) {
+        XsTAttribute xsTAttr = (XsTAttribute) o;
+        if (XsTAttribute.PROHIBITED.equals(xsTAttr.getUse())) {
+        	continue;
+        }
+        XSAttribute attribute = pObject.getXSSchema().getXSObjectFactory().newXSAttribute(pObject, xsTAttr);
+        attribute.validate();
+        attributes.add(attribute);
+      } else if (o instanceof XsTAttributeGroupRef) {
+        XsTAttributeGroupRef agRef = (XsTAttributeGroupRef) o;
+        XsQName ref = agRef.getRef();
+        if (ref == null) {
+          throw new LocSAXException("Invalid attribute group: Missing 'ref' attribute", pObject.getLocator());
+        }
+        XSAttributeGroup attributeGroup = pObject.getXSSchema().getAttributeGroup(ref);
+        if (attributeGroup == null) {
+          throw new LocSAXException("Unknown attribute group name: " + ref, pObject.getLocator());
+        }
+        attributeGroup.validate();
+        XSAttributable[] agAttributes = attributeGroup.getAttributes();
+        for (int j = 0;  j < agAttributes.length;  j++) {
+          attributes.add(agAttributes[j]);
+        }
+      } else if (o instanceof XsTAttributeGroup) {
+        XsTAttributeGroup ag = (XsTAttributeGroup) o;
+        XSAttributable[] agAttributes = getAttributes(pObject, ag);
+        for (int j = 0;  j < agAttributes.length;  j++) {
+          attributes.add(agAttributes[j]);
+        }
+      } else if (o instanceof XsTWildcard) {
+        XSWildcard wildcard = pObject.getXSSchema().getXSObjectFactory().newXSWildcard(pObject, (XsTWildcard) o);
+        wildcard.validate();
+        attributes.add(wildcard);
+      } else {
+        throw new IllegalStateException("Unknown attribute type: " + o.getClass().getName());
+      }
+    }
+    return (XSAttributable[]) attributes.toArray(new XSAttributable[attributes.size()]);
+  }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAttributeImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAttributeImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAttributeImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSAttributeImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import org.apache.ws.jaxme.xs.XSAnnotation;
+import org.apache.ws.jaxme.xs.XSAttribute;
+import org.apache.ws.jaxme.xs.XSObject;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
+import org.apache.ws.jaxme.xs.types.XSAnySimpleType;
+import org.apache.ws.jaxme.xs.xml.XsAnyURI;
+import org.apache.ws.jaxme.xs.xml.XsEAnnotation;
+import org.apache.ws.jaxme.xs.xml.XsESchema;
+import org.apache.ws.jaxme.xs.xml.XsFormChoice;
+import org.apache.ws.jaxme.xs.xml.XsNCName;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+import org.apache.ws.jaxme.xs.xml.XsTAttribute;
+import org.apache.ws.jaxme.xs.xml.XsTLocalSimpleType;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSAttributeImpl extends XSOpenAttrsImpl implements XSAttribute {
+  private final XsQName name;
+  private final XsEAnnotation xsAnnotation;
+  private final boolean isGlobal;
+  private XSAnnotation[] annotations;
+  private boolean isValidated;
+  private XSType type;
+
+  protected XsTAttribute getXsTAttribute() {
+    return (XsTAttribute) getXsObject();
+  }
+
+  protected boolean isReference() {
+    return getXsTAttribute().getRef() != null;
+  }
+
+  protected boolean isInnerSimpleType() {
+    return getXsTAttribute().getSimpleType() != null;
+  }
+
+  protected XSAttributeImpl(XSObject pParent, XsTAttribute pBaseAttribute) throws SAXException {
+    super(pParent, pBaseAttribute);
+    if (isReference()) {
+      this.name = pBaseAttribute.getRef();
+      isGlobal = pBaseAttribute.isGlobal();
+    } else {
+      XsNCName myName = pBaseAttribute.getName();
+      if (myName == null) {
+        throw new LocSAXException("Invalid attribute: Neither of its 'name' or 'ref' attributes are set.",
+                                     pBaseAttribute.getLocator());
+      }
+      XsESchema schema = pBaseAttribute.getXsESchema();
+      XsAnyURI namespace;
+      String namespacePrefix;
+      boolean qualified = isGlobal = pBaseAttribute.isGlobal();
+      if (!qualified) {
+        XsFormChoice form = pBaseAttribute.getForm();
+        if (form == null) {
+          form = schema.getAttributeFormDefault();
+        }
+        qualified = XsFormChoice.QUALIFIED.equals(form);
+      }
+      if (qualified) {
+        namespace = schema.getTargetNamespace();
+        namespacePrefix = schema.getTargetNamespacePrefix();
+      } else {
+        namespace = null;
+        namespacePrefix = null;
+      }
+      this.name = new XsQName(namespace, myName.toString(), namespacePrefix);
+    }
+
+    xsAnnotation = pBaseAttribute.getAnnotation();
+  }
+
+  public boolean isGlobal() {
+    return isGlobal;
+  }
+
+  public XsQName getName() {
+    return name;
+  }
+
+  public XSType getType() {
+    return type;
+  }
+
+  public XSAnnotation[] getAnnotations() {
+    return annotations;
+  }
+
+  protected boolean isValidated() {
+    return isValidated;
+  }
+
+  public void validate() throws SAXException {
+    if (isValidated()) {
+      return;
+    } else {
+      isValidated = true;
+    }
+
+    if (xsAnnotation == null) {
+      annotations = new XSAnnotation[0];
+    } else {
+      XSAnnotation ann = getXSSchema().getXSObjectFactory().newXSAnnotation(this, xsAnnotation);
+      annotations = new XSAnnotation[]{ ann };
+      ann.validate();
+    }
+
+    XSType myType;
+    if (isReference()) {
+      XSAttribute attribute = getXSSchema().getAttribute(getName());
+      if (attribute == null) {
+          throw new LocSAXException("Invalid attribute reference: No type named " + getName() + " defined.",
+                                       getXsTAttribute().getLocator());
+      }
+      attribute.validate();
+      myType = attribute.getType();
+      if (myType == null) {
+          throw new IllegalStateException("The referenced attributes type must not be null.");
+      }
+    } else if (isInnerSimpleType()) {
+      XsTLocalSimpleType innerSimpleType = getXsTAttribute().getSimpleType();
+      myType = getXSSchema().getXSObjectFactory().newXSType(this, innerSimpleType);
+      myType.validate();
+    } else {
+      XsQName typeName = getXsTAttribute().getType();
+      if (typeName == null) {
+        typeName = XSAnySimpleType.getInstance().getName();
+      }
+      myType = getXSSchema().getType(typeName);
+      if (myType == null) {
+        throw new LocSAXException("Invalid attribute: The referenced type " + typeName + " is not defined in the schema.",
+                                     getXsTAttribute().getLocator());
+      }
+    }
+    this.type = myType;
+  }
+
+  public boolean isOptional() {
+    XsTAttribute.Use use = getXsTAttribute().getUse();
+    if (XsTAttribute.PROHIBITED.equals(use)) {
+      throw new IllegalStateException("This attribute is prohibited.");
+    }
+    return XsTAttribute.OPTIONAL.equals(use);
+  }
+
+  public String getDefault() {
+    return getXsTAttribute().getDefault();
+  }
+
+  public String getFixed() {
+    return getXsTAttribute().getFixed();
+  }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSContentHandlerImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSContentHandlerImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSContentHandlerImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSContentHandlerImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.UndeclaredThrowableException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.ws.jaxme.xs.XSContentHandler;
+import org.apache.ws.jaxme.xs.XSSchema;
+import org.apache.ws.jaxme.xs.parser.XSContext;
+import org.apache.ws.jaxme.xs.parser.XsSAXParser;
+import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
+import org.apache.ws.jaxme.xs.xml.XsESchema;
+import org.apache.ws.jaxme.xs.xml.XsObjectFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+class XSContentHandlerImpl implements XSContentHandler {
+  private final XSLogicalParser parser;
+  private final XsSAXParser xsSAXParser;
+  private boolean finished;
+  private int level = 0;
+  private final String systemId;
+
+  XSContentHandlerImpl(XSLogicalParser pParser, String pSystemId) throws SAXException {
+    parser = pParser;
+	systemId = pSystemId;
+    XSContext data = parser.getData();
+    data.setXSLogicalParser(parser);
+    parser.clearSyntaxSchemas();
+    XsObjectFactory factory = data.getXsObjectFactory();
+    XsESchema mySchema = factory.newXsESchema();
+    parser.setSchema(data.getXSObjectFactory().newXSSchema(data, mySchema));
+    xsSAXParser = factory.newXsSAXParser(mySchema);
+    parser.addSyntaxSchema(mySchema);
+    data.setCurrentContentHandler(xsSAXParser);
+  }
+
+  public XSSchema getXSSchema() {
+    if (!finished) {
+      throw new IllegalStateException("The endDocument() method has not yet been invoked.");
+    }
+    return parser.getSchema();
+  }
+
+  public void startDocument() throws SAXException {
+    xsSAXParser.startDocument();
+  }
+
+  public void endDocument() throws SAXException {
+    xsSAXParser.endDocument();
+    XsESchema syntaxSchema = (XsESchema) xsSAXParser.getBean();
+    parser.removeSyntaxSchema();
+    XSContext data = parser.getData();
+    data.setCurrentContentHandler(null);
+
+    try {
+      parser.parse(syntaxSchema, systemId);
+      XSSchema mySchema = parser.getSchema();
+      parser.createSubstitutionGroups(mySchema);
+      mySchema.validate();
+      finished = true;
+    } catch (IOException e) {
+      throw new SAXException(e);
+    } catch (ParserConfigurationException e) {
+      throw new SAXException(e);
+    } catch (RuntimeException e) {
+      Exception ex = e;
+      for (;;) {
+        UndeclaredThrowableException te = null;
+        Throwable t;
+        if (ex instanceof UndeclaredThrowableException) {
+          te = ((UndeclaredThrowableException) ex);
+          t = te.getUndeclaredThrowable();
+        } else if (ex instanceof InvocationTargetException) {
+          t = ((InvocationTargetException) ex).getTargetException();
+        } else {
+          break;
+        }
+        if (t instanceof Exception) {
+          ex = (Exception) t;
+        } else {
+          if (te == null) {
+            te = new UndeclaredThrowableException(t);
+          }
+          t.printStackTrace();
+          throw te;
+        }
+      }
+      throw new LocSAXException(ex.getClass().getName() + ": " + ex.getMessage(),
+                                 parser.getData().getLocator(), ex);
+    }
+  }
+
+  public void characters(char[] pChars, int pStart, int pLen) throws SAXException {
+    xsSAXParser.characters(pChars, pStart, pLen);
+  }
+
+  public void ignorableWhitespace(char[] pChars, int pStart, int pLen) throws SAXException {
+    xsSAXParser.ignorableWhitespace(pChars, pStart, pLen);
+  }
+
+  public void endPrefixMapping(String pPrefix) throws SAXException {
+    xsSAXParser.endPrefixMapping(pPrefix);
+  }
+
+  public void skippedEntity(String pEntity) throws SAXException {
+    xsSAXParser.skippedEntity(pEntity);
+  }
+
+  public void setDocumentLocator(Locator pLocator) {
+    xsSAXParser.setDocumentLocator(pLocator);
+  }
+
+  public void processingInstruction(String pTarget, String pData) throws SAXException {
+    xsSAXParser.processingInstruction(pTarget, pData);
+  }
+
+  public void startPrefixMapping(String pPrefix, String pURI) throws SAXException {
+    xsSAXParser.startPrefixMapping(pPrefix, pURI);
+  }
+
+  public void endElement(String pNamespaceURI, String pLocalName, String pQName) throws SAXException {
+    xsSAXParser.endElement(pNamespaceURI, pLocalName, pQName);
+    --level;
+  }
+
+  public void startElement(String pNamespaceURI, String pLocalName, String pQName, Attributes pAttrs)
+      throws SAXException {
+    xsSAXParser.startElement(pNamespaceURI, pLocalName, pQName, pAttrs);
+  }
+}
\ No newline at end of file

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSDocumentationImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSDocumentationImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSDocumentationImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSDocumentationImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import org.apache.ws.jaxme.xs.XSDocumentation;
+import org.apache.ws.jaxme.xs.XSObject;
+import org.apache.ws.jaxme.xs.xml.XmlLang;
+import org.apache.ws.jaxme.xs.xml.XsAnyURI;
+import org.apache.ws.jaxme.xs.xml.XsEDocumentation;
+
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSDocumentationImpl extends XSObjectImpl implements XSDocumentation {
+
+  /** <p>Creates a new instance of XSDocumentationImpl.java.</p>
+   */
+  protected XSDocumentationImpl(XSObject pParent, XsEDocumentation pBaseDocumentation) {
+    super(pParent, pBaseDocumentation);
+  }
+
+  /* @see org.apache.ws.jaxme.xs.XSDocumentation#getLanguage()
+   */
+  public XmlLang getLanguage() {
+    return ((XsEDocumentation) getXsObject()).getLang();
+  }
+
+  /* @see org.apache.ws.jaxme.xs.XSDocumentation#getSource()
+   */
+  public XsAnyURI getSource() {
+    return ((XsEDocumentation) getXsObject()).getSource();
+  }
+
+  /* @see org.apache.ws.jaxme.xs.XSDocumentation#getChilds()
+   */
+  public Object[] getChilds() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  /* @see org.apache.ws.jaxme.xs.XSDocumentation#getText()
+   */
+  public String getText() {
+    return ((XsEDocumentation) getXsObject()).getText();
+  }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSElementImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSElementImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSElementImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,309 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ws.jaxme.xs.XSAnnotation;
+import org.apache.ws.jaxme.xs.XSElement;
+import org.apache.ws.jaxme.xs.XSGroup;
+import org.apache.ws.jaxme.xs.XSIdentityConstraint;
+import org.apache.ws.jaxme.xs.XSKeyRef;
+import org.apache.ws.jaxme.xs.XSObject;
+import org.apache.ws.jaxme.xs.XSObjectFactory;
+import org.apache.ws.jaxme.xs.XSSchema;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
+import org.apache.ws.jaxme.xs.xml.XsAnyURI;
+import org.apache.ws.jaxme.xs.xml.XsBlockSet;
+import org.apache.ws.jaxme.xs.xml.XsEKey;
+import org.apache.ws.jaxme.xs.xml.XsEKeyref;
+import org.apache.ws.jaxme.xs.xml.XsESchema;
+import org.apache.ws.jaxme.xs.xml.XsEUnique;
+import org.apache.ws.jaxme.xs.xml.XsFormChoice;
+import org.apache.ws.jaxme.xs.xml.XsNCName;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+import org.apache.ws.jaxme.xs.xml.XsTElement;
+import org.apache.ws.jaxme.xs.xml.XsTIdentityConstraint;
+import org.apache.ws.jaxme.xs.xml.XsTTopLevelElement;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSElementImpl extends XSOpenAttrsImpl implements XSElement {
+  private static final XSIdentityConstraint[] NO_CONSTRAINTS
+  = new XSIdentityConstraint[] {};
+
+  private static final XSKeyRef[] NO_KEY_REFS = new XSKeyRef[] {};
+
+  private final XsQName name;
+  private final boolean isGlobal;
+  private XSAnnotation[] annotations;
+  private boolean isValidated;
+  private boolean isNillable;
+  private XSType type;
+  private XSGroup substitutionGroup;
+  private XSIdentityConstraint[] identityConstraints;
+  private XSKeyRef[] keyReferences;
+
+  protected XsTElement getXsTElement() {
+    return (XsTElement) getXsObject();
+  }
+
+  public boolean isReference() {
+    return getXsTElement().getRef() != null;
+  }
+
+  protected boolean isInnerSimpleType() {
+    return getXsTElement().getSimpleType() != null;
+  }
+
+  protected boolean isInnerComplexType() {
+    return getXsTElement().getComplexType() != null;
+  }
+
+  protected XSElementImpl(XSObject pParent, XsTElement pBaseElement)
+      throws SAXException 
+  {
+    super(pParent, pBaseElement);
+
+    XsQName qName;
+
+    if (isReference()) {
+      qName = pBaseElement.getRef();
+    } else {
+      XsNCName myName = pBaseElement.getName();
+      if (myName == null) {
+        throw new LocSAXException("Invalid element: Must have either of its 'ref' or 'name' attributes set.",
+                                     getLocator());
+      }
+
+      XsESchema schema = pBaseElement.getXsESchema();
+      XsAnyURI namespace;
+      String namespacePrefix;
+      boolean qualified = pBaseElement.isGlobal();
+      if (!qualified) {
+        XsFormChoice form = pBaseElement.getForm();
+        if (form == null) {
+          form = schema.getElementFormDefault();
+        }
+        qualified = XsFormChoice.QUALIFIED.equals(form);
+      }
+      if (qualified) {
+        namespace = schema.getTargetNamespace();
+        namespacePrefix = schema.getTargetNamespacePrefix();
+      } else {
+        namespace = null;
+        namespacePrefix = null;
+      }
+      qName = new XsQName(namespace, myName.toString(), namespacePrefix);
+
+      configureIdentityConstraints(pParent, pBaseElement);
+    }
+
+    name = qName;
+    isGlobal = isReference()  ||  (pBaseElement instanceof XsTTopLevelElement);
+    isNillable = pBaseElement.getNillable();
+
+    annotations = getXSSchema().getXSObjectFactory().newXSAnnotations(
+      this, 
+      pBaseElement.getAnnotation()
+    );
+  }
+
+  public boolean isGlobal() {
+    return isGlobal;
+  }
+  
+  public boolean isNillable() {
+    return isNillable;
+  }  
+
+  public XsQName getName() {
+    return name;
+  }
+
+  public XSType getType() {
+    return type;
+  }
+
+  protected boolean isValidated() {
+    return isValidated;
+  }
+
+  public void validate() throws SAXException {
+    if (isValidated()) {
+      return;
+    } else {
+      isValidated = true;
+    }
+
+    XSSchema schema = getXSSchema();
+    XSObjectFactory factory = schema.getXSObjectFactory();
+
+    XSType myType;
+    if (isReference()) {
+      XSElement element = schema.getElement(getName());
+      if (element == null) {
+        throw new LocSAXException("Invalid element reference: " + getName() + " is not defined.",
+                                     getLocator());
+      }
+      element.validate();
+      isNillable = element.isNillable();    
+      myType = element.getType();
+      
+    } else {
+      XsTElement element = getXsTElement();
+      if (isInnerSimpleType()) {
+        myType = factory.newXSType(this, element.getSimpleType());
+      } else if (isInnerComplexType()) {
+        myType = factory.newXSType(this, element.getComplexType());
+      } else {
+        XsQName typeName = element.getType();
+        if (typeName == null) {
+          throw new LocSAXException("Invalid element: Either of its 'type' or 'ref' attributes or its 'simpleType' or 'complexType' children must be set.",
+                                       getLocator());
+        }
+        myType = schema.getType(typeName);
+        if (myType == null) {
+          throw new LocSAXException("Invalid element: The type " + typeName + " is not defined.",
+                                       getLocator());
+        }
+      }
+    }
+    this.type = myType;
+    
+
+    myType.validate();
+    validateAllIn( annotations );
+    validateAllIn( identityConstraints );
+    validateAllIn( keyReferences );
+  }
+
+  public XSAnnotation[] getAnnotations() {
+    return annotations;
+  }
+
+  public String getDefault() {
+    return getXsTElement().getDefault();
+  }
+
+  public String getFixed() {
+    return getXsTElement().getFixed();
+  }
+
+  public XsQName getSubstitutionGroupName() {
+    return getXsTElement().getSubstitutionGroup();
+  }
+
+  public boolean isBlockedForSubstitution() {
+    XsBlockSet blockSet = getXsTElement().getBlock();
+    if (blockSet == null) {
+      blockSet = getXsTElement().getXsESchema().getBlockDefault();
+    }
+    return !blockSet.isSubstitutionAllowed();
+  }
+
+  public boolean isAbstract() {
+    return getXsTElement().getAbstract();
+  }
+
+  public void setSubstitutionGroup(XSGroup pGroup) {
+    substitutionGroup = pGroup;
+  }
+
+  public XSGroup getSubstitutionGroup() {
+    return substitutionGroup;
+  }
+
+  public XSIdentityConstraint[] getIdentityConstraints() {
+    return identityConstraints;
+  }
+
+  public XSKeyRef[] getKeyRefs() {
+    return keyReferences;
+  }
+
+  /**
+   * Process the unique, key and keyref identity constraints into instances
+   * of XSIdentityConstraint and XSKeyRef.
+   */
+  private void configureIdentityConstraints(XSObject pParent, XsTElement base)
+    throws SAXException
+  {
+    XsTIdentityConstraint[] rawConstraints = base.getIdentityConstraints();
+    final int numRawConstraints = rawConstraints.length;
+
+    if ( numRawConstraints == 0 ) {
+      identityConstraints = NO_CONSTRAINTS;
+      keyReferences = NO_KEY_REFS;
+
+      return;
+    }
+
+    XSSchema schema = getXSSchema();
+    XSObjectFactory factory = schema.getXSObjectFactory();
+    List constraints = new ArrayList(1);
+    List refKeys  = new ArrayList(1);
+
+    for ( int i=0; i<numRawConstraints; i++ ) {
+      XsTIdentityConstraint raw = rawConstraints[i];
+
+      if ( raw instanceof XsEKeyref ) {
+        XSKeyRef keyRef = factory.newXSKeyRef( this, (XsEKeyref) raw );
+
+        refKeys.add( keyRef );
+        schema.add( keyRef );
+      } else if ( raw instanceof XsEKey ) {
+        XSIdentityConstraint ic = factory.newXSIdentityConstraint( 
+          this, 
+          (XsEKey) raw 
+        );
+
+        constraints.add( ic );
+        schema.add( ic );
+      } else if( raw instanceof XsEUnique ) {
+        XSIdentityConstraint ic = factory.newXSIdentityConstraint( 
+          this, 
+          (XsEUnique) raw 
+        );
+
+        constraints.add( ic );
+        schema.add( ic );
+      }
+    }
+
+    int numConstraints = constraints.size();
+    if ( numConstraints == 0 ) {
+      identityConstraints =  NO_CONSTRAINTS;
+    } else {
+      identityConstraints = (XSIdentityConstraint[]) constraints.toArray( 
+        new XSIdentityConstraint[numConstraints] 
+      );
+    }
+
+    int numKeyRefs = refKeys.size();
+    if ( numKeyRefs == 0 ) {
+      keyReferences =  NO_KEY_REFS;
+    } else {
+      keyReferences = (XSKeyRef[]) refKeys.toArray(new XSKeyRef[numKeyRefs]);
+    }
+  }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSEnumerationImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSEnumerationImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSEnumerationImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSEnumerationImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import org.apache.ws.jaxme.xs.XSAnnotation;
+import org.apache.ws.jaxme.xs.XSEnumeration;
+import org.apache.ws.jaxme.xs.XSObject;
+import org.apache.ws.jaxme.xs.xml.XsEAnnotation;
+import org.apache.ws.jaxme.xs.xml.XsEEnumeration;
+import org.xml.sax.SAXException;
+
+
+/** <p>Implementation of an <code>xs:enumeration</code> facet, as specified
+ * by {@link org.apache.ws.jaxme.xs.XSEnumeration}.</p>
+ *
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSEnumerationImpl extends XSObjectImpl implements XSEnumeration {
+  private final XSAnnotation[] annotations;
+
+  /** <p>Creates a new instance of XSEnumerationImpl.java.</p>
+   */
+  public XSEnumerationImpl(XSObject pParent, XsEEnumeration pBaseEnumeration) throws SAXException {
+    super(pParent, pBaseEnumeration);
+    if (pBaseEnumeration.getValue() == null) {
+      throw new NullPointerException("Missing attribute: 'value'");
+    }
+    XsEAnnotation xsAnnotation = pBaseEnumeration.getAnnotation();
+    if (xsAnnotation == null) {
+      annotations = new XSAnnotation[0];
+    } else {
+      annotations = new XSAnnotation[]{getXSSchema().getXSObjectFactory().newXSAnnotation(this, xsAnnotation)};
+    }
+  }
+
+  public String getValue() { return ((XsEEnumeration) getXsObject()).getValue(); }
+
+  public XSAnnotation[] getAnnotations() { return annotations; }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSGroupImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSGroupImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSGroupImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSGroupImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,313 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import org.apache.ws.jaxme.xs.XSAnnotation;
+import org.apache.ws.jaxme.xs.XSAny;
+import org.apache.ws.jaxme.xs.XSElement;
+import org.apache.ws.jaxme.xs.XSGroup;
+import org.apache.ws.jaxme.xs.XSModelGroup;
+import org.apache.ws.jaxme.xs.XSObject;
+import org.apache.ws.jaxme.xs.XSParticle;
+import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
+import org.apache.ws.jaxme.xs.xml.XsAGOccurs;
+import org.apache.ws.jaxme.xs.xml.XsEAnnotation;
+import org.apache.ws.jaxme.xs.xml.XsEAny;
+import org.apache.ws.jaxme.xs.xml.XsEChoice;
+import org.apache.ws.jaxme.xs.xml.XsESchema;
+import org.apache.ws.jaxme.xs.xml.XsESequence;
+import org.apache.ws.jaxme.xs.xml.XsNCName;
+import org.apache.ws.jaxme.xs.xml.XsObject;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+import org.apache.ws.jaxme.xs.xml.XsTAll;
+import org.apache.ws.jaxme.xs.xml.XsTGroupRef;
+import org.apache.ws.jaxme.xs.xml.XsTLocalElement;
+import org.apache.ws.jaxme.xs.xml.XsTNamedGroup;
+import org.apache.ws.jaxme.xs.xml.XsTNestedParticle;
+import org.apache.ws.jaxme.xs.xml.XsTParticle;
+import org.apache.ws.jaxme.xs.xml.impl.XsTGroupRefImpl;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSGroupImpl extends XSOpenAttrsImpl implements XSGroup {
+  private final XsQName name;
+  private final XsTNestedParticle[] nestedParticles;
+  private final XsTParticle[] particles;
+  private final XsEAnnotation xsAnnotation;
+  private XSAnnotation[] annotations;
+  private boolean isGlobal;
+  private XSModelGroup modelGroup;
+  private final XSModelGroupImpl modelGroupImpl;
+  private boolean isValidated;
+
+  protected XSGroupImpl(XSObject pParent, XsTGroupRef pBaseGroup)
+      throws SAXException {
+    super(pParent, pBaseGroup);
+    XsQName qName = pBaseGroup.getRef();
+    if (qName == null) {
+      qName = getQName(pBaseGroup.getName());
+    } else {
+      setGlobal(true);
+    }
+    name = qName;
+    modelGroupImpl = null;
+    nestedParticles = null;
+    particles = null;
+    xsAnnotation = pBaseGroup.getAnnotation();
+  }
+
+  protected XSGroupImpl(XSObject pParent, XsTNamedGroup pBaseGroup) throws SAXException {
+    super(pParent, pBaseGroup);
+    name = getQName(pBaseGroup.getName());
+    XSModelGroupImpl myModelGroup;
+    XsTNamedGroup group = (XsTNamedGroup) getXsObject();
+    if (group.getSequence() != null) {
+      myModelGroup = modelGroupImpl = new XSModelGroupImpl(XSModelGroup.SEQUENCE, pBaseGroup.getLocator());
+      nestedParticles = group.getSequence().getParticles();
+      particles = null;
+    } else if (group.getChoice() != null) {
+      myModelGroup = modelGroupImpl = new XSModelGroupImpl(XSModelGroup.CHOICE, pBaseGroup.getLocator());
+      nestedParticles = group.getChoice().getParticles();
+      particles = null;
+    } else if (group.getAll() != null) {
+      myModelGroup = modelGroupImpl = new XSModelGroupImpl(XSModelGroup.ALL, pBaseGroup.getLocator());
+      nestedParticles = group.getAll().getElements();
+      particles = null;
+    } else {
+      throw new IllegalStateException("Invalid group: Neither of 'sequence', 'choice'. or 'all' elements is set.");
+    }
+    this.modelGroup = myModelGroup;
+    xsAnnotation = pBaseGroup.getAnnotation();
+  }
+
+  protected XSGroupImpl(XSObject pParent, XsEChoice pChoice) throws SAXException {
+    super(pParent, pChoice);
+    name = null;
+    modelGroup = modelGroupImpl = new XSModelGroupImpl(XSModelGroup.CHOICE, pChoice.getLocator());
+    particles = pChoice.getParticles();
+    nestedParticles = null;
+    xsAnnotation = pChoice.getAnnotation();
+  }
+
+  protected XSGroupImpl(XSObject pParent, XsESequence pSequence) throws SAXException {
+    super(pParent, pSequence);
+    name = null;
+    modelGroup = modelGroupImpl = new XSModelGroupImpl(XSModelGroup.SEQUENCE, pSequence.getLocator());
+    particles = pSequence.getParticles();
+    nestedParticles = null;
+    xsAnnotation = pSequence.getAnnotation();
+  }
+
+  protected XSGroupImpl(XSObject pParent, XsTAll pAll) throws SAXException {
+    super(pParent, pAll);
+    name = null;
+    modelGroup = modelGroupImpl = new XSModelGroupImpl(XSModelGroup.ALL, pAll.getLocator());
+    particles = pAll.getParticles();
+    nestedParticles = null;
+    xsAnnotation = pAll.getAnnotation();
+  }
+
+  protected XsQName getQName(XsNCName pName) throws SAXException {
+    if (pName == null) {
+      throw new LocSAXException("Invalid group: Either of its 'ref' or 'name' attributes must be set.",
+                                   getLocator());
+    }
+    XsESchema syntaxSchema = getXsObject().getXsESchema();
+    return new XsQName(syntaxSchema.getTargetNamespace(), pName.toString(), syntaxSchema.getTargetNamespacePrefix());
+  }
+
+  protected void initParticles(XSModelGroupImpl pModelGroup, XsTNestedParticle[] pParticles) throws SAXException {
+    for (int i = 0;  i < pParticles.length;  i++) {
+      addParticle(pModelGroup, pParticles[i]);
+    }
+  }
+
+  protected void initParticles(XSModelGroupImpl pModelGroup, XsTParticle[] pParticles) throws SAXException {
+    for (int i = 0;  i < pParticles.length;  i++) {
+      addParticle(pModelGroup, pParticles[i]);
+    }
+  }
+
+  protected void addParticle(XSModelGroupImpl pModelGroup, XsTParticle pParticle) throws SAXException {
+    XsAGOccurs occurs;
+    XSParticleImpl p;
+    if (pParticle instanceof XsTAll) {
+      XsTAll all = (XsTAll) pParticle;
+      occurs = all;
+      XSGroup group = getXSSchema().getXSObjectFactory().newXSGroup(this, all);
+      group.validate();
+      p = new XSParticleImpl(group);
+    } else if (pParticle instanceof XsTNestedParticle) {
+      addParticle(pModelGroup, (XsTNestedParticle) pParticle);
+      return;
+    } else {
+      throw new IllegalStateException("Unknown particle type: " + pParticle.getClass().getName());
+    }
+    pModelGroup.addParticle(p);
+    p.setMaxOccurs(occurs.getMaxOccurs());
+    p.setMinOccurs(occurs.getMinOccurs());
+  }
+
+  protected void addParticle(XSModelGroupImpl pModelGroup, XsTNestedParticle pParticle) throws SAXException {
+    XsAGOccurs occurs;
+    XSParticleImpl p;
+    if (pParticle instanceof XsEAny) {
+      XsEAny any = (XsEAny) pParticle;
+      occurs = any;
+      XSAny wildcard = getXSSchema().getXSObjectFactory().newXSAny(this, any);
+      wildcard.validate();
+      p = new XSParticleImpl(wildcard);
+    } else if (pParticle instanceof XsEChoice) {
+      XsEChoice choice = (XsEChoice) pParticle;
+      occurs = choice;
+      XSGroup group = getXSSchema().getXSObjectFactory().newXSGroup(this, choice);
+      group.validate();
+      p = new XSParticleImpl(group);
+    } else if (pParticle instanceof XsESequence) {
+      XsESequence sequence = (XsESequence) pParticle;
+      occurs = sequence;
+      XSGroup group = getXSSchema().getXSObjectFactory().newXSGroup(this, sequence);
+      group.validate();
+      p = new XSParticleImpl(group);
+    } else {
+      XsTGroupRef groupRef = null;
+      XsTLocalElement localElement = null;
+      if (pParticle instanceof XsTGroupRef) {
+        groupRef = (XsTGroupRef) pParticle;
+      } else if (pParticle instanceof XsTLocalElement) {
+        localElement = (XsTLocalElement) pParticle;
+        // May be the referenced element is the head of a substitution group
+        XsQName ref = localElement.getRef();
+        if (ref != null) {
+          XSElement referencedElement = getXSSchema().getElement(ref);
+          if (referencedElement == null) {
+            throw new LocSAXException("The referenced element " + ref + " is undefined.", localElement.getLocator());
+          }
+          XSGroup substitutedGroup = referencedElement.getSubstitutionGroup();
+          if (substitutedGroup != null  &&  substitutedGroup != this) {
+            XsObject parent = localElement.getParentObject();
+            XsTGroupRefImpl groupRefImpl = (XsTGroupRefImpl) localElement.getObjectFactory().newXsTGroupRef(parent);
+            groupRefImpl.setRef(substitutedGroup.getName());
+            int maxOccurs = localElement.getMaxOccurs();
+            if (maxOccurs == -1) {
+              groupRefImpl.setMaxOccurs("unbounded");
+            } else {
+              groupRefImpl.setMaxOccurs(Integer.toString(maxOccurs));
+            }
+            groupRefImpl.setMinOccurs(localElement.getMinOccurs());
+            groupRef = groupRefImpl;
+          }
+        }
+      } else {
+        throw new IllegalStateException("Unknown particle type: " + pParticle.getClass().getName());
+      }
+      if (groupRef == null) {
+        occurs = localElement;
+        XSElement element = getXSSchema().getXSObjectFactory().newXSElement(this, localElement);
+        element.validate();
+        p = new XSParticleImpl(element);
+      } else {
+        occurs = groupRef;
+        XSGroup group = getXSSchema().getXSObjectFactory().newXSGroup(this, groupRef);
+        group.validate();
+        p = new XSParticleImpl(group);
+      }
+    }
+    pModelGroup.addParticle(p);
+    p.setMaxOccurs(occurs.getMaxOccurs());
+    p.setMinOccurs(occurs.getMinOccurs());
+  }
+
+  public boolean isGlobal() {
+    return isGlobal;
+  }
+
+  public void setGlobal(boolean pGlobal) {
+    isGlobal = pGlobal;
+  }
+
+  public XsQName getName() {
+    return name;
+  }
+
+  protected boolean isValidated() {
+    return isValidated;
+  }
+
+  public void validate() throws SAXException {
+    if (isValidated()) {
+      return;
+    } else {
+      isValidated = true;
+    }
+
+    if (xsAnnotation == null) {
+      annotations = new XSAnnotation[0];
+    } else {
+      XSAnnotation result = getXSSchema().getXSObjectFactory().newXSAnnotation(this, xsAnnotation);
+      result.validate();
+      annotations = new XSAnnotation[]{result};
+    }
+
+    if (modelGroup == null) {
+      XsQName myName = getName();
+      if (myName == null) {
+        throw new NullPointerException("Missing group name");
+      }
+      XSGroup group = getXSSchema().getGroup(myName);
+      if (group == null) {
+        throw new LocSAXException("Unknown group: " + myName, getLocator());
+      }
+      modelGroup = group;
+    }
+
+    if (particles != null) {
+      initParticles(modelGroupImpl, particles);
+    } else if (nestedParticles != null) {
+      initParticles(modelGroupImpl, nestedParticles);
+    }
+
+    modelGroup.validate();
+  }
+
+  public Compositor getCompositor() {
+    return modelGroup.getCompositor();
+  }
+
+  public XSParticle[] getParticles() {
+    return modelGroup.getParticles();
+  }
+
+  public boolean isSequence() {
+    return modelGroup.isSequence();
+  }
+
+  public boolean isChoice() {
+    return modelGroup.isChoice();
+  }
+
+  public boolean isAll() {
+    return modelGroup.isAll();
+  }
+
+  public XSAnnotation[] getAnnotations() {
+    return annotations;
+  }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSIdentityConstraintImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSIdentityConstraintImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSIdentityConstraintImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSIdentityConstraintImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import org.apache.ws.jaxme.xs.XSAnnotation;
+import org.apache.ws.jaxme.xs.XSIdentityConstraint;
+import org.apache.ws.jaxme.xs.XSElement;
+import org.apache.ws.jaxme.xs.XSElementOrAttrRef;
+import org.apache.ws.jaxme.xs.XPathMatcher;
+import org.apache.ws.jaxme.xs.xml.XsEKey;
+import org.apache.ws.jaxme.xs.xml.XsTKeybase;
+import org.apache.ws.jaxme.xs.xml.XsEUnique;
+import org.xml.sax.SAXException;
+
+/** 
+ * Default implementation of the XSIdentityConstraint.
+ *
+ * @author <a href="mailto:mrck1996@yahoo.co.uk">Chris Kirk</a>
+ */
+public class XSIdentityConstraintImpl extends XSOpenAttrsImpl 
+  implements XSIdentityConstraint 
+{
+  private XSAnnotation[] annotations;
+  private String name;
+  private boolean isUnique;
+  private XsTKeybase keyBase;
+  private XSElementOrAttrRef[][] matchCriteria;
+
+  protected XSIdentityConstraintImpl( XSElement pParent, XsEKey key ) 
+    throws SAXException
+  {
+    super( pParent, key );
+
+    initSelf( pParent, key, false );
+  }
+
+  protected XSIdentityConstraintImpl( XSElement pParent, XsEUnique unique ) 
+    throws SAXException
+  {
+    super( pParent, unique );
+
+    initSelf( pParent, unique, true );
+  }
+
+  public XSAnnotation[] getAnnotations() {
+    return annotations;
+  }
+
+  /** 
+   * @see XSIdentityConstraintImpl#getName
+   */
+  public String getName() {
+    return name;
+  }
+
+  /**
+   * @see XSIdentityConstraintImpl#isUnique
+   */
+  public boolean isUnique() {
+    return isUnique;
+  }
+
+  /**
+   * @see XSIdentityConstraintImpl#getMatchCriteria
+   */
+  public XSElementOrAttrRef[][] getMatchCriteria() {
+    return matchCriteria;
+  }
+
+  public void validate() throws SAXException {
+    matchCriteria = XPathMatcher.match( 
+      keyBase, 
+      (XSElement) getParentObject() 
+    );
+
+    validateAllIn( annotations );
+  }
+
+  private void initSelf( 
+    XSElement pParent, 
+    XsTKeybase keyBase, 
+    boolean isUnique 
+  ) throws SAXException {
+    this.isUnique = isUnique;
+    this.name = keyBase.getName().getValue();
+    this.keyBase = keyBase;
+
+    this.annotations = getXSSchema().getXSObjectFactory().newXSAnnotations(
+      this, 
+      keyBase.getAnnotation()
+    );
+  }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSKeyRefImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSKeyRefImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSKeyRefImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSKeyRefImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import org.apache.ws.jaxme.xs.XPathMatcher;
+import org.apache.ws.jaxme.xs.XSAnnotation;
+import org.apache.ws.jaxme.xs.XSElement;
+import org.apache.ws.jaxme.xs.XSElementOrAttrRef;
+import org.apache.ws.jaxme.xs.XSIdentityConstraint;
+import org.apache.ws.jaxme.xs.XSKeyRef;
+import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
+import org.apache.ws.jaxme.xs.xml.XsEKeyref;
+import org.xml.sax.SAXException;
+
+/** 
+ * Default implementation of the XSKeyRef.
+ *
+ * @author <a href="mailto:mrck1996@yahoo.co.uk">Chris Kirk</a>
+ */
+public class XSKeyRefImpl extends XSOpenAttrsImpl 
+  implements XSKeyRef
+{
+  private XSAnnotation[] annotations;
+  private String name;
+  private XSIdentityConstraint identityConstraint;
+  private XsEKeyref keyRef;
+  private XSElementOrAttrRef[][] matchCriteria;
+
+  protected XSKeyRefImpl( XSElement pParent, XsEKeyref keyRef ) 
+    throws SAXException
+  {
+    super( pParent, keyRef );
+
+    this.annotations = getXSSchema().getXSObjectFactory().newXSAnnotations(
+      this, 
+      keyRef.getAnnotation()
+    );
+
+    this.name = keyRef.getName().getValue();
+    this.keyRef = keyRef;
+  }
+
+  public XSAnnotation[] getAnnotations() {
+    return annotations;
+  }
+
+  /** 
+   * @see XSKeyRef#getName
+   */
+  public String getName() {
+    return name;
+  }
+
+  /**
+   * @see XSKeyRef#getIdentityConstraint
+   */
+  public XSIdentityConstraint getIdentityConstraint() {
+    return identityConstraint;
+  }
+
+  /**
+   * @see XSKeyRef#getMatchCriteria
+   */
+  public XSElementOrAttrRef[][] getMatchCriteria() {
+    return matchCriteria;
+  }
+
+  public void validate() throws SAXException {
+    validateAllIn( annotations );
+
+    String referredIdentity = keyRef.getRefer().getLocalName();
+    identityConstraint = (XSIdentityConstraint) getXSSchema().getIdentityConstraints().get(
+      referredIdentity 
+    );
+
+    if ( identityConstraint == null ) {
+      throw new LocSAXException( 
+        "Unknown identity constraint: " + referredIdentity, 
+        keyRef.getLocator()
+      );
+    }
+
+    matchCriteria = XPathMatcher.match( 
+      keyRef, 
+      (XSElement) getParentObject() 
+    );
+  }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSListTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSListTypeImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSListTypeImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSListTypeImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import org.apache.ws.jaxme.xs.XSEnumeration;
+import org.apache.ws.jaxme.xs.XSListType;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
+import org.apache.ws.jaxme.xs.xml.XsEList;
+import org.apache.ws.jaxme.xs.xml.XsQName;
+import org.apache.ws.jaxme.xs.xml.XsTLocalSimpleType;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSListTypeImpl extends XSSimpleTypeImpl implements XSListType {
+  private static final String[][] ZERO_PATTERNS = new String[0][];
+  private static final XSEnumeration[] ZERO_ENUMERATIONS = new XSEnumeration[0];
+  private final XSType itemType;
+
+  public boolean isRestriction() { return false; }
+  public XSType getRestrictedType() {
+    throw new IllegalStateException("This is a basic list type and not a restriction of another simple type.");
+  }
+
+  public XSListTypeImpl(XSType pOwner, XsEList pBaseList) throws SAXException {
+    XsQName itemTypeName = pBaseList.getItemType();
+    if (itemTypeName == null) {
+      XsTLocalSimpleType simpleType = pBaseList.getSimpleType();
+      if (simpleType == null) {
+        throw new LocSAXException("You must either set the 'itemType' attribute or add a 'simpleType' element.",
+                                   pBaseList.getLocator());
+      }
+      XSType type = pOwner.getXSSchema().getXSObjectFactory().newXSType(pOwner, simpleType);
+      type.validate();
+      itemType = type;
+    } else {
+      XSType type = pOwner.getXSSchema().getType(itemTypeName);
+      if (type == null) {
+        throw new LocSAXException("Unknown item type: " + itemTypeName, pBaseList.getLocator());
+      }
+      type.validate();
+      if (!type.isSimple()) {
+        throw new LocSAXException("The item type " + itemTypeName + " is complex.",
+                                     pBaseList.getLocator());
+      }
+      itemType = type;
+    }
+  }
+
+  public boolean isList() { return true; }
+  public XSListType getListType() { return this; }
+  public String[][] getPattern() { return ZERO_PATTERNS; }
+  public XSEnumeration[] getEnumerations() { return ZERO_ENUMERATIONS; }
+  public Long getLength() { return null; }
+  public Long getMinLength() { return null; }
+  public Long getMaxLength() { return null; }
+  public XSType getItemType() { return itemType; }
+}

Added: webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSListTypeRestrictionImpl.java
URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSListTypeRestrictionImpl.java?view=auto&rev=478855
==============================================================================
--- webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSListTypeRestrictionImpl.java (added)
+++ webservices/jaxme/branches/MAVEN/jaxme-xs/src/main/java/org/apache/ws/jaxme/xs/impl/XSListTypeRestrictionImpl.java Fri Nov 24 04:14:48 2006
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.xs.impl;
+
+import org.apache.ws.jaxme.xs.XSAtomicType;
+import org.apache.ws.jaxme.xs.XSListType;
+import org.apache.ws.jaxme.xs.XSType;
+import org.apache.ws.jaxme.xs.xml.XsELength;
+import org.apache.ws.jaxme.xs.xml.XsEMaxLength;
+import org.apache.ws.jaxme.xs.xml.XsEMinLength;
+import org.apache.ws.jaxme.xs.xml.XsGSimpleRestrictionModel;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
+ */
+public class XSListTypeRestrictionImpl extends XSSimpleTypeRestrictionImpl implements XSListType {
+  private final XSListType listBaseType;
+
+  public XSListTypeRestrictionImpl(XSType pParent,
+                                    XSType pRestrictedType, XsGSimpleRestrictionModel pRestriction)
+      throws SAXException {
+    super(pParent, pRestrictedType, pRestriction);
+    listBaseType = pRestrictedType.getSimpleType().getListType();
+  }
+
+  public boolean isList() { return true; }
+
+  public XSListType getListType() {
+    return this;
+  }
+
+  public XSType getItemType() {
+    return listBaseType.getItemType();
+  }
+
+  public Long getLength() {
+    XsELength length = getRestriction().getLength();
+    if (length == null) {
+      return listBaseType.getLength();
+    } else {
+      return new Long(length.getValue());
+    }
+  }
+
+  public Long getMinLength() {
+    XsEMinLength length = getRestriction().getMinLength();
+    if (length == null) {
+      return listBaseType.getMinLength();
+    } else {
+      return new Long(length.getValue());
+    }
+  }
+
+  public Long getMaxLength() {
+    XsEMaxLength length = getRestriction().getMaxLength();
+    if (length == null) {
+      return listBaseType.getMaxLength();
+    } else {
+      return new Long(length.getValue());
+    }
+  }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org