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 he...@apache.org on 2004/09/21 08:38:34 UTC
svn commit: rev 46963 - in webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal: . src src/java src/java/org src/java/org/apache src/java/org/apache/axis src/java/org/apache/axis/om src/java/org/apache/axis/om/storage src/java/org/apache/axis/om/traversal src/java/org/apache/axis/om/util src/test src/test-resources src/test/org src/test/org/apache src/test/org/apache/axis src/test/org/apache/axis/om
Author: hemapani
Date: Mon Sep 20 23:38:32 2004
New Revision: 46963
Added:
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/project.properties
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/project.xml
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/OMBuilderException.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/OMConstants.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/OMTableModel.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/StreamingOmBuilder.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/AttributeRow.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/ElementRow.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/GlobalRow.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/NodeRow.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/NodeTable.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/Row.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/Table.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/TextRow.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/traversal/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/traversal/NodeIterator.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/traversal/OmIterator.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/util/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/util/Sequence.java (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test-resources/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test-resources/testFile.xml (contents, props changed)
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test/org/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test/org/apache/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test/org/apache/axis/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test/org/apache/axis/om/
webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test/org/apache/axis/om/StreamingOmBuilderTest.java (contents, props changed)
Log:
initial commit of the prototype
of OM based on a table model. Commiting on behalf of the Ajith,Eran,Deepal,Dasarath
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/project.properties
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/project.properties Mon Sep 20 23:38:32 2004
@@ -0,0 +1,9 @@
+##
+## $Revision: 1.3 $ $Date: 2004/07/28 15:21:22 $
+##
+
+maven.repo.remote=http://ws.apache.org/~dims/maven, http://www.ibiblio.org/maven, http://ws.apache.org/~hemapani/maven
+maven.xdoc.date=left
+maven.xdoc.version=${pom.currentVersion}
+
+maven.jar.excludes=**/jndi.properties
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/project.xml
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/project.xml Mon Sep 20 23:38:32 2004
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project>
+ <pomVersion>3</pomVersion>
+
+ <id>axis-om</id>
+
+ <name>Axisom</name>
+
+ <currentVersion>1.0</currentVersion>
+
+ <organization>
+ <name>Apache Software Foundation</name>
+ <url>http://www.apache.org/</url>
+ <logo>http://maven.apache.org/images/jakarta-logo-blue.gif</logo>
+ </organization>
+
+ <!-- the year the project started -->
+ <inceptionYear>2004</inceptionYear>
+ <package>org.apache.axis.om</package>
+ <logo>http://maven.apache.org/images/maven.jpg</logo>
+ <description>
+ </description>
+ <!-- a short description of what the project does -->
+ <shortDescription>
+ </shortDescription>
+
+ <!-- the project home page -->
+ <url>http://ws.apache.org/axis/</url>
+ <issueTrackingUrl>http://nagoya.apache.org/scarab/servlet/scarab/</issueTrackingUrl>
+ <siteAddress>ws.apache.org</siteAddress>
+ <siteDirectory>/www/ews.ws.apache.org/</siteDirectory>
+ <distributionDirectory>/www/ws.apache.org/builds/</distributionDirectory>
+
+ <!-- the version control repository and http url for online access
+ the connection element has the form:
+ scm:<system>:<system specific connection string> -->
+ <repository>
+ <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:ws-axis/contrib/ews</connection>
+ <url>http://cvs.apache.org/viewcvs/ws-axis/contrib/ews/</url>
+ </repository>
+
+ <!-- any mailing lists for the project -->
+ <mailingLists>
+ <mailingList>
+ <name>Axis Developer List</name>
+ <subscribe>axis-dev-subscribe@ws.apache.org</subscribe>
+ <unsubscribe>axis-dev-unsubscribe@ws.apache.org</unsubscribe>
+ </mailingList>
+ </mailingLists>
+
+ <!-- ========== -->
+ <!-- Developers -->
+ <!-- ========== -->
+
+
+
+ <!-- who the developers are for the project -->
+ <developers/>
+
+ <!-- build information for the project -->
+ <build>
+ <nagEmailAddress>axis-dev@ws.apache.org</nagEmailAddress>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+
+ <unitTest>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+
+ <resources>
+ <resource>
+ <directory>src/test-resources</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+
+ <!-- ============ -->
+ <!-- Dependencies -->
+ <!-- ============ -->
+
+ <dependencies>
+ <!-- -->
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ <version>1.1.3.3</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ </dependencies>
+</project>
+
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/OMBuilderException.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/OMBuilderException.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,39 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 10:29:37 PM
+ */
+public class OMBuilderException extends Exception {
+
+
+ public OMBuilderException() {
+ }
+
+ public OMBuilderException(String message) {
+ super(message);
+ }
+
+ public OMBuilderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public OMBuilderException(Throwable cause) {
+ super(cause);
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/OMConstants.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/OMConstants.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,30 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 6:24:52 PM
+ */
+public class OMConstants {
+
+ public static final int TYPE_ELEMENT = 0;
+ public static final int TYPE_ATTRIBUTE = 1;
+ public static final int TYPE_TEXT = 2;
+ public static final int TYPE_COMMENT = 3;
+ public static final int TYPE_CDATA = 4;
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/OMTableModel.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/OMTableModel.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,461 @@
+package org.apache.axis.om;
+
+import org.apache.axis.om.storage.AttributeRow;
+import org.apache.axis.om.storage.ElementRow;
+import org.apache.axis.om.storage.GlobalRow;
+import org.apache.axis.om.storage.NodeTable;
+import org.apache.axis.om.storage.Row;
+import org.apache.axis.om.storage.Table;
+import org.apache.axis.om.storage.TextRow;
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 6:44:16 PM
+ *
+ * Note that since the OMTableModel is an abstraction of the XML document, it
+ * implements the DOM document interface .
+ * At leaset it should, in my opinion!
+ */
+public class OMTableModel implements Document{
+
+// private Sequence globalSequence = new Sequence();
+// private Sequence elementSequence = new Sequence();
+// private Sequence textSequence = new Sequence();
+// private Sequence attributeSequence = new Sequence();
+
+ private Table globalTable = new Table();
+ private NodeTable elementTable = new NodeTable();
+ private NodeTable textTable = new NodeTable();
+ private NodeTable attributeTable = new NodeTable();
+ // a flag that indicates whether the model is
+ // completed or not
+ private boolean completed = false;
+ private StreamingOmBuilder builder;
+
+ public OMTableModel(StreamingOmBuilder builder) {
+ this.builder = builder;
+ }
+
+ /**
+ * Get elements by parent
+ * @param parent
+ * @return
+ */
+ public Object[] getElementsByParent(Object parent){
+ return elementTable.getRowsbyParent(parent);
+ }
+
+ /**
+ * get the attributes by parent
+ * @param parent
+ * @return
+ */
+ public Object[] getAttribtByParent(Object parent){
+ return attributeTable.getRowsbyParent(parent);
+ }
+
+ /**
+ * Get the text nodes (text,comments and Cdata)
+ * @param parent
+ * @return
+ */
+ public Object[] getTextByParent(Object parent){
+ return textTable.getRowsbyParent(parent);
+ }
+
+ /**
+ * @param URI
+ * @param localName
+ * @param prefix
+ * @param parent
+ */
+ public Object addElement(String URI, String localName, String prefix, Object parent,StreamingOmBuilder builder) {
+
+ ElementRow eltRow = new ElementRow(builder,this);
+ eltRow.setKey(eltRow);//set the object itself as the key
+ eltRow.setURI(URI);
+ eltRow.setDone(false);
+ eltRow.setParent(parent);
+ eltRow.setLocalName(localName);
+ eltRow.setPrefix(prefix);
+ eltRow.setNextSibling(null);
+
+ elementTable.addRow(eltRow);
+
+ //add an entry to the global table as well
+ addToGlobalTable(OMConstants.TYPE_ELEMENT, eltRow);
+
+ return eltRow;
+
+ }
+
+ /**
+ * @param parent
+ * @param child
+ */
+ public void updateElementParent(Object parent, Object child) {
+ ElementRow row = (ElementRow) elementTable.getRowByKey(child);
+ row.setParent(parent);
+
+ }
+
+ /**
+ * @param key
+ */
+ public void updateElementDone(Object key) {
+ ElementRow row = (ElementRow) elementTable.getRowByKey(key);
+ row.setDone(true);
+ }
+
+ /**
+ * @param value
+ * @param parent
+ *
+ */
+ public Object addText(String value, Object parent) {
+
+ return addCharacterData(value,OMConstants.TYPE_TEXT,parent);
+ }
+
+
+
+ /**
+ * @param localName
+ * @param prefix
+ * @param URI
+ * @param value
+ * @param parent
+ *
+ */
+ public Object addAttribute(String localName, String prefix, String URI, String value, Object parent) {
+
+ AttributeRow attRow = new AttributeRow();
+
+ attRow.setKey(attRow);
+ attRow.setLocalName(localName);
+ attRow.setPrefix(prefix);
+ attRow.setURI(URI);
+ attRow.setValue(value);
+ attRow.setParent(parent);
+
+
+ attributeTable.addRow(attRow);
+
+ return attRow;
+ }
+
+ public void updateAttributeSibling(Object myKey,Object siblingKey){
+
+ AttributeRow attrRow = (AttributeRow)attributeTable.getRowByKey(myKey);
+ attrRow.setNextSibling(siblingKey);
+
+ }
+ /**
+ * @param type
+ * @param referenceKey
+ */
+ private void addToGlobalTable(int type, Object referenceKey) {
+ GlobalRow globalRow = new GlobalRow();
+
+ globalRow.setType(type);
+ globalRow.setReferenceKey(referenceKey);
+
+ globalTable.addRow(globalRow);
+
+ }
+
+ /**
+ * @return
+ */
+ public int getElementCount() {
+ return elementTable.getSize();
+ }
+
+ public Row getElement(Object key) {
+ return elementTable.getRowByKey(key);
+ }
+
+ public Row getElementByIndex(int index) {
+ return elementTable.getRowByIndex(index);
+ }
+
+ public Object addCData(String value,Object parent){
+ return addCharacterData(value,OMConstants.TYPE_CDATA,parent);
+ }
+
+ public Object addComment(String value,Object parent){
+ return addCharacterData(value,OMConstants.TYPE_COMMENT,parent);
+ }
+
+ private Object addCharacterData(String value,int type,Object parentKey){
+ TextRow textRow = new TextRow();
+
+ textRow.setKey(textRow);
+ textRow.setParent(parentKey);
+ textRow.setValue(value);
+ textRow.setType(type);
+ textTable.addRow(textRow);
+
+ //add an entry to the global table as well
+ addToGlobalTable(type, textRow);
+ return textRow;
+ }
+
+ private Object getRoot(){
+ Object[] rootChildren = elementTable.getRowsbyParent(null);
+
+ return (rootChildren==null || rootChildren.length==0)?null:rootChildren[0];
+ }
+ /**
+ * Debug method
+ */
+ public void dumpTablesToConsole() {
+ System.out.println("Global \n");
+ System.out.println(globalTable);
+ System.out.println("Elements \n");
+ System.out.println(elementTable);
+ System.out.println("Attribute \n");
+ System.out.println(attributeTable);
+ System.out.println("text \n");
+ System.out.println(textTable);
+
+ }
+
+ /* Interface Methods */
+
+ public DocumentType getDoctype() {
+ return null;
+ }
+
+ public DOMImplementation getImplementation() {
+ return null;
+ }
+
+ public Element getDocumentElement() {
+ //return the first element
+ while(getRoot()==null){
+ try {
+ builder.proceed();
+ } catch (OMBuilderException e) {
+ e.printStackTrace();
+ break;
+ }
+ }
+ return (Element)getRoot();
+
+ }
+
+ public Element createElement(String tagName)
+ throws DOMException {
+ return null;
+ }
+
+ public DocumentFragment createDocumentFragment() {
+ return null;
+ }
+
+ public Text createTextNode(String data) {
+ return null;
+ }
+
+ public Comment createComment(String data) {
+ return null;
+ }
+
+ public CDATASection createCDATASection(String data)
+ throws DOMException {
+ return null;
+ }
+
+ public ProcessingInstruction createProcessingInstruction(String target,
+ String data)
+ throws DOMException {
+ return null;
+ }
+
+ public Attr createAttribute(String name)
+ throws DOMException {
+ return null;
+ }
+
+ public EntityReference createEntityReference(String name)
+ throws DOMException {
+ return null;
+ }
+
+ public NodeList getElementsByTagName(String tagname) {
+ return null;
+ }
+
+ public Node importNode(Node importedNode,
+ boolean deep)
+ throws DOMException {
+ return null;
+ }
+
+ public Element createElementNS(String namespaceURI,
+ String qualifiedName)
+ throws DOMException {
+ return null;
+ }
+
+ public Attr createAttributeNS(String namespaceURI,
+ String qualifiedName)
+ throws DOMException {
+ return null;
+ }
+
+ public NodeList getElementsByTagNameNS(String namespaceURI,
+ String localName) {
+ return null;
+ }
+
+ public Element getElementById(String elementId) {
+ return null;
+ }
+
+ public String getNodeName() {
+ return null;
+ }
+
+ public String getNodeValue()
+ throws DOMException {
+ return null;
+ }
+
+ public void setNodeValue(String nodeValue)
+ throws DOMException {
+ }
+
+ public short getNodeType() {
+ return 0;
+ }
+
+ public Node getParentNode() {
+ return null;
+ }
+
+ public NodeList getChildNodes() {
+ return null;
+ }
+
+ public Node getFirstChild() {
+ return null;
+ }
+
+ public Node getLastChild() {
+ return null;
+ }
+
+ public Node getPreviousSibling() {
+ return null;
+ }
+
+ public Node getNextSibling() {
+ return null;
+ }
+
+ public NamedNodeMap getAttributes() {
+ return null;
+ }
+
+ public Document getOwnerDocument() {
+ return null;
+ }
+
+ public Node insertBefore(Node newChild,
+ Node refChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node replaceChild(Node newChild,
+ Node oldChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node removeChild(Node oldChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node appendChild(Node newChild)
+ throws DOMException {
+ return null;
+ }
+
+ public boolean hasChildNodes() {
+ return false;
+ }
+
+ public Node cloneNode(boolean deep) {
+ return null;
+ }
+
+ public void normalize() {
+ }
+
+ public boolean isSupported(String feature,
+ String version) {
+ return false;
+ }
+
+ public String getNamespaceURI() {
+ return null;
+ }
+
+ public String getPrefix() {
+ return null;
+ }
+
+ public void setPrefix(String prefix)
+ throws DOMException {
+ }
+
+ public String getLocalName() {
+ return null;
+ }
+
+ public boolean hasAttributes() {
+ return false;
+ }
+
+ public boolean isCompleted() {
+ return completed;
+ }
+
+ public void setCompleted(boolean completed) {
+ this.completed = completed;
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/StreamingOmBuilder.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/StreamingOmBuilder.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,224 @@
+package org.apache.axis.om;
+
+import java.io.IOException;
+import java.util.Stack;
+
+import org.w3c.dom.Document;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 10:00:16 PM
+ * <p/>
+ * This class accepts pull events and generates the OMTableModel
+ */
+public class StreamingOmBuilder {
+
+ private XmlPullParser pullparser;
+ private OMTableModel tableModel=null;
+ private Stack elementStack = new Stack();
+
+ /**
+ * @param pullparser
+ */
+ public StreamingOmBuilder(XmlPullParser pullparser) {
+ this.pullparser = pullparser;
+ //////////////////////////////////
+ //todo CHECK THIS
+ this.tableModel = new OMTableModel(this); //the parser never seems to get the
+ //start document event!!!!!!!!!!!!!
+ //////////////////////////////////
+
+ }
+
+ public XmlPullParser getPullparser() {
+ return pullparser;
+ }
+
+ /**
+ * Since this is the entry point to the undelying XML representation
+ * this method contains the only reference to its own proceed method.
+ * it parses the XML until the document is created.
+ * In other words it will parse until the START_DOCUMENT event is generated
+ * @return
+ */
+ public Document getDocument() {
+ while (tableModel==null){
+ try {
+ proceed();
+ } catch (OMBuilderException e) {
+ e.printStackTrace();
+ break;
+ //just break the loop for now.
+ //todo think of a better way to handle this
+ }
+ }
+ return tableModel;
+ }
+
+ /**
+ * Call the next method once, of pull parser
+ * update the Table Model depending on the pull event recd from pull parser.
+ *
+ * @throws OMBuilderException
+ */
+ public void proceed() throws OMBuilderException {
+
+ try {
+ pullparser.next();
+ int eventType = pullparser.getEventType();
+ //do the necessary to each type of event
+ if (eventType==XmlPullParser.START_DOCUMENT){
+ processStartDocument();
+ }else if (eventType==XmlPullParser.END_DOCUMENT){
+ processEndDocument();
+ }else if (eventType==XmlPullParser.START_TAG){
+ processStartElement();
+ }else if (eventType==XmlPullParser.END_TAG){
+ processEndElement();
+ }else if (eventType==XmlPullParser.CDSECT){
+ processCDATA();
+ }else if (eventType==XmlPullParser.COMMENT){
+ processComment();
+ }else if (eventType==XmlPullParser.TEXT){
+ processText();
+ }else{
+ return ;//any other events are not interesting :)
+ }
+
+ } catch (XmlPullParserException e) {
+ throw new OMBuilderException("parser Exception",e);
+ } catch (IOException e) {
+ throw new OMBuilderException("IO Exception",e);
+ } catch (Exception e) {
+ throw new OMBuilderException("Unknown process Exception",e);
+ }
+
+
+ }
+
+ /**
+ * Processing the start tag has some more things to than just inserting an
+ * elemnt. It has to update the parent and set up the attributes for that particular
+ * element
+ */
+ private void processStartElement(){
+
+ //Check the stack for an element. The one at the peek
+ //is this ones parent!
+ Object parent =null;
+ if (!elementStack.isEmpty())
+ parent = elementStack.peek();
+
+ //first insert the elemnt to the model
+ Object currentElement = tableModel.addElement(pullparser.getNamespace(),
+ pullparser.getName(),
+ "", //where am I supposed to get this
+ parent,
+ this); //pass this instamce as the builder. It will be needed by the
+
+ //fill in the set of attributes
+ int attribCount = pullparser.getAttributeCount();
+ Object previousAttribute = null;
+ Object currentAttribute = null;
+ for (int i = 0; i < attribCount; i++) {
+ currentAttribute = tableModel.addAttribute(
+ pullparser.getAttributeName(i),
+ pullparser.getAttributePrefix(i),
+ pullparser.getAttributeNamespace(i),
+ pullparser.getAttributeValue(i),
+ currentElement); //parent element
+
+ //set the next sibling of the previous attribute
+ if (previousAttribute!=null){
+ tableModel.updateAttributeSibling(previousAttribute,currentAttribute);
+ }
+ //swap the attribute references
+ previousAttribute = currentAttribute ;
+ }
+
+ //update siblings
+ //todo this needs to be written!! How am I supposed to do this? By a Queue?
+
+ //push to the stack for later use
+ elementStack.push(currentElement);
+
+
+ }
+
+ /**
+ * Processsig the end element is simple. Just mark the peek element as
+ * processed and pop it from the stack
+ */
+ private void processEndElement(){
+ tableModel.updateElementDone(elementStack.pop());
+ }
+
+ private void processStartDocument(){
+ //since the table model is THE DOCUMENT make it here
+ this.tableModel = new OMTableModel(this);
+ }
+
+ private void processEndDocument(){
+ this.tableModel.setCompleted(true);
+ }
+
+ private void processText(){
+ //Check the stack for an element. The one at the peek
+ //is this ones parent!
+ Object parent = elementStack.peek();
+ if (parent==null){
+ //having text without a parent is not correct XML syntax.
+ //ideally this should be taken care of by the parser
+ throw new UnsupportedOperationException("Invlid XML");
+ }
+
+ tableModel.addText(pullparser.getText(),parent);
+
+
+ }
+
+ private void processCDATA(){
+ //Check the stack for an element. The one at the peek
+ //is this ones parent!
+ Object parent = elementStack.peek();
+ if (parent==null){
+ //having text without a parent is not correct XML syntax.
+ //ideally this should be taken care of by the parser
+ throw new UnsupportedOperationException("Invlid XML");
+ }
+
+ tableModel.addCData(pullparser.getText(),parent);
+
+ }
+
+ private void processComment(){
+ //Check the stack for an element. The one at the peek
+ //is this ones parent!
+ Object parent = elementStack.peek();
+ if (parent==null){
+ //having text without a parent is not correct XML syntax.
+ //ideally this should be taken care of by the parser
+ throw new UnsupportedOperationException("Invlid XML");
+ }
+
+ tableModel.addComment(pullparser.getText(),parent);
+
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/AttributeRow.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/AttributeRow.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,188 @@
+package org.apache.axis.om.storage;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 6:18:52 PM
+ */
+public class AttributeRow extends NodeRow implements Attr{
+
+ private String URI;
+ private String Prefix;
+ private String localName;
+ private String value;
+// private String valueURI;
+
+ private Object nextSibling;
+
+
+ public String getURI() {
+ return URI;
+ }
+
+ public void setURI(String URI) {
+ this.URI = URI;
+ }
+
+ public String getPrefix() {
+ return Prefix;
+ }
+
+ public void setPrefix(String prefix) {
+ Prefix = prefix;
+ }
+
+ public String getLocalName() {
+ return localName;
+ }
+
+ public void setLocalName(String localName) {
+ this.localName = localName;
+ }
+
+
+
+ public Node getNextSibling() {
+ return (Node)this.nextSibling;
+ }
+
+ public void setNextSibling(Object nextSibling) {
+ this.nextSibling = nextSibling;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+
+ /* Interface methods */
+ public String getNodeName() {
+ return null;
+ }
+
+ public String getNodeValue()
+ throws DOMException {
+ return null;
+ }
+
+ public void setNodeValue(String nodeValue)
+ throws DOMException {
+ }
+
+ public short getNodeType() {
+ return 0;
+ }
+
+ public Node getParentNode() {
+ return null;
+ }
+
+ public NodeList getChildNodes() {
+ return null;
+ }
+
+ public Node getFirstChild() {
+ return null;
+ }
+
+ public Node getLastChild() {
+ return null;
+ }
+
+ public Node getPreviousSibling() {
+ return null;
+ }
+
+ public NamedNodeMap getAttributes() {
+ return null;
+ }
+
+ public Document getOwnerDocument() {
+ return null;
+ }
+
+ public Node insertBefore(Node newChild,
+ Node refChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node replaceChild(Node newChild,
+ Node oldChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node removeChild(Node oldChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node appendChild(Node newChild)
+ throws DOMException {
+ return null;
+ }
+
+ public boolean hasChildNodes() {
+ return false;
+ }
+
+ public Node cloneNode(boolean deep) {
+ return null;
+ }
+
+ public void normalize() {
+ }
+
+ public boolean isSupported(String feature,
+ String version) {
+ return false;
+ }
+
+ public String getNamespaceURI() {
+ return null;
+ }
+
+ public boolean hasAttributes() {
+ return false;
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public boolean getSpecified() {
+ return false;
+ }
+
+ public Element getOwnerElement() {
+ return null;
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/ElementRow.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/ElementRow.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,289 @@
+package org.apache.axis.om.storage;
+
+import org.apache.axis.om.OMBuilderException;
+import org.apache.axis.om.OMTableModel;
+import org.apache.axis.om.StreamingOmBuilder;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 6:18:52 PM
+ */
+public class ElementRow extends NodeRow implements Element {
+
+ private String URI;
+ private String Prefix;
+ private String localName;
+
+ private Object nextSibling;
+ private StreamingOmBuilder builder;
+ private Document parentDocument;
+
+ public ElementRow(StreamingOmBuilder builder,Document parentDocument) {
+ this.builder = builder;
+ this.parentDocument = parentDocument ;
+ }
+
+ private boolean done;
+
+ public String getURI() {
+ return URI;
+ }
+
+ public void setURI(String URI) {
+ this.URI = URI;
+ }
+
+ public String getPrefix() {
+ return Prefix;
+ }
+
+ public void setPrefix(String prefix) {
+ Prefix = prefix;
+ }
+
+ public String getLocalName() {
+ return localName;
+ }
+
+ public void setLocalName(String localName) {
+ this.localName = localName;
+ }
+
+
+
+
+
+ public void setNextSibling(Object nextSibling) {
+ this.nextSibling = nextSibling;
+ }
+
+ public boolean isDone() {
+ return done;
+ }
+
+ public void setDone(boolean done) {
+ this.done = done;
+ }
+
+
+ /* Interface methods */
+ public String getNodeName() {
+ return localName;
+ }
+
+ public String getNodeValue()
+ throws DOMException {
+ return null;
+ //todo implement this
+ }
+
+ public void setNodeValue(String nodeValue)
+ throws DOMException {
+ //not supported
+ throw new UnsupportedOperationException();
+ }
+
+ public short getNodeType() {
+ return ELEMENT_NODE;
+ }
+
+ public Node getParentNode() {
+ return (Node)this.parent;
+ }
+
+ public NodeList getChildNodes() {
+ //implement this
+ return null;
+ }
+
+ public Node getFirstChild() {
+ OMTableModel omTableModel = (OMTableModel)this.parentDocument;
+ Object[] children = omTableModel.getElementsByParent(this);
+
+ while(children != null && !this.done){ //todo is this logic right?????
+
+ try {
+ builder.proceed();
+ } catch (OMBuilderException e) {
+ break; //just get out of here if the proceeding failed
+ }
+ //see whether there are children already for this element
+ children = omTableModel.getElementsByParent(this);
+ }
+
+ if ((children==null) ||children.length==0){
+ return null;
+ }else{
+ return (Node)children[0];
+ }
+
+ }
+
+ public Node getLastChild() {
+ return null;
+ }
+
+ public Node getPreviousSibling() {
+ return null;
+ }
+
+ public Node getNextSibling() {
+ return null;
+ //return ((OMTableModel)this.parentDocument).;
+ }
+
+ public NamedNodeMap getAttributes() {
+
+ //todo this needs to be filled
+
+ return null;
+ }
+
+ public Document getOwnerDocument() {
+ return null;
+ }
+
+ public Node insertBefore(Node newChild,
+ Node refChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node replaceChild(Node newChild,
+ Node oldChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node removeChild(Node oldChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node appendChild(Node newChild)
+ throws DOMException {
+ return null;
+ }
+
+ public boolean hasChildNodes() {
+ return false;
+ }
+
+ public Node cloneNode(boolean deep) {
+ return null;
+ }
+
+ public void normalize() {
+ }
+
+ public boolean isSupported(String feature,
+ String version) {
+ return false;
+ }
+
+ public String getNamespaceURI() {
+ return null;
+ }
+
+ public boolean hasAttributes() {
+ return false;
+ }
+
+ public String getTagName() {
+ return null;
+ }
+
+ public String getAttribute(String name) {
+ return null;
+ }
+
+ public void setAttribute(String name,
+ String value)
+ throws DOMException {
+ }
+
+ public void removeAttribute(String name)
+ throws DOMException {
+ }
+
+ public Attr getAttributeNode(String name) {
+ return null;
+ }
+
+ public Attr setAttributeNode(Attr newAttr)
+ throws DOMException {
+ return null;
+ }
+
+ public Attr removeAttributeNode(Attr oldAttr)
+ throws DOMException {
+ return null;
+ }
+
+ public NodeList getElementsByTagName(String name) {
+ return null;
+ }
+
+ public String getAttributeNS(String namespaceURI,
+ String localName) {
+ return null;
+ }
+
+ public void setAttributeNS(String namespaceURI,
+ String qualifiedName,
+ String value)
+ throws DOMException {
+ }
+
+ public void removeAttributeNS(String namespaceURI,
+ String localName)
+ throws DOMException {
+ }
+
+ public Attr getAttributeNodeNS(String namespaceURI,
+ String localName) {
+ return null;
+ }
+
+ public Attr setAttributeNodeNS(Attr newAttr)
+ throws DOMException {
+ return null;
+ }
+
+ public NodeList getElementsByTagNameNS(String namespaceURI,
+ String localName) {
+ return null;
+ }
+
+ public boolean hasAttribute(String name) {
+ return false;
+ }
+
+ public boolean hasAttributeNS(String namespaceURI,
+ String localName) {
+ return false;
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/GlobalRow.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/GlobalRow.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,45 @@
+package org.apache.axis.om.storage;
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 6:22:22 PM
+ */
+public class GlobalRow extends Row {
+
+ private int type;
+ private Object referenceKey;
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public Object getReferenceKey() {
+ return referenceKey;
+ }
+
+ public void setReferenceKey(Object referenceKey) {
+ this.referenceKey = referenceKey;
+ }
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/NodeRow.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/NodeRow.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,33 @@
+package org.apache.axis.om.storage;
+
+/** Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ */
+
+import org.w3c.dom.Node;
+
+public abstract class NodeRow extends Row implements Node {
+ protected Object parent;
+
+ public Object getParent() {
+ return parent;
+ }
+
+ public void setParent(Object parent) {
+ this.parent = parent;
+ }
+ //Anything here ????
+}
+
+
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/NodeTable.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/NodeTable.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,60 @@
+package org.apache.axis.om.storage;
+
+import java.util.ArrayList;
+
+/**
+ * * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 19, 2004
+ * Time: 4:00:48 PM
+ *
+ * The difference between a simple table and the node table is the specific
+ * search mechanism with the parent
+ */
+public class NodeTable extends Table {
+
+ /**
+ *
+ * @param parentKey
+ * @return
+ */
+ public Object[] getRowsbyParent(Object parentKey){
+
+ ArrayList list = new ArrayList();
+
+ for (int i = 0; i < rowList.size(); i++) {
+ NodeRow nodeRow = (NodeRow) rowList.get(i);
+ if (parentKey==null){
+ if (nodeRow.getParent()==parentKey){
+ list.add(nodeRow);
+ }
+ } else{
+ if (nodeRow.getParent().equals(parentKey)){
+ list.add(nodeRow);
+ }
+ }
+ }
+
+ Object[] rowObjects = list.toArray();
+ return rowObjects;
+
+ }
+
+
+
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/Row.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/Row.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,37 @@
+package org.apache.axis.om.storage;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 6:17:59 PM
+ */
+public abstract class Row {
+
+ // TODO sizeof(object) > sizeof(int) ???
+ /* this key is of type Object, simply because we wanted to make this a unique one.
+ * and this Object reference is unique. */
+
+ protected Object key;
+
+ public Object getKey() {
+ return key;
+ }
+
+ public void setKey(Object key) {
+ this.key = key;
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/Table.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/Table.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,80 @@
+package org.apache.axis.om.storage;
+
+import java.util.ArrayList;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 6:08:12 PM
+ */
+public class Table {
+
+ protected ArrayList rowList = new ArrayList();
+ protected ArrayList keyList = new ArrayList();
+
+ /**
+ * @param key
+ * @return
+ */
+ public Row getRowByKey(Object key) {
+ //search for the key
+ int i = 0;
+ for (; i < keyList.size(); i++) {
+ if (keyList.get(i).equals(key)) {
+ return (Row) rowList.get(i);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param index
+ * @return
+ */
+ public Row getRowByIndex(int index) {
+ return (Row) rowList.get(index);
+ }
+
+ /**
+ * @param row
+ */
+ public void addRow(Row row) {
+ rowList.add(row);
+ keyList.add(row.getKey());
+ }
+
+ /**
+ * @return
+ */
+ public int getSize() {
+ return rowList.size();
+ }
+
+ /**
+ * @return
+ */
+ public String toString() {
+ String returnStr = "";
+ for (int i = 0; i < rowList.size(); i++) {
+ Row row = (Row) rowList.get(i);
+ returnStr = returnStr + row.toString() + "\n";
+ }
+ return returnStr;
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/TextRow.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/storage/TextRow.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,211 @@
+package org.apache.axis.om.storage;
+
+import org.apache.axis.om.OMConstants;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 6:29:38 PM
+ */
+public class TextRow extends NodeRow implements Text,Comment,CDATASection {
+
+ private String value;
+
+ /* This class will be used to hold both the CDATA and PCDATA. Both these items have same attributes. So opted to use
+ * the same class with a type attribute to say the type of the class
+ *
+ */
+ private int type = OMConstants.TYPE_TEXT; //default is type text
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ /* interface methods */
+
+ public String getNodeName() {
+ return null;
+ }
+
+ public String getNodeValue()
+ throws DOMException {
+ return null;
+ }
+
+ public void setNodeValue(String nodeValue)
+ throws DOMException {
+ }
+
+ public short getNodeType() {
+ return 0;
+ }
+
+ public Node getParentNode() {
+ return null;
+ }
+
+ public NodeList getChildNodes() {
+ return null;
+ }
+
+ public Node getFirstChild() {
+ return null;
+ }
+
+ public Node getLastChild() {
+ return null;
+ }
+
+ public Node getPreviousSibling() {
+ return null;
+ }
+
+ public Node getNextSibling() {
+ return null;
+ }
+
+ public NamedNodeMap getAttributes() {
+ return null;
+ }
+
+ public Document getOwnerDocument() {
+ return null;
+ }
+
+ public Node insertBefore(Node newChild,
+ Node refChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node replaceChild(Node newChild,
+ Node oldChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node removeChild(Node oldChild)
+ throws DOMException {
+ return null;
+ }
+
+ public Node appendChild(Node newChild)
+ throws DOMException {
+ return null;
+ }
+
+ public boolean hasChildNodes() {
+ return false;
+ }
+
+ public Node cloneNode(boolean deep) {
+ return null;
+ }
+
+ public void normalize() {
+ }
+
+ public boolean isSupported(String feature,
+ String version) {
+ return false;
+ }
+
+ public String getNamespaceURI() {
+ return null;
+ }
+
+ public String getPrefix() {
+ return null;
+ }
+
+ public void setPrefix(String prefix)
+ throws DOMException {
+ }
+
+ public String getLocalName() {
+ return null;
+ }
+
+ public boolean hasAttributes() {
+ return false;
+ }
+
+ public Text splitText(int offset)
+ throws DOMException {
+ return null;
+ }
+
+ public String getData()
+ throws DOMException {
+ return null;
+ }
+
+ public void setData(String data)
+ throws DOMException {
+ }
+
+ public int getLength() {
+ return 0;
+ }
+
+ public String substringData(int offset,
+ int count)
+ throws DOMException {
+ return null;
+ }
+
+ public void appendData(String arg)
+ throws DOMException {
+ }
+
+ public void insertData(int offset,
+ String arg)
+ throws DOMException {
+ }
+
+ public void deleteData(int offset,
+ int count)
+ throws DOMException {
+ }
+
+ public void replaceData(int offset,
+ int count,
+ String arg)
+ throws DOMException {
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/traversal/NodeIterator.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/traversal/NodeIterator.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,36 @@
+package org.apache.axis.om.traversal;
+
+import org.apache.axis.om.OMTableModel;
+import org.apache.axis.om.StreamingOmBuilder;
+
+/**
+ * * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 19, 2004
+ * Time: 4:51:45 PM
+ *
+ * This class is the node iterator for the specific case of
+ * elements children
+ */
+public class NodeIterator extends OmIterator{
+
+ public NodeIterator(OMTableModel model, StreamingOmBuilder builder) {
+ super(model, builder);
+ }
+
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/traversal/OmIterator.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/traversal/OmIterator.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,46 @@
+package org.apache.axis.om.traversal;
+
+import org.apache.axis.om.OMTableModel;
+import org.apache.axis.om.StreamingOmBuilder;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 19, 2004
+ * Time: 3:29:34 PM
+ *
+ * Serving a list in an iterative manner is REALLY DIFFICULT!!!!!!!!!
+ */
+public abstract class OmIterator implements NodeList {
+
+ protected OMTableModel model;
+ protected StreamingOmBuilder builder;
+
+ public OmIterator(OMTableModel model, StreamingOmBuilder builder) {
+ this.model = model;
+ this.builder = builder;
+ }
+
+ public Node item(int index) {
+ return null;
+ }
+
+ public int getLength() {
+ return 0;
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/util/Sequence.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/java/org/apache/axis/om/util/Sequence.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,32 @@
+package org.apache.axis.om.util;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 6:53:19 PM
+ * @deprecated
+ */
+public class Sequence {
+ private int sequenceValue = 0;
+
+ /**
+ * @return
+ */
+ public int getNextValue() {
+ return sequenceValue++;
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test-resources/testFile.xml
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test-resources/testFile.xml Mon Sep 20 23:38:32 2004
@@ -0,0 +1,7 @@
+<root>
+ <name type="original">
+ <firstname>Ajith</firstname>
+ <surname>Ranabahu</surname>
+ </name>
+ <age>26</age>
+</root>
\ No newline at end of file
Added: webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test/org/apache/axis/om/StreamingOmBuilderTest.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_eran_dasarath_deepal/src/test/org/apache/axis/om/StreamingOmBuilderTest.java Mon Sep 20 23:38:32 2004
@@ -0,0 +1,58 @@
+package org.apache.axis.om;
+
+import org.w3c.dom.Document;
+import org.xmlpull.mxp1.MXParserFactory;
+import org.xmlpull.v1.XmlPullParser;
+
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+
+import junit.framework.TestCase;
+
+/**
+ *Copyright 2001-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.
+ */
+public class StreamingOmBuilderTest extends TestCase{
+
+
+ public void testSampleOne(){
+
+ try {
+ //Create the builder
+ XmlPullParser pullparser = MXParserFactory.newInstance().newPullParser();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ pullparser.setInput(new InputStreamReader(cl.getResourceAsStream("testFile.xml")));
+ StreamingOmBuilder builder = new StreamingOmBuilder(pullparser);
+
+ Document doc = builder.getDocument();
+ doc.getDocumentElement();
+
+ ((OMTableModel)doc).dumpTablesToConsole();
+
+
+ //no assertions yet :)
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+
+ }
+
+
+
+}