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 2006/02/02 12:32:19 UTC
svn commit: r374365 - in /webservices/axis2/trunk/java/modules:
adb/src/org/apache/axis2/databinding/utils/
adb/test/org/apache/axis2/databinding/utils/
codegen/src/org/apache/axis2/schema/template/
Author: ajith
Date: Thu Feb 2 03:31:57 2006
New Revision: 374365
URL: http://svn.apache.org/viewcvs?rev=374365&view=rev
Log:
Halfway through re-implemnting the de-serialization logic in ADB
1. Added several state machines to process the simple elements, simple element arrays
2. Added the relevant tests
Added:
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NamedStaxOMBuilder.java
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/States.java
webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/NamedStaxOMBuilderTest.java
webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachineTest.java
webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachineTest.java
Removed:
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/MethodCache.java
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
Added: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NamedStaxOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NamedStaxOMBuilder.java?rev=374365&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NamedStaxOMBuilder.java (added)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NamedStaxOMBuilder.java Thu Feb 2 03:31:57 2006
@@ -0,0 +1,72 @@
+package org.apache.axis2.databinding.utils;
+
+import org.apache.ws.commons.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.namespace.QName;
+/*
+ * 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 NamedStaxOMBuilder {
+
+ //wrap a StAXOMBuilder
+ private StAXOMBuilder builder;
+ private XMLStreamReader reader;
+ private QName nameToMatch;
+
+ /**
+ *
+ * @param xmlStreamReader
+ * @param nameToMatch
+ */
+ public NamedStaxOMBuilder(XMLStreamReader xmlStreamReader, QName nameToMatch) {
+ reader = xmlStreamReader;
+ builder = new StAXOMBuilder(xmlStreamReader);
+ this.nameToMatch = nameToMatch;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public OMElement getOMElement(){
+ //force to build within the given QName
+ boolean done = false;
+ int depth = 0;
+ while(!done){
+ if (reader.getEventType()==XMLStreamConstants.END_ELEMENT){
+ depth--;
+ }else if (reader.getEventType()==XMLStreamConstants.START_ELEMENT){
+ depth++;
+ }
+
+ if (depth==0 && reader.getEventType()==XMLStreamConstants.END_ELEMENT &&
+ nameToMatch.equals(reader.getName())){
+ done = true;
+ }else{
+ builder.next();
+ }
+
+ }
+
+ return builder.getDocumentElement();
+ }
+
+
+
+}
Added: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java?rev=374365&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java (added)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java Thu Feb 2 03:31:57 2006
@@ -0,0 +1,113 @@
+package org.apache.axis2.databinding.utils;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamConstants;
+import java.util.List;
+import java.util.ArrayList;
+/*
+ * 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.
+ */
+
+/**
+ * A state machine that reads arrays with simple content. returns a string array
+ */
+public class SimpleArrayReaderStateMachine implements States {
+
+ private QName elementNameToTest = null;
+ private int currentState = INIT_STATE;
+ private List list = new ArrayList();
+
+ public String[] getTextArray() {
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public void setElementNameToTest(QName elementNameToTest) {
+ this.elementNameToTest = elementNameToTest;
+ }
+
+ /**
+ * public read method - reads a given reader to extract the text value
+ * @param reader
+ */
+ public void read(XMLStreamReader reader) throws XMLStreamException {
+
+ do{
+ updateState(reader);
+ if (currentState==TEXT_FOUND_STATE){
+ //read the text value and store it
+ list.add(reader.getText());
+ }
+ if (currentState!=FINISHED_STATE
+ && currentState!= ILLEGAL_STATE){
+ reader.next();
+ }
+
+ }while(currentState!=FINISHED_STATE
+ && currentState!= ILLEGAL_STATE);
+
+ if (currentState==ILLEGAL_STATE){
+ throw new RuntimeException("Illegal state!");
+ }
+
+ }
+
+
+ private void updateState(XMLStreamReader reader){
+ int event = reader.getEventType();
+
+ //state 1
+ if (event== XMLStreamConstants.START_DOCUMENT && currentState==INIT_STATE){
+ currentState = STARTED_STATE;
+ }else if (event==XMLStreamConstants.START_ELEMENT && currentState==INIT_STATE){
+ if (elementNameToTest.equals(reader.getName())){
+ currentState = START_ELEMENT_FOUND_STATE;
+ }else{
+ currentState = STARTED_STATE;
+ }
+ }else if (event==XMLStreamConstants.START_ELEMENT && currentState==STARTED_STATE) {
+ if (elementNameToTest.equals(reader.getName())){
+ currentState = START_ELEMENT_FOUND_STATE;
+ }
+ }else if (event==XMLStreamConstants.CHARACTERS && currentState==START_ELEMENT_FOUND_STATE){
+ currentState = TEXT_FOUND_STATE;
+
+ //state 3
+ } else if (event==XMLStreamConstants.END_ELEMENT && currentState==TEXT_FOUND_STATE){
+ if (elementNameToTest.equals(reader.getName())){
+ currentState = END_ELEMENT_FOUND_STATE;
+ }else{
+ currentState = ILLEGAL_STATE;
+ }
+
+ //state 4
+ }else if (event==XMLStreamConstants.START_ELEMENT && currentState==END_ELEMENT_FOUND_STATE ) {
+ if (elementNameToTest.equals(reader.getName())){
+ currentState = START_ELEMENT_FOUND_STATE;
+ }else{
+ currentState = FINISHED_STATE;
+ }
+ }else if (event==XMLStreamConstants.END_ELEMENT && currentState==END_ELEMENT_FOUND_STATE ) {
+ currentState = FINISHED_STATE;
+ }else if (event==XMLStreamConstants.END_DOCUMENT){
+ currentState = FINISHED_STATE;
+ }else{
+ currentState = ILLEGAL_STATE;
+ }
+ }
+
+
+}
Added: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java?rev=374365&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java (added)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java Thu Feb 2 03:31:57 2006
@@ -0,0 +1,115 @@
+package org.apache.axis2.databinding.utils;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+/*
+ * 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.
+ */
+
+/**
+ * A state machine to read elements with simple content. Returns the text
+ * of the element and the stream reader will be one event beyond the
+ * end element at return
+ */
+public class SimpleElementReaderStateMachine implements States{
+
+
+
+ private QName elementNameToTest = null;
+ private int currentState = INIT_STATE;
+ private String text="";
+
+ public String getText() {
+ return text;
+ }
+
+ public void setElementNameToTest(QName elementNameToTest) {
+ this.elementNameToTest = elementNameToTest;
+ }
+
+ public void reset(){
+ elementNameToTest = null;
+ currentState = INIT_STATE;
+ text="";
+ }
+ /**
+ * public read method - reads a given reader to extract the text value
+ * @param reader
+ */
+ public void read(XMLStreamReader reader) throws XMLStreamException {
+
+ do{
+ updateState(reader);
+ if (currentState==TEXT_FOUND_STATE){
+ //read the text value and store it
+ text = reader.getText();
+ }
+ if (currentState!=FINISHED_STATE
+ && currentState!= ILLEGAL_STATE){
+ reader.next();
+ }
+
+ }while(currentState!=FINISHED_STATE
+ && currentState!= ILLEGAL_STATE);
+
+ if (currentState==ILLEGAL_STATE){
+ throw new RuntimeException("Illegal state!");
+ }
+
+ }
+
+
+ private void updateState(XMLStreamReader reader){
+ int event = reader.getEventType();
+
+ //state 1
+ if (event==XMLStreamConstants.START_DOCUMENT && currentState==INIT_STATE){
+ currentState = STARTED_STATE;
+ }else if (event==XMLStreamConstants.START_ELEMENT && currentState==INIT_STATE){
+ if (elementNameToTest.equals(reader.getName())){
+ currentState = START_ELEMENT_FOUND_STATE;
+ }else{
+ currentState = STARTED_STATE;
+ }
+ }else if (event==XMLStreamConstants.START_ELEMENT && currentState==STARTED_STATE) {
+ if (elementNameToTest.equals(reader.getName())){
+ currentState = START_ELEMENT_FOUND_STATE;
+ }
+ }else if (event==XMLStreamConstants.CHARACTERS && currentState==START_ELEMENT_FOUND_STATE){
+ currentState = TEXT_FOUND_STATE;
+
+ //state 3
+ } else if (event==XMLStreamConstants.END_ELEMENT && currentState==TEXT_FOUND_STATE){
+ if (elementNameToTest.equals(reader.getName())){
+ currentState = END_ELEMENT_FOUND_STATE;
+ }else{
+ currentState = ILLEGAL_STATE;
+ }
+
+ //state 4
+ }else if (currentState==END_ELEMENT_FOUND_STATE) {
+ currentState = FINISHED_STATE;
+ }else{
+ currentState = ILLEGAL_STATE;
+ }
+ }
+
+
+
+
+
+}
Added: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/States.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/States.java?rev=374365&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/States.java (added)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/States.java Thu Feb 2 03:31:57 2006
@@ -0,0 +1,29 @@
+package org.apache.axis2.databinding.utils;
+/*
+ * 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 interface States {
+
+ static int INIT_STATE = -1;
+ static int STARTED_STATE = 0;
+ static int START_ELEMENT_FOUND_STATE = 1;
+ static int TEXT_FOUND_STATE = 2;
+ static int END_ELEMENT_FOUND_STATE = 3;
+ static int FINISHED_STATE = 4;
+ static int ILLEGAL_STATE = 5;
+ static int CONTENT_FOUND_STATE = 6;
+
+}
Added: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/NamedStaxOMBuilderTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/NamedStaxOMBuilderTest.java?rev=374365&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/NamedStaxOMBuilderTest.java (added)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/NamedStaxOMBuilderTest.java Thu Feb 2 03:31:57 2006
@@ -0,0 +1,45 @@
+package org.apache.axis2.databinding.utils;
+
+import junit.framework.TestCase;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
+import java.io.StringReader;
+
+import org.apache.ws.commons.om.OMElement;
+/*
+ * 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 NamedStaxOMBuilderTest extends TestCase {
+
+ public void testNamedOMBulder() throws Exception{
+
+ String xmlDoc="<wrapper><myIntVal>200</myIntVal></wrapper>";
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+ new StringReader(xmlDoc));
+
+ NamedStaxOMBuilder sm = new NamedStaxOMBuilder(reader,new QName("wrapper"));
+ OMElement elt = sm.getOMElement();
+
+ assertNotNull(elt);
+
+
+
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachineTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachineTest.java?rev=374365&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachineTest.java (added)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachineTest.java Thu Feb 2 03:31:57 2006
@@ -0,0 +1,103 @@
+package org.apache.axis2.databinding.utils;
+
+import junit.framework.TestCase;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.namespace.QName;
+import java.io.StringReader;
+/*
+ * 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 SimpleArrayReaderStateMachineTest extends TestCase {
+
+ public void testStateMachine() throws Exception{
+ String xmlDoc="<wrapper><myIntVal>200</myIntVal><myIntVal>200</myIntVal><myIntVal>200</myIntVal>" +
+ "<myIntVal>200</myIntVal><myIntVal>200</myIntVal><myIntVal>200</myIntVal></wrapper>";
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+ new StringReader(xmlDoc));
+ SimpleArrayReaderStateMachine sm = new SimpleArrayReaderStateMachine();
+ sm.setElementNameToTest(new QName("myIntVal"));
+ try {
+ sm.read(reader);
+ } catch (XMLStreamException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ assertEquals(6,sm.getTextArray().length);
+
+ }
+
+ public void testStateMachine3() throws Exception{
+ String xmlDoc="<wrapper><myIntVal>200</myIntVal><myIntVal>200</myIntVal><myIntVal>200</myIntVal>" +
+ "<myIntVal>200</myIntVal><myIntVal>200</myIntVal><myIntVal>200</myIntVal></wrapper>";
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+ new StringReader(xmlDoc));
+
+ while(reader.hasNext()){
+ int event = reader.next();
+ if (event== XMLStreamConstants.START_ELEMENT && "myIntVal".equals(reader.getLocalName())){
+ break;
+ }
+
+ }
+
+ SimpleArrayReaderStateMachine sm = new SimpleArrayReaderStateMachine();
+ sm.setElementNameToTest(new QName("myIntVal"));
+ try {
+ sm.read(reader);
+ } catch (XMLStreamException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ assertEquals(6,sm.getTextArray().length);
+
+ }
+
+ public void testStateMachine2() throws Exception{
+ String xmlDoc="<wrapper><myIntVal>200</myIntVal></wrapper>";
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+ new StringReader(xmlDoc));
+ SimpleArrayReaderStateMachine sm = new SimpleArrayReaderStateMachine();
+ sm.setElementNameToTest(new QName("myIntVal"));
+ try {
+ sm.read(reader);
+ } catch (XMLStreamException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ assertEquals("200",sm.getTextArray()[0]);
+ }
+
+// public void testStateMachine3() throws Exception{
+// String xmlDoc="<myIntVal>200<a/></myIntVal>";
+// XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+// new StringReader(xmlDoc));
+// SimpleElementReaderStateMachine sm = new SimpleElementReaderStateMachine();
+// sm.setElementNameToTest(new QName("myIntVal"));
+// try {
+// sm.read(reader);
+// fail();
+// } catch (Exception e) {
+//
+// }
+//
+//
+// }
+
+}
Added: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachineTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachineTest.java?rev=374365&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachineTest.java (added)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachineTest.java Thu Feb 2 03:31:57 2006
@@ -0,0 +1,74 @@
+package org.apache.axis2.databinding.utils;
+
+import junit.framework.TestCase;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
+import java.io.StringReader;
+/*
+ * 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 SimpleElementReaderStateMachineTest extends TestCase {
+
+ public void testStateMachine() throws Exception{
+ String xmlDoc="<myIntVal>200</myIntVal>";
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+ new StringReader(xmlDoc));
+ SimpleElementReaderStateMachine sm = new SimpleElementReaderStateMachine();
+ sm.setElementNameToTest(new QName("myIntVal"));
+ try {
+ sm.read(reader);
+ } catch (XMLStreamException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ assertEquals("200",sm.getText());
+ }
+
+ public void testStateMachine2() throws Exception{
+ String xmlDoc="<wrapper><myIntVal>200</myIntVal></wrapper>";
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+ new StringReader(xmlDoc));
+ SimpleElementReaderStateMachine sm = new SimpleElementReaderStateMachine();
+ sm.setElementNameToTest(new QName("myIntVal"));
+ try {
+ sm.read(reader);
+ } catch (XMLStreamException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ assertEquals("200",sm.getText());
+ }
+
+ public void testStateMachine3() throws Exception{
+ String xmlDoc="<myIntVal>200<a/></myIntVal>";
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+ new StringReader(xmlDoc));
+ SimpleElementReaderStateMachine sm = new SimpleElementReaderStateMachine();
+ sm.setElementNameToTest(new QName("myIntVal"));
+ try {
+ sm.read(reader);
+ fail();
+ } catch (Exception e) {
+
+ }
+
+
+ }
+
+}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=374365&r1=374364&r2=374365&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Thu Feb 2 03:31:57 2006
@@ -230,7 +230,8 @@
}
- /** Factory class that keeps the parse method
+ /**
+ * Factory class that keeps the parse method
*/
public static class Factory{
/**