Author: bimargulies
Date: Wed Oct 13 01:00:35 2010
New Revision: 1021968
URL: http://svn.apache.org/viewvc?rev=1021968&view=rev
Log:
Add an interface to give more commonality to the global items with names and
ref=
Added:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaItemWithRef.java
- copied, changed from r1021948,
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaItemWithRefBase.java
- copied, changed from r1021948,
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java?rev=1021968&r1=1021967&r2=1021968&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java
Wed Oct 13 01:00:35 2010
@@ -24,6 +24,7 @@ import javax.xml.namespace.QName;
import org.apache.ws.commons.schema.utils.XmlSchemaNamedWithForm;
import org.apache.ws.commons.schema.utils.XmlSchemaNamedWithFormImpl;
import org.apache.ws.commons.schema.utils.XmlSchemaRef;
+import org.apache.ws.commons.schema.utils.XmlSchemaRefBase;
/**
* Class for attribute types. Represents the World Wide Web Consortium (W3C)
attribute element.
@@ -31,7 +32,7 @@ import org.apache.ws.commons.schema.util
* ref= attributes are in the parent items collection, not in the map of named
items.
*/
public class XmlSchemaAttribute extends XmlSchemaAttributeOrGroupRef
implements XmlSchemaNamedWithForm,
- XmlSchemaAttributeGroupMember {
+ XmlSchemaAttributeGroupMember, XmlSchemaItemWithRef<XmlSchemaAttribute> {
private String defaultValue;
private String fixedValue;
@@ -160,4 +161,16 @@ public class XmlSchemaAttribute extends
public QName getWireName() {
return namedDelegate.getWireName();
}
+
+ public boolean isRef() {
+ return ref.getTargetQName() != null;
+ }
+
+ public QName getTargetQName() {
+ return ref.getTargetQName();
+ }
+
+ public XmlSchemaRefBase getRefBase() {
+ return ref;
+ }
}
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java?rev=1021968&r1=1021967&r2=1021968&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java
Wed Oct 13 01:00:35 2010
@@ -19,17 +19,21 @@
package org.apache.ws.commons.schema;
+import javax.xml.namespace.QName;
+
import org.apache.ws.commons.schema.utils.XmlSchemaRef;
+import org.apache.ws.commons.schema.utils.XmlSchemaRefBase;
/**
- * Class for the attribute group reference.
+ * Class for the attribute group reference.
* Represents the World Wide Web Consortium (W3C) attributeGroup
* element with the ref attribute.
*/
public class XmlSchemaAttributeGroupRef extends XmlSchemaAttributeOrGroupRef
- implements XmlSchemaAttributeGroupMember {
+ implements XmlSchemaAttributeGroupMember,
+ XmlSchemaItemWithRef<XmlSchemaAttributeGroup> {
private XmlSchemaRef<XmlSchemaAttributeGroup> ref;
-
+
/**
* Create an attribute group reference.
* @param parent containing schema.
@@ -45,4 +49,16 @@ public class XmlSchemaAttributeGroupRef
public XmlSchemaRef<XmlSchemaAttributeGroup> getRef() {
return ref;
}
+
+ public boolean isRef() {
+ return ref.getTargetQName() != null;
+ }
+
+ public QName getTargetQName() {
+ return ref.getTargetQName();
+ }
+
+ public XmlSchemaRefBase getRefBase() {
+ return ref;
+ }
}
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java?rev=1021968&r1=1021967&r2=1021968&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java
Wed Oct 13 01:00:35 2010
@@ -28,16 +28,18 @@ import javax.xml.namespace.QName;
import org.apache.ws.commons.schema.utils.XmlSchemaNamedWithForm;
import org.apache.ws.commons.schema.utils.XmlSchemaNamedWithFormImpl;
import org.apache.ws.commons.schema.utils.XmlSchemaRef;
+import org.apache.ws.commons.schema.utils.XmlSchemaRefBase;
/**
* Class for elements. Represents the World Wide Web Consortium (W3C) element
element.
- *
+ *
* Note that ref= elements are in the parent schema 'items' collection,
* not in the 'element' Map.
*/
public class XmlSchemaElement extends XmlSchemaParticle implements
TypeReceiver, XmlSchemaNamedWithForm,
- XmlSchemaChoiceMember, XmlSchemaSequenceMember {
+ XmlSchemaChoiceMember, XmlSchemaSequenceMember,
+ XmlSchemaItemWithRef<XmlSchemaElement> {
/**
* Attribute used to block a type derivation.
@@ -75,7 +77,7 @@ public class XmlSchemaElement extends Xm
* QName of an element that can be a substitute for this element.
*/
private QName substitutionGroup;
-
+
private XmlSchemaNamedWithFormImpl namedDelegate;
/**
@@ -152,11 +154,11 @@ public class XmlSchemaElement extends Xm
this.nillable = isNillable;
}
-
+
public XmlSchemaRef<XmlSchemaElement> getRef() {
return ref;
}
-
+
public XmlSchemaType getSchemaType() {
return schemaType;
}
@@ -184,32 +186,32 @@ public class XmlSchemaElement extends Xm
public void setType(XmlSchemaType type) {
this.schemaType = type;
}
-
+
public String getName() {
return namedDelegate.getName();
}
-
+
public XmlSchema getParent() {
return namedDelegate.getParent();
}
-
+
public QName getQName() {
return namedDelegate.getQName();
}
-
+
public boolean isAnonymous() {
return namedDelegate.isAnonymous();
}
-
+
public boolean isTopLevel() {
return namedDelegate.isTopLevel();
}
-
+
public void setName(String name) {
if (namedDelegate.isTopLevel() && namedDelegate.getName() != null) {
namedDelegate.getParent().getElements().remove(getQName());
@@ -274,4 +276,16 @@ public class XmlSchemaElement extends Xm
public XmlSchemaDerivationMethod getFinalDerivationResolved() {
return finalDerivationResolved;
}
+
+ public boolean isRef() {
+ return ref.getTargetQName() != null;
+ }
+
+ public QName getTargetQName() {
+ return ref.getTargetQName();
+ }
+
+ public XmlSchemaRefBase getRefBase() {
+ return ref;
+ }
}
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java?rev=1021968&r1=1021967&r2=1021968&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java
Wed Oct 13 01:00:35 2010
@@ -25,7 +25,6 @@ import javax.xml.namespace.QName;
* Class used within complex types that defines the reference to groups
defined at the schema level.
* Represents the World Wide Web Consortium (W3C) group element with ref
attribute.
*/
-
public class XmlSchemaGroupRef extends XmlSchemaParticle implements
XmlSchemaSequenceMember {
private XmlSchemaGroupParticle particle;
@@ -53,5 +52,4 @@ public class XmlSchemaGroupRef extends X
void setParticle(XmlSchemaGroupParticle particle) {
this.particle = particle;
}
-
}
Copied:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaItemWithRef.java
(from r1021948,
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaItemWithRef.java?p2=webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaItemWithRef.java&p1=webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java&r1=1021948&r2=1021968&rev=1021968&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaItemWithRef.java
Wed Oct 13 01:00:35 2010
@@ -1,48 +1,30 @@
-/**
- * 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.ws.commons.schema;
-
-import org.apache.ws.commons.schema.utils.XmlSchemaRef;
-
-/**
- * Class for the attribute group reference.
- * Represents the World Wide Web Consortium (W3C) attributeGroup
- * element with the ref attribute.
- */
-public class XmlSchemaAttributeGroupRef extends XmlSchemaAttributeOrGroupRef
- implements XmlSchemaAttributeGroupMember {
- private XmlSchemaRef<XmlSchemaAttributeGroup> ref;
-
- /**
- * Create an attribute group reference.
- * @param parent containing schema.
- */
- public XmlSchemaAttributeGroupRef(XmlSchema parent) {
- ref = new XmlSchemaRef<XmlSchemaAttributeGroup>(parent,
XmlSchemaAttributeGroup.class);
- }
-
- /**
- * Return the reference object.
- * @return
- */
- public XmlSchemaRef<XmlSchemaAttributeGroup> getRef() {
- return ref;
- }
-}
+/**
+ * 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.ws.commons.schema;
+
+import org.apache.ws.commons.schema.utils.XmlSchemaNamed;
+import org.apache.ws.commons.schema.utils.XmlSchemaRef;
+
+/**
+ * Interface implemented by the objects that support ref=.
+ */
+public interface XmlSchemaItemWithRef<T extends XmlSchemaNamed> extends
XmlSchemaItemWithRefBase {
+ XmlSchemaRef<T> getRef();
+}
Copied:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaItemWithRefBase.java
(from r1021948,
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaItemWithRefBase.java?p2=webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaItemWithRefBase.java&p1=webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java&r1=1021948&r2=1021968&rev=1021968&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaGroupRef.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaItemWithRefBase.java
Wed Oct 13 01:00:35 2010
@@ -1,57 +1,48 @@
-/**
- * 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.ws.commons.schema;
-
-import javax.xml.namespace.QName;
-
-/**
- * Class used within complex types that defines the reference to groups
defined at the schema level.
- * Represents the World Wide Web Consortium (W3C) group element with ref
attribute.
- */
-
-public class XmlSchemaGroupRef extends XmlSchemaParticle implements
XmlSchemaSequenceMember {
-
- private XmlSchemaGroupParticle particle;
-
- private QName refName;
-
- /**
- * Creates new XmlSchemaGroupRef
- */
- public XmlSchemaGroupRef() {
- }
-
- public XmlSchemaGroupParticle getParticle() {
- return this.particle;
- }
-
- public QName getRefName() {
- return this.refName;
- }
-
- public void setRefName(QName refName) {
- this.refName = refName;
- }
-
- void setParticle(XmlSchemaGroupParticle particle) {
- this.particle = particle;
- }
-
-}
+/**
+ * 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.ws.commons.schema;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ws.commons.schema.utils.XmlSchemaRefBase;
+
+/**
+ * Common interface for all objects that can 'ref=' to a global item of the
same type.
+ * Note that this interface does not return the XmlSchemaRef, since that type
is generic.
+ * It is convenient to have a non-generic interface in common for the ref=
items since
+ * there are cases where code wants to treat them independent of the type.
+ */
+public interface XmlSchemaItemWithRefBase {
+ /**
+ * @return true if this object has a non-null ref.
+ */
+ boolean isRef();
+
+ /**
+ * @return the Qualified Name of the target of the ref.
+ */
+ QName getTargetQName();
+
+ /**
+ * @return the non-generic reference object.
+ */
+ XmlSchemaRefBase getRefBase();
+
+}