You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by bi...@apache.org on 2009/04/13 03:10:40 UTC
svn commit: r764346 - in /webservices/commons/trunk/modules/XmlSchema/src:
main/java/org/apache/ws/commons/schema/ test/java/tests/
Author: bimargulies
Date: Mon Apr 13 01:10:39 2009
New Revision: 764346
URL: http://svn.apache.org/viewvc?rev=764346&view=rev
Log:
Change XmlSchemaAnnotation to use List<> instead of XmlSchemaCollection. Introduce common parent class for appInfo and documentation.
Added:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotationItem.java (with props)
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotation.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAppInfo.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaDocumentation.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnnotationDeepTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnnotationTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/NotationTest.java
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java?rev=764346&r1=764345&r2=764346&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java Mon Apr 13 01:10:39 2009
@@ -231,7 +231,8 @@
* add it to annotation collection
*/
XmlSchemaAnnotation handleAnnotation(Element annotEl) {
- XmlSchemaObjectCollection content = new XmlSchemaObjectCollection();
+ XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
+ List<XmlSchemaAnnotationItem> content = annotation.getItems();
XmlSchemaAppInfo appInfoObj;
XmlSchemaDocumentation docsObj;
@@ -256,9 +257,6 @@
}
}
- XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
- annotation.items = content;
-
// process extra attributes and elements
processExtensibilityComponents(annotation, annotEl);
return annotation;
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotation.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotation.java?rev=764346&r1=764345&r2=764346&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotation.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotation.java Mon Apr 13 01:10:39 2009
@@ -19,21 +19,24 @@
package org.apache.ws.commons.schema;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Defines an annotation. Represents the World Wide Web Consortium (W3C) annotation element.
*/
public class XmlSchemaAnnotation extends XmlSchemaObject {
- XmlSchemaObjectCollection items;
+ private List<XmlSchemaAnnotationItem> items;
/**
* Creates new XmlSchemaAnnotation
*/
public XmlSchemaAnnotation() {
- items = new XmlSchemaObjectCollection();
+ items = new ArrayList<XmlSchemaAnnotationItem>();
}
- public XmlSchemaObjectCollection getItems() {
+ public List<XmlSchemaAnnotationItem> getItems() {
return items;
}
}
Added: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotationItem.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotationItem.java?rev=764346&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotationItem.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotationItem.java Mon Apr 13 01:10:39 2009
@@ -0,0 +1,28 @@
+/**
+ * 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;
+
+/**
+ * Common base class of the items that can live inside an annotation.
+ */
+public class XmlSchemaAnnotationItem
+ extends XmlSchemaObject {
+
+}
Propchange: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotationItem.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAnnotationItem.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAppInfo.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAppInfo.java?rev=764346&r1=764345&r2=764346&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAppInfo.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaAppInfo.java Mon Apr 13 01:10:39 2009
@@ -28,7 +28,7 @@
// Jan 24 2002 - Joni - Change the Node into NodeList
-public class XmlSchemaAppInfo extends XmlSchemaObject {
+public class XmlSchemaAppInfo extends XmlSchemaAnnotationItem {
/**
* Provides the source of the application information.
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaDocumentation.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaDocumentation.java?rev=764346&r1=764345&r2=764346&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaDocumentation.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaDocumentation.java Mon Apr 13 01:10:39 2009
@@ -26,7 +26,7 @@
* Wide Web Consortium (W3C) documentation element.
*/
-public class XmlSchemaDocumentation extends XmlSchemaObject {
+public class XmlSchemaDocumentation extends XmlSchemaAnnotationItem {
/**
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java?rev=764346&r1=764345&r2=764346&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java Mon Apr 13 01:10:39 2009
@@ -203,11 +203,11 @@
Element annotation = createNewElement(doc, "annotation", schema.getSchemaNamespacePrefix(),
XmlSchema.SCHEMA_NS);
- XmlSchemaObjectCollection contents = annotationObj.items;
- int contentLength = contents.getCount();
+ List<XmlSchemaAnnotationItem> contents = annotationObj.getItems();
+ int contentLength = contents.size();
for (int i = 0; i < contentLength; i++) {
- XmlSchemaObject obj = contents.getItem(i);
+ XmlSchemaObject obj = contents.get(i);
if (obj instanceof XmlSchemaAppInfo) {
XmlSchemaAppInfo appinfo = (XmlSchemaAppInfo)obj;
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnnotationDeepTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnnotationDeepTest.java?rev=764346&r1=764345&r2=764346&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnnotationDeepTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnnotationDeepTest.java Mon Apr 13 01:10:39 2009
@@ -20,6 +20,7 @@
import java.io.FileInputStream;
import java.io.InputStream;
+import java.util.List;
import javax.xml.transform.stream.StreamSource;
@@ -32,9 +33,9 @@
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaAnnotation;
+import org.apache.ws.commons.schema.XmlSchemaAnnotationItem;
import org.apache.ws.commons.schema.XmlSchemaAppInfo;
import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
public class AnnotationDeepTest extends TestCase {
@@ -76,8 +77,8 @@
XmlSchemaAnnotation annotation = schema.getAnnotation();
assertTrue("annotation is retrieved ok", null != annotation);
- XmlSchemaObjectCollection items = annotation.getItems();
- assertEquals("Annotation contains an appinfo and yet this fails", 1, items.getCount());
+ List<XmlSchemaAnnotationItem> items = annotation.getItems();
+ assertEquals("Annotation contains an appinfo and yet this fails", 1, items.size());
}
@@ -119,9 +120,9 @@
XmlSchemaAnnotation annotation = schema.getAnnotation();
assertTrue("annotation is retrieved ok", null != annotation);
- XmlSchemaObjectCollection items = annotation.getItems();
- assertTrue(items.getItem(0) instanceof XmlSchemaAppInfo);
- XmlSchemaAppInfo appInfo = (XmlSchemaAppInfo) items.getItem(0);
+ List<XmlSchemaAnnotationItem> items = annotation.getItems();
+ assertTrue(items.get(0) instanceof XmlSchemaAppInfo);
+ XmlSchemaAppInfo appInfo = (XmlSchemaAppInfo) items.get(0);
NodeList markup = appInfo.getMarkup();
assertTrue("The markup exists", null != markup);
Node node = markup.item(1);
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnnotationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnnotationTest.java?rev=764346&r1=764345&r2=764346&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnnotationTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnnotationTest.java Mon Apr 13 01:10:39 2009
@@ -21,6 +21,7 @@
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.xml.namespace.QName;
@@ -31,11 +32,11 @@
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaAnnotation;
+import org.apache.ws.commons.schema.XmlSchemaAnnotationItem;
import org.apache.ws.commons.schema.XmlSchemaAppInfo;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaDocumentation;
import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
import org.apache.ws.commons.schema.XmlSchemaSimpleType;
import org.junit.Assert;
@@ -69,13 +70,13 @@
XmlSchemaAnnotation xsa = simpleType.getAnnotation();
assertNotNull(xsa);
- XmlSchemaObjectCollection col = xsa.getItems();
- assertEquals(1, col.getCount());
+ List<XmlSchemaAnnotationItem> col = xsa.getItems();
+ assertEquals(1, col.size());
Set<String> s = new HashSet<String>();
s.add(XmlSchemaDocumentation.class.getName());
- for (int i = 0; i < col.getCount(); i++) {
- XmlSchemaObject o = col.getItem(i);
+ for (int i = 0; i < col.size(); i++) {
+ XmlSchemaObject o = col.get(i);
if (o instanceof XmlSchemaAppInfo) {
fail("The appinfo element did not contain a source"
+ " attribute or any content, so this element" + " was not exptected to be found.");
@@ -121,13 +122,13 @@
XmlSchemaAnnotation xsa = simpleType.getAnnotation();
assertNotNull(xsa);
- XmlSchemaObjectCollection col = xsa.getItems();
- assertEquals(1, col.getCount());
+ List<XmlSchemaAnnotationItem> col = xsa.getItems();
+ assertEquals(1, col.size());
Set<String> s = new HashSet<String>();
s.add(XmlSchemaAppInfo.class.getName());
- for (int i = 0; i < col.getCount(); i++) {
- XmlSchemaObject o = col.getItem(i);
+ for (int i = 0; i < col.size(); i++) {
+ XmlSchemaObject o = col.get(i);
if (o instanceof XmlSchemaAppInfo) {
assertEquals("http://test/source/appinfo", ((XmlSchemaAppInfo)o).getSource());
NodeList nl = ((XmlSchemaAppInfo)o).getMarkup();
@@ -171,8 +172,8 @@
XmlSchemaAnnotation xsa = simpleType.getAnnotation();
assertNotNull(xsa);
- XmlSchemaObjectCollection col = xsa.getItems();
- assertEquals(0, col.getCount());
+ List<XmlSchemaAnnotationItem> col = xsa.getItems();
+ assertEquals(0, col.size());
}
@@ -202,14 +203,14 @@
XmlSchemaAnnotation xsa = simpleType.getAnnotation();
assertNotNull(xsa);
- XmlSchemaObjectCollection col = xsa.getItems();
- assertEquals(2, col.getCount());
+ List<XmlSchemaAnnotationItem> col = xsa.getItems();
+ assertEquals(2, col.size());
Set<String> s = new HashSet<String>();
s.add(XmlSchemaAppInfo.class.getName());
s.add(XmlSchemaDocumentation.class.getName());
- for (int i = 0; i < col.getCount(); i++) {
- XmlSchemaObject o = col.getItem(i);
+ for (int i = 0; i < col.size(); i++) {
+ XmlSchemaObject o = col.get(i);
if (o instanceof XmlSchemaAppInfo) {
assertEquals("http://test/source/appinfo", ((XmlSchemaAppInfo)o).getSource());
NodeList nl = ((XmlSchemaAppInfo)o).getMarkup();
@@ -254,14 +255,14 @@
XmlSchema schema = schemaCol.read(new StreamSource(is));
XmlSchemaAnnotation xsa = schema.getAnnotation();
- XmlSchemaObjectCollection col = xsa.getItems();
- assertEquals(2, col.getCount());
+ List<XmlSchemaAnnotationItem> col = xsa.getItems();
+ assertEquals(2, col.size());
Set<String> s = new HashSet<String>();
s.add(XmlSchemaAppInfo.class.getName());
s.add(XmlSchemaDocumentation.class.getName());
- for (int i = 0; i < col.getCount(); i++) {
- XmlSchemaObject o = col.getItem(i);
+ for (int i = 0; i < col.size(); i++) {
+ XmlSchemaObject o = col.get(i);
if (o instanceof XmlSchemaAppInfo) {
assertEquals("http://test101/source/appinfo", ((XmlSchemaAppInfo)o).getSource());
NodeList nl = ((XmlSchemaAppInfo)o).getMarkup();
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/NotationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/NotationTest.java?rev=764346&r1=764345&r2=764346&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/NotationTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/NotationTest.java Mon Apr 13 01:10:39 2009
@@ -22,6 +22,7 @@
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -33,6 +34,7 @@
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaAnnotation;
+import org.apache.ws.commons.schema.XmlSchemaAnnotationItem;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaDocumentation;
import org.apache.ws.commons.schema.XmlSchemaElement;
@@ -117,11 +119,11 @@
XmlSchemaNotation xsn = e.getValue();
String name = xsn.getName();
XmlSchemaAnnotation xsa = xsn.getAnnotation();
- XmlSchemaObjectCollection col = xsa.getItems();
- assertEquals(1, col.getCount());
+ List<XmlSchemaAnnotationItem> col = xsa.getItems();
+ assertEquals(1, col.size());
XmlSchemaDocumentation xsd = null;
- for (int k = 0; k < col.getCount(); k++) {
- xsd = (XmlSchemaDocumentation)col.getItem(k);
+ for (int k = 0; k < col.size(); k++) {
+ xsd = (XmlSchemaDocumentation)col.get(k);
}
if ("teamMascot".equals(name)) {
assertEquals("http://www.team.com/graphics/teamMascot", xsn.getPublic());