You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by he...@apache.org on 2004/10/06 15:00:49 UTC
svn commit: rev 53861 - in webservices/axis/trunk/java/dev/scratch/ajith_deepal: . omTableModel omTableModel/src omTableModel/src/java omTableModel/src/java/org omTableModel/src/java/org/apache omTableModel/src/java/org/apache/axis omTableModel/src/java/org/apache/axis/om omTableModel/src/java/org/apache/axis/om/impl omTableModel/src/java/org/apache/axis/om/impl/traversal omTableModel/src/java/org/apache/axis/om/pool omTableModel/src/java/org/apache/axis/om/storage omTableModel/src/java/org/apache/axis/om/storage/column omTableModel/src/java/org/apache/axis/om/storage/table omTableModel/src/java/org/apache/axis/om/util omTableModel/src/test omTableModel/src/test-resources omTableModel/src/test/org omTableModel/src/test/org/apache omTableModel/src/test/org/apache/axis omTableModel/src/test/org/apache/axis/om omTableModel/src/test/org/apache/axis/om/storage omTableModel/src/test/org/apache/axis/om/storage/table omTableModel/src/test/org/apache/axis/om/util
Author: hemapani
Date: Wed Oct 6 06:00:47 2004
New Revision: 53861
Added:
webservices/axis/trunk/java/dev/scratch/ajith_deepal/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMAttribute.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMDocument.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMElement.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMException.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMModel.java
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/OMNamedNode.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMNamespace.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMNode.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMText.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/StreamingOMBuilder.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/
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/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/traversal/AttributeIteratorImpl.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/pool/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/AbstractPool.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMAttributePool.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMElementPool.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMNameSpacePool.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMTextPool.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/ObjectPool.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/PooledObject.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/OMStorageException.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/
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/BooleanColumn.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/Column.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/IntegerColumn.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/StringColumn.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/AbstractTable.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/NodeTable.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/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/IntegerStack.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/java/org/apache/axis/om/util/Sequence.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/soapmessage.xml
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/soapmessage1.xml
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/testFile.xml
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/tester-out.xml
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/
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/PullGeneratorTester.java
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/
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
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/util/
webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/util/IntegerStackTest.java
Log:
adding a OM based on a real table Model on behalf of Ajith. This is implemented by creating the table columns with arrays.
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMAttribute.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMAttribute.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,28 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 11:49:01 AM
+ *
+ * One must implement relevant constructors for the class implementing this interface
+ * all the things like namespace, parent, value, etc., that should come in this are defined in base classes
+ */
+public interface OMAttribute extends OMNamedNode{
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMDocument.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMDocument.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,31 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Axis team
+ * Date: Oct 4, 2004
+ * Time: 4:48:10 PM
+ *
+ */
+public interface OMDocument extends OMNode{
+
+ /**
+ * Get the root element of this document
+ * @return the root element
+ */
+ OMElement getDocumentElement();
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMElement.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMElement.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,105 @@
+package org.apache.axis.om;
+
+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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 11:52:18 AM
+ *
+ * One must make sure to insert relevant constructors for the classes that are implementing this interface
+ */
+public interface OMElement extends OMNamedNode {
+
+ /**
+ * This will add child to the element. One can decide whether he append the child or he adds to the
+ * front of the children list
+ *
+ * @param omNode
+ */
+ public void addChild(OMNode omNode);
+
+ /**
+ * This will add a child in a specific location given in the index. If there are no preceding elements
+ * this will throw an AxisFault.
+ * Example if one tries to add child number four, but if there is no third child, throw an exception.
+ *
+ * @param omNode
+ * @param index
+ */
+ public void addChild(OMNode omNode, int index) throws OMException;
+
+ /**
+ * Returns the first child of this element
+ * @return
+ */
+ public OMNode getFirstChild();
+ /**
+ * This returns a collection of this element.
+ * Children can be of types OMElement, OMText.
+ */
+ public Iterator getChildren();
+
+ /**
+ * THis will create a namespace in the current element scope
+ *
+ * @param uri
+ * @param prefix
+ * @return
+ */
+ public OMNamespace createNamespace(String uri, String prefix);
+
+ /**
+ * This will find a namespace with the given uri and prefix, in the scope of the docuemnt.
+ * This will start to find from the current element and goes up in the hiararchy until this finds one.
+ * If none is found, return null
+ *
+ * @param uri
+ * @param prefix
+ * @return
+ * @throws OMException
+ */
+ public OMNamespace resolveNamespace(String uri, String prefix) throws OMException;
+
+ /**
+ * This will returns the first attribute of the element or null, if none is present
+ *
+ * @return
+ */
+ public OMAttribute getFirstAttribute();
+
+ /**
+ * This will return a List of OMAttributes
+ * @return
+ */
+ public Iterator getAttributes();
+
+ /**
+ * This will insert attribute to this element. Implementor can decide as to insert this
+ * in the front or at the end of set of attributes
+ *
+ * @param attr
+ */
+ public void insertAttribute(OMAttribute attr);
+
+ /**
+ * Remove the attribute from the attribute set
+ * @param attr
+ */
+ public void removeAttribute(OMAttribute attr);
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMException.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMException.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,55 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Axis team
+ * Date: Sep 27, 2004
+ * Time: 5:04:41 PM
+ *
+ */
+public class OMException extends RuntimeException {
+
+ /**
+ * Standard constructor
+ */
+ public OMException() {
+ }
+
+ /**
+ *
+ * @param message
+ */
+ public OMException(String message) {
+ super(message);
+ }
+
+ /**
+ *
+ * @param message
+ * @param cause
+ */
+ public OMException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ *
+ * @param cause
+ */
+ public OMException(Throwable cause) {
+ super(cause);
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMModel.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMModel.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,272 @@
+package org.apache.axis.om;
+
+
+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 28, 2004
+ * Time: 10:40:52 AM
+ *
+ * This interface governs the methods Exposed by the "Model" of the OM
+ * It is meant to cover the underlying implementation of the model
+ *
+ */
+public interface OMModel {
+
+ /**
+ * Add a new element to the model
+ * @param localName
+ * @param parentElement
+ * @return
+ */
+ int addElement(String localName,int parentElement);
+
+ /**
+ * Add an attribute to the model
+ * @param localName
+ * @param value
+ * @param parentElement
+ * @return
+ */
+ int addAttribute(String localName,String value,int parentElement);
+
+ /**
+ * Add a text node
+ * @param value
+ * @param parent
+ * @return
+ */
+ int addText(String value,int parent);
+
+ /**
+ * Add a CDATA section
+ * @param value
+ * @param parent
+ * @return
+ */
+ int addCDATA(String value,int parent);
+
+ /**
+ * Add a comment
+ * @param value
+ * @param parent
+ * @return
+ */
+ int addComment(String value,int parent);
+
+ /**
+ * Add a namespace. Namespaces are treated as a seperate entitiy
+ * @param URI
+ * @param prefix
+ * @param declaredElementKey
+ * @return
+ */
+ int addNamespace(String URI,String prefix, int declaredElementKey);
+
+ /**
+ * Add an event into this
+ * @param type
+ * @param reference
+ * @return
+ */
+ int addEvent(int type,int reference);
+
+ /**
+ * Removes the element given the key
+ * @param key
+ * @return
+ */
+ int removeElement(int key);
+
+ /**
+ * remove the attribute given the key
+ * @param key
+ * @return
+ */
+ int removeAttribute(int key);
+
+ /**
+ * Remove the text node given the key
+ * @param key
+ * @return
+ */
+ int removeText(int key);
+
+ /**
+ * Remove the event
+ * @param key
+ * @return
+ */
+ int removeEvent(int key);
+
+ /**
+ * this is a very special method that allows the updation of several
+ * attributes. The type parameter determines what should be updated.
+ * Similar methods exist for attributes and other infoset items
+ * @param key
+ * @param stringValue
+ * @param intValue
+ * @param type
+ */
+ void updateElement(int key,String stringValue,int intValue,int type);
+ /**
+ * @see #updateElement
+ * @param key
+ * @param stringValue
+ * @param intValue
+ * @param type
+ */
+ void updateAttribute(int key,String stringValue,int intValue,int type);
+
+ /**
+ * @see #updateElement
+ * @param key
+ * @param stringValue
+ * @param intValue
+ * @param type
+ */
+ void updateText(int key,String stringValue,int intValue,int type);
+
+ /**
+ * @see #updateElement
+ * @param key
+ * @param stringValue
+ * @param intValue
+ * @param type
+ */
+ void updateNameSpace(int key,String stringValue,int intValue,int type);
+
+ /**
+ *
+ * @param key
+ * @return OMElement object
+ */
+ OMElement getElement(int key);
+
+ /**
+ *
+ * @param key
+ * @return
+ */
+ OMAttribute getAttribute(int key);
+
+ /**
+ *
+ * @param key
+ * @return
+ */
+ OMText getText(int key);
+
+ /**
+ *
+ * @param key
+ * @return
+ */
+ OMNamespace getNamespace(int key);
+
+ /**
+ *
+ * @return the docuement object
+ */
+ OMDocument getDocument();
+
+ /**
+ *
+ * @param key
+ * @return
+ */
+ Object getEvent(int key);
+
+ /**
+ *
+ * @param key
+ * @return
+ */
+ int getPullEvent(int key);
+
+ /**
+ *
+ * @return the number of elements (including the removed ones)
+ */
+ int getElementCount();
+
+ /**
+ *
+ * @return The attribute count
+ */
+ int getAttributeCount();
+
+ /**
+ *
+ * @return the number of text items
+ */
+ int getTextCount();
+
+ /**
+ *
+ * @return the number of events
+ */
+ int getEventCount();
+
+ /**
+ * Set the caching off
+ */
+ void setCacheOff();
+
+ /**
+ * Return the parser underneath
+ * @return
+ */
+ XmlPullParser getParser();
+
+ /**
+ * Move the underlying build mechanism one even further
+ * @return
+ */
+ int proceed();
+
+ /**
+ * A flag saying whether the model is completed
+ * @return
+ */
+ boolean isComplete();
+
+ /**
+ * Set the completed flag
+ * @param b
+ */
+ void setComplete(boolean b);
+
+ /**
+ * Returns the status of the particular object
+ * Used for synchronization
+ * @param key
+ * @param type
+ * @return
+ */
+ Object update(int key,int type);
+
+ /**
+ * Resolve the namespace
+ * @param parent
+ * @param uri
+ * @param prefix
+ * @return
+ */
+ int resolveNamespace(int parent,String uri,String prefix);
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMModelImpl.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMModelImpl.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,507 @@
+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("----------------------------");
+
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMNamedNode.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMNamedNode.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,50 @@
+package org.apache.axis.om;
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 11:39:01 AM
+ *
+ * OMElement and OMAttribute must have namespace support and those two behave in same manner as far as the namespaces are concerned.
+ * So one can implement this interface specific methods in an abstract class.
+ */
+public interface OMNamedNode extends OMNode{
+
+ /**
+ *
+ * @return the local name
+ */
+ String getLocalName();
+ /**
+ *
+ * @param localName
+ */
+ void setLocalName(String localName);
+
+ /**
+ *
+ * @return
+ * @throws OMException
+ */
+ OMNamespace getNamespace() throws OMException;
+
+ /**
+ * @param namespace
+ */
+ void setNamespace(OMNamespace namespace);
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMNamespace.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMNamespace.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,57 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 1:24:00 PM
+ */
+public interface OMNamespace extends OMNode{
+
+ /**
+ *
+ * @param ns
+ * @return whether this is equivalent to the
+ * given namespace or not
+ */
+ boolean equals(OMNamespace ns) ;
+
+ /**
+ *
+ * @param uri
+ * @param prefix
+ * @return
+ */
+ boolean equals(String uri, String prefix);
+
+ /**
+ *
+ * @return a boolean that says whether this is the default
+ * namespace or not
+ */
+ boolean isDefaultNs();
+ /**
+ *
+ * @return the prefix of this namepace
+ */
+ String getPrefix() ;
+
+ /**
+ *
+ * @return the uri of this namespace
+ */
+ String getURI();
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMNode.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMNode.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,113 @@
+package org.apache.axis.om;
+
+
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 1, 2004
+ * Time: 3:36:14 PM
+ */
+public interface OMNode {
+ //==================================================================================
+
+ // Followings are the codes for node types. Extracted these from DOM API
+ /**
+ * The node is an <code>Element</code>.
+ */
+ public static final short ELEMENT_NODE = 1;
+ /**
+ * The node is an <code>Attr</code>.
+ */
+ public static final short ATTRIBUTE_NODE = 2;
+ /**
+ * The node is a <code>Text</code> node.
+ */
+ public static final short TEXT_NODE = 3;
+ /**
+ * The node is a <code>CDATASection</code>.
+ */
+ public static final short CDATA_SECTION_NODE = 4;
+
+ /**
+ * The node is a <code>Comment</code>.
+ */
+ public static final short COMMENT_NODE = 8;
+ /**
+ * The node is a <code>Document</code>.
+ */
+ public static final short DOCUMENT_NODE = 9;
+
+ //==================================================================================
+
+ /**
+ * This method should return the immediate parent of the node.
+ * Parent is always an Element
+ * @return
+ * @throws OMException
+ */
+ OMElement getParent() throws OMException;
+ void setParent(OMElement element);
+
+ /**
+ * This will give the next sibling. This can be an OMAttribute for OMAttribute or OMText or OMELement for others.
+ * @return
+ * @throws OMException
+ */
+ OMNode getNextSibling() throws OMException;
+ void setNextSibling(OMNode node);
+
+ /**
+ * This will return the literal value of the node.
+ * OMText --> the text
+ * OMElement --> name of the element as a QName in String format
+ * OMAttribute --> the value of the attribue
+ * @return
+ * @throws OMException
+ */
+ String getValue() throws OMException;
+ void setValue(String value);
+
+ /**
+ * this will indicate whether parser has parsed this information item completely or not.
+ * If somethings info are not available in the item, one has to check this attribute to make sure that, this
+ * item has been parsed completely or not.
+ * @return
+ */
+ boolean isComplete();
+ void setComplete(boolean state);
+
+ /**
+ * This will remove this information item and its children, from the model completely
+ * @throws OMException
+ */
+ void detach() throws OMException;
+
+ /**
+ * This will insert a sibling just after the current information item.
+ * @param sibling
+ * @throws OMException
+ */
+ void insertSiblingAfter(OMNode sibling) throws OMException;
+
+ /**
+ * This will insert a sibling just before the current information item
+ * @param sibling
+ * @throws OMException
+ */
+ void insertSiblingBefore(OMNode sibling) throws OMException;
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMText.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/OMText.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,36 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 2:04:43 PM
+ */
+public interface OMText extends OMNode{
+ /**
+ * We use the OMText class to hold comments, text, characterData, CData, etc.,
+ * The codes are found in OMNode class
+ * @see org.apache.axis.om.OMNode
+ * @param type
+ */
+ public void setTextType(short type);
+
+ /**
+ *
+ * @return the type of this node
+ */
+ public short getTextType();
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/PullEventGenerator.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/PullEventGenerator.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,67 @@
+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;
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/StreamingOMBuilder.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/StreamingOMBuilder.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,367 @@
+package org.apache.axis.om;
+
+import org.apache.axis.om.util.IntegerStack;
+import org.apache.axis.om.util.OMConstants;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation. <p/>Licensed under the
+ * Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0 <p/>Unless required by applicable
+ * law or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ *
+ * @author Ajith Ranabahu
+ * Date: Sep 16, 2004
+ * Time: 10:00:16 PM
+ * This class accepts pull events and generates the OMModel. It encapsultes
+ * all the logic that is needed to build the model. And most importantly
+ * the builder is unaware of the underlying storage mechanism since it
+ * accesses the model through the model interface
+ */
+public class StreamingOMBuilder {
+
+ private XmlPullParser pullparser;
+ private OMModel tableModel = null;
+ private IntegerStack stack = new IntegerStack();
+
+ private int lastSibling = OMConstants.DEFAULT_INT_VALUE;
+ private int lastSiblingType= OMConstants.DEFAULT_INT_VALUE;
+
+ private boolean cache = true;
+
+ /**
+ * Cache status
+ * @return
+ */
+ public boolean isCache() {
+ return cache;
+ }
+
+ /**
+ * Set the cache status
+ * @param cache
+ */
+ public void setCache(boolean cache) {
+ this.cache = cache;
+ }
+
+ /**
+ * @param pullparser to be used. this cannot be changed
+ * during the build cycle
+ */
+ public StreamingOMBuilder(XmlPullParser pullparser) {
+ this.pullparser = pullparser;
+ this.tableModel = new OMModelImpl(this);
+ }
+
+ /**
+ *
+ * @return the OMModel inside
+ */
+ public OMModel getTableModel() {
+ return tableModel;
+ }
+
+ /**
+ *
+ * @return XMLpullparser The parser within
+ */
+ public XmlPullParser getPullparser() {
+ return pullparser;
+ }
+
+ /**
+ * Call the next method once, of pull parser update the Table Model
+ * depending on the pull event recd from pull parser.
+ *
+ * @throws OMException
+ */
+ public int proceed() throws OMException {
+ int eventType = OMConstants.DEFAULT_INT_VALUE;
+ try {
+
+ eventType = pullparser.next();
+ if (cache) {
+ //do the necessary to each type of event
+ if (eventType == XmlPullParser.START_DOCUMENT) {
+ processStartDocument();
+ } else if (eventType == XmlPullParser.END_DOCUMENT) {
+ processEndDocument();
+ } else if (eventType == XmlPullParser.START_TAG) {
+ processStartElement();
+ } else if (eventType == XmlPullParser.END_TAG) {
+ processEndElement();
+ } else if (eventType == XmlPullParser.CDSECT) {
+ processCDATA();
+ } else if (eventType == XmlPullParser.COMMENT) {
+ processComment();
+ } else if (eventType == XmlPullParser.TEXT) {
+ processText();
+ }
+ }
+ } catch (XmlPullParserException e) {
+ throw new OMException("parser Exception", e);
+ } catch (IOException e) {
+ throw new OMException("IO Exception", e);
+ } catch (Exception e) {
+ throw new OMException("Unknown process Exception", e);
+ }
+
+ return eventType;
+ }
+
+ /**
+ * Processing the start tag has some more things to than just inserting an
+ * elemnt. It has to update the parent and set up the attributes for that
+ * particular element
+ */
+ private void processStartElement() throws XmlPullParserException{
+
+ int parent = OMConstants.DEFAULT_INT_VALUE;
+ if(!stack.isEmpty()){
+ parent = stack.peek();
+ }
+
+ //insert the element
+ int elementKey = tableModel.addElement(pullparser.getName(),
+ parent);
+
+ //update the namespaces
+ int nsStart = pullparser.getNamespaceCount(pullparser.getDepth()-1);
+ int nsEnd = pullparser.getNamespaceCount(pullparser.getDepth());
+ for (int i = nsStart; i < nsEnd; i++) {
+ String prefix = pullparser.getNamespacePrefix(i);
+ String ns = pullparser.getNamespaceUri(i);
+ tableModel.addNamespace(
+ ns,
+ prefix,
+ elementKey
+ );
+ }
+
+ //set up this elements namespace
+ int namespacekey = this.resolveNamespace(elementKey,
+ pullparser.getNamespace(),
+ pullparser.getPrefix());
+ if (namespacekey!= OMConstants.DEFAULT_INT_VALUE){
+ tableModel.updateElement(elementKey,
+ OMConstants.DEFAULT_STRING_VALUE,
+ namespacekey,
+ OMConstants.UPDATE_NAMESPACE);
+ }
+
+
+ //insert the attributes
+ int attribCount = pullparser.getAttributeCount();
+ int currentAttribKey;
+ int previousAttribKey = OMConstants.DEFAULT_INT_VALUE;
+
+ for (int i = 0; i < attribCount; i++) {
+ currentAttribKey = tableModel.addAttribute(
+ pullparser.getAttributeName(i),
+ pullparser.getAttributeValue(i),
+ elementKey );
+
+ //add the first attribute
+ if (i==0){
+ tableModel.updateElement(elementKey,
+ OMConstants.DEFAULT_STRING_VALUE,
+ currentAttribKey,
+ OMConstants.UPDATE_FIRST_ATTRIBUTE);
+ }
+
+ //update the attribute namespacs
+ namespacekey = this.resolveNamespace(elementKey,
+ pullparser.getAttributeNamespace(i),
+ pullparser.getAttributePrefix(i));
+ if (namespacekey!= OMConstants.DEFAULT_INT_VALUE){
+ tableModel.updateAttribute(currentAttribKey,
+ OMConstants.DEFAULT_STRING_VALUE,
+ namespacekey,
+ OMConstants.UPDATE_NAMESPACE);
+ }
+
+ //update the next sibling of the attribute
+ if (previousAttribKey!=OMConstants.DEFAULT_INT_VALUE){
+ tableModel.updateAttribute(previousAttribKey,
+ OMConstants.DEFAULT_STRING_VALUE,
+ currentAttribKey,
+ OMConstants.UPDATE_NEXT_SIBLING);
+ }
+ previousAttribKey = currentAttribKey;
+ }
+
+ //insert the event
+ tableModel.addEvent(XmlPullParser.START_TAG,elementKey);
+
+ //update the first child
+ //NOTE - order is *very* important here
+ updateFirstChild(elementKey,OMConstants.ELEMENT);
+ //update the sibling
+ updateLastSibling(elementKey,OMConstants.ELEMENT);
+
+ stack.push(elementKey);
+
+ }
+
+ /**
+ * Processsig the end element is simple. Just mark the peek element as
+ * processed and pop it from the stack
+ */
+ private void processEndElement() {
+
+ //mark the element as processed
+ int key = stack.pop();
+ tableModel.updateElement(key,
+ null,
+ OMConstants.DEFAULT_INT_VALUE,
+ OMConstants.UPDATE_DONE);
+
+ //insert the event
+ tableModel.addEvent(XmlPullParser.END_TAG,key);
+
+ //update the siblings
+ lastSibling = key;
+ lastSiblingType = OMConstants.ELEMENT;
+ }
+
+ /**
+ * Process the start docuemnt. this may not
+ * be visible at anytime
+ */
+ private void processStartDocument() {
+ //do nothing!!!!!!!!!
+ }
+
+ /**
+ * Process the end of the document
+ */
+ private void processEndDocument() {
+ //mark the document as done
+ tableModel.setComplete(true);
+ tableModel.addEvent(XmlPullParser.END_DOCUMENT,OMConstants.DEFAULT_INT_VALUE);
+ }
+
+ /**
+ * Process a text node
+ */
+ private void processText() {
+
+ int key = tableModel.addText(
+ pullparser.getText(),
+ stack.peek() //parent
+ );
+
+ //update the first child
+ //NOTE - order is *very* important here
+ updateFirstChild(key,OMConstants.TEXT);
+ updateLastSibling(key,OMConstants.TEXT);
+ tableModel.addEvent(XmlPullParser.TEXT,key);
+
+ }
+
+ /**
+ * process a CDATA section
+ */
+ private void processCDATA() {
+ int key = tableModel.addCDATA(
+ pullparser.getText(),
+ stack.peek() //parent
+ );
+
+ //update the first child
+ //NOTE - order is *very* important here
+ updateFirstChild(key,OMConstants.CDATA);
+ updateLastSibling(key,OMConstants.CDATA);
+ tableModel.addEvent(XmlPullParser.CDSECT,key);
+ }
+
+ /**
+ * Process a comment
+ */
+ private void processComment() {
+ int key = tableModel.addComment(
+ pullparser.getText(),
+ stack.peek() //parent
+ );
+
+ //update the first child
+ //NOTE - order is *very* important here
+ updateFirstChild(key,OMConstants.COMMENT);
+ updateLastSibling(key,OMConstants.COMMENT);
+ tableModel.addEvent(XmlPullParser.COMMENT,key);
+ }
+
+ /**
+ *
+ * @param key
+ * @param type
+ */
+ private void updateFirstChild(int key,int type){
+
+ if (stack.isEmpty())
+ return; //stack is empty. Just return
+
+
+ //at this point the siblings are not yet updated. So if the last sibling (being an element) is
+ //still the parent then that means we have the first child here
+ if (lastSiblingType==OMConstants.ELEMENT && lastSibling == stack.peek()){
+ tableModel.updateElement(stack.peek(),
+ type+"",
+ key,
+ OMConstants.UPDATE_FIRST_CHILD);
+ }
+
+ }
+
+ /**
+ *
+ * @param currentKey
+ * @param type
+ */
+ private void updateLastSibling(int currentKey,int type){
+
+ if (lastSibling != OMConstants.DEFAULT_INT_VALUE ){
+ if (!(lastSiblingType==OMConstants.ELEMENT && lastSibling==stack.peek())){
+ //ths means the last sibling pointer is actually set to the parent element
+ if (lastSiblingType==OMConstants.ELEMENT){
+ tableModel.updateElement(
+ lastSibling,
+ type+"", //type
+ currentKey,
+ OMConstants.UPDATE_NEXT_SIBLING);
+ }else if (lastSiblingType==OMConstants.TEXT ||
+ lastSiblingType==OMConstants.CDATA ||
+ lastSiblingType==OMConstants.COMMENT){
+ tableModel.updateText(
+ lastSibling,
+ type+"", //type
+ currentKey,
+ OMConstants.UPDATE_NEXT_SIBLING);
+ }
+ }
+ }
+ lastSibling = currentKey;
+ lastSiblingType = type;
+ }
+
+ /**
+ *
+ * @param elementKey
+ * @param uri
+ * @param prefix
+ * @return
+ */
+ public int resolveNamespace(int elementKey,String uri,String prefix){
+ return tableModel.resolveNamespace(elementKey,uri,prefix);
+ }
+
+}
\ No newline at end of file
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMAttributeImpl.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMAttributeImpl.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,90 @@
+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));
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMDocumentImpl.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMDocumentImpl.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,61 @@
+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();
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMElementImpl.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMElementImpl.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,176 @@
+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) {
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNameSpaceImpl.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNameSpaceImpl.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,57 @@
+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;
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNodeImpl.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMNodeImpl.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,123 @@
+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 {
+ }
+
+ //
+
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMTextImpl.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/OMTextImpl.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,53 @@
+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));
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/traversal/AttributeIteratorImpl.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/traversal/AttributeIteratorImpl.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,86 @@
+package org.apache.axis.om.impl.traversal;
+
+import org.apache.axis.om.impl.OMAttributeImpl;
+import org.apache.axis.om.impl.OMElementImpl;
+import org.apache.axis.om.util.OMConstants;
+import org.apache.axis.om.OMModel;
+import org.apache.axis.om.OMAttribute;
+
+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 5, 2004
+ * Time: 1:53:12 PM
+ *
+ */
+public class AttributeIteratorImpl implements Iterator {
+
+ private OMAttributeImpl lastAttribute;
+ private OMElementImpl parentElement;
+ private OMModel model;
+
+ /**
+ * Needs both the parent element and the model for this
+ * attribute to be constructed
+ * @param parentElement
+ * @param model
+ */
+ public AttributeIteratorImpl(OMElementImpl parentElement, OMModel model) {
+ this.parentElement = parentElement;
+ this.model = model;
+ }
+
+ /**
+ * @return whether the next attribute is available
+ */
+ public boolean hasNext() {
+ boolean returnVal = true;
+ if (lastAttribute==null){
+ int firstAttribKey = parentElement.getFirstAttributeKey();
+ returnVal = (firstAttribKey!=OMConstants.DEFAULT_INT_VALUE);
+ }else{
+ returnVal = (lastAttribute.getNextSiblingKey()!=OMConstants.DEFAULT_INT_VALUE);
+ }
+ return returnVal;
+ }
+
+
+ /**
+ *
+ * @return the next object for this iterator
+ */
+ public Object next() {
+ if (lastAttribute==null){
+ lastAttribute = (OMAttributeImpl)parentElement.getFirstAttribute();
+ }else{
+ int attribKey = lastAttribute.getNextSiblingKey();
+ if (attribKey!=OMConstants.DEFAULT_INT_VALUE){
+ lastAttribute = (OMAttributeImpl)model.getAttribute(attribKey);
+ }
+ }
+ return lastAttribute;
+ }
+
+
+ /**
+ * remove method is still not implemented
+ */
+ public void remove() {
+ //todo
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/traversal/NodeIteratorImpl.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/impl/traversal/NodeIteratorImpl.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,93 @@
+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!!
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/AbstractPool.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/AbstractPool.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,38 @@
+package org.apache.axis.om.pool;
+
+/**
+ * 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:10:50 PM
+ *
+ * An abstract pool to make the life easier
+ */
+public abstract class AbstractPool implements ObjectPool{
+
+ protected int poolSize = 20;
+
+ /**
+ * the default implementation is to reset the object
+ * while taking it back
+ * @param po
+ */
+ public void putObjectIntoPool(PooledObject po) {
+ po.reset();
+ }
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMAttributePool.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMAttributePool.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,45 @@
+/**
+ * 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:22:35 PM
+ */
+package org.apache.axis.om.pool;
+
+import org.apache.axis.om.impl.OMAttributeImpl;
+
+public class OMAttributePool extends AbstractPool{
+ private static OMAttributePool ourInstance;
+
+ public synchronized static OMAttributePool getInstance() {
+ if (ourInstance == null) {
+ ourInstance = new OMAttributePool();
+ }
+ return ourInstance;
+ }
+
+ private OMAttributePool() {
+ }
+
+ /**
+ *
+ * @return an instance of the OMAttribute
+ */
+ public PooledObject getPooledObject() {
+ return new OMAttributeImpl();
+ }
+}
+
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMElementPool.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMElementPool.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,54 @@
+/**
+ * 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:16:12 PM
+ *
+ * A pool for element nodes
+ * Note - this is singleton
+ */
+package org.apache.axis.om.pool;
+
+import org.apache.axis.om.impl.OMElementImpl;
+
+public class OMElementPool extends AbstractPool{
+
+ private static OMElementPool ourInstance;
+
+
+ public synchronized static OMElementPool getInstance() {
+ if (ourInstance == null) {
+ ourInstance = new OMElementPool();
+ }
+ return ourInstance;
+ }
+
+ private OMElementPool() {
+ }
+
+ /**
+ *
+ * @return an OMElement object
+ */
+ public PooledObject getPooledObject() {
+ return new OMElementImpl();
+ }
+
+ public void putObjectIntoPool(PooledObject po) {
+ super.putObjectIntoPool(po);
+ }
+}
+
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMNameSpacePool.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMNameSpacePool.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,48 @@
+/**
+ * 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:45:17 PM
+ *
+ * A pool for namespace nodes
+ * Note - this is singleton
+ */
+package org.apache.axis.om.pool;
+
+import org.apache.axis.om.impl.OMNameSpaceImpl;
+
+public class OMNameSpacePool extends AbstractPool {
+ private static OMNameSpacePool ourInstance;
+
+ public synchronized static OMNameSpacePool getInstance() {
+ if (ourInstance == null) {
+ ourInstance = new OMNameSpacePool();
+ }
+ return ourInstance;
+ }
+
+ private OMNameSpacePool() {
+ }
+
+ /**
+ *
+ * @return an OMNamepace node
+ */
+ public PooledObject getPooledObject() {
+ return new OMNameSpaceImpl();
+ }
+}
+
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMTextPool.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/OMTextPool.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,49 @@
+/**
+ * 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:27:33 PM
+ * A pool for text nodes
+ * Note - this is singleton
+ */
+package org.apache.axis.om.pool;
+
+import org.apache.axis.om.impl.OMTextImpl;
+
+public class OMTextPool extends AbstractPool {
+
+ private static OMTextPool ourInstance;
+
+ public synchronized static OMTextPool getInstance() {
+ if (ourInstance == null) {
+ ourInstance = new OMTextPool();
+ }
+ return ourInstance;
+ }
+
+ private OMTextPool() {
+ }
+
+ /**
+ *
+ * @return a OMTextImpl object
+ * Note - still not implemented properly
+ */
+ public PooledObject getPooledObject() {
+ return new OMTextImpl();
+ }
+}
+
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/ObjectPool.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/ObjectPool.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,38 @@
+package org.apache.axis.om.pool;
+
+/**
+ * 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:48:26 PM
+ *
+ */
+public interface ObjectPool {
+
+ /**
+ *
+ * @return an object form the pool
+ */
+ PooledObject getPooledObject();
+
+ /**
+ * put an object back in the pool
+ * @param po
+ */
+ void putObjectIntoPool(PooledObject po);
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/PooledObject.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/pool/PooledObject.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,29 @@
+package org.apache.axis.om.pool;
+
+/**
+ * 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:09:08 PM
+ */
+public interface PooledObject {
+
+ /**
+ * A method that resets the pooled objects. Objects that are to be
+ * pooled must implement this interface
+ */
+ void reset();
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/OMStorageException.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/OMStorageException.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,27 @@
+package org.apache.axis.om.storage;
+
+import org.apache.axis.om.OMException;
+
+/**
+ * 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:03:56 PM
+ *
+ * A special version of the OMExcpetion thrown by this storage
+ */
+public class OMStorageException extends OMException {
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/AbstractColumn.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/AbstractColumn.java Wed Oct 6 06:00:47 2004
@@ -0,0 +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;
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/BooleanColumn.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/BooleanColumn.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,71 @@
+package org.apache.axis.om.storage.column;
+
+import org.apache.axis.om.storage.OMStorageException;
+
+/**
+ * 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:15:08 PM
+ *
+ */
+public class BooleanColumn extends AbstractColumn{
+
+ private boolean[] values = new boolean[chunkSize];
+
+ /**
+ * Append a boolean value to this column
+ * @param value
+ */
+ public void appendValue(boolean value){
+ int valueLength = values.length;
+ if (length==valueLength){
+ //make a new array and put all the contents of the older array in that
+ boolean[] newArray = new boolean[valueLength + chunkSize];
+ System.arraycopy(values,0,newArray,0,valueLength);
+ values = newArray;
+ }
+
+ values[length++] = value;
+
+
+ }
+
+ /**
+ * return a boolean given the index
+ * @param index
+ * @return
+ */
+ public boolean getValue(int index){
+ if (index>length)
+ throw new OMStorageException();
+
+ return values[index];
+
+ }
+
+ /**
+ * set the value at a given location
+ * @param index
+ * @param value
+ */
+ public void setValue(int index,boolean value){
+ if (index>length)
+ throw new OMStorageException();
+ values[index] = value ;
+
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/Column.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/Column.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,39 @@
+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: 4:42:04 PM
+ *
+ * A minimum guideline for a column
+ */
+public interface Column {
+
+ /**
+ *
+ * @return the chunk size of a column
+ */
+ int getChunkSize();
+
+ /**
+ * Set the chunk size
+ * @param chunkSize
+ */
+ void setChunkSize(int chunkSize);
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/IntegerColumn.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/IntegerColumn.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,74 @@
+package org.apache.axis.om.storage.column;
+
+import org.apache.axis.om.storage.OMStorageException;
+
+/**
+ * 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: 4:42:54 PM
+ *
+ */
+public class IntegerColumn extends AbstractColumn{
+
+ private int[] values = new int[chunkSize];
+
+
+
+ /**
+ * Append an integer value
+ * @param value
+ */
+ public void appendValue(int value){
+ int valueLength = values.length;
+ if (length==valueLength){
+ //make a new array and put all the contents of the older array in that
+ int[] newArray = new int[valueLength + chunkSize];
+ System.arraycopy(values,0,newArray,0,valueLength);
+ values = newArray;
+ }
+
+ values[length++] = value;
+
+
+ }
+
+
+ /**
+ *
+ * @param index
+ * @return
+ */
+ public int getValue(int index){
+ if (index>length)
+ throw new OMStorageException();
+
+ return values[index];
+
+ }
+
+ /**
+ *
+ * @param index
+ * @param value
+ */
+ public void setValue(int index,int value){
+ if (index>length)
+ throw new OMStorageException();
+ values[index] = value ;
+
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/StringColumn.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/column/StringColumn.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,73 @@
+package org.apache.axis.om.storage.column;
+
+import org.apache.axis.om.storage.OMStorageException;
+
+/**
+ * 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: 4:43:48 PM
+ *
+ */
+public class StringColumn extends AbstractColumn{
+
+
+ private String[] values = new String[chunkSize];
+
+ /**
+ * Append a string value
+ * @param value
+ */
+ public void appendValue(String value){
+ int valueLength = values.length;
+ if (length==valueLength){
+ //make a new array and put all the contents of the older array in that
+ String[] newArray = new String[valueLength + chunkSize];
+ System.arraycopy(values,0,newArray,0,valueLength);
+ values = newArray;
+ }
+
+ values[length++] = value;
+
+
+ }
+
+ /**
+ * get the string value
+ * @param index
+ * @return
+ */
+ public String getValue(int index){
+ if (index>length)
+ throw new OMStorageException();
+
+ return values[index];
+
+ }
+
+ /**
+ * Set the value at a given location
+ * @param index
+ * @param value
+ */
+ public void setValue(int index,String value){
+ if (index>length)
+ throw new OMStorageException();
+ values[index] = value ;
+
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/AbstractTable.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/AbstractTable.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,63 @@
+package org.apache.axis.om.storage.table;
+
+import org.apache.axis.om.storage.column.IntegerColumn;
+import org.apache.axis.om.util.Sequence;
+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:21:16 PM
+ *
+ */
+public abstract class AbstractTable implements Table{
+
+ protected IntegerColumn keyColumn = new IntegerColumn();
+ protected Sequence pkGenerator = new Sequence();
+
+ /**
+ * returns the size of the table
+ * Note that this only takes into account the
+ * size of the key column and hence even the removed ones
+ * will be counted!
+ * @return
+ */
+ public int getSize(){
+ return keyColumn.getCurrentSize();
+ }
+
+ /**
+ * searches for the presence of a given key
+ * @param key
+ * @return
+ */
+ public boolean isKeyPresent(int key){
+ return ((key != OMConstants.DEFAULT_INT_VALUE) && (key < this.getSize()) && keyColumn.getValue(key) != OMConstants.DEFAULT_INT_VALUE);
+ }
+
+ /**
+ * implement this seperately for other tables if the need arises to reset ALL the columns
+ * this default implementation only erases the key (actually replace it with the default value)
+ * If this is to be re written then it would be better to override the isKeyPresnt method as well
+ * @param key
+ */
+ protected void reset(int key){
+ this.keyColumn.setValue(key,OMConstants.DEFAULT_INT_VALUE);
+
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/AttributeTable.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/AttributeTable.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,148 @@
+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)
+
+ );
+
+
+ }
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/ElementTable.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/ElementTable.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,199 @@
+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)
+
+ );
+
+
+ }
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/EventTable.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/EventTable.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,103 @@
+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)
+
+
+ );
+
+
+ }
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/NameSpaceTable.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/NameSpaceTable.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,129 @@
+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)
+ );
+
+
+ }
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/NodeTable.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/NodeTable.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,30 @@
+package org.apache.axis.om.storage.table;
+
+import org.apache.axis.om.storage.column.IntegerColumn;
+
+/**
+ * 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:57:11 PM
+ *
+ * A simple abstraction to make the life easier with Attribute and Element tables
+ */
+public abstract class NodeTable extends AbstractTable{
+
+ protected IntegerColumn parentColumn = new IntegerColumn();
+ protected IntegerColumn nextSiblingColumn = new IntegerColumn();
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/Table.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/Table.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,28 @@
+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();
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/TextTable.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/storage/table/TextTable.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,116 @@
+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)
+
+ );
+
+
+ }
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/IntegerStack.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/IntegerStack.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,85 @@
+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 28, 2004
+ * Time: 1:17:22 PM
+ *
+ * This is a minimum integer stack. I wanted a simpler stack that does not have the
+ * overhead of the List. that is why the standard stack is not used. Besides I just want
+ * to have ints in my stack!
+ */
+public class IntegerStack {
+
+ private static int CHUNK_SIZE=10;
+ private int[] values = new int[CHUNK_SIZE];
+ private int length = 0;
+
+ /**
+ * Push the value
+ * @param val
+ */
+ public void push(int val){
+ int valueLength = values.length;
+ if (length==valueLength){
+ //make a new array and put all the contents of the older array in that
+ int[] newArray = new int[valueLength + CHUNK_SIZE];
+ System.arraycopy(values,0,newArray,0,valueLength);
+ values = newArray;
+ }
+
+ values[length++] = val;
+ }
+
+ /**
+ * pop the value
+ * @return
+ */
+ public int pop(){
+ if (length>0){
+ return values[--length];
+ }else{
+ throw new RuntimeException("Stack is Empty!!!");
+ }
+
+ }
+
+ /**
+ * have alook at the top most value
+ * @return
+ */
+ public int peek(){
+ return values[length-1];
+ }
+
+ /**
+ * Rest the stack
+ */
+ public void reset(){
+ values = new int[CHUNK_SIZE];
+ length = 0;
+ }
+
+ /**
+ * Check whether the stack is empty
+ * @return
+ */
+ public boolean isEmpty(){
+ return (length==0);
+ }
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/OMConstants.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/OMConstants.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,66 @@
+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";
+
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/Sequence.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/java/org/apache/axis/om/util/Sequence.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,39 @@
+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:35:12 PM
+ *
+ * This is semantically equal to a database stack
+ */
+public class Sequence {
+ private int value = 0;
+
+ /**
+ *
+ * @return the next value of the sequence
+ */
+ public int nextVal(){
+ if (value==Integer.MAX_VALUE)
+ value=0;
+
+ return value++;
+ }
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/soapmessage.xml
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/soapmessage.xml Wed Oct 6 06:00:47 2004
@@ -0,0 +1,15 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing">
+ <soapenv:Header>
+ <wsa:MessageID soapenv:mustUnderstand="0">uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID>
+ <wsa:To soapenv:mustUnderstand="0">http://localhost:8081/axis/services/BankPort</wsa:To>
+ <wsa:From soapenv:mustUnderstand="0">
+ <Address xmlns="http://schemas.xmlsoap.org/ws/2004/03/addressing">http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</Address>
+ </wsa:From>
+ </soapenv:Header>
+ <soapenv:Body>
+ <ns1:getBalance soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://localhost:8081/axis/services/BankPort">
+ <accountNo href="#id0"/>
+ </ns1:getBalance>
+ <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1001</multiRef>
+ </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/soapmessage1.xml
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/soapmessage1.xml Wed Oct 6 06:00:47 2004
@@ -0,0 +1 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" attr1="val1" attr2="val2"><soapenv:Header><wsa:MessageID soapenv:mustUnderstand="0">uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID><wsa:To soapenv:mustUnderstand="0">http://localhost:8081/axis/services/BankPort</wsa:To><wsa:From soapenv:mustUnderstand="0"><Address xmlns="http://schemas.xmlsoap.org/ws/2004/03/addressing">http://schemas.xmlsoap.org/ws/2004/<!-- Hi this is a comment-->03/addressing/role/anonymous</Address></wsa:From></soapenv:Header><soapenv:Body><ns1:getBalance soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://localhost:8081/axis/services/BankPort"><accountNo href="#id0"/></ns1:getBalance><multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1001</multiRef></soapenv:Body></soapenv:Envelope>
\ No newline at end of file
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/testFile.xml
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/testFile.xml Wed Oct 6 06:00:47 2004
@@ -0,0 +1,7 @@
+<root>
+ <name type="original">
+ <firstname>Ajith</firstname>
+ <surname>Ranabahu</surname>
+ </name>
+ <age>26</age>
+</root>
\ No newline at end of file
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/tester-out.xml
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test-resources/tester-out.xml Wed Oct 6 06:00:47 2004
@@ -0,0 +1 @@
+<soapenv:Envelope xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><wsa:MessageID soapenv:mustUnderstand="0">uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID><wsa:To soapenv:mustUnderstand="0">http://localhost:8081/axis/services/BankPort</wsa:To><wsa:From soapenv:mustUnderstand="0"><Address xmlns="http://schemas.xmlsoap.org/ws/2004/03/addressing">http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</Address></wsa:From><wsa:RelatesTo soapenv:mustUnderstand="0" RelationshipType="wsa:Reply">uuid:3821F4F0-D020-11D8-A10A-E4EE6425FCB0</wsa:RelatesTo></soapenv:Header></soapenv:Envelope>
\ No newline at end of file
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModelTest.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/OMModelTest.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,181 @@
+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+" #########################");
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/PullGeneratorTester.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/PullGeneratorTester.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,101 @@
+package org.apache.axis.om;
+
+import junit.framework.TestCase;
+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: Sep 30, 2004
+ * Time: 10:05:56 PM
+ */
+public class PullGeneratorTester extends TestCase{
+
+ OMModel model;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ XmlPullParser parser = MXParserFactory.newInstance().newPullParser();
+ parser.setInput(new FileReader("test-resources/soapmessage1.xml"));
+ StreamingOMBuilder builder = new StreamingOMBuilder(parser);
+ model = builder.getTableModel();
+ }
+
+
+ /**
+ * Generate the pull events directly from the stream with no caching
+ */
+ public void testFullStream(){
+ System.out.println("------------ Testing full stream ------------------");
+ System.out.println("------------ Model dump ------------------");
+ ((OMModelImpl)model).dump();
+ System.out.println("------------------- end of model dump----------------------------");
+ PullEventGenerator pg = new PullEventGenerator(model);
+ int event =XmlPullParser.START_DOCUMENT;
+ while(event!=XmlPullParser.END_DOCUMENT){
+ event=pg.generatePullEvent();
+ System.out.println("Event = "+event);
+ }
+ }
+
+ /**
+ * parse the document fully and generate the pull events
+ */
+ public void testFullObjectModel(){
+
+ while(!model.isComplete())
+ model.proceed();
+ System.out.println("------------ Testing full model ------------------");
+ System.out.println("------------ Model dump ------------------");
+ ((OMModelImpl)model).dump();
+ System.out.println("------------------- end of model dump----------------------------");
+ PullEventGenerator pg = new PullEventGenerator(model);
+
+ int event =XmlPullParser.START_DOCUMENT;
+ while(event!=XmlPullParser.END_DOCUMENT){
+ event=pg.generatePullEvent();
+ System.out.println("Event = "+event);
+ }
+ }
+
+
+ /**
+ * Parse the document halfway an generate the pull events
+ */
+ public void testPartialObjectModel(){
+
+ //this forces the document to partially build
+ Iterator it = model.getDocument().getDocumentElement().getChildren();
+ it.next();
+ it.next();
+
+ int i=0;
+
+ System.out.println("------------ Testing full model ------------------");
+ System.out.println("------------ Model dump ------------------");
+ ((OMModelImpl)model).dump();
+ System.out.println("------------------- end of model dump----------------------------");
+ PullEventGenerator pg = new PullEventGenerator(model);
+ int event =XmlPullParser.START_DOCUMENT;
+ while(event!=XmlPullParser.END_DOCUMENT){
+ event=pg.generatePullEvent();
+ System.out.println(i++ +" Event = "+event);
+ }
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/AttributeTableTest.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/AttributeTableTest.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,62 @@
+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+"");
+ }
+ }
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/ElementTableTest.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/storage/table/ElementTableTest.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,92 @@
+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);
+ }
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/util/IntegerStackTest.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/ajith_deepal/omTableModel/src/test/org/apache/axis/om/util/IntegerStackTest.java Wed Oct 6 06:00:47 2004
@@ -0,0 +1,84 @@
+package org.apache.axis.om.util;
+
+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: 1:29:23 PM
+ */
+public class IntegerStackTest extends TestCase{
+
+ private IntegerStack stack = null;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ stack = new IntegerStack();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ stack=null;
+ }
+
+ public void testPop(){
+ stack.reset();
+ stack.push(10);
+ stack.push(20);
+ stack.push(30);
+
+ assertEquals(stack.pop(),30);
+ assertEquals(stack.pop(),20);
+ assertEquals(stack.pop(),10);
+
+
+ }
+
+ public void testPeek(){
+ stack.reset();
+ stack.push(10);
+ stack.push(20);
+ stack.push(30);
+
+ assertEquals(stack.peek(),30);
+ stack.pop();
+ assertEquals(stack.peek(),20);
+ stack.pop();
+ assertEquals(stack.peek(),10);
+
+
+ }
+
+ public void tetsIsEmpty(){
+
+ stack.reset();
+ assertEquals(stack.isEmpty(),true);
+
+ stack.push(10);
+ assertEquals(stack.isEmpty(),false);
+ }
+
+ public void testExpansion(){
+ stack.reset();
+ for (int i = 0; i < 15; i++) {
+ stack.push(i+10);
+ }
+ assertEquals(stack.peek(),24);
+ }
+
+
+}