You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2005/10/07 11:57:24 UTC
svn commit: r307066 - in
/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding:
schema/ utils/ utils/support/
Author: ajith
Date: Fri Oct 7 02:57:12 2005
New Revision: 307066
URL: http://svn.apache.org/viewcvs?rev=307066&view=rev
Log:
1.Removed some more remnants from the last cleanup
2.Added a preliminary level schema compiler (rightnow it does nothing) based on WS-commons XMLSchema
Added:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompilationException.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
Removed:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/JavaUtils.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/XMLUtils.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/support/
Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java?rev=307066&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/CompilerOptions.java Fri Oct 7 02:57:12 2005
@@ -0,0 +1,36 @@
+package org.apache.axis2.databinding.schema;
+
+import java.io.File;
+/*
+ * Copyright 2004,2005 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.
+ */
+
+/**
+ * This is a bean class that captures all the compiler ptions/parameterss
+ */
+public class CompilerOptions {
+
+ File outputLocation;
+
+ public File getOutputLocation() {
+ return outputLocation;
+ }
+
+ public CompilerOptions setOutputLocation(File outputLocation) {
+ this.outputLocation = outputLocation;
+ return this;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompilationException.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompilationException.java?rev=307066&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompilationException.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompilationException.java Fri Oct 7 02:57:12 2005
@@ -0,0 +1,34 @@
+package org.apache.axis2.databinding.schema;
+/*
+ * Copyright 2004,2005 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.
+ */
+
+public class SchemaCompilationException extends Exception{
+
+ public SchemaCompilationException() {
+ }
+
+ public SchemaCompilationException(String message) {
+ super(message);
+ }
+
+ public SchemaCompilationException(Throwable cause) {
+ super(cause);
+ }
+
+ public SchemaCompilationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java?rev=307066&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java Fri Oct 7 02:57:12 2005
@@ -0,0 +1,133 @@
+package org.apache.axis2.databinding.schema;
+
+import org.apache.ws.commons.schema.*;
+
+import java.util.List;
+import java.util.Iterator;
+/*
+ * Copyright 2004,2005 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.
+ */
+
+public class SchemaCompiler {
+
+ CompilerOptions options;
+
+ /**
+ *
+ * @param options
+ */
+ public SchemaCompiler(CompilerOptions options) {
+ if (options==null){
+ //create an empty options object
+ this.options = new CompilerOptions();
+ }else{
+ this.options = options;
+ }
+
+ }
+
+ /**
+ *
+ * @param schemalist
+ * @throws SchemaCompilationException
+ */
+ public void compile(List schemalist) throws SchemaCompilationException{
+ XmlSchema schema;
+ try {
+ for (int i = 0; i < schemalist.size(); i++) {
+ schema = (XmlSchema)schemalist.get(i);
+ compile(schema);
+ }
+ } catch (Exception e) {
+ throw new SchemaCompilationException(e);
+ }
+ }
+
+ /**
+ *
+ *
+ * @param schema
+ * @throws SchemaCompilationException
+ */
+ public void compile(XmlSchema schema) throws SchemaCompilationException{
+ //write the code here to do the schema compilation
+ XmlSchemaObjectTable elements = schema.getElements();
+ XmlSchemaElement xsElt;
+ Iterator xmlSchemaElementIterator = elements.getValues();
+ while (xmlSchemaElementIterator.hasNext()) {
+ xsElt = (XmlSchemaElement)xmlSchemaElementIterator.next();
+ processElement(xsElt);
+ }
+
+ }
+
+ /**
+ *
+ * @param xsElt
+ */
+ private void processElement(XmlSchemaElement xsElt){
+
+ XmlSchemaType schemaType = xsElt.getSchemaType();
+ if (schemaType!=null){
+ if (schemaType instanceof XmlSchemaComplexType){
+ //write classes for complex types
+ processComplexSchemaType((XmlSchemaComplexType)schemaType);
+ }else if (schemaType instanceof XmlSchemaSimpleType){
+ processSimpleSchemaType((XmlSchemaSimpleType)schemaType);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param complexType
+ */
+ private void processComplexSchemaType(XmlSchemaComplexType complexType){
+ //to start with we need to write a class to represent this
+ //
+ XmlSchemaParticle particle = complexType.getParticle();
+ if (particle!=null){
+ //check the particle
+ if (particle instanceof XmlSchemaSequence){
+ XmlSchemaObjectCollection items = ((XmlSchemaSequence)particle).getItems();
+ int count = items.getCount();
+ for (int i = 0; i < count; i++) {
+ XmlSchemaObject item = items.getItem(i);
+ if (item instanceof XmlSchemaElement){
+ //recursively process the element
+ processElement((XmlSchemaElement)item);
+ }
+
+ //process the items here. Usually the complex type needs to be represented as a bean class
+
+
+ //populate a type map
+
+ }
+ }
+
+
+ }
+
+ }
+
+ /**
+ * Handle the simple content
+ * @param simpleType
+ */
+ private void processSimpleSchemaType(XmlSchemaSimpleType simpleType){
+ //nothing to here yet
+ }
+}