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 as...@apache.org on 2004/10/16 01:01:21 UTC
svn commit: rev 54882 - in webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src: java/org/apache/axis/om java/org/apache/axis/om/impl java/org/apache/axis/om/impl/traversal java/org/apache/axis/om/serialize java/org/apache/axis/om/storage/column java/org/apache/axis/om/storage/table java/org/apache/axis/om/util test/org/apache/axis/om test/org/apache/axis/om/storage/table test/org/apache/axis/om/util
Author: aslom
Date: Fri Oct 15 16:01:20 2004
New Revision: 54882
Added:
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/serialize/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/serialize/OMSerializer.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModelTest2.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModleTest3.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/util/TimeTester.java
Modified:
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMModelImpl.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/PullEventGenerator.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMAttributeImpl.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMDocumentImpl.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMElementImpl.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNameSpaceImpl.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNodeImpl.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMTextImpl.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/traversal/NodeIteratorImpl.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/AbstractColumn.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/AttributeTable.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/ElementTable.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/EventTable.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/NameSpaceTable.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/Table.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/TextTable.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/OMConstants.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModelTest.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/AttributeTableTest.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/ElementTableTest.java
Log:
applied patch
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMModelImpl.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMModelImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMModelImpl.java Fri Oct 15 16:01:20 2004
@@ -1,507 +1,510 @@
-package org.apache.axis.om;
-
-import org.apache.axis.om.*;
-import org.apache.axis.om.impl.*;
-import org.apache.axis.om.pool.OMAttributePool;
-import org.apache.axis.om.pool.OMElementPool;
-import org.apache.axis.om.pool.OMNameSpacePool;
-import org.apache.axis.om.pool.OMTextPool;
-import org.apache.axis.om.storage.table.*;
-import org.apache.axis.om.util.OMConstants;
-import org.xmlpull.v1.XmlPullParser;
-
-/**
- * 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 Axis team
- * Date: Sep 27, 2004
- * Time: 6:29:36 PM
- *
- */
-public class OMModelImpl implements OMModel {
-
- private ElementTable elementTable = new ElementTable();
- private AttributeTable attribTable = new AttributeTable();
- private TextTable textTable = new TextTable();
- private EventTable eventTable = new EventTable();
- private NameSpaceTable nameSpaceTable = new NameSpaceTable();
- private boolean completed=false;
- private StreamingOMBuilder builder = null;
-
-
- public OMModelImpl() {
- }
-
- /**
- * Needs a builder for the model
- * @param builder
- */
- public OMModelImpl(StreamingOMBuilder builder) {
- this.builder = builder;
- }
-
- /**
- * The builder can either be passed in construction or set as an attribute
- * However a new builder cannot be set once a builder is set
- * @param builder
- */
- public void setBuilder(StreamingOMBuilder builder) {
- if (this.builder ==null)
- this.builder = builder;
- }
-
-
- /**
- * @see org.apache.axis.om.OMModel#addElement
- * @param localName
- * @param parentElement
- * @return
- */
- public int addElement(String localName, int parentElement) {
- return elementTable.addElement(localName,parentElement);
- }
-
- /**
- * @see org.apache.axis.om.OMModel#addAttribute
- * @param localName
- * @param value
- * @param parentElement
- * @return
- */
- public int addAttribute(String localName, String value, int parentElement) {
- return attribTable.addAttribute(localName,value,parentElement);
- }
-
- /**
- * @see org.apache.axis.om.OMModel#addText
- * @param value
- * @param parent
- * @return
- */
- public int addText(String value, int parent) {
- return textTable.addText(value,OMConstants.TEXT,parent);
- }
-
- /**
- * @see org.apache.axis.om.OMModel#addCDATA
- * @param value
- * @param parent
- * @return
- */
- public int addCDATA(String value, int parent) {
- return textTable.addText(value,OMConstants.CDATA,parent);
- }
-
- /**
- * @see org.apache.axis.om.OMModel#addComment
- * @param value
- * @param parent
- * @return
- */
- public int addComment(String value, int parent) {
- return textTable.addText(value,OMConstants.COMMENT,parent);
- }
-
- /**
- * @see org.apache.axis.om.OMModel#addNamespace
- * @param URI
- * @param prefix
- * @param declaredElementKey
- * @return
- */
- public int addNamespace(String URI, String prefix, int declaredElementKey) {
- return nameSpaceTable.addNamespace(URI,prefix,declaredElementKey);
- }
-
- /**
- * @see org.apache.axis.om.OMModel#updateElement
- * @param key
- * @param stringValue
- * @param intValue
- * @param type
- *
- * supports the following updations
- * done,namespace,next sibling,first child,first attribute
- */
- public void updateElement(int key, String stringValue, int intValue, int type) {
-
- if (type==OMConstants.UPDATE_DONE){
- elementTable.updateDone(key);
- }else if (type==OMConstants.UPDATE_NAMESPACE) {
- elementTable.updateNameSpace(key,intValue);
- }else if(type == OMConstants.UPDATE_NEXT_SIBLING){
- elementTable.updateNextSibling(key,
- intValue,
- Integer.parseInt(stringValue));//the type of the element must be passed
- //as the string value argument
- } else if(type == OMConstants.UPDATE_FIRST_CHILD){
- elementTable.updateFirstChild(key,
- intValue,
- Integer.parseInt(stringValue));//the type of the element must be passed
- //as the string value argument
- }else if(type == OMConstants.UPDATE_FIRST_ATTRIBUTE){
- elementTable.updateFirstAttribute(key,intValue);
- }
-
- }
-
- /**
- * @see org.apache.axis.om.OMModel#updateAttribute
- * @param key
- * @param stringValue
- * @param intValue
- * @param type
- * Supports updating namespace and next sibling
- */
- public void updateAttribute(int key, String stringValue, int intValue, int type) {
-
- if (type==OMConstants.UPDATE_NAMESPACE) {
- attribTable.updateNameSpace(key,intValue);
- }else if(type == OMConstants.UPDATE_NEXT_SIBLING){
- attribTable.updateNextSibling(key,intValue);
- }
-
-
- }
-
- /**
- * @see org.apache.axis.om.OMModel#updateText
- * @param key
- * @param stringValue
- * @param intValue
- * @param type
- * supports updating next sibling
- */
- public void updateText(int key, String stringValue, int intValue, int type) {
-
- if(type == OMConstants.UPDATE_NEXT_SIBLING){
-
- textTable.updateNextSibling(key,
- intValue,
- Integer.parseInt(stringValue));//the type of the element must be passed as the string value argument
- }
-
- }
-
-
- /**
- *
- * @param key
- * @param stringValue
- * @param intValue
- * @param type
- * Not yet supported!!!
- */
- public void updateNameSpace(int key, String stringValue, int intValue, int type) {
-
- }
-
- /**
- * @see org.apache.axis.om.OMModel#isComplete
- * @return
- */
- public boolean isComplete() {
- return completed;
- }
-
- /**
- * @see org.apache.axis.om.OMModel#setComplete
- * @param b
- */
- public void setComplete(boolean b) {
- this.completed = b;
- }
-
-
- /**
- * @see org.apache.axis.om.OMModel#getElement
- * @param key
- * @return
- */
- public OMElement getElement(int key) {
- OMElementImpl element = (OMElementImpl)OMElementPool.getInstance().getPooledObject();
- element.init(this,key,this.elementTable.getElement(key));
- return element;
- }
-
- /**
- * @see org.apache.axis.om.OMModel#getAttribute
- * @param key
- * @return
- */
- public OMAttribute getAttribute(int key) {
- OMAttributeImpl attrib = (OMAttributeImpl)OMAttributePool.getInstance().getPooledObject();
- attrib.init(this,key,this.attribTable.getAttribute(key));
- return attrib;
- }
-
- /**
- * @see org.apache.axis.om.OMModel#getText
- * @param key
- * @return
- */
- public OMText getText(int key) {
- OMTextImpl text = (OMTextImpl)OMTextPool.getInstance().getPooledObject();
- text.init(this,key,textTable.getText(key));
- return text;
- }
-
- /**
- * @see org.apache.axis.om.OMModel#getNamespace
- * @param key
- * @return
- */
- public OMNamespace getNamespace(int key) {
- OMNameSpaceImpl nameSpace = (OMNameSpaceImpl)OMNameSpacePool.getInstance().getPooledObject();
- nameSpace.init(this,key,nameSpaceTable.getNamespace(key));
- return nameSpace;
- }
-
- /**
- * @see org.apache.axis.om.OMModel#addEvent
- * @param type
- * @param reference
- * @return
- */
- public int addEvent(int type, int reference) {
- return eventTable.addEvent(type,reference);
- }
-
- /**
- * @see org.apache.axis.om.OMModel#getPullEvent
- * @param key
- * @return
- */
- public int getPullEvent(int key) {
- //todo fill this
- return eventTable.getPullEvent(key);
-
-
- }
-
- /**
- * @see org.apache.axis.om.OMModel#getEvent
- * @param key
- * @return
- */
- public Object getEvent(int key) {
- return eventTable.getEvent(key);
-
-
- }
-
- /**
- * @see org.apache.axis.om.OMModel#proceed
- * @return
- */
- public int proceed() {
- return this.builder.proceed();
- }
-
-
- /**
- * @see org.apache.axis.om.OMModel#getDocument
- * @return
- */
- public OMDocument getDocument() {
- return new OMDocumentImpl(this,
- OMConstants.DEFAULT_INT_VALUE,
- null);
-
- }
-
- /**
- * @see org.apache.axis.om.OMModel#update
- * @param key
- * @param type
- * @return
- */
- public Object update(int key, int type) {
- if (type==OMConstants.ELEMENT){
- return elementTable.getElement(key);
- }else if (type==OMConstants.ATTRIBUTE){
- return attribTable.getAttribute(key);
- }else if (type==OMConstants.TEXT){
- return textTable.getText(key);
- }else if (type==OMConstants.CDATA){
- return textTable.getText(key);
- }else if (type==OMConstants.COMMENT){
- return textTable.getText(key);
- }
- return null;
- }
-
- /**
- * @return the root element. Uilised by internal methods
- */
- public OMElement getRootElement(){
- int size = elementTable.getSize();
- OMElementImpl elt=null;
- for (int i = 0; i < size; i++) {
- elt = (OMElementImpl)getElement(i);
- if (elt.getParentKey()==OMConstants.DEFAULT_INT_VALUE)
- return elt;
-
- }
- return null;
- }
-
- /**
- * gets the first child
- * @param key
- * @return
- */
- public int getFirstChild(int key) {
- return elementTable.getFirstChild(key);
- }
-
- /**
- * @see org.apache.axis.om.OMModel#getElementCount
- * @return
- */
- public int getElementCount() {
- return elementTable.getSize();
- }
-
- /**
- * @see org.apache.axis.om.OMModel#getAttributeCount
- * @return
- */
- public int getAttributeCount() {
- return attribTable.getSize();
- }
-
- /**
- * @see org.apache.axis.om.OMModel#getTextCount
- * @return
- */
- public int getTextCount() {
- return textTable.getSize();
- }
-
- /**
- * @see org.apache.axis.om.OMModel#getEventCount
- * @return
- */
- public int getEventCount() {
- return eventTable.getSize();
- }
-
- /**
- * @see org.apache.axis.om.OMModel#setCacheOff
- */
- public void setCacheOff() {
- builder.setCache(false);
- }
-
- /**
- * @see org.apache.axis.om.OMModel#getParser
- * @return the parser if the cache is off, otherwise throws an exception
- */
- public XmlPullParser getParser() {
- if (!builder.isCache())
- return builder.getPullparser();
- else
- throw new OMException("cache is on!!");
-
- }
-
- /**
- * removes the element
- * @param key
- * @return
- * Note - not yet implemented
- */
- public int removeElement(int key) {
- return 0;
- }
-
-
- /**
- * removes the given attribute
- * @param key
- * @return
- * Note - parent element must adjust itself when the child is the
- * first child
- */
- public int removeAttribute(int key) {
- return attribTable.removeAttribute(key);
- }
-
-
- /**
- *
- * @param key
- * @return
- * Note - not yet implemented
- */
- public int removeText(int key) {
- return 0;
- }
-
- /**
- *
- * @param key
- * @return
- * Note - not yet implemented
- */
- public int removeEvent(int key) {
- return 0;
- }
-
-
- /**
- * @see org.apache.axis.om.OMModel#resolveNamespace
- * @param parent
- * @param uri
- * @param prefix
- * @return
- */
- public int resolveNamespace(int parent,String uri, String prefix) {
- int namespace = nameSpaceTable.findNamespace(parent,uri,prefix);
-
- while (namespace==OMConstants.DEFAULT_INT_VALUE){
- //get the parent element and try to resolve it there
- parent = elementTable.getParent(parent);
- if (parent==OMConstants.DEFAULT_INT_VALUE){
- //we have reached the root. So break out. (there is no point of searching anymore
- break;
- }else{
- namespace = nameSpaceTable.findNamespace(parent,uri,prefix);
- }
- }
-
- return namespace;
- }
-
- /**
- * Debugging method to dump the content of the model
- */
- public void dump(){
-
- elementTable.dumpValues();
- System.out.println("----------------------------");
- attribTable.dumpValues();
- System.out.println("----------------------------");
- textTable.dumpValues();
- System.out.println("----------------------------");
- //eventTable.dumpValues();
- //System.out.println("----------------------------");
- nameSpaceTable.dumpValues();
- System.out.println("----------------------------");
-
- }
-
-}
+package org.apache.axis.om;
+
+import org.apache.axis.om.*;
+import org.apache.axis.om.impl.*;
+import org.apache.axis.om.pool.OMAttributePool;
+import org.apache.axis.om.pool.OMElementPool;
+import org.apache.axis.om.pool.OMNameSpacePool;
+import org.apache.axis.om.pool.OMTextPool;
+import org.apache.axis.om.storage.table.*;
+import org.apache.axis.om.util.OMConstants;
+import org.xmlpull.v1.XmlPullParser;
+
+/**
+ * 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 Axis team
+ * Date: Sep 27, 2004
+ * Time: 6:29:36 PM
+ *
+ */
+public class OMModelImpl implements OMModel {
+
+ private ElementTable elementTable = new ElementTable();
+ private AttributeTable attribTable = new AttributeTable();
+ private TextTable textTable = new TextTable();
+ private EventTable eventTable = new EventTable();
+ private NameSpaceTable nameSpaceTable = new NameSpaceTable();
+ private boolean completed=false;
+ private StreamingOMBuilder builder = null;
+
+
+ public OMModelImpl() {
+ }
+
+ /**
+ * Needs a builder for the model
+ * @param builder
+ */
+ public OMModelImpl(StreamingOMBuilder builder) {
+ this.builder = builder;
+ }
+
+ /**
+ * The builder can either be passed in construction or set as an attribute
+ * However a new builder cannot be set once a builder is set
+ * @param builder
+ */
+ public void setBuilder(StreamingOMBuilder builder) {
+ if (this.builder ==null)
+ this.builder = builder;
+ }
+
+
+ /**
+ * @see org.apache.axis.om.OMModel#addElement
+ * @param localName
+ * @param parentElement
+ * @return
+ */
+ public int addElement(String localName, int parentElement) {
+ return elementTable.addElement(localName,parentElement);
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#addAttribute
+ * @param localName
+ * @param value
+ * @param parentElement
+ * @return
+ */
+ public int addAttribute(String localName, String value, int parentElement) {
+ return attribTable.addAttribute(localName,value,parentElement);
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#addText
+ * @param value
+ * @param parent
+ * @return
+ */
+ public int addText(String value, int parent) {
+ return textTable.addText(value,OMConstants.TEXT,parent);
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#addCDATA
+ * @param value
+ * @param parent
+ * @return
+ */
+ public int addCDATA(String value, int parent) {
+ return textTable.addText(value,OMConstants.CDATA,parent);
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#addComment
+ * @param value
+ * @param parent
+ * @return
+ */
+ public int addComment(String value, int parent) {
+ return textTable.addText(value,OMConstants.COMMENT,parent);
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#addNamespace
+ * @param URI
+ * @param prefix
+ * @param declaredElementKey
+ * @return
+ */
+ public int addNamespace(String URI, String prefix, int declaredElementKey) {
+ return nameSpaceTable.addNamespace(URI,prefix,declaredElementKey);
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#updateElement
+ * @param key
+ * @param stringValue
+ * @param intValue
+ * @param type
+ *
+ * supports the following updations
+ * done,namespace,next sibling,first child,first attribute
+ */
+ public void updateElement(int key, String stringValue, int intValue, int type) {
+
+ if (type==OMConstants.UPDATE_DONE){
+ elementTable.updateDone(key);
+ }else if (type==OMConstants.UPDATE_NAMESPACE) {
+ elementTable.updateNameSpace(key,intValue);
+ }else if(type == OMConstants.UPDATE_NEXT_SIBLING){
+ elementTable.updateNextSibling(key,
+ intValue,
+ Integer.parseInt(stringValue));//the type of the element must be passed
+ //as the string value argument
+ } else if(type == OMConstants.UPDATE_FIRST_CHILD){
+ elementTable.updateFirstChild(key,
+ intValue,
+ Integer.parseInt(stringValue));//the type of the element must be passed
+ //as the string value argument
+ }else if(type == OMConstants.UPDATE_FIRST_ATTRIBUTE){
+ elementTable.updateFirstAttribute(key,intValue);
+ }
+
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#updateAttribute
+ * @param key
+ * @param stringValue
+ * @param intValue
+ * @param type
+ * Supports updating namespace and next sibling
+ */
+ public void updateAttribute(int key, String stringValue, int intValue, int type) {
+
+ if (type==OMConstants.UPDATE_NAMESPACE) {
+ attribTable.updateNameSpace(key,intValue);
+ }else if(type == OMConstants.UPDATE_NEXT_SIBLING){
+ attribTable.updateNextSibling(key,intValue);
+ }
+
+
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#updateText
+ * @param key
+ * @param stringValue
+ * @param intValue
+ * @param type
+ * supports updating next sibling
+ */
+ public void updateText(int key, String stringValue, int intValue, int type) {
+
+ if(type == OMConstants.UPDATE_NEXT_SIBLING){
+
+ textTable.updateNextSibling(key,
+ intValue,
+ Integer.parseInt(stringValue));//the type of the element must be passed as the string value argument
+ }
+
+ }
+
+
+ /**
+ *
+ * @param key
+ * @param stringValue
+ * @param intValue
+ * @param type
+ * Not yet supported!!!
+ */
+ public void updateNameSpace(int key, String stringValue, int intValue, int type) {
+
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#isComplete
+ * @return
+ */
+ public boolean isComplete() {
+ return completed;
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#setComplete
+ * @param b
+ */
+ public void setComplete(boolean b) {
+ this.completed = b;
+ }
+
+
+ /**
+ * @see org.apache.axis.om.OMModel#getElement
+ * @param key
+ * @return
+ */
+ public OMElement getElement(int key) {
+ OMElementImpl element = (OMElementImpl)OMElementPool.getInstance().getPooledObject();
+ element.init(this,key,this.elementTable.getRow(key));
+ return element;
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#getAttribute
+ * @param key
+ * @return
+ */
+ public OMAttribute getAttribute(int key) {
+ OMAttributeImpl attrib = (OMAttributeImpl)OMAttributePool.getInstance().getPooledObject();
+ attrib.init(this,key,this.attribTable.getRow(key));
+ return attrib;
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#getText
+ * @param key
+ * @return
+ */
+ public OMText getText(int key) {
+ OMTextImpl text = (OMTextImpl)OMTextPool.getInstance().getPooledObject();
+ text.init(this,key,textTable.getRow(key));
+ return text;
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#getNamespace
+ * @param key
+ * @return
+ */
+ public OMNamespace getNamespace(int key) {
+ OMNameSpaceImpl nameSpace = (OMNameSpaceImpl)OMNameSpacePool.getInstance().getPooledObject();
+ nameSpace.init(this,key,nameSpaceTable.getRow(key));
+ return nameSpace;
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#addEvent
+ * @param type
+ * @param reference
+ * @return
+ */
+ public int addEvent(int type, int reference) {
+ return eventTable.addEvent(type,reference);
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#getPullEvent
+ * @param key
+ * @return
+ */
+ public int getPullEvent(int key) {
+ //todo fill this
+ return eventTable.getPullEvent(key);
+
+
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#getEvent
+ * @param key
+ * @return
+ */
+ public Object getEvent(int key) {
+ return eventTable.getRow(key);
+
+
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#proceed
+ * @return
+ */
+ public int proceed() {
+ if (!this.isComplete())
+ return this.builder.proceed();
+ else
+ return XmlPullParser.END_DOCUMENT ;
+ }
+
+
+ /**
+ * @see org.apache.axis.om.OMModel#getDocument
+ * @return
+ */
+ public OMDocument getDocument() {
+ return new OMDocumentImpl(this,
+ OMConstants.DEFAULT_INT_VALUE,
+ null);
+
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#update
+ * @param key
+ * @param type
+ * @return
+ */
+ public Object update(int key, int type) {
+ if (type==OMConstants.ELEMENT){
+ return elementTable.getRow(key);
+ }else if (type==OMConstants.ATTRIBUTE){
+ return attribTable.getRow(key);
+ }else if (type==OMConstants.TEXT){
+ return textTable.getRow(key);
+ }else if (type==OMConstants.CDATA){
+ return textTable.getRow(key);
+ }else if (type==OMConstants.COMMENT){
+ return textTable.getRow(key);
+ }
+ return null;
+ }
+
+ /**
+ * @return the root element. Uilised by internal methods
+ */
+ public OMElement getRootElement(){
+ int size = elementTable.getSize();
+ OMElementImpl elt=null;
+ for (int i = 0; i < size; i++) {
+ elt = (OMElementImpl)getElement(i);
+ if (elt.getParentKey()==OMConstants.DEFAULT_INT_VALUE)
+ return elt;
+
+ }
+ return null;
+ }
+
+ /**
+ * gets the first child
+ * @param key
+ * @return
+ */
+ public int getFirstChild(int key) {
+ return elementTable.getFirstChild(key);
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#getElementCount
+ * @return
+ */
+ public int getElementCount() {
+ return elementTable.getSize();
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#getAttributeCount
+ * @return
+ */
+ public int getAttributeCount() {
+ return attribTable.getSize();
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#getTextCount
+ * @return
+ */
+ public int getTextCount() {
+ return textTable.getSize();
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#getEventCount
+ * @return
+ */
+ public int getEventCount() {
+ return eventTable.getSize();
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#setCacheOff
+ */
+ public void setCacheOff() {
+ builder.setCache(false);
+ }
+
+ /**
+ * @see org.apache.axis.om.OMModel#getParser
+ * @return the parser if the cache is off, otherwise throws an exception
+ */
+ public XmlPullParser getParser() {
+ if (!builder.isCache())
+ return builder.getPullparser();
+ else
+ throw new OMException("cache is on!!");
+
+ }
+
+ /**
+ * removes the element
+ * @param key
+ * @return
+ * Note - not yet implemented
+ */
+ public int removeElement(int key) {
+ return 0;
+ }
+
+
+ /**
+ * removes the given attribute
+ * @param key
+ * @return
+ * Note - parent element must adjust itself when the child is the
+ * first child
+ */
+ public int removeAttribute(int key) {
+ return attribTable.removeAttribute(key);
+ }
+
+
+ /**
+ *
+ * @param key
+ * @return
+ * Note - not yet implemented
+ */
+ public int removeText(int key) {
+ return 0;
+ }
+
+ /**
+ *
+ * @param key
+ * @return
+ * Note - not yet implemented
+ */
+ public int removeEvent(int key) {
+ return 0;
+ }
+
+
+ /**
+ * @see org.apache.axis.om.OMModel#resolveNamespace
+ * @param parent
+ * @param uri
+ * @param prefix
+ * @return
+ */
+ public int resolveNamespace(int parent,String uri, String prefix) {
+ int namespace = nameSpaceTable.findNamespace(parent,uri,prefix);
+
+ while (namespace==OMConstants.DEFAULT_INT_VALUE){
+ //get the parent element and try to resolve it there
+ parent = elementTable.getParent(parent);
+ if (parent==OMConstants.DEFAULT_INT_VALUE){
+ //we have reached the root. So break out. (there is no point of searching anymore
+ break;
+ }else{
+ namespace = nameSpaceTable.findNamespace(parent,uri,prefix);
+ }
+ }
+
+ return namespace;
+ }
+
+ /**
+ * Debugging method to dump the content of the model
+ */
+ public void dump(){
+
+ elementTable.dumpValues();
+ System.out.println("----------------------------");
+ attribTable.dumpValues();
+ System.out.println("----------------------------");
+ textTable.dumpValues();
+ System.out.println("----------------------------");
+ //eventTable.dumpValues();
+ //System.out.println("----------------------------");
+ nameSpaceTable.dumpValues();
+ System.out.println("----------------------------");
+
+ }
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/PullEventGenerator.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/PullEventGenerator.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/PullEventGenerator.java Fri Oct 15 16:01:20 2004
@@ -1,67 +1,68 @@
-package org.apache.axis.om;
-
-import org.apache.axis.om.util.OMConstants;
-import org.xmlpull.v1.XmlPullParser;
-
-/**
- * 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 Axis team
- * Date: Sep 30, 2004
- * Time: 9:41:22 PM
- *
- * Generates the pull events fpr the mode
- * Still preliminary
- */
-public class PullEventGenerator {
-
- private OMModel model;
- private int currentCount = 0;
- private XmlPullParser parser;
-
- /**
- *
- * @param model
- */
- public PullEventGenerator(OMModel model) {
- this.model = model;
- }
-
- /**
- *
- * @return an integer that represents the pull event
- */
- public int generatePullEvent(){
- try {
- int size = model.getEventCount();
- if (size==currentCount){
- //set the caching to off
- model.setCacheOff();
- parser = model.getParser();
- currentCount ++;
- return parser.next();
- }else if (currentCount>size){
- currentCount ++;
- return parser.next();
- }else if (currentCount<size){
- return model.getPullEvent(currentCount++);
- }
- } catch (Exception e) {
- throw new OMException(e);
- }
- return OMConstants.DEFAULT_INT_VALUE;
- }
-
-}
+package org.apache.axis.om;
+
+import org.apache.axis.om.util.OMConstants;
+import org.xmlpull.v1.XmlPullParser;
+
+/**
+ * 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 Axis team
+ * Date: Sep 30, 2004
+ * Time: 9:41:22 PM
+ *
+ * Generates the pull events from the model
+ * Still preliminary
+ */
+//todo make this implement the Stax APi and make it a compelte pull parser like thing
+public class PullEventGenerator {
+
+ private OMModel model;
+ private int currentCount = 0;
+ private XmlPullParser parser;
+
+ /**
+ *
+ * @param model
+ */
+ public PullEventGenerator(OMModel model) {
+ this.model = model;
+ }
+
+ /**
+ *
+ * @return an integer that represents the pull event
+ */
+ public int generatePullEvent(){
+ try {
+ int size = model.getEventCount();
+ if (size==currentCount){
+ //set the caching to off
+ model.setCacheOff();
+ parser = model.getParser();
+ currentCount ++;
+ return parser.next();
+ }else if (currentCount>size){
+ currentCount ++;
+ return parser.next();
+ }else if (currentCount<size){
+ return model.getPullEvent(currentCount++);
+ }
+ } catch (Exception e) {
+ throw new OMException(e);
+ }
+ return OMConstants.DEFAULT_INT_VALUE;
+ }
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMAttributeImpl.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMAttributeImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMAttributeImpl.java Fri Oct 15 16:01:20 2004
@@ -1,90 +1,99 @@
-package org.apache.axis.om.impl;
-
-import org.apache.axis.om.OMAttribute;
-import org.apache.axis.om.OMModel;
-import org.apache.axis.om.OMNamespace;
-import org.apache.axis.om.OMException;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- * 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 Axis team
- * Date: Sep 28, 2004
- * Time: 3:54:19 PM
- */
-public class OMAttributeImpl extends OMNodeImpl implements OMAttribute{
-
- public OMAttributeImpl() {
- }
-
- /**
- * Special constructor to be used by the model implementation
- * @param model
- * @param key
- * @param values
- */
- public OMAttributeImpl(OMModel model,int key,String[][] values) {
- init(model,key,values);
- }
-
- public void setValue(String value) {
- }
-
- /**
- * @see org.apache.axis.om.OMAttribute#getValue
- * @return
- */
- public String getValue() {
- return findValueByIdentifier(OMConstants.VALUE_KEY);
- }
-
- public void update() {
- this.values =(String[][]) model.update(key,OMConstants.ELEMENT);
- }
-
- public String getLocalName() {
- return findValueByIdentifier(OMConstants.LOCAL_NAME_KEY);
- }
-
- public void setLocalName(String localName) {
- //todo
- }
-
- public OMNamespace getNamespace() throws OMException {
- //get the namespace key
- int nskey = Integer.parseInt(findValueByIdentifier(OMConstants.NAME_SPACE_KEY));
- if (nskey!=OMConstants.DEFAULT_INT_VALUE){
- return model.getNamespace(nskey);
- }else{
- return null;
- }
- }
-
- /**
- *
- * @see
- */
- public void setNamespace(OMNamespace namespace) {
- }
-
- /**
- * Get the parent
- * @return
- */
- public int getParentKey(){
- return Integer.parseInt(findValueByIdentifier(OMConstants.PARENT_ID_KEY));
- }
-}
+package org.apache.axis.om.impl;
+
+import org.apache.axis.om.*;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ * 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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 3:54:19 PM
+ */
+public class OMAttributeImpl extends OMNodeImpl implements OMAttribute{
+
+ public OMAttributeImpl() {
+ }
+
+ /**
+ * Special constructor to be used by the model implementation
+ * @param model
+ * @param key
+ * @param values
+ */
+ public OMAttributeImpl(OMModel model,int key,String[] values) {
+ init(model,key,values);
+ }
+
+ public void setValue(String value) {
+ }
+
+ /**
+ * @see org.apache.axis.om.OMAttribute#getValue
+ * @return
+ */
+ public String getValue() {
+ return values[OMConstants.VALUE_INDEX];
+ }
+
+ public void update() {
+ this.values =(String[]) model.update(key,OMConstants.ELEMENT);
+ }
+
+ public String getLocalName() {
+ return values[OMConstants.LOCAL_NAME_INDEX];
+ }
+
+ public void setLocalName(String localName) {
+ //todo
+ }
+
+ public OMNamespace getNamespace() throws OMException {
+ //get the namespace key
+ int nskey = Integer.parseInt(values[OMConstants.NAMESPACE_INDEX]);
+ if (nskey!=OMConstants.DEFAULT_INT_VALUE){
+ return model.getNamespace(nskey);
+ }else{
+ return null;
+ }
+ }
+
+ /**
+ *
+ * @see
+ */
+ public void setNamespace(OMNamespace namespace) {
+ }
+
+ /**
+ * Get the parent
+ * @return
+ */
+ public int getParentKey(){
+ return Integer.parseInt(values[OMConstants.PARENT_INDEX]);
+ }
+
+ public int getNextSiblingKey() {
+ return Integer.parseInt(values[OMConstants.NEXT_SIBLING_INDEX]);
+ }
+
+ public int getNextSiblingType() {
+ return OMNode.ATTRIBUTE_NODE;
+ }
+
+ public int getType() {
+ return OMNode.ATTRIBUTE_NODE;
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMDocumentImpl.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMDocumentImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMDocumentImpl.java Fri Oct 15 16:01:20 2004
@@ -1,61 +1,76 @@
-package org.apache.axis.om.impl;
-
-import org.apache.axis.om.OMModel;
-import org.apache.axis.om.OMModelImpl;
-import org.apache.axis.om.OMElement;
-import org.apache.axis.om.OMDocument;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- *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 Axis team
- * Date: Sep 28, 2004
- * Time: 10:36:05 PM
- *
- */
-public class OMDocumentImpl extends OMNodeImpl implements OMDocument{
- public OMDocumentImpl() {
- }
-
- public OMDocumentImpl(OMModel model,int key,String[][] values) {
- init(model,key,values);
- }
-
-
- public OMElement getDocumentElement() {
- //search through the model to find an element with the parent (DEFAULT) whic means
- //that the particular element has no child
- while(((OMModelImpl)model).getRootElement()==null){
- model.proceed();
- }
- return ((OMModelImpl)model).getRootElement();
-
-
- }
-
- public int getType() {
- return 0;
- }
-
- public void update() {
- //do nothing
- }
-
- public boolean isComplete() {
- return super.isComplete();
- }
-
-}
+package org.apache.axis.om.impl;
+
+import org.apache.axis.om.OMModel;
+import org.apache.axis.om.OMModelImpl;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMDocument;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ *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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 10:36:05 PM
+ *
+ */
+public class OMDocumentImpl extends OMNodeImpl implements OMDocument{
+ public OMDocumentImpl() {
+ }
+
+ public OMDocumentImpl(OMModel model,int key,String[] values) {
+ init(model,key,values);
+ }
+
+
+ public OMElement getDocumentElement() {
+ //search through the model to find an element with the parent (DEFAULT) whic means
+ //that the particular element has no child
+ while(((OMModelImpl)model).getRootElement()==null){
+ model.proceed();
+ }
+ return ((OMModelImpl)model).getRootElement();
+
+
+ }
+
+ public int getType() {
+ return 0;
+ }
+
+ public void update() {
+ //do nothing
+ }
+
+ public boolean isComplete() {
+ return super.isComplete();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getNextSiblingKey() {
+ return 0;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getNextSiblingType() {
+ return 0;
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMElementImpl.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMElementImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMElementImpl.java Fri Oct 15 16:01:20 2004
@@ -1,176 +1,209 @@
-package org.apache.axis.om.impl;
-
-import org.apache.axis.om.*;
-import org.apache.axis.om.impl.traversal.NodeIteratorImpl;
-import org.apache.axis.om.impl.traversal.AttributeIteratorImpl;
-import org.apache.axis.om.util.OMConstants;
-
-import java.util.Iterator;
-
-/**
- * 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 Axis team
- * Date: Sep 28, 2004
- * Time: 3:52:24 PM
- */
-public class OMElementImpl extends OMNodeImpl implements OMElement {
-
- public OMElementImpl() {
- }
-
- public OMElementImpl(OMModel model,int key,String[][] values) {
- init(model,key,values);
- }
-
- public OMNode getFirstChild() {
-
- int firstChildKey = Integer.parseInt(findValueByIdentifier(OMConstants.FIRST_CHILD_KEY));
- while (firstChildKey==OMConstants.DEFAULT_INT_VALUE && !isComplete()){
- model.proceed();
- //update to syncronize the values
- update();
- firstChildKey = Integer.parseInt(findValueByIdentifier(OMConstants.FIRST_CHILD_KEY));
- }
-
- if (isComplete())
- return null;
-
- int firstChildType = Integer.parseInt(findValueByIdentifier(OMConstants.FIRST_CHILD_TYPE_KEY));
- if (firstChildType==OMConstants.ELEMENT){
- return model.getElement(firstChildKey);
- }else if (firstChildType==OMConstants.TEXT){
- return model.getText(firstChildKey);
- }
- return null;
- }
-
-
- public String getLocalName() {
- return findValueByIdentifier(OMConstants.LOCAL_NAME_KEY);
- }
-
- public Iterator getChildren() {
- return new NodeIteratorImpl(this,this.model);
- }
-
- public boolean isComplete() {
- return findValueByIdentifier(OMConstants.DONE_KEY).equals("1")?true:false;
- }
-
-
- public void update() {
- this.values =(String[][]) model.update(key,OMConstants.ELEMENT);
- }
-
- public OMElement getParent() throws OMException {
- int parentKey = getParentKey();
- if (parentKey!=OMConstants.DEFAULT_INT_VALUE){
- return model.getElement(parentKey);
- }else{
- return null;
- }
-
- }
-
- public int getParentKey(){
- return Integer.parseInt(findValueByIdentifier(OMConstants.PARENT_ID_KEY));
- }
-
- public void addChild(OMNode omNode) {
- }
-
- public void addChild(OMNode omNode, int index) throws OMException {
- }
-
- public OMNamespace createNamespace(String uri, String prefix) {
- return null;
- }
-
-
- public OMNamespace resolveNamespace(String uri, String prefix) throws OMException {
- int nameSpaceKey = model.resolveNamespace(Integer.parseInt(findValueByIdentifier(OMConstants.ID_KEY)),
- uri,
- prefix);
- if (nameSpaceKey!=OMConstants.DEFAULT_INT_VALUE)
- return model.getNamespace(nameSpaceKey);
- else
- return null;
- }
-
- /**
- * Note - the attributes will be updated along with the START_ELEMENT event which creates
- * this element. So no need to proceed through the model.
- * @return
- */
- public int getFirstAttributeKey(){
- return Integer.parseInt(findValueByIdentifier(OMConstants.FIRST_ATTRIBUTE_KEY));
- }
- /**
- *
- * @return
- */
- public OMAttribute getFirstAttribute() {
-
- int firstAttribKey = getFirstAttributeKey();
- if (firstAttribKey!=OMConstants.DEFAULT_INT_VALUE){
- return model.getAttribute(firstAttribKey);
- }else{
- return null;
- }
- }
-
- public Iterator getAttributes() {
- return new AttributeIteratorImpl(this,this.model);
- }
-
- public void insertAttribute(OMAttribute attr) {
- }
-
- public void removeAttribute(OMAttribute attr) {
- OMAttributeImpl omAttribute = ((OMAttributeImpl)attr);
- int attribKey = omAttribute.key;
- int parentKey = omAttribute.getParentKey();
- if (parentKey!=this.key){
- throw new OMException("Attributes that are not part of this element cannot be removed");
- }
- if (this.getFirstAttributeKey()==attribKey){
- int nextAttributeKey = omAttribute.getNextSiblingKey();
- model.updateElement(this.key,OMConstants.DEFAULT_STRING_VALUE,nextAttributeKey,OMConstants.UPDATE_FIRST_ATTRIBUTE);
- }
- model.removeAttribute(attribKey);
-
- //update tbe model
- update();
-
- }
-
-
- public void setLocalName(String localName) {
- }
-
- public OMNamespace getNamespace() throws OMException {
- //get the namespace key
- int nskey = Integer.parseInt(findValueByIdentifier(OMConstants.NAME_SPACE_KEY));
- if (nskey!=OMConstants.DEFAULT_INT_VALUE){
- return model.getNamespace(nskey);
- }else{
- return null;
- }
- }
-
- public void setNamespace(OMNamespace namespace) {
- }
-}
+package org.apache.axis.om.impl;
+
+import org.apache.axis.om.*;
+import org.apache.axis.om.impl.traversal.NodeIteratorImpl;
+import org.apache.axis.om.impl.traversal.AttributeIteratorImpl;
+import org.apache.axis.om.util.OMConstants;
+
+import java.util.Iterator;
+
+/**
+ * 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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 3:52:24 PM
+ */
+public class OMElementImpl extends OMNodeImpl implements OMElement {
+
+ public OMElementImpl() {
+ }
+
+ /**
+ * Not operational yet
+ * @param model
+ */
+ public OMElementImpl(OMModel model) {
+ this.model = model;
+
+ //create an Element in the model
+ // this.key = model.addElement();
+
+
+
+ }
+
+ public OMElementImpl(OMModel model,int key,String[] values) {
+ init(model,key,values);
+
+ }
+
+ public OMNode getFirstChild() {
+
+ int firstChildKey = Integer.parseInt(values[OMConstants.FIRST_CHILD_INDEX]);
+ while (firstChildKey==OMConstants.DEFAULT_INT_VALUE && !isComplete()){
+ model.proceed();
+ //update to syncronize the values
+ update();
+ firstChildKey = Integer.parseInt(values[OMConstants.FIRST_CHILD_INDEX]);
+ }
+
+ if (isComplete() && firstChildKey==OMConstants.DEFAULT_INT_VALUE)
+ return null;
+
+ int firstChildType = Integer.parseInt(values[OMConstants.FIRST_CHILD_TYPE_INDEX]);
+ if (firstChildType==OMConstants.ELEMENT){
+ return model.getElement(firstChildKey);
+ }else if (firstChildType==OMConstants.TEXT){
+ return model.getText(firstChildKey);
+ }
+ return null;
+ }
+
+
+ public String getLocalName() {
+ return values[OMConstants.LOCAL_NAME_INDEX];
+ }
+
+ public Iterator getChildren() {
+ return new NodeIteratorImpl(this,this.model);
+ }
+
+ public boolean isComplete() {
+ return values[OMConstants.ELEMENT_DONE_INDEX].equals("1")?true:false;
+ }
+
+
+ public void update() {
+ this.values =(String[]) model.update(key,OMConstants.ELEMENT);
+ }
+
+ public OMElement getParent() throws OMException {
+ int parentKey = getParentKey();
+ if (parentKey!=OMConstants.DEFAULT_INT_VALUE){
+ return model.getElement(parentKey);
+ }else{
+ return null;
+ }
+
+ }
+
+ public int getParentKey(){
+ return Integer.parseInt(values[OMConstants.PARENT_INDEX]);
+ }
+
+ public void addChild(OMNode omNode) {
+ }
+
+
+ public OMNamespace createNamespace(String uri, String prefix) {
+ //create a new namespace in the model
+ int nameSpaceKey = model.addNamespace(uri,prefix,this.key);
+ if (nameSpaceKey!=OMConstants.DEFAULT_INT_VALUE)
+ return model.getNamespace(nameSpaceKey);
+ else
+ return null;
+ }
+
+
+ public OMNamespace resolveNamespace(String uri, String prefix) throws OMException {
+
+ int nameSpaceKey = model.resolveNamespace(Integer.parseInt(values[OMConstants.ID_INDEX]),
+ uri,
+ prefix);
+ if (nameSpaceKey!=OMConstants.DEFAULT_INT_VALUE)
+ return model.getNamespace(nameSpaceKey);
+ else
+ return null;
+ }
+
+ /**
+ * Note - the attributes will be updated along with the START_ELEMENT event which creates
+ * this element. So no need to proceed through the model.
+ * @return
+ */
+ public int getFirstAttributeKey(){
+ return Integer.parseInt(values[OMConstants.FIRST_ATTRIBUTE_INDEX]);
+ }
+ /**
+ *
+ * @return
+ */
+ public OMAttribute getFirstAttribute() {
+
+ int firstAttribKey = getFirstAttributeKey();
+ if (firstAttribKey!=OMConstants.DEFAULT_INT_VALUE){
+ return model.getAttribute(firstAttribKey);
+ }else{
+ return null;
+ }
+ }
+
+ public Iterator getAttributes() {
+ return new AttributeIteratorImpl(this,this.model);
+ }
+
+ public void insertAttribute(OMAttribute attr) {
+ }
+
+ public void removeAttribute(OMAttribute attr) {
+ OMAttributeImpl omAttribute = ((OMAttributeImpl)attr);
+ int attribKey = omAttribute.key;
+ int parentKey = omAttribute.getParentKey();
+ if (parentKey!=this.key){
+ throw new OMException("Attributes that are not part of this element cannot be removed");
+ }
+ if (this.getFirstAttributeKey()==attribKey){
+ int nextAttributeKey = omAttribute.getNextSiblingKey();
+ model.updateElement(this.key,OMConstants.DEFAULT_STRING_VALUE,nextAttributeKey,OMConstants.UPDATE_FIRST_ATTRIBUTE);
+ }
+ model.removeAttribute(attribKey);
+
+ //update tbe model
+ update();
+
+ }
+
+
+ public void setLocalName(String localName) {
+ model.updateElement(this.key,localName,OMConstants.DEFAULT_INT_VALUE,OMConstants.UPDATE_ELEMENT_LOCALNAME);
+ update();
+ }
+
+ public OMNamespace getNamespace() throws OMException {
+ //get the namespace key
+ int nskey = Integer.parseInt(values[OMConstants.NAMESPACE_INDEX]);
+ if (nskey!=OMConstants.DEFAULT_INT_VALUE){
+ return model.getNamespace(nskey);
+ }else{
+ return null;
+ }
+ }
+
+ public void setNamespace(OMNamespace namespace) {
+ }
+
+ public int getNextSiblingKey() {
+ return Integer.parseInt(values[OMConstants.NEXT_SIBLING_INDEX]);
+ }
+
+ public int getNextSiblingType() {
+ return Integer.parseInt(values[OMConstants.ELEMENT_NEXTSIBLING_TYPE_INDEX]);
+ }
+
+ public int getType() {
+ return OMNode.ELEMENT_NODE;
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNameSpaceImpl.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNameSpaceImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNameSpaceImpl.java Fri Oct 15 16:01:20 2004
@@ -1,57 +1,62 @@
-package org.apache.axis.om.impl;
-
-import org.apache.axis.om.OMModel;
-import org.apache.axis.om.OMNamespace;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- * 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 Axis team
- * Date: Sep 28, 2004
- * Time: 9:39:52 PM
- */
-public class OMNameSpaceImpl extends OMNodeImpl implements OMNamespace{
- public OMNameSpaceImpl() {
- }
-
- public OMNameSpaceImpl(OMModel model,int key,String[][] values) {
- init(model,key,values);
- }
-
- public String getURI() {
- return findValueByIdentifier(OMConstants.NAMESPACE_URI_KEY);
- }
-
- public String getPrefix() {
- return findValueByIdentifier(OMConstants.NAMESPACE_PREFIX_KEY);
- }
-
- public void update() {
- this.values =(String[][]) model.update(key,OMConstants.NAMESPACE);
- }
-
- public boolean equals(OMNamespace ns) {
- return false;
- }
-
- public boolean equals(String uri, String prefix) {
- return false;
- }
-
- public boolean isDefaultNs() {
- return false;
- }
-}
+package org.apache.axis.om.impl;
+
+import org.apache.axis.om.OMModel;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ * 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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 9:39:52 PM
+ */
+public class OMNameSpaceImpl extends OMNodeImpl implements OMNamespace{
+ public OMNameSpaceImpl() {
+ }
+
+ public OMNameSpaceImpl(OMModel model,int key,String[] values) {
+ init(model,key,values);
+ }
+
+ public String getURI() {
+ return values[OMConstants.NAMESPACE_URI_INDEX];
+ }
+
+ public String getPrefix() {
+ return values[OMConstants.NAMESPACE_PREFIX_INDEX];
+ }
+
+ public void update() {
+ this.values =(String[]) model.update(key,OMConstants.NAMESPACE);
+ }
+
+ public boolean equals(OMNamespace ns) {
+ return false;
+ }
+
+ public boolean equals(String uri, String prefix) {
+ return false;
+ }
+
+ public boolean isDefaultNs() {
+ return false;
+ }
+
+ public int getType() {
+ return OMConstants.DEFAULT_INT_VALUE;
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNodeImpl.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNodeImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNodeImpl.java Fri Oct 15 16:01:20 2004
@@ -1,123 +1,114 @@
-package org.apache.axis.om.impl;
-
-import org.apache.axis.om.OMElement;
-import org.apache.axis.om.OMException;
-import org.apache.axis.om.OMModel;
-import org.apache.axis.om.OMNode;
-import org.apache.axis.om.pool.PooledObject;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- * 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 Axis team
- * Date: Sep 28, 2004
- * Time: 9:22:42 PM
- */
-public abstract class OMNodeImpl implements OMNode,PooledObject{
-
- protected OMModel model ;
- protected String[][] values;
- protected int key;
-
- protected String findValueByIdentifier(String identifier){
- String[] keyArray = values[0];
- String[] valueArray = values[1];
-
- for (int i = 0; i < keyArray.length; i++) {
- if (keyArray[i].equals(identifier))
- return valueArray[i];
- }
-
- return OMConstants.DEFAULT_STRING_VALUE;
- }
-
-
-
-
- public void init(OMModel model,int key,String[][] values) {
- this.model = model;
- this.key = key;
- this.values = values;
- }
-
- public void reset() {
- this.model = null;
- this.key = OMConstants.DEFAULT_INT_VALUE;
- this.values = null;
- }
-
- public int getNextSiblingKey(){
- return Integer.parseInt(findValueByIdentifier(OMConstants.NEXT_SIBLING_KEY));
- }
-
- public int getNextSiblingType(){
- return Integer.parseInt(findValueByIdentifier(OMConstants.NEXT_SIBLING_TYPE_KEY));
- }
-
- public int getType() {
- return Integer.parseInt(findValueByIdentifier(OMConstants.TYPE_KEY));
- }
-
- public Object getId() {
- return findValueByIdentifier(OMConstants.ID_KEY);
- }
-
- public abstract void update();
-
-
- public OMElement getParent() throws OMException {
- return null;
- }
-
- public void setParent(OMElement element) {
- //not allowed yet
- }
-
- public OMNode getNextSibling() throws OMException {
- return null;
- }
-
- public void setNextSibling(OMNode node) {
- }
-
- public String getValue() throws OMException {
- return null;
- }
-
- public void setValue(String value) {
- }
-
- public boolean isComplete() {
- return false;
- }
-
- public void setComplete(boolean state) {
- }
-
- public void detach() throws OMException {
- }
-
- public void insertSiblingAfter(OMNode sibling) throws OMException {
- }
-
- public void insertSiblingBefore(OMNode sibling) throws OMException {
- }
-
- //
-
-
-
-}
+package org.apache.axis.om.impl;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMModel;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.pool.PooledObject;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ * 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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 9:22:42 PM
+ */
+public abstract class OMNodeImpl implements OMNode,PooledObject{
+
+ protected OMModel model ;
+ protected String[] values;
+ protected int key;
+ //The boolean that specifies whether the object can
+ //be "constructed"
+ protected boolean creatable=true;
+
+ public void init(OMModel model,int key,String[] values) {
+ this.model = model;
+ this.key = key;
+ this.values = values;
+ //once the init method is called this object becomes uncreatable
+ creatable=false;
+
+ }
+
+ public void reset() {
+ this.model = null;
+ this.key = OMConstants.DEFAULT_INT_VALUE;
+ this.values = null;
+ //reset the flag
+ creatable = true;
+ }
+
+
+ public abstract int getType() ;
+
+
+ public Object getId() {
+ return values[OMConstants.ID_INDEX];
+ }
+
+ public abstract void update();
+
+
+ public OMElement getParent() throws OMException {
+ return null;
+ }
+
+ public void setParent(OMElement element) {
+ //not allowed yet
+ }
+
+ public OMNode getNextSibling() throws OMException {
+ return null;
+ }
+
+ public void setNextSibling(OMNode node) {
+ }
+
+ public String getValue() throws OMException {
+ return null;
+ }
+
+ public void setValue(String value) {
+ }
+
+ public boolean isComplete() {
+ return false;
+ }
+
+ public void setComplete(boolean state) {
+ }
+
+ public void detach() throws OMException {
+ }
+
+ public void insertSiblingAfter(OMNode sibling) throws OMException {
+ }
+
+ public void insertSiblingBefore(OMNode sibling) throws OMException {
+ }
+
+ public int getNextSiblingKey() {
+ return OMConstants.DEFAULT_INT_VALUE;
+ }
+
+ public int getNextSiblingType() {
+ return OMConstants.DEFAULT_INT_VALUE;
+ }
+
+
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMTextImpl.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMTextImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMTextImpl.java Fri Oct 15 16:01:20 2004
@@ -1,53 +1,64 @@
-package org.apache.axis.om.impl;
-
-import org.apache.axis.om.OMModel;
-import org.apache.axis.om.OMText;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- * 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 Axis team
- * Date: Sep 28, 2004
- * Time: 3:57:12 PM
- */
-public class OMTextImpl extends OMNodeImpl implements OMText{
- public OMTextImpl() {
- }
-
- public OMTextImpl(OMModel model,int key,String[][] values) {
- init(model,key,values);
- }
-
- public void setValue(String value) {
- //todo
- }
-
- public String getValue() {
- return findValueByIdentifier(OMConstants.VALUE_KEY);
- }
-
- public void update() {
- this.values =(String[][]) model.update(key,OMConstants.TEXT);
- }
-
- public void setTextType(short type) {
- }
-
- public short getTextType() {
- return Short.parseShort(findValueByIdentifier(OMConstants.TYPE_KEY));
- }
-
-}
+package org.apache.axis.om.impl;
+
+import org.apache.axis.om.OMModel;
+import org.apache.axis.om.OMText;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ * 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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 3:57:12 PM
+ */
+public class OMTextImpl extends OMNodeImpl implements OMText{
+ public OMTextImpl() {
+ }
+
+ public OMTextImpl(OMModel model,int key,String[] values) {
+ init(model,key,values);
+ }
+
+ public void setValue(String value) {
+ //todo
+ }
+
+ public String getValue() {
+ return values[OMConstants.VALUE_INDEX];
+ }
+
+ public void update() {
+ this.values =(String[]) model.update(key,OMConstants.TEXT);
+ }
+
+ public void setTextType(short type) {
+ }
+
+ public short getTextType() {
+ return Short.parseShort(values[OMConstants.TEXT_TYPE_INDEX]);
+ }
+
+ public int getType() {
+ return getTextType();
+ }
+
+ public int getNextSiblingKey() {
+ return Integer.parseInt(values[OMConstants.NEXT_SIBLING_INDEX]);
+ }
+
+ public int getNextSiblingType() {
+ return Integer.parseInt(values[OMConstants.TEXT_NEXTSIBLING_TYPE_INDEX]);
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/traversal/NodeIteratorImpl.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/traversal/NodeIteratorImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/traversal/NodeIteratorImpl.java Fri Oct 15 16:01:20 2004
@@ -1,93 +1,97 @@
-package org.apache.axis.om.impl.traversal;
-
-import org.apache.axis.om.OMModel;
-import org.apache.axis.om.impl.OMElementImpl;
-import org.apache.axis.om.impl.OMNodeImpl;
-import org.apache.axis.om.util.OMConstants;
-
-import java.util.Iterator;
-
-/**
- * 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 Axis team
- * Date: Sep 28, 2004
- * Time: 11:45:40 PM
- */
-public class NodeIteratorImpl implements Iterator{
-
- private OMElementImpl parentElement;
- private OMModel model;
- private OMNodeImpl lastNode;
-
- /**
- * Construction needs both the
- * @param parentElement
- * @param model
- */
- public NodeIteratorImpl(OMElementImpl parentElement, OMModel model) {
- this.parentElement = parentElement;
- this.model = model;
- }
-
- /**
- * Next method of the iterator.
- * @return an OMNode that represents the next element or null if
- * there are none
- */
- public Object next() {
-
- if (lastNode==null){
- lastNode =(OMNodeImpl)parentElement.getFirstChild();
- return lastNode;
- }else{
- while ( !hasNext() && lastNode.getNextSiblingKey()==OMConstants.DEFAULT_INT_VALUE){
- model.proceed();
- lastNode.update();
- }
-
- if (lastNode.getNextSiblingKey()!=OMConstants.DEFAULT_INT_VALUE){
- //create the last node by the relevant type
- int nextSiblingKey = lastNode.getNextSiblingKey();
- int nextSiblingType = lastNode.getNextSiblingType();
-
- if (nextSiblingType==OMConstants.ELEMENT){
- lastNode = (OMNodeImpl)model.getElement(nextSiblingKey);
- }else if (nextSiblingType==OMConstants.TEXT){
- lastNode = (OMNodeImpl)model.getText(nextSiblingKey);
- }
-
- return lastNode;
- }else if (hasNext()){
- return null;
- }
- }
-
- return null;
- }
-
- /**
- *
- * @return a boolean values that says whether there are
- * any more children.
- */
- public boolean hasNext() {
- return parentElement.isComplete() || model.isComplete() ;
- }
-
- public void remove() {
- //do nothing!!
- }
-}
+package org.apache.axis.om.impl.traversal;
+
+import org.apache.axis.om.OMModel;
+import org.apache.axis.om.impl.OMElementImpl;
+import org.apache.axis.om.impl.OMNodeImpl;
+import org.apache.axis.om.util.OMConstants;
+
+import java.util.Iterator;
+
+/**
+ * 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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 11:45:40 PM
+ */
+public class NodeIteratorImpl implements Iterator{
+
+ private OMElementImpl parentElement;
+ private OMModel model;
+ private OMNodeImpl lastNode;
+
+ /**
+ * Construction needs both the
+ * @param parentElement
+ * @param model
+ */
+ public NodeIteratorImpl(OMElementImpl parentElement, OMModel model) {
+ this.parentElement = parentElement;
+ this.model = model;
+ }
+
+ /**
+ * Next method of the iterator.
+ * @return an OMNode that represents the next element or null if
+ * there are none
+ */
+ public Object next() {
+
+ if (lastNode==null){
+ lastNode =(OMNodeImpl)parentElement.getFirstChild();
+ return lastNode;
+ }else{
+ while (!parentElement.isComplete() && lastNode.getNextSiblingKey()==OMConstants.DEFAULT_INT_VALUE){
+ model.proceed();
+ parentElement.update();
+ lastNode.update();
+ };
+
+ if (lastNode.getNextSiblingKey()!=OMConstants.DEFAULT_INT_VALUE){
+ //create the last node by the relevant type
+ int nextSiblingKey = lastNode.getNextSiblingKey();
+ int nextSiblingType = lastNode.getNextSiblingType();
+
+ if (nextSiblingType==OMConstants.ELEMENT){
+ lastNode = (OMNodeImpl)model.getElement(nextSiblingKey);
+ }else if (nextSiblingType==OMConstants.TEXT){
+ lastNode = (OMNodeImpl)model.getText(nextSiblingKey);
+ }
+
+ return lastNode;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @return a boolean values that says whether there are
+ * any more children.
+ */
+ public boolean hasNext() {
+ if (!parentElement.isComplete())
+ return true;
+ else if (lastNode!=null)
+ return (lastNode.getNextSiblingKey()!=OMConstants.DEFAULT_INT_VALUE);
+ else
+ return parentElement.getFirstChild()!=null;
+ }
+
+ public void remove() {
+ //do nothing!!
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/serialize/OMSerializer.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/serialize/OMSerializer.java Fri Oct 15 16:01:20 2004
@@ -0,0 +1,35 @@
+package org.apache.axis.om.serialize;
+
+import org.apache.axis.om.OMNode;
+
+/**
+ * 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 Axis team
+ * Date: Oct 15, 2004
+ * Time: 2:51:18 PM
+ *
+ */
+public class OMSerializer {
+
+ public String serialize(OMNode node){
+ return null;
+ }
+
+ private String serialzeDocment(){
+ return null;
+ }
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/AbstractColumn.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/AbstractColumn.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/AbstractColumn.java Fri Oct 15 16:01:20 2004
@@ -1,50 +1,50 @@
-package org.apache.axis.om.storage.column;
-
-/**
- * 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 Axis team
- * Date: Sep 27, 2004
- * Time: 5:18:26 PM
- *
- */
-public abstract class AbstractColumn implements Column {
- protected int chunkSize = 10; //default
- protected int length = 0;
-
- /**
- * @see org.apache.axis.om.storage.column.Column#getChunkSize
- * @return
- */
- public int getChunkSize() {
- return chunkSize;
- }
-
- /**
- * @see org.apache.axis.om.storage.column.Column#setChunkSize
- * @param chunkSize
- */
- public void setChunkSize(int chunkSize) {
- this.chunkSize = chunkSize;
- }
-
- /**
- *
- * @return the current length of the column
- */
- public int getCurrentSize(){
- return this.length;
- }
-}
+package org.apache.axis.om.storage.column;
+
+/**
+ * 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 Axis team
+ * Date: Sep 27, 2004
+ * Time: 5:18:26 PM
+ *
+ */
+public abstract class AbstractColumn implements Column {
+ protected int chunkSize = 150; //default
+ protected int length = 0;
+
+ /**
+ * @see org.apache.axis.om.storage.column.Column#getChunkSize
+ * @return
+ */
+ public int getChunkSize() {
+ return chunkSize;
+ }
+
+ /**
+ * @see org.apache.axis.om.storage.column.Column#setChunkSize
+ * @param chunkSize
+ */
+ public void setChunkSize(int chunkSize) {
+ this.chunkSize = chunkSize;
+ }
+
+ /**
+ *
+ * @return the current length of the column
+ */
+ public int getCurrentSize(){
+ return this.length;
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/AttributeTable.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/AttributeTable.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/AttributeTable.java Fri Oct 15 16:01:20 2004
@@ -1,148 +1,142 @@
-package org.apache.axis.om.storage.table;
-
-import org.apache.axis.om.storage.OMStorageException;
-import org.apache.axis.om.storage.column.IntegerColumn;
-import org.apache.axis.om.storage.column.StringColumn;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- * 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 Axis team
- * Date: Sep 27, 2004
- * Time: 5:56:31 PM
- *
- */
-public class AttributeTable extends NodeTable {
-
- private static final int COLUMN_COUNT=6;
-
- private IntegerColumn nameSpaceKeyColumn = new IntegerColumn();
- private StringColumn localNameColumn = new StringColumn();
- private StringColumn valueColumn = new StringColumn();
-
- /**
- *
- * @param localName
- * @param value
- * @param parentElementKey
- * @return
- */
- public int addAttribute(String localName,String value,int parentElementKey){
-
- int key = pkGenerator.nextVal();
-
- keyColumn.appendValue(key);
- parentColumn.appendValue(parentElementKey);
- nextSiblingColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
- nameSpaceKeyColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
- localNameColumn.appendValue(localName);
- valueColumn.appendValue(value);
-
- return key;
-
- }
-
- /**
- * get the values of a particular row
- * @param key
- * @return
- */
- public String[][] getAttribute(int key){
- if (!isKeyPresent(key)){
- throw new OMStorageException();
- }
-
- String[][] values = new String[2][COLUMN_COUNT];
- //add the lables and values
- values[0][0] = OMConstants.ID_KEY ;values[1][0] = Integer.toString(keyColumn.getValue(key));
- values[0][1] = OMConstants.PARENT_ID_KEY ;values[1][1] = Integer.toString(parentColumn.getValue(key));
- values[0][2] = OMConstants.NEXT_SIBLING_KEY ;values[1][2] = Integer.toString(nextSiblingColumn.getValue(key));
- values[0][3] = OMConstants.NAME_SPACE_KEY ;values[1][3] = Integer.toString(nameSpaceKeyColumn.getValue(key));
- values[0][4] = OMConstants.VALUE_KEY ;values[1][4] = valueColumn.getValue(key);
- values[0][5] = OMConstants.LOCAL_NAME_KEY ;values[1][5] = localNameColumn.getValue(key);
-
- return values;
- }
-
- /**
- *
- * @param key
- * @return
- */
- public int removeAttribute(int key){
- if (isKeyPresent(key)){
- //first figure out the siblings of this attribute
- int nextSiblingKey = nextSiblingColumn.getValue(key);
- int previousSibingKey = findPreviousSibling(key);
-
- //update the value in the previous sibling if it is available
- if (previousSibingKey!=OMConstants.DEFAULT_INT_VALUE){
- nextSiblingColumn.setValue(previousSibingKey,nextSiblingKey);
- }
- //reset the attribute
- reset(key);
- }
- return key;
- }
-
-
-
-
- private int findPreviousSibling(int key){
- int returnVal=OMConstants.DEFAULT_INT_VALUE;
- for (int i=0;i<this.getSize();i++){
- if (key==nextSiblingColumn.getValue(i)){
- returnVal=i;
- break;
- }
- }
- return returnVal;
- }
-
- public void updateNextSibling(int key,int nextSiblingKey){
- nextSiblingColumn.setValue(key,nextSiblingKey);
- }
-
- public void updateNameSpace(int key,int namespaceKey){
- nameSpaceKeyColumn.setValue(key,namespaceKey);
- }
-
- public void dumpValues(){
- System.out.println("content of "+this);
- System.out.println("key" +
- " - " + "parent"+
- " - " + "next sib"+
- " - " + "ns"+
- " - " + "value"+
- " - " +"name"
-
- );
- for (int i = 0; i < this.getSize(); i++) {
-
- System.out.println(keyColumn.getValue(i) +
- " - " + parentColumn.getValue(i)+
- " - " + nextSiblingColumn.getValue(i)+
- " - " + nameSpaceKeyColumn.getValue(i)+
- " - " + valueColumn.getValue(i)+
- " - " + localNameColumn.getValue(i)
-
- );
-
-
- }
- }
-
-}
+package org.apache.axis.om.storage.table;
+
+import org.apache.axis.om.storage.OMStorageException;
+import org.apache.axis.om.storage.column.IntegerColumn;
+import org.apache.axis.om.storage.column.StringColumn;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ * 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 Axis team
+ * Date: Sep 27, 2004
+ * Time: 5:56:31 PM
+ *
+ */
+public class AttributeTable extends NodeTable {
+
+ private static final int COLUMN_COUNT=6;
+
+ private IntegerColumn nameSpaceKeyColumn = new IntegerColumn();
+ private StringColumn localNameColumn = new StringColumn();
+ private StringColumn valueColumn = new StringColumn();
+
+ /**
+ *
+ * @param localName
+ * @param value
+ * @param parentElementKey
+ * @return
+ */
+ public int addAttribute(String localName,String value,int parentElementKey){
+
+ int key = pkGenerator.nextVal();
+
+ keyColumn.appendValue(key);
+ parentColumn.appendValue(parentElementKey);
+ nextSiblingColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
+ nameSpaceKeyColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
+ localNameColumn.appendValue(localName);
+ valueColumn.appendValue(value);
+
+ return key;
+
+ }
+
+ public String[] getRow(int key) {
+ if (!isKeyPresent(key)){
+ throw new OMStorageException();
+ }
+
+ String[] values = new String[COLUMN_COUNT];
+ values[OMConstants.ID_INDEX] = Integer.toString(keyColumn.getValue(key));
+ values[OMConstants.PARENT_INDEX] = Integer.toString(parentColumn.getValue(key));
+ values[OMConstants.NEXT_SIBLING_INDEX] = Integer.toString(nextSiblingColumn.getValue(key));
+ values[OMConstants.NAMESPACE_INDEX] = Integer.toString(nameSpaceKeyColumn.getValue(key));
+ values[OMConstants.VALUE_INDEX] = valueColumn.getValue(key);
+ values[OMConstants.LOCAL_NAME_INDEX] = localNameColumn.getValue(key);
+
+ return values;
+ }
+
+ /**
+ *
+ * @param key
+ * @return
+ */
+ public int removeAttribute(int key){
+ if (isKeyPresent(key)){
+ //first figure out the siblings of this attribute
+ int nextSiblingKey = nextSiblingColumn.getValue(key);
+ int previousSibingKey = findPreviousSibling(key);
+
+ //update the value in the previous sibling if it is available
+ if (previousSibingKey!=OMConstants.DEFAULT_INT_VALUE){
+ nextSiblingColumn.setValue(previousSibingKey,nextSiblingKey);
+ }
+ //reset the attribute
+ reset(key);
+ }
+ return key;
+ }
+
+
+
+
+ private int findPreviousSibling(int key){
+ int returnVal=OMConstants.DEFAULT_INT_VALUE;
+ for (int i=0;i<this.getSize();i++){
+ if (key==nextSiblingColumn.getValue(i)){
+ returnVal=i;
+ break;
+ }
+ }
+ return returnVal;
+ }
+
+ public void updateNextSibling(int key,int nextSiblingKey){
+ nextSiblingColumn.setValue(key,nextSiblingKey);
+ }
+
+ public void updateNameSpace(int key,int namespaceKey){
+ nameSpaceKeyColumn.setValue(key,namespaceKey);
+ }
+
+ public void dumpValues(){
+ System.out.println("content of "+this);
+ System.out.println("key" +
+ " - " + "parent"+
+ " - " + "next sib"+
+ " - " + "ns"+
+ " - " + "value"+
+ " - " +"name"
+
+ );
+ for (int i = 0; i < this.getSize(); i++) {
+
+ System.out.println(keyColumn.getValue(i) +
+ " - " + parentColumn.getValue(i)+
+ " - " + nextSiblingColumn.getValue(i)+
+ " - " + nameSpaceKeyColumn.getValue(i)+
+ " - " + valueColumn.getValue(i)+
+ " - " + localNameColumn.getValue(i)
+
+ );
+
+
+ }
+ }
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/ElementTable.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/ElementTable.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/ElementTable.java Fri Oct 15 16:01:20 2004
@@ -1,199 +1,218 @@
-package org.apache.axis.om.storage.table;
-
-import org.apache.axis.om.storage.OMStorageException;
-import org.apache.axis.om.storage.column.BooleanColumn;
-import org.apache.axis.om.storage.column.IntegerColumn;
-import org.apache.axis.om.storage.column.StringColumn;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- * 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 Axis team
- * Date: Sep 27, 2004
- * Time: 5:10:23 PM
- *
- */
-public class ElementTable extends NodeTable{
-
- private static final int COLUMN_COUNT=10;
-
- //The next sibling type is required since e need to figure out the
- //type of the next sibling as well (whether it is Text or Element)
- private IntegerColumn nextsiblingTypeColumn = new IntegerColumn();
- private IntegerColumn nameSpaceColumn = new IntegerColumn();
- private IntegerColumn firstChildColumn = new IntegerColumn();
- private IntegerColumn firstChildTypeColumn = new IntegerColumn();
- private IntegerColumn firstAttributeColumn = new IntegerColumn();
- private BooleanColumn doneColumn = new BooleanColumn();
- private StringColumn localNameColumn = new StringColumn();
-
- /**
- *
- * @param localName
- * @param parentKey
- * @return
- */
- public int addElement(String localName,int parentKey){
- int key = pkGenerator.nextVal();
-
- keyColumn.appendValue(key);
- parentColumn.appendValue(parentKey);
- nextSiblingColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
- nextsiblingTypeColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
- nameSpaceColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
- firstChildColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
- firstChildTypeColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
- firstAttributeColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
- doneColumn.appendValue(false);
- localNameColumn.appendValue(localName);
-
-
- return key;
- }
-
- /**
- * returns the firstchild key of a given element
- * @param key
- * @return
- */
- public int getFirstChild(int key){
- return firstChildColumn.getValue(key);
- }
-
- /**
- * get the parent key of a given element
- * @param key
- * @return
- */
- public int getParent(int key){
- return parentColumn.getValue(key);
- }
-
- /**
- *
- * @param key
- * @return the set of values in a particular row
- */
- public String[][] getElement(int key){
- if (!isKeyPresent(key)){
- throw new OMStorageException();
- }
-
- String[][] values = new String[2][COLUMN_COUNT];
- //add the lables and values
- values[0][0] = OMConstants.ID_KEY ;values[1][0] = Integer.toString(keyColumn.getValue(key));
- values[0][1] = OMConstants.PARENT_ID_KEY ;values[1][1] = Integer.toString(parentColumn.getValue(key));
- values[0][2] = OMConstants.NEXT_SIBLING_KEY ;values[1][2] = Integer.toString(nextSiblingColumn.getValue(key));
- values[0][3] = OMConstants.NEXT_SIBLING_TYPE_KEY ;values[1][3] = Integer.toString(nextsiblingTypeColumn.getValue(key));
- values[0][4] = OMConstants.NAME_SPACE_KEY ;values[1][4] = Integer.toString(nameSpaceColumn.getValue(key));
- values[0][5] = OMConstants.DONE_KEY ;values[1][5] = doneColumn.getValue(key)?"1":"0";
- values[0][6] = OMConstants.LOCAL_NAME_KEY ;values[1][6] = localNameColumn.getValue(key);
- values[0][7] = OMConstants.FIRST_CHILD_KEY ;values[1][7] =Integer.toString(firstChildColumn.getValue(key));
- values[0][8] = OMConstants.FIRST_CHILD_TYPE_KEY ;values[1][8] =Integer.toString(firstChildTypeColumn.getValue(key));
- values[0][9] = OMConstants.FIRST_ATTRIBUTE_KEY ;values[1][9] =Integer.toString(firstAttributeColumn.getValue(key));
-
- return values;
- }
-
- /**
- * updates the next sibling
- * @param key
- * @param nextSiblingkey
- * @param nextSiblingType
- */
- public void updateNextSibling(int key,int nextSiblingkey,int nextSiblingType){
-
- nextSiblingColumn.setValue(key,nextSiblingkey);
- nextsiblingTypeColumn.setValue(key,nextSiblingType);
-
-
- }
-
- /**
- * updates the done flag
- * @param key
- */
- public void updateDone(int key){
- doneColumn.setValue(key,true);
- }
-
- /**
- * Updates the namespace
- * @param elementKey
- * @param namespaceKey
- */
- public void updateNameSpace(int elementKey,int namespaceKey){
- nameSpaceColumn.setValue(elementKey,namespaceKey);
- }
-
- /**
- * updates the first child
- * @param key
- * @param firstChildKey
- * @param firstChildType
- */
- public void updateFirstChild(int key,int firstChildKey,int firstChildType){
- firstChildColumn.setValue(key,firstChildKey);
- firstChildTypeColumn.setValue(key,firstChildType);
- }
-
- /**
- *
- * @param key
- * @param firstChildKey
- */
- public void updateFirstAttribute(int key,int firstChildKey){
- firstAttributeColumn.setValue(key,firstChildKey);
-
- }
-
- /**
- * Debug method!!
- */
- public void dumpValues(){
- System.out.println("content of "+this);
- System.out.println("key" +
- " - " + "parent"+
- " - " + "nexr sib"+
- " - " + "next sib type"+
- " - " + "ns"+
- " - " + "done"+
- " - " + "fc"+
- " - " + "fct"+
- " - " + "ln" +
- " - " + "firstAttr")
- ;
-
-
- for (int i = 0; i < this.getSize(); i++) {
-
- System.out.println(keyColumn.getValue(i) +
- " - " + parentColumn.getValue(i)+
- " - " + nextSiblingColumn.getValue(i)+
- " - " + nextsiblingTypeColumn.getValue(i)+
- " - " + nameSpaceColumn.getValue(i)+
- " - " + doneColumn.getValue(i)+
- " - " + firstChildColumn.getValue(i)+
- " - " + firstChildTypeColumn.getValue(i)+
- " - " + localNameColumn.getValue(i)+
- " - " + firstAttributeColumn.getValue(i)
-
- );
-
-
- }
- }
-}
+package org.apache.axis.om.storage.table;
+
+import org.apache.axis.om.storage.OMStorageException;
+import org.apache.axis.om.storage.column.BooleanColumn;
+import org.apache.axis.om.storage.column.IntegerColumn;
+import org.apache.axis.om.storage.column.StringColumn;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ * 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 Axis team
+ * Date: Sep 27, 2004
+ * Time: 5:10:23 PM
+ *
+ */
+public class ElementTable extends NodeTable{
+
+ private static final int COLUMN_COUNT=10;
+
+ //The next sibling type is required since e need to figure out the
+ //type of the next sibling as well (whether it is Text or Element)
+ private IntegerColumn nextsiblingTypeColumn = new IntegerColumn();
+ private IntegerColumn nameSpaceColumn = new IntegerColumn();
+ private IntegerColumn firstChildColumn = new IntegerColumn();
+ private IntegerColumn firstChildTypeColumn = new IntegerColumn();
+ private IntegerColumn firstAttributeColumn = new IntegerColumn();
+ private BooleanColumn doneColumn = new BooleanColumn();
+ private StringColumn localNameColumn = new StringColumn();
+
+ /**
+ *
+ * @param localName
+ * @param parentKey
+ * @return
+ */
+ public int addElement(String localName,int parentKey){
+ int key = pkGenerator.nextVal();
+
+ keyColumn.appendValue(key);
+ parentColumn.appendValue(parentKey);
+ nextSiblingColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
+ nextsiblingTypeColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
+ nameSpaceColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
+ firstChildColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
+ firstChildTypeColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
+ firstAttributeColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
+ doneColumn.appendValue(false);
+ localNameColumn.appendValue(localName);
+
+
+ return key;
+ }
+
+ /**
+ * returns the firstchild key of a given element
+ * @param key
+ * @return
+ */
+ public int getFirstChild(int key){
+ return firstChildColumn.getValue(key);
+ }
+
+ /**
+ * get the parent key of a given element
+ * @param key
+ * @return
+ */
+ public int getParent(int key){
+ return parentColumn.getValue(key);
+ }
+
+
+ /**
+ * ID
+ * PARENT
+ * NEXT_SIBLING
+ * NAME_SPACE
+ * DONE
+ * LOCALNAME
+ * NEXT_SIBLING_TYPE
+ * FIRST_CHILD
+ * FIRST_CHILD_TYPE
+ * FIRST_ATTRIBUTE
+ * @param key
+ * @return
+ */
+ public String[] getRow(int key) {
+ if (!isKeyPresent(key)){
+ throw new OMStorageException();
+ }
+
+ String[] values = new String[COLUMN_COUNT];
+ values[OMConstants.ID_INDEX] = Integer.toString(keyColumn.getValue(key));
+ values[OMConstants.PARENT_INDEX] = Integer.toString(parentColumn.getValue(key));
+ values[OMConstants.NEXT_SIBLING_INDEX] = Integer.toString(nextSiblingColumn.getValue(key));
+ values[OMConstants.NAMESPACE_INDEX] = Integer.toString(nameSpaceColumn.getValue(key));
+ values[OMConstants.ELEMENT_DONE_INDEX] = doneColumn.getValue(key)?"1":"0";
+ values[OMConstants.LOCAL_NAME_INDEX] = localNameColumn.getValue(key);
+ values[OMConstants.ELEMENT_NEXTSIBLING_TYPE_INDEX] = Integer.toString(nextsiblingTypeColumn.getValue(key));
+ values[OMConstants.FIRST_CHILD_INDEX] = Integer.toString(firstChildColumn.getValue(key));
+ values[OMConstants.FIRST_CHILD_TYPE_INDEX] = Integer.toString(firstChildTypeColumn.getValue(key));
+ values[OMConstants.FIRST_ATTRIBUTE_INDEX] = Integer.toString(firstAttributeColumn.getValue(key));
+
+ return values;
+ }
+
+
+ /**
+ * updates the next sibling
+ * @param key
+ * @param nextSiblingkey
+ * @param nextSiblingType
+ */
+ public void updateNextSibling(int key,int nextSiblingkey,int nextSiblingType){
+
+ nextSiblingColumn.setValue(key,nextSiblingkey);
+ nextsiblingTypeColumn.setValue(key,nextSiblingType);
+
+
+ }
+
+ /**
+ * updates the done flag
+ * @param key
+ */
+ public void updateDone(int key){
+ doneColumn.setValue(key,true);
+ }
+
+ /**
+ * Updates the namespace
+ * @param elementKey
+ * @param namespaceKey
+ */
+ public void updateNameSpace(int elementKey,int namespaceKey){
+ nameSpaceColumn.setValue(elementKey,namespaceKey);
+ }
+
+ /**
+ * updates the first child
+ * @param key
+ * @param firstChildKey
+ * @param firstChildType
+ */
+ public void updateFirstChild(int key,int firstChildKey,int firstChildType){
+ firstChildColumn.setValue(key,firstChildKey);
+ firstChildTypeColumn.setValue(key,firstChildType);
+ }
+
+ /**
+ *
+ * @param key
+ * @param firstChildKey
+ */
+ public void updateFirstAttribute(int key,int firstChildKey){
+ firstAttributeColumn.setValue(key,firstChildKey);
+
+ }
+
+ /**
+ *
+ * @param key
+ * @param localName
+ */
+ public void updateLocalName(int key,String localName){
+ localNameColumn.setValue(key, localName);
+ }
+
+ /**
+ * Debug method!!
+ */
+ public void dumpValues(){
+ System.out.println("content of "+this);
+ System.out.println("key" +
+ " - " + "parent"+
+ " - " + "nexr sib"+
+ " - " + "next sib type"+
+ " - " + "ns"+
+ " - " + "done"+
+ " - " + "fc"+
+ " - " + "fct"+
+ " - " + "ln" +
+ " - " + "firstAttr")
+ ;
+
+
+ for (int i = 0; i < this.getSize(); i++) {
+
+ System.out.println(keyColumn.getValue(i) +
+ " - " + parentColumn.getValue(i)+
+ " - " + nextSiblingColumn.getValue(i)+
+ " - " + nextsiblingTypeColumn.getValue(i)+
+ " - " + nameSpaceColumn.getValue(i)+
+ " - " + doneColumn.getValue(i)+
+ " - " + firstChildColumn.getValue(i)+
+ " - " + firstChildTypeColumn.getValue(i)+
+ " - " + localNameColumn.getValue(i)+
+ " - " + firstAttributeColumn.getValue(i)
+
+ );
+
+
+ }
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/EventTable.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/EventTable.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/EventTable.java Fri Oct 15 16:01:20 2004
@@ -1,103 +1,104 @@
-package org.apache.axis.om.storage.table;
-
-import org.apache.axis.om.storage.OMStorageException;
-import org.apache.axis.om.storage.column.IntegerColumn;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- * 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 Axis team
- * Date: Sep 27, 2004
- * Time: 6:30:37 PM
- *
- */
-public class EventTable extends AbstractTable {
-
- private IntegerColumn typeColumn = new IntegerColumn();
- private IntegerColumn referenceKeyColumn = new IntegerColumn();
- private static int COLUMN_COUNT=3;
-
- /**
- *
- * @param type
- * @param referencekey
- */
- public int addEvent(int type, int referencekey){
- int key = pkGenerator.nextVal();
-
- keyColumn.appendValue(key);
- typeColumn.appendValue(type);
- referenceKeyColumn.appendValue(referencekey);
-
- return key;
- }
-
- /**
- *
- * @return
- */
- public String[][] getEvent(int key){
- if (!isKeyPresent(key)){
- throw new OMStorageException();
- }
-
- String[][] values = new String[2][COLUMN_COUNT];
- //add the lables and values
- values[0][0] = OMConstants.ID_KEY ;values[1][0] = Integer.toString(keyColumn.getValue(key));
- values[0][1] = OMConstants.TYPE_KEY ;values[1][1] = Integer.toString(typeColumn.getValue(key));
- values[0][2] = OMConstants.REFERENCE_KEY ;values[1][2] = Integer.toString(referenceKeyColumn.getValue(key));
-
- return values;
- }
-
- /**
- * get the pull event
- * @param key
- * @return
- */
- public int getPullEvent(int key){
- if (key > this.getSize()){
- throw new OMStorageException();
- }
-
- return typeColumn.getValue(key);
- }
-
- /**
- * Debug method
- */
-
- public void dumpValues(){
- System.out.println("content of "+this);
- System.out.println("key" +
- " - " + "type"+
- " - " + "reference")
- ;
-
-
- for (int i = 0; i < this.getSize(); i++) {
-
- System.out.println(keyColumn.getValue(i) +
- " - " + typeColumn.getValue(i)+
- " - " + referenceKeyColumn.getValue(i)
-
-
- );
-
-
- }
- }
-}
+package org.apache.axis.om.storage.table;
+
+import org.apache.axis.om.storage.OMStorageException;
+import org.apache.axis.om.storage.column.IntegerColumn;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ * 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 Axis team
+ * Date: Sep 27, 2004
+ * Time: 6:30:37 PM
+ *
+ */
+public class EventTable extends AbstractTable {
+
+ private IntegerColumn typeColumn = new IntegerColumn();
+ private IntegerColumn referenceKeyColumn = new IntegerColumn();
+ private static int COLUMN_COUNT=3;
+
+ /**
+ *
+ * @param type
+ * @param referencekey
+ */
+ public int addEvent(int type, int referencekey){
+ int key = pkGenerator.nextVal();
+
+ keyColumn.appendValue(key);
+ typeColumn.appendValue(type);
+ referenceKeyColumn.appendValue(referencekey);
+
+ return key;
+ }
+ /**
+ * ID
+ * TYPE
+ * REFERENCE
+ * @param key
+ * @return
+ */
+ public String[] getRow(int key) {
+ if (!isKeyPresent(key)){
+ throw new OMStorageException();
+ }
+
+ String[] values = new String[COLUMN_COUNT];
+ values[OMConstants.ID_INDEX] = Integer.toString(keyColumn.getValue(key));
+ values[OMConstants.EVENT_TYPE_INDEX] = Integer.toString(typeColumn.getValue(key));
+ values[OMConstants.EVENT_REFERENCE_INDEX] = Integer.toString(referenceKeyColumn.getValue(key));
+
+ return values;
+ }
+
+ /**
+ * get the pull event
+ * @param key
+ * @return
+ */
+ public int getPullEvent(int key){
+ if (key > this.getSize()){
+ throw new OMStorageException();
+ }
+
+ return typeColumn.getValue(key);
+ }
+
+ /**
+ * Debug method
+ */
+
+ public void dumpValues(){
+ System.out.println("content of "+this);
+ System.out.println("key" +
+ " - " + "type"+
+ " - " + "reference")
+ ;
+
+
+ for (int i = 0; i < this.getSize(); i++) {
+
+ System.out.println(keyColumn.getValue(i) +
+ " - " + typeColumn.getValue(i)+
+ " - " + referenceKeyColumn.getValue(i)
+
+
+ );
+
+
+ }
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/NameSpaceTable.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/NameSpaceTable.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/NameSpaceTable.java Fri Oct 15 16:01:20 2004
@@ -1,129 +1,132 @@
-package org.apache.axis.om.storage.table;
-
-import org.apache.axis.om.storage.OMStorageException;
-import org.apache.axis.om.storage.column.IntegerColumn;
-import org.apache.axis.om.storage.column.StringColumn;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- * 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 Axis team
- * Date: Sep 28, 2004
- * Time: 11:38:23 AM
- */
-public class NameSpaceTable extends AbstractTable {
-
- private StringColumn nameSpaceURIColumn = new StringColumn();
- private StringColumn nameSpacePrefixColumn = new StringColumn();
- // parent means the declared Element. The namespace of the parent
- // may or may not be the namespace in question
- private IntegerColumn parentColumn = new IntegerColumn();
- private static int COLUMN_COUNT=4;
-
-
- /**
- * Adds a namespace
- * @param nameSpaceURI
- * @param nameSpacePrefix
- * @param parent
- * @return
- */
- public int addNamespace(String nameSpaceURI,String nameSpacePrefix,int parent){
- int key = pkGenerator.nextVal();
-
- keyColumn.appendValue(key);
- parentColumn.appendValue(parent);
- nameSpaceURIColumn.appendValue(nameSpaceURI);
- nameSpacePrefixColumn.appendValue(nameSpacePrefix);
-
- return key;
- }
-
- /**
- * Get the namespace details
- * @param key
- * @return
- */
- public String[][] getNamespace(int key){
- if (key > this.getSize()){
- throw new OMStorageException();
- }
-
- String[][] values = new String[2][COLUMN_COUNT];
- //add the lables and values
- values[0][0] = OMConstants.ID_KEY ;values[1][0] = Integer.toString(keyColumn.getValue(key));
- values[0][1] = OMConstants.PARENT_ID_KEY ;values[1][1] = Integer.toString(parentColumn.getValue(key));
- values[0][2] = OMConstants.NAMESPACE_URI_KEY ;values[1][2] = nameSpaceURIColumn.getValue(key);
- values[0][3] = OMConstants.NAMESPACE_PREFIX_KEY ;values[1][3] = nameSpacePrefixColumn.getValue(key);
-
- return values;
- }
-
- /**
- * find a namepace
- * @param parent the parent element of the namespace
- * @param URI
- * @param prefix
- * @return
- */
- public int findNamespace(int parent,String URI,String prefix){
- int size = this.getSize();
- String tempUri;
- String tempPrefix;
- for (int i = 0; i < size; i++) {
- if (parent == parentColumn.getValue(i)){
- tempUri = nameSpaceURIColumn.getValue(i);
- tempPrefix = nameSpacePrefixColumn.getValue(i);
- if (prefix!=null){
- if (prefix.equals(tempPrefix) && URI.equals(tempUri)){
- return keyColumn.getValue(i);
- }
- }else{
- if (URI.equals(tempUri)){
- return keyColumn.getValue(i);
- }
- }
- }
-
- }
-
- return OMConstants.DEFAULT_INT_VALUE;
- }
-
- /**
- * Debug method
- */
- public void dumpValues(){
- System.out.println("content of "+this);
- System.out.println("Key" +
- " - " + "parent"+
- " - " + "URI"+
- " - " +" prefix"
-
- );
- for (int i = 0; i < this.getSize(); i++) {
-
- System.out.println(keyColumn.getValue(i) +
- " - " + parentColumn.getValue(i) +
- " - " + nameSpaceURIColumn.getValue(i) +
- " - " + nameSpacePrefixColumn.getValue(i)
- );
-
-
- }
- }
-
-}
+package org.apache.axis.om.storage.table;
+
+import org.apache.axis.om.storage.OMStorageException;
+import org.apache.axis.om.storage.column.IntegerColumn;
+import org.apache.axis.om.storage.column.StringColumn;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ * 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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 11:38:23 AM
+ */
+public class NameSpaceTable extends AbstractTable {
+
+ private StringColumn nameSpaceURIColumn = new StringColumn();
+ private StringColumn nameSpacePrefixColumn = new StringColumn();
+ // parent means the declared Element. The namespace of the parent
+ // may or may not be the namespace in question
+ private IntegerColumn parentColumn = new IntegerColumn();
+ private static int COLUMN_COUNT=4;
+
+
+ /**
+ * Adds a namespace
+ * @param nameSpaceURI
+ * @param nameSpacePrefix
+ * @param parent
+ * @return
+ */
+ public int addNamespace(String nameSpaceURI,String nameSpacePrefix,int parent){
+ int key = pkGenerator.nextVal();
+
+ keyColumn.appendValue(key);
+ parentColumn.appendValue(parent);
+ nameSpaceURIColumn.appendValue(nameSpaceURI);
+ nameSpacePrefixColumn.appendValue(nameSpacePrefix);
+
+ return key;
+ }
+
+ /**
+ * ID
+ * PARENT
+ * URI
+ * PREFIX
+ * @param key
+ * @return
+ */
+ public String[] getRow(int key) {
+ if (!isKeyPresent(key)){
+ throw new OMStorageException();
+ }
+
+ String[] values = new String[COLUMN_COUNT];
+ values[OMConstants.ID_INDEX] = Integer.toString(keyColumn.getValue(key));
+ values[OMConstants.PARENT_INDEX] = Integer.toString(parentColumn.getValue(key));
+ values[OMConstants.NAMESPACE_URI_INDEX] = nameSpaceURIColumn.getValue(key);
+ values[OMConstants.NAMESPACE_PREFIX_INDEX] = nameSpacePrefixColumn.getValue(key);
+
+ return values;
+ }
+
+
+ /**
+ * find a namepace
+ * @param parent the parent element of the namespace
+ * @param URI
+ * @param prefix
+ * @return
+ */
+ public int findNamespace(int parent,String URI,String prefix){
+ int size = this.getSize();
+ String tempUri;
+ String tempPrefix;
+ for (int i = 0; i < size; i++) {
+ if (parent == parentColumn.getValue(i)){
+ tempUri = nameSpaceURIColumn.getValue(i);
+ tempPrefix = nameSpacePrefixColumn.getValue(i);
+ if (prefix!=null){
+ if (prefix.equals(tempPrefix) && URI.equals(tempUri)){
+ return keyColumn.getValue(i);
+ }
+ }else{
+ if (URI.equals(tempUri)){
+ return keyColumn.getValue(i);
+ }
+ }
+ }
+
+ }
+
+ return OMConstants.DEFAULT_INT_VALUE;
+ }
+
+ /**
+ * Debug method
+ */
+ public void dumpValues(){
+ System.out.println("content of "+this);
+ System.out.println("Key" +
+ " - " + "parent"+
+ " - " + "URI"+
+ " - " +" prefix"
+
+ );
+ for (int i = 0; i < this.getSize(); i++) {
+
+ System.out.println(keyColumn.getValue(i) +
+ " - " + parentColumn.getValue(i) +
+ " - " + nameSpaceURIColumn.getValue(i) +
+ " - " + nameSpacePrefixColumn.getValue(i)
+ );
+
+
+ }
+ }
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/Table.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/Table.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/Table.java Fri Oct 15 16:01:20 2004
@@ -1,28 +1,30 @@
-package org.apache.axis.om.storage.table;
-
-/**
- * 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 Axis team
- * Date: Sep 27, 2004
- * Time: 5:08:35 PM
- *
- * A minimum guideline for the tables
- */
-public interface Table {
-
- int getSize();
-
-}
+package org.apache.axis.om.storage.table;
+
+/**
+ * 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 Axis team
+ * Date: Sep 27, 2004
+ * Time: 5:08:35 PM
+ *
+ * A minimum guideline for the tables
+ */
+public interface Table {
+
+ int getSize();
+
+ String[] getRow(int key);
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/TextTable.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/TextTable.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/TextTable.java Fri Oct 15 16:01:20 2004
@@ -1,116 +1,120 @@
-package org.apache.axis.om.storage.table;
-
-import org.apache.axis.om.storage.OMStorageException;
-import org.apache.axis.om.storage.column.IntegerColumn;
-import org.apache.axis.om.storage.column.StringColumn;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- * 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 Axis team
- * Date: Sep 27, 2004
- * Time: 6:15:05 PM
- *
- */
-public class TextTable extends NodeTable {
-
- private StringColumn valueColumn = new StringColumn();
- private IntegerColumn typeColumn = new IntegerColumn();
- private IntegerColumn nextsiblingTypeColumn = new IntegerColumn();
- private static int COLUMN_COUNT=6;
-
- /**
- *
- * @param value
- * @param type
- * @param parentKey
- * @return
- */
- public int addText(String value,int type,int parentKey){
- int key = pkGenerator.nextVal();
-
- keyColumn.appendValue(key);
- parentColumn.appendValue(parentKey);
- valueColumn.appendValue(value);
- typeColumn.appendValue(type);
- nextSiblingColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
- nextsiblingTypeColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
-
- return key;
- }
-
- /**
- *
- * @param key
- * @return
- */
- public String[][] getText(int key){
- if (key > this.getSize()){
- throw new OMStorageException();
- }
-
- String[][] values = new String[2][COLUMN_COUNT];
- //add the lables and values
- values[0][0] = OMConstants.ID_KEY ;values[1][0] = Integer.toString(keyColumn.getValue(key));
- values[0][1] = OMConstants.PARENT_ID_KEY ;values[1][1] = Integer.toString(parentColumn.getValue(key));
- values[0][2] = OMConstants.VALUE_KEY ;values[1][2] = valueColumn.getValue(key);
- values[0][3] = OMConstants.TYPE_KEY ;values[1][3] = Integer.toString(typeColumn.getValue(key));
- values[0][4] = OMConstants.NEXT_SIBLING_KEY ;values[1][4] = Integer.toString(nextSiblingColumn.getValue(key));
- values[0][5] = OMConstants.NEXT_SIBLING_TYPE_KEY ;values[1][5] = Integer.toString(nextsiblingTypeColumn.getValue(key));
-
- return values;
- }
-
- /**
- *
- * @param key
- * @param nextSiblingkey
- * @param nextSiblingType
- */
- public void updateNextSibling(int key,int nextSiblingkey,int nextSiblingType){
- nextSiblingColumn.setValue(key,nextSiblingkey);
- nextsiblingTypeColumn.setValue(key,nextSiblingType);
- }
-
-
- /**
- * Debug method
- */
- public void dumpValues(){
- System.out.println("content of "+this);
- System.out.println("Key" +
- " - " + "parent"+
- " - " + "next sib"+
- " - " +" type"+
- " - " + "value"+
- " - " + "next sibling type"
-
- );
- for (int i = 0; i < this.getSize(); i++) {
-
- System.out.println(keyColumn.getValue(i) +
- " - " + parentColumn.getValue(i)+
- " - " + nextSiblingColumn.getValue(i)+
- " - " + typeColumn.getValue(i)+
- " - " + valueColumn.getValue(i)+
- " - " + nextsiblingTypeColumn.getValue(i)
-
- );
-
-
- }
- }
-}
+package org.apache.axis.om.storage.table;
+
+import org.apache.axis.om.storage.OMStorageException;
+import org.apache.axis.om.storage.column.IntegerColumn;
+import org.apache.axis.om.storage.column.StringColumn;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ * 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 Axis team
+ * Date: Sep 27, 2004
+ * Time: 6:15:05 PM
+ *
+ */
+public class TextTable extends NodeTable {
+
+ private StringColumn valueColumn = new StringColumn();
+ private IntegerColumn typeColumn = new IntegerColumn();
+ private IntegerColumn nextsiblingTypeColumn = new IntegerColumn();
+ private static int COLUMN_COUNT=6;
+
+ /**
+ *
+ * @param value
+ * @param type
+ * @param parentKey
+ * @return
+ */
+ public int addText(String value,int type,int parentKey){
+ int key = pkGenerator.nextVal();
+
+ keyColumn.appendValue(key);
+ parentColumn.appendValue(parentKey);
+ valueColumn.appendValue(value);
+ typeColumn.appendValue(type);
+ nextSiblingColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
+ nextsiblingTypeColumn.appendValue(OMConstants.DEFAULT_INT_VALUE);
+
+ return key;
+ }
+ /**
+ * ID
+ * PARENT
+ * NEXTSIBLING
+ * TYPE
+ * VALUE
+ * NEXT_SIBLING_TYPE
+ * @param key
+ * @return
+ */
+ public String[] getRow(int key) {
+ if (!isKeyPresent(key)){
+ throw new OMStorageException();
+ }
+
+ String[] values = new String[COLUMN_COUNT];
+ values[OMConstants.ID_INDEX] = Integer.toString(keyColumn.getValue(key));
+ values[OMConstants.PARENT_INDEX] = Integer.toString(parentColumn.getValue(key));
+ values[OMConstants.NEXT_SIBLING_INDEX] = Integer.toString(nextSiblingColumn.getValue(key));
+ values[OMConstants.TEXT_TYPE_INDEX] =Integer.toString(typeColumn.getValue(key));
+ values[OMConstants.VALUE_INDEX] =(valueColumn.getValue(key));
+ values[OMConstants.TEXT_NEXTSIBLING_TYPE_INDEX] =Integer.toString(nextsiblingTypeColumn.getValue(key));
+
+ return values;
+ }
+
+
+ /**
+ *
+ * @param key
+ * @param nextSiblingkey
+ * @param nextSiblingType
+ */
+ public void updateNextSibling(int key,int nextSiblingkey,int nextSiblingType){
+ nextSiblingColumn.setValue(key,nextSiblingkey);
+ nextsiblingTypeColumn.setValue(key,nextSiblingType);
+ }
+
+
+ /**
+ * Debug method
+ */
+ public void dumpValues(){
+ System.out.println("content of "+this);
+ System.out.println("Key" +
+ " - " + "parent"+
+ " - " + "next sib"+
+ " - " +" type"+
+ " - " + "value"+
+ " - " + "next sibling type"
+
+ );
+ for (int i = 0; i < this.getSize(); i++) {
+
+ System.out.println(keyColumn.getValue(i) +
+ " - " + parentColumn.getValue(i)+
+ " - " + nextSiblingColumn.getValue(i)+
+ " - " + typeColumn.getValue(i)+
+ " - " + valueColumn.getValue(i)+
+ " - " + nextsiblingTypeColumn.getValue(i)
+
+ );
+
+
+ }
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/OMConstants.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/OMConstants.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/OMConstants.java Fri Oct 15 16:01:20 2004
@@ -1,66 +1,109 @@
-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 Axis team
- * Date: Sep 27, 2004
- * Time: 5:38:37 PM
- *
- * Holder for all the constants
- * It is helpful to have a single constants container
- * to avoid confusions
- */
-public class OMConstants {
-
- public static final int DEFAULT_INT_VALUE = -1;
- public static final String DEFAULT_STRING_VALUE = "-1";
-
- //update constants for the table model
- public static final int UPDATE_NEXT_SIBLING = 1;
- public static final int UPDATE_DONE = 2;
- public static final int UPDATE_NAMESPACE = 3;
- public static final int UPDATE_VALUE = 4;
- public static final int UPDATE_FIRST_CHILD = 5;
- public static final int UPDATE_FIRST_ATTRIBUTE = 6;
-
- //Node type constants
- public static final int ELEMENT = 100;
- public static final int TEXT = 200;
- public static final int COMMENT = 300;
- public static final int CDATA = 400;
- public static final int ATTRIBUTE = 500;
- public static final int NAMESPACE = 600;
-
- //value keys
- public static final String LOCAL_NAME_KEY = "n";
- public static final String ID_KEY = "id";
- public static final String PARENT_ID_KEY = "pid";
- public static final String VALUE_KEY = "val";
- public static final String NEXT_SIBLING_KEY = "ns";
- public static final String NEXT_SIBLING_TYPE_KEY = "nst";
- public static final String NAME_SPACE_KEY = "nsk";
- public static final String DONE_KEY = "d";
- public static final String NAMESPACE_URI_KEY = "nsu";
- public static final String NAMESPACE_PREFIX_KEY = "nsp";
- public static final String TYPE_KEY = "t";
- public static final String REFERENCE_KEY = "r";
- public static final String FIRST_CHILD_KEY = "fc";
- public static final String FIRST_CHILD_TYPE_KEY = "fct";
- public static final String FIRST_ATTRIBUTE_KEY = "fat";
-
-
-
-}
+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 Axis team
+ * Date: Sep 27, 2004
+ * Time: 5:38:37 PM
+ *
+ * Holder for all the constants
+ * It is helpful to have a single constants container
+ * to avoid confusions
+ */
+public class OMConstants {
+
+ public static final int DEFAULT_INT_VALUE = -1;
+ public static final String DEFAULT_STRING_VALUE = "-1";
+
+ //update constants for the table model
+ public static final int UPDATE_NEXT_SIBLING = 1;
+ public static final int UPDATE_DONE = 2;
+ public static final int UPDATE_NAMESPACE = 3;
+ public static final int UPDATE_VALUE = 4;
+ public static final int UPDATE_FIRST_CHILD = 5;
+ public static final int UPDATE_FIRST_ATTRIBUTE = 6;
+ public static final int UPDATE_ELEMENT_LOCALNAME = 7;
+
+ //Node type constants
+ public static final int ELEMENT = 100;
+ public static final int TEXT = 200;
+ public static final int COMMENT = 300;
+ public static final int CDATA = 400;
+ public static final int ATTRIBUTE = 500;
+ public static final int NAMESPACE = 600;
+
+ //value keys
+// public static final String LOCAL_NAME_KEY = "n";
+// public static final String ID_KEY = "id";
+// public static final String PARENT_ID_KEY = "pid";
+// public static final String VALUE_KEY = "val";
+// public static final String NEXT_SIBLING_KEY = "ns";
+// public static final String NEXT_SIBLING_TYPE_KEY = "nst";
+// public static final String NAME_SPACE_KEY = "nsk";
+// public static final String DONE_KEY = "d";
+// public static final String NAMESPACE_URI_KEY = "nsu";
+// public static final String NAMESPACE_PREFIX_KEY = "nsp";
+// public static final String TYPE_KEY = "t";
+// public static final String REFERENCE_KEY = "r";
+// public static final String FIRST_CHILD_KEY = "fc";
+// public static final String FIRST_CHILD_TYPE_KEY = "fct";
+// public static final String FIRST_ATTRIBUTE_KEY = "fat";
+
+
+ /*
+Attribute Element text Namespace Event
+ID ID ID ID ID
+PARENT PARENT PARENT PARENT TYPE
+NEXT_SIBLING NEXT_SIBLING NEXTSIBLING URI REFERENCE
+NAME_SPACE NAME_SPACE TYPE PREFIX
+VALUE DONE VALUE
+LOCALNAME LOCALNAME NEXT_SIBLING_TYPE
+ NEXT_SIBLING_TYPE
+ FIRST_CHILD
+ FIRST_CHILD_TYPE
+ FIRST_ATTRIBUTE
+
+ */
+
+ public static int ID_INDEX = 0;
+
+ public static int PARENT_INDEX = 1;
+ public static int EVENT_TYPE_INDEX = 1;
+
+ public static int NEXT_SIBLING_INDEX = 2;
+ public static int NAMESPACE_URI_INDEX = 2;
+ public static int EVENT_REFERENCE_INDEX = 2;
+
+ public static int NAMESPACE_INDEX = 3;
+ public static int TEXT_TYPE_INDEX = 3;
+ public static int NAMESPACE_PREFIX_INDEX = 3;
+
+ public static int VALUE_INDEX = 4;
+ public static int ELEMENT_DONE_INDEX = 4;
+
+ public static int LOCAL_NAME_INDEX = 5;
+ public static int TEXT_NEXTSIBLING_TYPE_INDEX = 5;
+
+ public static int ELEMENT_NEXTSIBLING_TYPE_INDEX = 6;
+
+ public static int FIRST_CHILD_INDEX = 7;
+
+ public static int FIRST_CHILD_TYPE_INDEX = 8;
+
+ public static int FIRST_ATTRIBUTE_INDEX = 9;
+
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModelTest.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModelTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModelTest.java Fri Oct 15 16:01:20 2004
@@ -1,181 +1,201 @@
-package org.apache.axis.om;
-
-import junit.framework.TestCase;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserFactory;
-import org.xmlpull.mxp1.MXParserFactory;
-
-import java.io.FileReader;
-import java.util.Iterator;
-
-/**
- * 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 Axis team
- * Date: Sep 28, 2004
- * Time: 10:07:33 PM
- * To change this template use Options | File Templates.
- */
-public class OMModelTest extends TestCase{
-
-
- private StreamingOMBuilder builder = null;
- private OMModel model=null;
-
- protected void setUp() throws Exception {
- super.setUp();
- XmlPullParserFactory xmlPullParserFactory = MXParserFactory.newInstance();
- xmlPullParserFactory.setNamespaceAware(true);
- XmlPullParser parser = xmlPullParserFactory.newPullParser();
- parser.setInput(new FileReader("test-resources/soapmessage1.xml"));
- builder = new StreamingOMBuilder(parser);
- model = builder.getTableModel();
- }
-
-
- /**
- * Test the presence of the root elements
- */
- public void testRootElement(){
- OMDocument doc = model.getDocument();
- OMElement elt = doc.getDocumentElement();
- assertTrue(elt!=null);
-
- }
-
- /**
- * test the presence of children
- */
- public void testChildren(){
- OMDocument doc = model.getDocument();
- OMElement elt = doc.getDocumentElement();
- Iterator iter = elt.getChildren();
- Object obj ;
-
- dumpModel("before all");
-
-
- obj=iter.next();
- System.out.println("obj = " + obj);
- if (obj instanceof OMElement)
- System.out.println("name =" + ((OMElement)obj).getLocalName());
- if (obj instanceof OMText)
- System.out.println("text =" + ((OMText)obj).getValue());
-
- dumpModel("cycle 1");
-
-
- obj=iter.next();
- System.out.println("obj = " + obj);
- if (obj instanceof OMElement)
- System.out.println("name =" + ((OMElement)obj).getLocalName());
- if (obj instanceof OMText)
- System.out.println("text =" + ((OMText)obj).getValue());
-
- dumpModel("cycle 2");
-
-
- }
-
- /**
- * Test the presence of athe attributes
- * Just loop through the attributes to see whether they work properly
- */
- public void testAttributes(){
- OMDocument doc = model.getDocument();
- OMElement elt = doc.getDocumentElement();
-
- dumpModel("cycle 1");
-
- Iterator iter = elt.getAttributes();
- while(iter.hasNext()){
- OMAttribute x = (OMAttribute)iter.next();
- System.out.println("object =" + x);
- System.out.println("local name =" + x.getLocalName());
- }
-
-
-
- }
- /**
- * Test removal of attributes
- * Case 1 - the attribute is not the first attribute
- */
- public void testRemoveAttribute1(){
- OMDocument doc = model.getDocument();
- OMElement elt = doc.getDocumentElement();
-
- dumpModel("cycle 1");
-
- Iterator iter = elt.getAttributes();
- OMAttribute x = null;
- while(iter.hasNext()){
- x = (OMAttribute)iter.next();
- System.out.println("object =" + x);
- System.out.println("local name =" + x.getLocalName());
- }
-
- //now remove the attribute
- elt.removeAttribute(x);
- dumpModel("cycle 2");
-
- iter = elt.getAttributes();
- while(iter.hasNext()){
- x = (OMAttribute)iter.next();
- System.out.println("object =" + x);
- System.out.println("local name =" + x.getLocalName());
- }
- }
-
- /**
- * Test the removal of attributes
- * Case 2 - the attribute is the first attribute
- */
- public void testRemoveAttribute2(){
- OMDocument doc = model.getDocument();
- OMElement elt = doc.getDocumentElement();
-
- dumpModel("cycle 1");
-
- OMAttribute x = elt.getFirstAttribute();
- elt.removeAttribute(x);
-
- dumpModel("cycle 2");
-
- Iterator iter = elt.getAttributes();
- while(iter.hasNext()){
- x = (OMAttribute)iter.next();
- System.out.println("object =" + x);
- System.out.println("local name =" + x.getLocalName());
- }
- }
-
- public void testProceeed(){
-
- //make the whole model
- while (!model.isComplete()){
- model.proceed();
- }
-
- dumpModel(" all ");
-
- }
- private void dumpModel(String heading) {
- System.out.println();
- System.out.println("############## "+heading+" #########################");
- ((OMModelImpl)model).dump();
- System.out.println("############## end "+heading+" #########################");
- }
-}
+package org.apache.axis.om;
+
+import junit.framework.TestCase;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserFactory;
+import org.xmlpull.mxp1.MXParserFactory;
+import org.apache.axis.om.util.TimeTester;
+
+import java.io.FileReader;
+import java.util.Iterator;
+
+/**
+ * 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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 10:07:33 PM
+ * To change this template use Options | File Templates.
+ */
+public class OMModelTest extends TestCase{
+
+
+ private StreamingOMBuilder builder = null;
+ private OMModel model=null;
+ private TimeTester timeTester = new TimeTester();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ XmlPullParserFactory xmlPullParserFactory = MXParserFactory.newInstance();
+ xmlPullParserFactory.setNamespaceAware(true);
+ XmlPullParser parser = xmlPullParserFactory.newPullParser();
+ parser.setInput(new FileReader("test-resources/soap2.xml"));
+ builder = new StreamingOMBuilder(parser);
+ model = builder.getTableModel();
+ }
+
+
+ /**
+ * Test the presence of the root elements
+ */
+ public void testRootElement(){
+ OMDocument doc = model.getDocument();
+ OMElement elt = doc.getDocumentElement();
+ assertTrue(elt!=null);
+
+ }
+
+ public void testChildren1(){
+ OMDocument doc = model.getDocument();
+ timeTester.enter();
+ OMElement elt = doc.getDocumentElement();
+ timeTester.exit();
+
+ Iterator iter = elt.getChildren();
+ while (iter.hasNext()){
+ timeTester.enter();
+ System.out.println("iter.next() = " + iter.next());
+ timeTester.exit();
+ }
+
+
+ //=========================
+ //dump the content of the table
+ dumpModel("After testing");
+ }
+ /**
+ * test the presence of children
+ */
+ public void testChildren2(){
+ OMDocument doc = model.getDocument();
+ OMElement elt = doc.getDocumentElement();
+ Iterator iter = elt.getChildren();
+ Object obj ;
+
+ dumpModel("before all");
+
+
+ obj=iter.next();
+ System.out.println("obj = " + obj);
+ if (obj instanceof OMElement)
+ System.out.println("name =" + ((OMElement)obj).getLocalName());
+ if (obj instanceof OMText)
+ System.out.println("text =" + ((OMText)obj).getValue());
+
+ dumpModel("cycle 1");
+
+
+ obj=iter.next();
+ System.out.println("obj = " + obj);
+ if (obj instanceof OMElement)
+ System.out.println("name =" + ((OMElement)obj).getLocalName());
+ if (obj instanceof OMText)
+ System.out.println("text =" + ((OMText)obj).getValue());
+
+ dumpModel("cycle 2");
+
+
+ }
+
+ /**
+ * Test the presence of athe attributes
+ * Just loop through the attributes to see whether they work properly
+ */
+ public void testAttributes(){
+ OMDocument doc = model.getDocument();
+ OMElement elt = doc.getDocumentElement();
+
+ dumpModel("cycle 1");
+
+ Iterator iter = elt.getAttributes();
+ while(iter.hasNext()){
+ OMAttribute x = (OMAttribute)iter.next();
+ System.out.println("object =" + x);
+ System.out.println("local name =" + x.getLocalName());
+ }
+
+
+
+ }
+ /**
+ * Test removal of attributes
+ * Case 1 - the attribute is not the first attribute
+ */
+ public void testRemoveAttribute1(){
+ OMDocument doc = model.getDocument();
+ OMElement elt = doc.getDocumentElement();
+
+ dumpModel("cycle 1");
+
+ Iterator iter = elt.getAttributes();
+ OMAttribute x = null;
+ while(iter.hasNext()){
+ x = (OMAttribute)iter.next();
+ System.out.println("object =" + x);
+ System.out.println("local name =" + x.getLocalName());
+ }
+
+ //now remove the attribute
+ elt.removeAttribute(x);
+ dumpModel("cycle 2");
+
+ iter = elt.getAttributes();
+ while(iter.hasNext()){
+ x = (OMAttribute)iter.next();
+ System.out.println("object =" + x);
+ System.out.println("local name =" + x.getLocalName());
+ }
+ }
+
+ /**
+ * Test the removal of attributes
+ * Case 2 - the attribute is the first attribute
+ */
+ public void testRemoveAttribute2(){
+ OMDocument doc = model.getDocument();
+ OMElement elt = doc.getDocumentElement();
+
+ dumpModel("cycle 1");
+
+ OMAttribute x = elt.getFirstAttribute();
+ elt.removeAttribute(x);
+
+ dumpModel("cycle 2");
+
+ Iterator iter = elt.getAttributes();
+ while(iter.hasNext()){
+ x = (OMAttribute)iter.next();
+ System.out.println("object =" + x);
+ System.out.println("local name =" + x.getLocalName());
+ }
+ }
+
+ public void testProceeed(){
+
+ //make the whole model
+ while (!model.isComplete()){
+ model.proceed();
+ }
+
+ dumpModel(" all ");
+
+ }
+ private void dumpModel(String heading) {
+ System.out.println();
+ System.out.println("############## "+heading+" #########################");
+ ((OMModelImpl)model).dump();
+ System.out.println("############## end "+heading+" #########################");
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModelTest2.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModelTest2.java Fri Oct 15 16:01:20 2004
@@ -0,0 +1,84 @@
+package org.apache.axis.om;
+
+import junit.framework.TestCase;
+
+import java.util.Iterator;
+import java.io.FileReader;
+
+import org.apache.axis.om.util.TimeTester;
+import org.xmlpull.v1.XmlPullParserFactory;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.mxp1.MXParserFactory;
+
+/**
+ * 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 Axis team
+ * Date: Oct 8, 2004
+ * Time: 10:16:39 AM
+ *
+ */
+public class OMModelTest2 extends TestCase {
+
+ private StreamingOMBuilder builder = null;
+ private OMModel model=null;
+ private TimeTester timeTester = new TimeTester();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ XmlPullParserFactory xmlPullParserFactory = MXParserFactory.newInstance();
+ xmlPullParserFactory.setNamespaceAware(true);
+ XmlPullParser parser = xmlPullParserFactory.newPullParser();
+ parser.setInput(new FileReader("test-resources/soap2.xml"));
+ builder = new StreamingOMBuilder(parser);
+ model = builder.getTableModel();
+ }
+
+
+ public void testChildren1(){
+ OMDocument doc = model.getDocument();
+ timeTester.enter();
+ OMElement elt = doc.getDocumentElement();
+ timeTester.exit();
+
+ Iterator iter = elt.getChildren();
+ while (iter.hasNext()){
+ timeTester.enter();
+ System.out.println("iter.next() = " + iter.next());
+ timeTester.exit();
+ }
+
+
+ }
+
+
+ public void testProceed(){
+
+ while (!model.isComplete()){
+ timeTester.enter();
+ model.proceed();
+ timeTester.exit();
+ }
+
+ dumpModel(" proceed");
+ }
+
+ private void dumpModel(String heading) {
+ System.out.println();
+ System.out.println("############## "+heading+" #########################");
+ ((OMModelImpl)model).dump();
+ System.out.println("############## end "+heading+" #########################");
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModleTest3.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModleTest3.java Fri Oct 15 16:01:20 2004
@@ -0,0 +1,73 @@
+package org.apache.axis.om;
+
+import junit.framework.TestCase;
+import org.apache.axis.om.util.TimeTester;
+import org.xmlpull.v1.XmlPullParserFactory;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.mxp1.MXParserFactory;
+
+import java.io.FileReader;
+import java.util.Iterator;
+
+/**
+ * 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 Axis team
+ * Date: Oct 8, 2004
+ * Time: 2:16:26 PM
+ *
+ */
+public class OMModleTest3 extends TestCase{
+
+ private StreamingOMBuilder builder = null;
+ private OMModel model=null;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ XmlPullParserFactory xmlPullParserFactory = MXParserFactory.newInstance();
+ xmlPullParserFactory.setNamespaceAware(true);
+ XmlPullParser parser = xmlPullParserFactory.newPullParser();
+ parser.setInput(new FileReader("test-resources/soap2.xml"));
+ builder = new StreamingOMBuilder(parser);
+ model = builder.getTableModel();
+ }
+
+ public void testChildren1(){
+ //build the complete model
+ while (!model.isComplete())
+ model.proceed();
+
+ OMDocument doc = model.getDocument();
+ OMElement elt = doc.getDocumentElement();
+
+ Iterator iter = elt.getChildren();
+ while (iter.hasNext()){
+ System.out.println("iter.next() = " + iter.next());
+ }
+
+
+ //=========================
+ //dump the content of the table
+ dumpModel("After testing");
+ }
+
+ private void dumpModel(String heading) {
+ System.out.println();
+ System.out.println("############## "+heading+" #########################");
+ ((OMModelImpl)model).dump();
+ System.out.println("############## end "+heading+" #########################");
+ }
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/AttributeTableTest.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/AttributeTableTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/AttributeTableTest.java Fri Oct 15 16:01:20 2004
@@ -1,62 +1,54 @@
-package org.apache.axis.om.storage.table;
-
-import org.apache.axis.om.util.OMConstants;
-import junit.framework.TestCase;
-
-/**
- * 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 Axis team
- * Date: Sep 28, 2004
- * Time: 7:40:32 PM
- */
-public class AttributeTableTest extends TestCase{
- private final String LOCAL_NAME= "name";
- private final String VALUE= "value";
- private final int PARENT_KEY =5;
- private int myKey;
- private AttributeTable table;
-
- protected void setUp() throws Exception {
- super.setUp();
- table = new AttributeTable();
- myKey=table.addAttribute(LOCAL_NAME,VALUE,PARENT_KEY);
- }
-
-
- public void testAddAttribute(){
- assertTrue(myKey>=0);
- }
-
- public void testGetAttribute(){
-
- String[][] values = table.getAttribute(myKey);
-
- String[] keyArray = values[0];
- String[] valueArray = values[1];
- for (int j = 0; j < valueArray.length; j++) {
- String key = keyArray[j];
- String value = valueArray[j];
-
- if (key.equals(OMConstants.VALUE_KEY)){
- assertEquals(value, VALUE);
- }else if (key.equals(OMConstants.LOCAL_NAME_KEY)){
- assertEquals(value, LOCAL_NAME);
- }else if (key.equals(OMConstants.PARENT_ID_KEY)){
- assertEquals(value, PARENT_KEY+"");
- }
- }
- }
-}
+package org.apache.axis.om.storage.table;
+
+import org.apache.axis.om.util.OMConstants;
+import junit.framework.TestCase;
+
+/**
+ * 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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 7:40:32 PM
+ */
+public class AttributeTableTest extends TestCase{
+ private final String LOCAL_NAME= "name";
+ private final String VALUE= "value";
+ private final int PARENT_KEY =5;
+ private int myKey;
+ private AttributeTable table;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ table = new AttributeTable();
+ myKey=table.addAttribute(LOCAL_NAME,VALUE,PARENT_KEY);
+ }
+
+
+ public void testAddAttribute(){
+ assertTrue(myKey>=0);
+ }
+
+ public void testGetAttribute(){
+
+ String[] values = table.getRow(myKey);
+
+ assertEquals(values[OMConstants.VALUE_INDEX], VALUE);
+ assertEquals(values[OMConstants.LOCAL_NAME_INDEX], LOCAL_NAME);
+ assertEquals(values[OMConstants.PARENT_INDEX], PARENT_KEY+"");
+
+
+
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/ElementTableTest.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/ElementTableTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/ElementTableTest.java Fri Oct 15 16:01:20 2004
@@ -1,92 +1,70 @@
-package org.apache.axis.om.storage.table;
-
-import junit.framework.TestCase;
-import org.apache.axis.om.util.OMConstants;
-
-/**
- * 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 Axis team
- * Date: Sep 28, 2004
- * Time: 7:14:44 PM
- */
-public class ElementTableTest extends TestCase {
- private final String LOCAL_NAME= "name";
- private final int PARENT_KEY =5;
- private int myKey;
- private ElementTable table;
-
- protected void setUp() throws Exception {
- super.setUp();
- table = new ElementTable();
- myKey=table.addElement(LOCAL_NAME,PARENT_KEY);
- }
-
-
- public void testAddElemenmt(){
- assertTrue(myKey>=0);
- }
-
- public void testGetElement(){
-
- String[][] values = table.getElement(myKey);
-
- String[] keyArray = values[0];
- String[] valueArray = values[1];
- for (int j = 0; j < valueArray.length; j++) {
- String key = keyArray[j];
- String value = valueArray[j];
-
- if (key.equals(OMConstants.VALUE_KEY)){
- assertEquals(value, "0");
- }else if (key.equals(OMConstants.LOCAL_NAME_KEY)){
- assertEquals(value, LOCAL_NAME);
- }else if (key.equals(OMConstants.PARENT_ID_KEY)){
- assertEquals(value, "5");
- }
- }
- }
-
- public void testUpdateDone(){
- table.updateDone(myKey);
-
- String[][] values = table.getElement(myKey);
-
- String[] keyArray = values[0];
- String[] valueArray = values[1];
- boolean found=false;
- for (int j = 0; j < valueArray.length; j++) {
- String key = keyArray[j];
- String value = valueArray[j];
-
- if (key.equals(OMConstants.DONE_KEY)){
- assertEquals(value, "1");
- found=true;
- break;
- }
- }
-
- assertTrue(found);
-
- }
-
- public void testSize(){
- assertEquals(table.getSize(),1);
- myKey=table.addElement(LOCAL_NAME,PARENT_KEY);
- assertEquals(table.getSize(),2);
- }
-
-
-}
+package org.apache.axis.om.storage.table;
+
+import junit.framework.TestCase;
+import org.apache.axis.om.util.OMConstants;
+
+/**
+ * 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 Axis team
+ * Date: Sep 28, 2004
+ * Time: 7:14:44 PM
+ */
+public class ElementTableTest extends TestCase {
+ private final String LOCAL_NAME= "name";
+ private final int PARENT_KEY =5;
+ private int myKey;
+ private ElementTable table;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ table = new ElementTable();
+ myKey=table.addElement(LOCAL_NAME,PARENT_KEY);
+ }
+
+
+ public void testAddElemenmt(){
+ assertTrue(myKey>=0);
+ }
+
+ public void testGetElement(){
+
+ String[] values = table.getRow(myKey);
+
+ assertEquals(values[OMConstants.VALUE_INDEX], "0");
+ assertEquals(values[OMConstants.LOCAL_NAME_INDEX], LOCAL_NAME);
+ assertEquals(values[OMConstants.PARENT_INDEX], PARENT_KEY+"");
+
+
+
+
+ }
+
+ public void testUpdateDone(){
+ table.updateDone(myKey);
+
+ String[] values = table.getRow(myKey);
+ assertEquals(values[OMConstants.ELEMENT_DONE_INDEX],"1");
+
+ }
+
+ public void testSize(){
+ assertEquals(table.getSize(),1);
+ myKey=table.addElement(LOCAL_NAME,PARENT_KEY);
+ assertEquals(table.getSize(),2);
+ }
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/util/TimeTester.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/util/TimeTester.java Fri Oct 15 16:01:20 2004
@@ -0,0 +1,41 @@
+package org.apache.axis.om.util;
+
+import java.util.Stack;
+
+/**
+ * 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 Axis team
+ * Date: Oct 8, 2004
+ * Time: 8:55:10 AM
+ *
+ */
+public class TimeTester {
+
+ Stack stack = new Stack();
+
+ public void enter(){
+ stack.push(new Long(System.currentTimeMillis()));
+ }
+
+ public void exit(){
+ long currenttime = System.currentTimeMillis();
+ long prevtime = ((Long)stack.pop()).longValue();
+
+ System.out.println("Time taken = " + (currenttime - prevtime));
+
+ }
+
+}