You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mirae-dev@ws.apache.org by da...@apache.org on 2005/02/03 13:41:11 UTC

svn commit: r151149 [5/19] - in webservices/mirae/trunk: ./ bin/ bin/linux/ bin/windows/ build/ docs/ docs/images/ docs/images/CVS/ docs/javadoc/ genstub/ genstub/example8/ genstub/lk/ genstub/lk/opensource/ genstub/lk/opensource/wsmobile/ genstub/org/ genstub/org/apache/ genstub/org/apache/mirae/ genstub/org/apache/mirae/builtin/ genstub/org/apache/mirae/builtin/simpletypes/ genstub/uk/ genstub/uk/co/ genstub/uk/co/dsdata/ genstub/uk/co/dsdata/ws/ genstub/uk/co/dsdata/ws/travel/ genstub/uk/co/dsdata/ws/travel/sbg/ genstub/uk/co/dsdata/ws/travel/sbg/SBGAirFareQuotes/ genstub/ws_mobile_point/ lib/ logs/ samples/ samples/documentsamples/ samples/documentsamples/calculator/ samples/documentsamples/calculator/calculator/ samples/documentsamples/calculator/calculator/axis/ samples/documentsamples/calculator/calculator/axis/localhost/ samples/documentsamples/calculator/org/ samples/documentsamples/calculator/org/apache/ samples/documentsamples/calculator/org/apache/mirae/ samples/documentsamples/calculator/org/apache/mirae/builtin/ samples/documentsamples/calculator/org/apache/mirae/builtin/simpletypes/ samples/documentsamples/echo/ samples/documentsamples/echo/org/ samples/documentsamples/echo/org/apache/ samples/documentsamples/echo/org/apache/mirae/ samples/documentsamples/echo/org/apache/mirae/builtin/ samples/documentsamples/echo/org/apache/mirae/builtin/simpletypes/ samples/documentsamples/echo/org/soapinterop/ samples/documentsamples/employee/ samples/documentsamples/employee/jSR172UseCases/ samples/documentsamples/employee/jSR172UseCases/com/ samples/documentsamples/employee/jSR172UseCases/com/sun/ samples/documentsamples/employee/jSR172UseCases/com/sun/www/ samples/documentsamples/employee/org/ samples/documentsamples/employee/org/apache/ samples/documentsamples/employee/org/apache/mirae/ samples/documentsamples/employee/org/apache/mirae/builtin/ samples/documentsamples/employee/org/apache/mirae/builtin/simpletypes/ samples/documentsamples/employee/xsd/ samples/documentsamples/employee/xsd/JSR172AppendixA/ samples/documentsamples/employee/xsd/JSR172AppendixA/com/ samples/documentsamples/employee/xsd/JSR172AppendixA/com/sun/ samples/documentsamples/employee/xsd/JSR172AppendixA/com/sun/www/ samples/rpcsamples/ samples/rpcsamples/airfarequote/ samples/rpcsamples/airfarequote/org/ samples/rpcsamples/airfarequote/org/apache/ samples/rpcsamples/airfarequote/org/apache/mirae/ samples/rpcsamples/airfarequote/org/apache/mirae/builtin/ samples/rpcsamples/airfarequote/org/apache/mirae/builtin/simpletypes/ samples/rpcsamples/airfarequote/uk/ samples/rpcsamples/airfarequote/uk/co/ samples/rpcsamples/airfarequote/uk/co/dsdata/ samples/rpcsamples/airfarequote/uk/co/dsdata/ws/ samples/rpcsamples/airfarequote/uk/co/dsdata/ws/travel/ samples/rpcsamples/airfarequote/uk/co/dsdata/ws/travel/sbg/ samples/rpcsamples/airfarequote/uk/co/dsdata/ws/travel/sbg/SBGAirFareQuotes/ samples/rpcsamples/calculator/ samples/rpcsamples/calculator/lk/ samples/rpcsamples/calculator/lk/opensource/ samples/rpcsamples/calculator/lk/opensource/wsmobile/ samples/rpcsamples/calculator/org/ samples/rpcsamples/calculator/org/apache/ samples/rpcsamples/calculator/org/apache/mirae/ samples/rpcsamples/calculator/org/apache/mirae/builtin/ samples/rpcsamples/calculator/org/apache/mirae/builtin/simpletypes/ samples/rpcsamples/distance/ samples/rpcsamples/distance/org/ samples/rpcsamples/distance/org/apache/ samples/rpcsamples/distance/org/apache/mirae/ samples/rpcsamples/distance/org/apache/mirae/builtin/ samples/rpcsamples/distance/org/apache/mirae/builtin/simpletypes/ samples/rpcsamples/distance/wsdl/ samples/rpcsamples/distance/wsdl/DistanceService/ samples/rpcsamples/distance/wsdl/DistanceService/sd/ samples/rpcsamples/distance/wsdl/DistanceService/sd/net/ samples/rpcsamples/distance/wsdl/DistanceService/sd/net/xmethods/ samples/rpcsamples/distance/wsdl/DistanceService/sd/net/xmethods/www/ samples/rpcsamples/point/ samples/rpcsamples/point/org/ samples/rpcsamples/point/org/apache/ samples/rpcsamples/point/org/apache/mirae/ samples/rpcsamples/point/org/apache/mirae/builtin/ samples/rpcsamples/point/org/apache/mirae/builtin/simpletypes/ samples/rpcsamples/point/ws_mobile_point/ samples/rpcsamples/student/ samples/rpcsamples/student/example8/ samples/rpcsamples/student/org/ samples/rpcsamples/student/org/apache/ samples/rpcsamples/student/org/apache/mirae/ samples/rpcsamples/student/org/apache/mirae/builtin/ samples/rpcsamples/student/org/apache/mirae/builtin/simpletypes/ src/ src/mirae/ src/mirae/jaxp/ src/mirae/jaxp/javax/ src/mirae/jaxp/javax/xml/ src/mirae/jaxp/javax/xml/parsers/ src/mirae/jaxp/org/ src/mirae/jaxp/org/apache/ src/mirae/jaxp/org/apache/mirae/ src/mirae/jaxp/org/apache/mirae/j2me/ src/mirae/jaxp/org/apache/mirae/j2me/xml/ src/mirae/jaxp/org/apache/mirae/j2me/xml/sax/ src/mirae/jaxp/org/xml/ src/mirae/jaxp/org/xml/sax/ src/mirae/jaxp/org/xml/sax/helpers/ src/mirae/jaxrpc/ src/mirae/jaxrpc/javax/ src/mirae/jaxrpc/javax/xml/ src/mirae/jaxrpc/javax/xml/namespace/ src/mirae/jaxrpc/javax/xml/rpc/ src/mirae/jaxrpc/org/ src/mirae/jaxrpc/org/apache/ src/mirae/jaxrpc/org/apache/mirae/ src/mirae/jaxrpc/org/apache/mirae/util/ src/mirae/jaxrpc/org/apache/mirae/xml/ src/mirae/jaxrpc/org/apache/mirae/xml/rpc/ src/tools/ src/tools/simpletypes/ src/tools/wsdl2ws_j2me/ src/tools/wsdl2ws_j2me/org/ src/tools/wsdl2ws_j2me/org/apache/ src/tools/wsdl2ws_j2me/org/apache/axis/ src/tools/wsdl2ws_j2me/org/apache/axis/wsdl/ src/tools/wsdl2ws_j2me/org/apache/axis/wsdl/symbolTable/ src/tools/wsdl2ws_j2me/org/apache/mirae/ src/tools/wsdl2ws_j2me/org/apache/mirae/wsdl2ws/ src/tools/wsdl2ws_j2me/org/apache/mirae/wsdl2ws/doclit/ src/tools/wsdl2ws_j2me/org/apache/mirae/wsdl2ws/info/ src/tools/wsdl2ws_j2me/org/apache/mirae/wsdl2ws/j2me/ src/tools/wsdl2ws_j2me/org/apache/mirae/wsdl2ws/j2me/client/ src/tools/wsdl2ws_j2me/org/apache/mirae/wsdl2ws/rpc/ tests/ tests/functional/ tests/functional/client/ tests/functional/client/SBGGetAirFareQuote-client1/ tests/functional/client/SBGGetAirFareQuote-client2/ tests/functional/client/calculator/ tests/functional/client/point/ tests/functional/client/wst/ tests/functional/wsdl/ tests/unit/ tests/unit/inmessage/ tests/unit/mirae/ tests/unit/outmessage/ tests/unit/wsdl2ws/ wsdl/ wsdltests/ wsdltests/calculator/ wsdltests/calculator/client/ wsdltests/calculator/server/ wsdltests/exceptiontest/ wsdltests/exceptiontest/client/ wsdltests/exceptiontest/server/ wsdltests/interoptestround1/ wsdltests/interoptestround1/client/ wsdltests/interoptestround1/server/

Added: webservices/mirae/trunk/samples/rpcsamples/student/example8/Student.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/samples/rpcsamples/student/example8/Student.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/samples/rpcsamples/student/example8/Student.java (added)
+++ webservices/mirae/trunk/samples/rpcsamples/student/example8/Student.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,114 @@
+package example8;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+/**
+ * <p>This class is genarated by the tool WSDL2WS_J2ME.
+ * It take care of the serialization and the desirialization of
+ * the parameter types. 
+*/public class Student  implements org.apache.mirae.xml.rpc.InOutParameter{
+	private java.util.Vector obj;
+	
+private org.apache.mirae.xml.rpc.InOutParameter childObj;	private java.lang.String name;
+	private java.lang.String[] detail;
+	 private example8.ArrayOf_xsd_string arrayT1;
+
+	public Student(){
+		obj=new java.util.Vector();
+	}
+	public Student(java.lang.String name,java.lang.String[] detail){
+		this.name = name;
+		this.detail = detail;
+	}
+
+
+	public void decode(String uri, String localName, String qName, Attributes attributes, String value)throws SAXException {
+				int localNameHash = qName.hashCode();
+				switch(localNameHash){
+					case 3373707:
+						this.name = (new org.apache.mirae.builtin.simpletypes.StringParam(value)).getParam();
+						break;
+					case -1335224239:
+						break;
+					 default:
+						 if (childObj!=null)
+							 childObj.decode(uri,localName,qName,attributes,value);
+						 	else
+							 throw new SAXException("unknown tag find "+ qName);
+				 }
+
+	}
+
+	public void endElement(String uri, String localName, String qName) throws SAXException {
+				int localNameHash = qName.hashCode();
+				switch(localNameHash){
+					case 3373707:
+						break;
+					case -1335224239:
+							 arrayT1.createArray();
+							this.detail=arrayT1.getParam();
+						break;
+					 default:
+						 if (childObj!=null)
+							 childObj.endElement(uri,localName,qName);
+						 	else
+							 throw new SAXException("unknown tag find "+ qName);
+					 }
+
+	}
+
+	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+				int localNameHash = qName.hashCode();
+				switch(localNameHash){
+					case 3373707:
+						break;
+					case -1335224239:
+						 arrayT1 = (new example8.ArrayOf_xsd_string());
+						childObj=arrayT1;
+						break;
+					 default:
+						 if (childObj!=null)
+							 childObj.startElement(uri,localName,qName,attributes);
+						 	else
+							 throw new SAXException("unknown tag find "+ qName);
+				 }
+
+	}
+	 public void createArray()throws SAXException {
+
+	}
+
+	public void serialize(StringBuffer buffer)throws java.io.IOException, Exception{
+		java.lang.String m_URI ="urn:Example8";
+		java.lang.String type_name = "Student";
+		//write the parameters
+
+		buffer.append("<name>");
+		if(this.name!=null){
+			buffer.append(java.lang.String.valueOf(name));
+		}
+		buffer.append("</name>\n");
+
+		buffer.append("<detail xsi:type=\"soapenc:Array\" soapenc:arrayType=\"ns2:ArrayOf_xsd_string[]\" xmlns:ns2 = \"urn:Example8\">");
+		if(this.detail!=null){
+			buffer.append("\n");
+			example8.ArrayOf_xsd_string item1 = new example8.ArrayOf_xsd_string();
+			item1.setParam(detail);
+			item1.serialize(buffer);
+		}
+		buffer.append("</detail>\n");
+
+	}
+
+	public void setName(java.lang.String name){
+		this.name = name;
+	}
+	public java.lang.String getName(){
+		return name;
+	}
+	public void setDetail(java.lang.String[] detail){
+		this.detail = detail;
+	}
+	public java.lang.String[] getDetail(){
+		return detail;
+	}
+}

Added: webservices/mirae/trunk/samples/rpcsamples/student/example8/StudentOpIF.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/samples/rpcsamples/student/example8/StudentOpIF.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/samples/rpcsamples/student/example8/StudentOpIF.java (added)
+++ webservices/mirae/trunk/samples/rpcsamples/student/example8/StudentOpIF.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,10 @@
+package example8;
+/*This interface is automatically generated by 
+*WSDL2WS_J2ME tool
+*The client side representation of the web service. 
+*/
+
+public interface StudentOpIF   {
+	public java.lang.String getStudentDetail(java.lang.String param0)throws Exception;
+	public example8.Student getStudentObj(java.lang.String param0)throws Exception;
+}

Added: webservices/mirae/trunk/samples/rpcsamples/student/example8/StudentOpStub.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/samples/rpcsamples/student/example8/StudentOpStub.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/samples/rpcsamples/student/example8/StudentOpStub.java (added)
+++ webservices/mirae/trunk/samples/rpcsamples/student/example8/StudentOpStub.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,52 @@
+package example8;
+/*This class is automatically generated by 
+*WSDL2WS_J2ME tool
+*The client side stub of the web service. 
+*/
+
+public class StudentOpStub implements example8.StudentOpIF{
+
+	private java.lang.String enduri;
+	private javax.xml.namespace.QName SOAPAction;
+	public StudentOpStub() throws Exception{
+		this.enduri="http://localhost:8080/axis/services/Student";
+		this.SOAPAction = new javax.xml.namespace.QName("StudentOpService");
+	}
+
+	public StudentOpStub(java.lang.String enduri) throws Exception {
+		this.enduri = enduri;
+		this.SOAPAction = new javax.xml.namespace.QName("StudentOpService");
+	}
+
+	public java.lang.String getStudentDetail(java.lang.String param0) throws Exception{
+		javax.xml.namespace.QName methodName = new javax.xml.namespace.QName("urn:Example8","getStudentDetail");
+		org.apache.mirae.xml.rpc.Call call = new org.apache.mirae.xml.rpc.Call();
+		call.setStyle(org.apache.mirae.util.Constants.STYLE_RPC);
+		call.setOperationName(methodName);
+		call.setSoapActonURI(SOAPAction);
+		org.apache.mirae.builtin.simpletypes.StringParam op0 = new org.apache.mirae.builtin.simpletypes.StringParam(param0);
+		call.addParameter(op0,"param0",new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));
+		call.setTargetEndpointAddress(this.enduri);
+		call.setReturnCategory(org.apache.mirae.util.Constants.TYPE_SIMPLE);
+		call.setReturnType( new org.apache.mirae.builtin.simpletypes.StringParam());
+		org.apache.mirae.builtin.simpletypes.StringParam res = (org.apache.mirae.builtin.simpletypes.StringParam)call.invoke();
+		return new java.lang.String(res.getParam());
+
+	}
+
+	public example8.Student getStudentObj(java.lang.String param0) throws Exception{
+		javax.xml.namespace.QName methodName = new javax.xml.namespace.QName("urn:Example8","getStudentObj");
+		org.apache.mirae.xml.rpc.Call call = new org.apache.mirae.xml.rpc.Call();
+		call.setStyle(org.apache.mirae.util.Constants.STYLE_RPC);
+		call.setOperationName(methodName);
+		call.setSoapActonURI(SOAPAction);
+		org.apache.mirae.builtin.simpletypes.StringParam op0 = new org.apache.mirae.builtin.simpletypes.StringParam(param0);
+		call.addParameter(op0,"param0",new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));
+		call.setTargetEndpointAddress(this.enduri);
+		call.setReturnCategory(org.apache.mirae.util.Constants.TYPE_COMPLEX);
+		call.setReturnType( new example8.Student());
+		example8.Student res = (example8.Student)call.invoke();
+		 return res;
+
+	}
+}

Added: webservices/mirae/trunk/samples/rpcsamples/student/org/apache/mirae/builtin/simpletypes/StringParam.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/samples/rpcsamples/student/org/apache/mirae/builtin/simpletypes/StringParam.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/samples/rpcsamples/student/org/apache/mirae/builtin/simpletypes/StringParam.java (added)
+++ webservices/mirae/trunk/samples/rpcsamples/student/org/apache/mirae/builtin/simpletypes/StringParam.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mirae.builtin.simpletypes;
+
+import java.io.IOException;
+
+
+import org.apache.mirae.xml.rpc.InOutParameter;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+
+
+public class StringParam implements InOutParameter {
+	public String param;
+
+	public StringParam() {
+	}
+
+	public StringParam(String param) {
+		this.param = param;
+	}
+	
+	public void decode(String uri, String localName, String qName, Attributes attributes, String value)throws SAXException {
+		this.param=value;		
+	}
+
+	public void serialize(StringBuffer buffer) throws IOException,Exception {
+
+			buffer.append(param);
+		
+	}
+
+	public String getParam() {
+		return param;
+	}
+
+	public String toString() {
+		return param;
+	}
+
+	/* (non-Javadoc)
+	 * @see j2me.xml.rpc.InOutParameter#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
+	 */
+	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+		// TODO Auto-generated method stub
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see j2me.xml.rpc.InOutParameter#endElement(java.lang.String, java.lang.String, java.lang.String)
+	 */
+	public void endElement(String uri, String localName, String qName) throws SAXException {
+		// TODO Auto-generated method stub
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see j2me.xml.rpc.InOutParameter#createArray()
+	 */
+	public void createArray() throws SAXException {
+		// TODO Auto-generated method stub
+		
+	}
+
+		
+
+}

Added: webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/FactoryConfigurationError.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/FactoryConfigurationError.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/FactoryConfigurationError.java (added)
+++ webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/FactoryConfigurationError.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.xml.parsers;
+
+/**
+ * Thrown when a problem with configuration with the Parser Factories
+ * exists. This error will typically be thrown when the class of a
+ * parser factory specified in the system properties cannot be found
+ * or instantiated.
+ *
+ * @author Ias (iasandcb@tmax.co.kr)
+ */
+
+public class FactoryConfigurationError extends Error {
+
+    /**
+     * Create a new <code>FactoryConfigurationError</code> with
+     * the <code>String </code> specified as an error message.
+     *
+     * @param msg The error message for the exception.
+     */
+    
+    public FactoryConfigurationError(String msg) {
+        super(msg);
+    }
+
+}
\ No newline at end of file

Added: webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/ParserConfigurationException.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/ParserConfigurationException.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/ParserConfigurationException.java (added)
+++ webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/ParserConfigurationException.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.xml.parsers;
+
+/**
+ * Indicates a serious configuration error.
+ *
+ * @author Ias (iasandcb@tmax.co.kr)
+ */
+
+public class ParserConfigurationException extends Exception {
+
+    /**
+     * Create a new <code>ParserConfigurationException</code> with no
+     * detail mesage.
+     */
+
+    public ParserConfigurationException() {
+        super();
+    }
+
+    /**
+     * Create a new <code>ParserConfigurationException</code> with
+     * the <code>String</code> specified as an error message.
+     *
+     * @param msg The error message for the exception.
+     */
+    
+    public ParserConfigurationException(String msg) {
+        super(msg);
+    }
+
+}
\ No newline at end of file

Added: webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/SAXParser.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/SAXParser.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/SAXParser.java (added)
+++ webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/SAXParser.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.xml.parsers;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Defines the API that wraps an {@link org.xml.sax.XMLReader}
+ * implementation class. In JAXP 1.0, this class wrapped the
+ * {@link org.xml.sax.Parser} interface, however this interface was
+ * replaced by the {@link org.xml.sax.XMLReader}. For ease
+ * of transition, this class continues to support the same name
+ * and interface as well as supporting new methods.
+ *
+ * An instance of this class can be obtained from the
+ * {@link javax.xml.parsers.SAXParserFactory#newSAXParser()} method.
+ * Once an instance of this class is obtained, XML can be parsed from
+ * a variety of input sources. These input sources are InputStreams,
+ * Files, URLs, and SAX InputSources.<p>
+ *
+ *
+ * As the content is parsed by the underlying parser, methods of the
+ * given {@link org.xml.sax.HandlerBase} or the
+ * {@link org.xml.sax.helpers.DefaultHandler} are called.<p>
+ *
+ * Implementors of this class which wrap an underlying implementation
+ * can consider using the {@link org.xml.sax.helpers.ParserAdapter}
+ * class to initially adapt their SAX1 impelemntation to work under
+ * this revised class.<p>
+ *
+ * An implementation of <code>SAXParser</code> is <em>NOT</em> 
+ * guaranteed to behave as per the specification if it is used concurrently by 
+ * two or more threads. It is recommended to have one instance of the
+ * <code>SAXParser</code> per thread or it is upto the application to 
+ * make sure about the use of <code>SAXParser</code> from more than one
+ * thread.
+ *
+ * @author Ias (iasandcb@tmax.co.kr)
+ */
+
+public abstract class SAXParser {
+
+	protected SAXParser() {
+
+	}
+
+	/**
+	 * Parse the content of the given {@link java.io.InputStream}
+	 * instance as XML using the specified
+	 * {@link org.xml.sax.helpers.DefaultHandler}.
+	 *
+	 * @param is InputStream containing the content to be parsed.
+	 * @param dh The SAX DefaultHandler to use.
+	 * @exception IOException If any IO errors occur.
+	 * @exception IllegalArgumentException If the given InputStream is null.
+	 * @exception SAXException If the underlying parser throws a
+	 * SAXException while parsing.
+	 * @see org.xml.sax.DocumentHandler
+	 */
+
+	public abstract void parse(InputStream is, DefaultHandler dh) throws SAXException, IOException;
+
+	/**
+	 * Parse the content given {@link org.xml.sax.InputSource}
+	 * as XML using the specified
+	 * {@link org.xml.sax.helpers.DefaultHandler}.
+	 *
+	 * @param is The InputSource containing the content to be parsed.
+	 * @param dh The SAX DefaultHandler to use.
+	 * @exception IOException If any IO errors occur.
+	 * @exception IllegalArgumentException If the InputSource is null.
+	 * @exception SAXException If the underlying parser throws a
+	 * SAXException while parsing.
+	 * @see org.xml.sax.DocumentHandler
+	 */
+
+	public abstract void parse(InputSource is, DefaultHandler dh) throws SAXException, IOException;
+
+	/**
+	 * Indicates whether or not this parser is configured to
+	 * understand namespaces.
+	 *
+	 * @return true if this parser is configured to
+	 *         understand namespaces; false otherwise.
+	 */
+
+	public abstract boolean isNamespaceAware();
+
+	/**
+	 * Indicates whether or not this parser is configured to
+	 * validate XML documents.
+	 *
+	 * @return true if this parser is configured to
+	 *         validate XML documents; false otherwise.
+	 */
+
+	public abstract boolean isValidating();
+
+}

Added: webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/SAXParserFactory.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/SAXParserFactory.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/SAXParserFactory.java (added)
+++ webservices/mirae/trunk/src/mirae/jaxp/javax/xml/parsers/SAXParserFactory.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,205 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.xml.parsers;
+
+import org.apache.mirae.j2me.xml.SAXParserFactoryImpl;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+/**
+ * Defines a factory API that enables applications to configure and
+ * obtain a SAX based parser to parse XML documents.<p>
+ * An implementation of the <code>SAXParserFactory</code> class is
+ * <em>NOT</em> guaranteed to be thread safe. It is up to the user application 
+ * to make sure about the use of the <code>SAXParserFactory</code> from 
+ * more than one thread. Alternatively the application can have one instance 
+ * of the <code>SAXParserFactory</code> per thread.
+ * An application can use the same instance of the factory to obtain one or 
+ * more instances of the <code>SAXParser</code> provided the instance
+ * of the factory isn't being used in more than one thread at a time.
+ * <p>
+ *
+ * The static <code>newInstance</code> method returns a new concrete 
+ * implementation of this class.
+ *
+ * @author Ias (iasandcb@tmax.co.kr)
+ */
+
+public abstract class SAXParserFactory {
+    private boolean validating = false;
+    private boolean namespaceAware= false;
+    
+    protected SAXParserFactory () {
+    
+    }
+
+    /**
+     * Obtain a new instance of a <code>SAXParserFactory</code>. This
+     * static method creates a new factory instance
+     * This method uses the following ordered lookup procedure to determine
+     * the <code>SAXParserFactory</code> implementation class to
+     * load:
+     * <ul>
+     * <li>
+     * Use the <code>javax.xml.parsers.SAXParserFactory</code> system
+     * property.
+     * </li>
+     * <li>
+     * Use the properties file "lib/jaxp.properties" in the JRE directory.
+     * This configuration file is in standard <code>java.util.Properties
+     * </code> format and contains the fully qualified name of the
+     * implementation class with the key being the system property defined
+     * above.
+     * </li>
+     * <li>
+     * Use the Services API (as detailed in the JAR specification), if
+     * available, to determine the classname. The Services API will look
+     * for a classname in the file
+     * <code>META-INF/services/javax.xml.parsers.SAXParserFactory</code>
+     * in jars available to the runtime.
+     * </li>
+     * <li>
+     * Platform default <code>SAXParserFactory</code> instance.
+     * </li>
+     * </ul>
+     *
+     * Once an application has obtained a reference to a
+     * <code>SAXParserFactory</code> it can use the factory to
+     * configure and obtain parser instances.
+     *
+     * @return A new instance of a SAXParserFactory.
+     *
+     * @exception FactoryConfigurationError if the implementation is
+     * not available or cannot be instantiated.
+     */
+
+    public static SAXParserFactory newInstance()
+        throws FactoryConfigurationError
+    {
+        return new SAXParserFactoryImpl();
+    }
+    
+    /**
+     * Creates a new instance of a SAXParser using the currently
+     * configured factory parameters.
+     *
+     * @return A new instance of a SAXParser.
+     *
+     * @exception ParserConfigurationException if a parser cannot
+     * be created which satisfies the requested configuration.
+     */
+    
+    public abstract SAXParser newSAXParser()
+        throws ParserConfigurationException, SAXException;
+
+    
+    /**
+     * Specifies that the parser produced by this code will
+     * provide support for XML namespaces. By default the value of this is set
+     * to <code>false</code>.
+     *
+     * @param awareness true if the parser produced by this code will
+     *                  provide support for XML namespaces; false otherwise.
+     */
+    
+    public void setNamespaceAware(boolean awareness)
+    {
+        this.namespaceAware = awareness;
+    }
+
+    /**
+     * Specifies that the parser produced by this code will
+     * validate documents as they are parsed. By default the value of this is
+     * set to <code>false</code>.
+     *
+     * @param validating true if the parser produced by this code will
+     *                   validate documents as they are parsed; false otherwise.
+     */
+    
+    public void setValidating(boolean validating)
+    {
+        this.validating = validating;
+    }
+
+    /**
+     * Indicates whether or not the factory is configured to produce
+     * parsers which are namespace aware.
+     *
+     * @return true if the factory is configured to produce
+     *         parsers which are namespace aware; false otherwise.
+     */
+    
+    public boolean isNamespaceAware() {
+        return namespaceAware;
+    }
+
+    /**
+     * Indicates whether or not the factory is configured to produce
+     * parsers which validate the XML content during parse.
+     *
+     * @return true if the factory is configured to produce parsers which validate
+     *         the XML content during parse; false otherwise.
+     */
+    
+    public boolean isValidating() {
+        return validating;
+    }
+
+    /**
+     *
+     * Sets the particular feature in the underlying implementation of
+     * org.xml.sax.XMLReader.
+     * A list of the core features and properties can be found at
+     * <a href="http://www.megginson.com/SAX/Java/features.html"> http://www.megginson.com/SAX/Java/features.html </a>
+     *
+     * @param name The name of the feature to be set.
+     * @param value The value of the feature to be set.
+     * @exception SAXNotRecognizedException When the underlying XMLReader does
+     *            not recognize the property name.
+     *
+     * @exception SAXNotSupportedException When the underlying XMLReader
+     *            recognizes the property name but doesn't support the
+     *            property.
+     *
+     * @see org.xml.sax.XMLReader#setFeature
+     */
+    public abstract void setFeature(String name, boolean value)
+        throws ParserConfigurationException, SAXNotRecognizedException,
+                SAXNotSupportedException;
+
+    /**
+     *
+     * Returns the particular property requested for in the underlying
+     * implementation of org.xml.sax.XMLReader.
+     *
+     * @param name The name of the property to be retrieved.
+     * @return Value of the requested property.
+     *
+     * @exception SAXNotRecognizedException When the underlying XMLReader does
+     *            not recognize the property name.
+     *
+     * @exception SAXNotSupportedException When the underlying XMLReader
+     *            recognizes the property name but doesn't support the
+     *            property.
+     *
+     * @see org.xml.sax.XMLReader#getProperty
+     */
+    public abstract boolean getFeature(String name)
+        throws ParserConfigurationException, SAXNotRecognizedException,
+                SAXNotSupportedException;
+}

Added: webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/EntityResolver.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/EntityResolver.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/EntityResolver.java (added)
+++ webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/EntityResolver.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mirae.j2me.xml;
+
+import java.util.Hashtable;
+
+/**
+ * This entity resolver is mainly used by NonValidatingParser
+ * @author Ias (iasandcb@tmax.co.kr)
+ *  
+ */
+public class EntityResolver {
+    /**
+	 * The registered entities.
+	 */
+    private Hashtable entities;
+
+    /**
+	 * Initializes the resolver.
+	 */
+    public EntityResolver() {
+        this.entities = new Hashtable();
+        this.entities.put("amp", "&#38;");
+        this.entities.put("quot", "&#34;");
+        this.entities.put("apos", "&#39;");
+        this.entities.put("lt", "&#60;");
+        this.entities.put("gt", "&#62;");
+    }
+
+    /**
+	 * Adds an internal entity.
+	 * 
+	 * @param name - the name of the entity.
+	 * @param value - the value of the entity.
+	 */
+    public void addInternalEntity(String name, String value) {
+        if (!this.entities.containsKey(name)) {
+            this.entities.put(name, value);
+        }
+    }
+
+    /**
+	 * Adds an external entity.
+	 * 
+	 * @param name - the name of the entity.
+	 * @param publicID - the public ID of the entity, which may be null.
+	 * @param systemID - the system ID of the entity.
+	 */
+    public void addExternalEntity(String name, String publicID, String systemID) {
+        if (!this.entities.containsKey(name)) {
+            this.entities.put(name, new String[] { publicID, systemID });
+        }
+    }
+
+    /**
+	 * Returns a Java reader containing the value of an entity.
+	 * 
+	 * @param xmlReader
+	 *            the current XML reader
+	 * @param name
+	 *            the name of the entity.
+	 * 
+	 * @return the reader, or null if the entity could not be resolved.
+	 */
+    public Object getEntity(String name) {
+        Object obj = this.entities.get(name);
+
+        if (obj == null) {
+            return null;
+        }
+        else if (obj instanceof java.lang.String) {
+            return (String) obj;
+        }
+        else {
+            String[] id = (String[]) obj;
+            return id;
+        }
+    }
+
+    /**
+	 * Returns true if an entity is external.
+	 * 
+	 * @param name
+	 *            the name of the entity.
+	 */
+    public boolean isExternalEntity(String name) {
+        Object obj = this.entities.get(name);
+        return !(obj instanceof java.lang.String);
+    }
+
+}

Added: webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/NonValidatingParser.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/NonValidatingParser.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/NonValidatingParser.java (added)
+++ webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/NonValidatingParser.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,1295 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mirae.j2me.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Hashtable;
+import java.util.Stack;
+
+import javax.microedition.io.Connector;
+
+import org.apache.mirae.j2me.xml.sax.AttributesImpl;
+import org.apache.mirae.j2me.xml.sax.LocatorImpl;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * This is a non-validating parser implementation for J2ME JAXP
+ * @author Ias (iasandcb@tmax.co.kr)
+ *  
+ */
+public class NonValidatingParser {
+
+    protected Hashtable attributeDefaultValues;
+    protected Hashtable attributeTypes;
+    private Hashtable elementTypes;
+    private boolean endOfDocument;
+    private EntityResolver entityResolver;
+
+    private DefaultHandler handler;
+    private LocatorImpl locator;
+    private Hashtable namespaces;
+
+    private EntityResolver parameterEntityResolver;
+    private Stack prefixes;
+    private PushBackReader reader;
+
+    private String rootElement;
+    private SAXParserImpl saxParser;
+
+    /**
+	 * Constructor with source, handler and SAXParserImpl
+	 * 
+	 * @param source
+	 * @param handler
+	 * @param saxParser
+	 * @throws IOException
+	 */
+    public NonValidatingParser(InputSource source, DefaultHandler handler, SAXParserImpl saxParser) throws IOException {
+    	
+    	Reader sourceReader = source.getCharacterStream();
+        if (sourceReader == null) {
+            InputStream ips = source.getByteStream();
+            if (ips == null) {
+                String systemId = source.getSystemId();      
+                
+                ips = Connector.openInputStream(systemId);                
+                
+                if (ips == null) {
+                    throw new IOException();
+                }
+            }
+            sourceReader = new InputStreamReader(ips);
+        }
+
+        locator = new LocatorImpl(source.getPublicId(), source.getSystemId(), 1, 1);
+        reader = new PushBackReader(sourceReader, locator);
+        namespaces = new Hashtable();
+        prefixes = new Stack();
+        this.handler = handler;
+        this.saxParser = saxParser;
+
+        attributeDefaultValues = new Hashtable();
+        attributeTypes = new Hashtable();
+
+        entityResolver = new EntityResolver();
+        parameterEntityResolver = new EntityResolver();
+
+        elementTypes = new Hashtable();
+    }
+
+    private boolean checkLiteral(String literal) throws Exception {
+        for (int i = 0; i < literal.length(); i++) {
+            if (reader.read() != literal.charAt(i)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    private String closeCdataTag() throws Exception {
+        boolean closed = false;
+        StringBuffer buffer = new StringBuffer();
+        while (!closed) {
+            char ch = reader.read();
+
+            if (ch == ']') {
+                char ch2 = reader.read();
+
+                if (ch2 == ']') {
+                    char ch3 = reader.read();
+
+                    if (ch3 == '>') {
+                        closed = true;
+                    }
+                    else {
+                        buffer.append(ch);
+                        buffer.append(ch2);
+                        buffer.append(ch3);
+                    }
+                }
+                else {
+                    buffer.append(ch);
+                    buffer.append(ch2);
+                }
+            }
+            else {
+                buffer.append(ch);
+            }
+        }
+        return buffer.toString();
+    }
+
+    private String closeDtdTag() throws Exception {
+        boolean closed = false;
+        StringBuffer buffer = new StringBuffer();
+        while (!closed) {
+            char ch = reader.read();
+
+            if (ch == '?') {
+                char ch2 = reader.read();
+
+                if (ch2 == '>') {
+                    closed = true;
+                }
+                else {
+                    buffer.append(ch);
+                    buffer.append(ch2);
+                }
+            }
+            else {
+                buffer.append(ch);
+            }
+        }
+        return buffer.toString();
+    }
+
+    private String closeInstructionTag() throws Exception {
+        boolean closed = false;
+        StringBuffer buffer = new StringBuffer();
+        while (!closed) {
+            char ch = reader.read();
+
+            if (ch == '?') {
+                char ch2 = reader.read();
+
+                if (ch2 == '>') {
+                    closed = true;
+                }
+                else {
+                    buffer.append(ch);
+                    buffer.append(ch2);
+                }
+            }
+            else {
+                buffer.append(ch);
+            }
+        }
+        return buffer.toString();
+    }
+
+    /**
+	 * start to parse the given document
+	 * 
+	 * @throws SAXException
+	 * @throws IOException
+	 */
+    public void parse() throws SAXException, IOException {
+        handler.setDocumentLocator(locator);
+        String token;
+        try {
+            while (!reader.isEof()) {
+                token = readToken('&');
+                char leading = token.charAt(0);
+                switch (leading) {
+                    case '<' :
+                        if (endOfDocument) {
+                            handler.fatalError(new SAXParseException("End of Document", locator));
+                            break;
+                        }
+                        parseTag(false);
+                        break;
+
+                    case '\n' :
+                        break;
+                    case ' ' :
+                        break;
+                    case '\t' :
+                        break;
+                    case '\r' :
+                        break;
+
+                    default :
+                        if (reader.isEof()) {
+                            break;
+                        }
+                        if (endOfDocument) {
+                            handler.fatalError(new SAXParseException("End of Document", locator));
+                            break;
+                        }
+                        handler.fatalError(new SAXParseException("'" + leading + "' invaid input", locator));
+                }
+            }
+        }
+        catch (SAXException se) {
+            throw se;
+        }
+        catch (IOException ie) {
+            throw ie;
+        }
+        catch (Exception e) {
+            throw new SAXException(e.getMessage());
+        }
+        finally {
+            handler.endDocument();
+        }
+
+    }
+
+    protected void parseAttribute(AttributesImpl attributes) throws Exception {
+        String key = readIdentifier();
+        skipWhitespace();
+
+        if (!readToken('&').equals("=")) {
+            handler.fatalError(new SAXParseException("'=' expected", locator));
+        }
+
+        skipWhitespace();
+        String type = attributes.getTypeFromDeclaration(key);
+        String value = readAttributeValue(!type.equals("CDATA"), entityResolver);
+        if (key.equals("xmlns")) {
+            String prefix = "";
+            namespaces.put(prefix, value);
+            prefixes.push(prefix);
+            if (saxParser.isNamespacePrefixAware()) {
+                attributes.add(key, type, value);
+            }
+            else {
+                handler.startPrefixMapping(prefix, value);
+            }
+        }
+        else if (key.startsWith("xmlns:")) {
+            String prefix = key.substring(6);
+            namespaces.put(prefix, value);
+            prefixes.push(prefix);
+            if (saxParser.isNamespacePrefixAware()) {
+                attributes.add(key, type, value);
+            }
+            else {
+                handler.startPrefixMapping(prefix, value);
+            }
+        }
+        else {
+            attributes.add(key, type, value);
+        }
+    }
+
+    private void parseCdata() throws Exception {
+        if (checkLiteral("CDATA[")) {
+            String data = closeCdataTag();
+            handler.characters(data.toCharArray(), 0, data.length());
+        }
+        else {
+            handler.fatalError(new SAXParseException("'<![[CDATA[' expected", locator));
+        }
+    }
+
+    private char parseCharLiteral(String entity) throws Exception {
+        if (entity.charAt(2) == 'x') {
+            entity = entity.substring(3, entity.length() - 1);
+            return (char) Integer.parseInt(entity, 16);
+        }
+        else {
+            entity = entity.substring(2, entity.length() - 1);
+            return (char) Integer.parseInt(entity, 10);
+        }
+    }
+
+    private void parseDocType() throws Exception {
+        if (!checkLiteral("OCTYPE")) {
+            handler.fatalError(new SAXParseException("'<!DOCTYPE' expected", locator));
+        }
+
+        skipWhitespace();
+        String systemID = null;
+        StringBuffer publicID = new StringBuffer();
+        rootElement = readIdentifier();
+        skipWhitespace();
+        char ch = reader.read();
+        if (ch == 'P') {
+            systemID = readPublicId(publicID);
+            handler.skippedEntity("[dtd]");
+            skipWhitespace();
+            ch = reader.read();
+        }
+        else if (ch == 'S') {
+            systemID = readSystemId();
+            handler.skippedEntity("[dtd]");
+            skipWhitespace();
+            ch = reader.read();
+        }
+
+        if (ch == '[') {
+            parseDtd();
+            skipWhitespace();
+            ch = reader.read();
+        }
+
+        if (ch != '>') {
+            handler.fatalError(new SAXParseException("'>' expected", locator));
+        }
+
+    }
+
+    private void parseDtd() throws Exception {
+        skipWhitespace();
+        for (;;) {
+            String str = readToken('%');
+            char ch = str.charAt(0);
+
+            if (ch == '%') {
+                parseDtdEntity(parameterEntityResolver);
+                continue;
+            }
+            else if (ch == '<') {
+                parseDtdDeclaration(entityResolver);
+            }
+            else if (ch == ']') {
+                return; // end internal DTD
+            }
+            else {
+                handler.fatalError(new SAXParseException("'" + str + "' invalid input", locator));
+            }
+            do {
+                ch = reader.read();
+            }
+            while ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\r'));
+
+            reader.unread();
+        }
+    }
+
+    protected void parseDtdAttributeList(EntityResolver entityResolver) throws Exception {
+        if (!checkLiteral("TTLIST")) {
+            skipTag();
+            return;
+        }
+
+        skipWhitespace();
+        String str = readToken('%');
+        char ch = str.charAt(0);
+        while (ch == '%') {
+            parseEntity(str, parameterEntityResolver);
+            str = readToken('%');
+            ch = str.charAt(0);
+        }
+        reader.unread();
+        String elementName = readIdentifier();
+        skipWhitespace();
+
+        str = readToken('%');
+        ch = str.charAt(0);
+        while (ch == '%') {
+            parseEntity(str, parameterEntityResolver);
+            str = readToken('%');
+            ch = str.charAt(0);
+        }
+
+        Hashtable defaultValues = new Hashtable();
+        Hashtable types = new Hashtable();
+
+        while (ch != '>') {
+            reader.unread();
+            String attName = readIdentifier();
+            skipWhitespace();
+            str = readToken('%');
+            ch = str.charAt(0);
+            while (ch == '%') {
+                parseEntity(str, parameterEntityResolver);
+                str = readToken('%');
+                ch = str.charAt(0);
+            }
+
+            if (ch == '(') {
+                StringBuffer typeBuffer = new StringBuffer();
+                typeBuffer.append(str);
+                while (ch != ')') {
+                    str = readToken('%');
+                    ch = str.charAt(0);
+                    while (ch == '%') {
+                        parseEntity(str, parameterEntityResolver);
+                        str = readToken('%');
+                        ch = str.charAt(0);
+                    }
+                    typeBuffer.append(str);
+                }
+                types.put(attName, typeBuffer.toString());
+            }
+            else {
+                reader.unread();
+                String type = readIdentifier();
+                types.put(attName, type);
+            }
+
+            skipWhitespace();
+            str = readToken('%');
+            ch = str.charAt(0);
+            while (ch == '%') {
+                parseEntity(str, parameterEntityResolver);
+                str = readToken('%');
+                ch = str.charAt(0);
+            }
+
+            if (ch == '#') {
+                str = readIdentifier();
+                skipWhitespace();
+
+                if (!str.equals("FIXED")) {
+                    skipWhitespace();
+
+                    str = readToken('%');
+                    ch = str.charAt(0);
+                    while (ch == '%') {
+                        parseEntity(str, parameterEntityResolver);
+                        str = readToken('%');
+                        ch = str.charAt(0);
+                    }
+
+                    continue;
+                }
+            }
+            else {
+                reader.unread();
+            }
+
+            String value = readString('%', parameterEntityResolver);
+            defaultValues.put(attName, value);
+            skipWhitespace();
+
+            str = readToken('%');
+            ch = str.charAt(0);
+            while (ch == '%') {
+                parseEntity(str, parameterEntityResolver);
+                str = readToken('%');
+                ch = str.charAt(0);
+            }
+        }
+
+        if (!types.isEmpty()) {
+            attributeTypes.put(elementName, types);
+        }
+
+        if (!defaultValues.isEmpty()) {
+            attributeDefaultValues.put(elementName, defaultValues);
+        }
+    }
+
+    private void parseDtdConditionalSection(EntityResolver entityResolver) throws Exception {
+        skipWhitespace();
+
+        // paramete entity should be supported. call readString instead.
+        String str = readString('%', entityResolver);
+        char ch = str.charAt(0);
+
+        if (ch != 'I') {
+            skipTag();
+            return;
+        }
+
+        str = readToken('%');
+        ch = str.charAt(0);
+
+        switch (ch) {
+            case 'G' :
+                parseDtdIgnoreSection(entityResolver);
+                return;
+
+            case 'N' :
+                break;
+
+            default :
+                skipTag();
+                return;
+        }
+
+        if (!checkLiteral("CLUDE")) {
+            skipTag();
+            return;
+        }
+
+        skipWhitespace();
+
+        str = readToken('%');
+        ch = str.charAt(0);
+
+        if (ch != '[') {
+            skipTag();
+            return;
+        }
+
+        reader.addString(closeCdataTag());
+    }
+
+    private void parseDtdDeclaration(EntityResolver entityResolver) throws Exception {
+        String str = readToken('%');
+        char ch = str.charAt(0);
+
+        if (ch != '!') {
+            skipTag();
+            return;
+        }
+
+        str = readToken('%');
+        ch = str.charAt(0);
+
+        switch (ch) {
+            case '-' :
+                skipComment();
+                break;
+
+            case '[' :
+                parseDtdConditionalSection(entityResolver);
+                break;
+
+            case 'E' :
+                ch = reader.read();
+                if (ch == 'L') {
+                    parseDtdElement(entityResolver);
+                }
+                else {
+                    reader.unread();
+                    parseDtdEntity(entityResolver);
+                }
+                break;
+
+            case 'A' :
+                parseDtdAttributeList(entityResolver);
+                break;
+
+            case 'N' :
+                parseDtdNotation(entityResolver);
+                break;
+
+            default :
+                skipTag();
+        }
+    }
+
+    protected void parseDtdElement(EntityResolver entityResolver) throws Exception {
+        if (!checkLiteral("EMENT")) {
+            skipTag();
+            return;
+        }
+
+        skipWhitespace();
+        String str = readToken('%');
+        char ch = str.charAt(0);
+        while (ch == '%') {
+            parseEntity(str, parameterEntityResolver);
+            str = readToken('%');
+            ch = str.charAt(0);
+        }
+        reader.unread();
+        String elementName = readIdentifier();
+        skipWhitespace();
+
+        str = readToken('%');
+        ch = str.charAt(0);
+        while (ch == '%') {
+            parseEntity(str, parameterEntityResolver);
+            str = readToken('%');
+            ch = str.charAt(0);
+        }
+
+        StringBuffer typeBuffer = new StringBuffer();
+        reader.unread();
+        skipWhitespace();
+        while (ch != '>') {
+            str = readToken('%');
+            ch = str.charAt(0);
+            while (ch == '%') {
+                parseEntity(str, parameterEntityResolver);
+                str = readToken('%');
+                ch = str.charAt(0);
+            }
+            typeBuffer.append(str);
+        }
+        elementTypes.put(elementName, typeBuffer.toString());
+
+    }
+
+    private void parseDtdEntity(EntityResolver entityResolver) throws Exception {
+        if (!checkLiteral("NTITY")) {
+            skipTag();
+            return;
+        }
+
+        skipWhitespace();
+        char ch = readChar('\0');
+
+        if (ch == '%') {
+            skipWhitespace();
+            entityResolver = parameterEntityResolver;
+        }
+        else {
+            reader.unread();
+        }
+
+        String name = readIdentifier();
+        skipWhitespace();
+        ch = readChar('%');
+        String systemId = null;
+        String publicId = null;
+        String notationMark = null;
+        String notationName = null;
+
+        switch (ch) {
+            case 'P' :
+                if (!checkLiteral("UBLIC")) {
+                    skipTag();
+                    return;
+                }
+
+                skipWhitespace();
+                publicId = readString('%', parameterEntityResolver);
+                skipWhitespace();
+                systemId = readString('%', parameterEntityResolver);
+                skipWhitespace();
+                notationMark = readString('%', parameterEntityResolver);
+                if (notationMark.startsWith("NDATA")) {
+                    skipWhitespace();
+                    notationName = readString('%', parameterEntityResolver);
+                }
+                break;
+
+            case 'S' :
+                if (!checkLiteral("YSTEM")) {
+                    skipTag();
+                    return;
+                }
+
+                skipWhitespace();
+                systemId = readString('%', parameterEntityResolver);
+                skipWhitespace();
+                notationMark = readString('%', parameterEntityResolver);
+                if (notationMark.startsWith("NDATA")) {
+                    skipWhitespace();
+                    notationName = readString('%', parameterEntityResolver);
+                }
+                break;
+
+            case '"' :
+            case '\'' :
+                reader.unread();
+                String value = readString('%', parameterEntityResolver);
+                entityResolver.addInternalEntity(name, value);
+                skipWhitespace();
+                readChar('%');
+                break;
+
+            default :
+                skipTag();
+        }
+
+        if (notationName != null) {
+            handler.unparsedEntityDecl(name, publicId, systemId, notationName);
+        }
+        if (systemId != null) {
+            entityResolver.addExternalEntity(name, publicId, systemId);
+        }
+    }
+
+    private void parseDtdIgnoreSection(EntityResolver entityResolver) throws Exception {
+        if (!checkLiteral("NORE")) {
+            skipTag();
+            return;
+        }
+
+        skipWhitespace();
+
+        String str = readToken('%');
+        char ch = str.charAt(0);
+
+        if (ch != '[') {
+            skipTag();
+            return;
+        }
+
+        closeCdataTag();
+    }
+
+    private void parseDtdNotation(EntityResolver entityResolver) throws Exception {
+        if (!checkLiteral("OTATION")) {
+            skipTag();
+            return;
+        }
+        skipWhitespace();
+        char ch = readChar('\0');
+
+        if (ch == '%') {
+            skipWhitespace();
+            entityResolver = parameterEntityResolver;
+        }
+        else {
+            reader.unread();
+        }
+
+        String name = readIdentifier();
+        skipWhitespace();
+        ch = readChar('%');
+        String systemId = null;
+        String publicId = null;
+
+        switch (ch) {
+            case 'P' :
+                if (!checkLiteral("UBLIC")) {
+                    skipTag();
+                    return;
+                }
+
+                skipWhitespace();
+                publicId = readString('%', parameterEntityResolver);
+                skipWhitespace();
+                systemId = readString('%', parameterEntityResolver);
+                skipWhitespace();
+                readChar('%');
+                break;
+
+            case 'S' :
+                if (!checkLiteral("YSTEM")) {
+                    skipTag();
+                    return;
+                }
+
+                skipWhitespace();
+                systemId = readString('%', parameterEntityResolver);
+                skipWhitespace();
+                readChar('%');
+                break;
+
+            default :
+                skipTag();
+        }
+
+        handler.notationDecl(name, publicId, systemId);
+    }
+
+    protected void parseElement() throws Exception {
+        String qName = readIdentifier();
+        String localName = qName;
+        skipWhitespace();
+        String prefix = null;
+        int colonIndex = qName.indexOf(':');
+
+        if (colonIndex > 0) {
+            prefix = qName.substring(0, colonIndex);
+            localName = qName.substring(colonIndex + 1);
+        }
+
+        Hashtable belongedAttributeDefaultValues = (Hashtable) attributeDefaultValues.get(qName);
+        Hashtable belongedAttributeTypes = (Hashtable) attributeTypes.get(qName);
+        AttributesImpl attributes = new AttributesImpl(namespaces, belongedAttributeDefaultValues, belongedAttributeTypes);
+        int previousPrefixesSize = prefixes.size();
+
+        char ch;
+        for (;;) {
+            ch = reader.read();
+
+            if ((ch == '/') || (ch == '>')) {
+                break;
+            }
+
+            reader.unread();
+
+            parseAttribute(attributes);
+            skipWhitespace();
+        }
+
+        String namespaceUri = "";
+        if (saxParser.isNamespaceAware()) {
+            if (prefix == null) {
+                String defaultNamespaceUri = (String) namespaces.get("");
+                if (defaultNamespaceUri != null) {
+                    namespaceUri = defaultNamespaceUri;
+                }
+            }
+            else {
+                String mappedNamespaceUri = (String) namespaces.get(prefix);
+                if (mappedNamespaceUri != null) {
+                    namespaceUri = mappedNamespaceUri;
+                }
+            }
+        }
+        if (rootElement == null) {
+            rootElement = qName;
+        }
+        handler.startElement(namespaceUri, localName, qName, attributes);
+
+        if (ch == '/') {
+            if (reader.read() != '>') {
+                handler.fatalError(new SAXParseException("'>' expected", locator));
+            }
+
+            handler.endElement(namespaceUri, localName, qName);
+            int currentPrefixesSize = prefixes.size();
+            for (int i = currentPrefixesSize; i > previousPrefixesSize; i--) {
+                String mappedPrefix = (String) prefixes.pop();
+                handler.endPrefixMapping(mappedPrefix);
+                namespaces.remove(mappedPrefix);
+            }
+            if (qName.equals(rootElement)) {
+                endOfDocument = true;
+            }
+            return;
+        }
+
+        StringBuffer buffer = new StringBuffer();
+        String str;
+
+        for (;;) {
+
+            for (;;) {
+                if (buffer.length() == 0) {
+                    String elementType = (String) elementTypes.get(qName);
+                    if ((elementType != null) && ((elementType.equals("EMPTY") || elementType.indexOf("#PCDATA") < 0))) {
+                        char[] whitespaces = parseWhitespace();
+                        if (whitespaces.length > 0) {
+                            handler.ignorableWhitespace(whitespaces, 0, whitespaces.length);
+                        }
+                    }
+                    else {
+                        skipWhitespace();
+                    }
+                }
+                str = readToken('&');
+
+                if ((str.charAt(0) == '&') && (str.charAt(1) != '#')) {
+                    parseEntity(str, entityResolver);
+                }
+                else {
+                    break;
+                }
+            }
+
+            if (str.charAt(0) == '<') {
+                if (buffer.length() > 0) {
+                    char[] characters = new char[buffer.length()];
+                    buffer.getChars(0, buffer.length(), characters, 0);
+                    handler.characters(characters, 0, buffer.length());
+                    buffer.setLength(0);
+                }
+                str = readToken('\0');
+
+                if (str.charAt(0) == '/') {
+                    skipWhitespace();
+                    str = readIdentifier();
+
+                    if (!str.equals(qName)) {
+                        handler.fatalError(new SAXParseException("Wrong closing tag: " + str, locator));
+                    }
+
+                    skipWhitespace();
+
+                    if (reader.read() != '>') {
+                        handler.fatalError(new SAXParseException("closing tag must be empty", locator));
+                    }
+
+                    handler.endElement(null, localName, qName);
+                    int currentPrefixesSize = prefixes.size();
+                    for (int i = currentPrefixesSize; i > previousPrefixesSize; i--) {
+                        String mappedPrefix = (String) prefixes.pop();
+                        handler.endPrefixMapping(mappedPrefix);
+                        namespaces.remove(mappedPrefix);
+                    }
+                    if (qName.equals(rootElement)) {
+                        endOfDocument = true;
+                    }
+                    break;
+                }
+                else { // <[^/]
+                    reader.unread();
+                    parseTag(true);
+                }
+            }
+            else { // [^<]
+                if (str.charAt(0) == '&') {
+                    ch = parseCharLiteral(str);
+                    buffer.append(ch);
+                }
+                else {
+                    buffer.append(str);
+                }
+            }
+        }
+    }
+
+    private void parseEntity(String entity, EntityResolver entityResolver) throws Exception {
+        entity = entity.substring(1, entity.length() - 1);
+        Object obj = entityResolver.getEntity(entity);
+
+        if (obj == null) {
+            handler.warning(new SAXParseException("'" + entity + "' invalid entity", locator));
+        }
+        else if (obj instanceof java.lang.String) {
+            reader.addString((String) obj);
+        }
+        else {
+            String[] id = (String[]) obj;
+            // NOTE: The following implementation depends on my decision on how this parser should work.
+            String publicId = id[0];
+            String systemId = id[1];
+            InputSource entitySource = handler.resolveEntity(publicId, systemId);
+            if (entitySource == null) {
+                if (systemId == null) {
+                    handler.skippedEntity(entityResolver == parameterEntityResolver ? "&" + entity : entity);
+                    return;
+                }
+                entitySource = new InputSource(systemId);
+            }
+            Reader entityReader = entitySource.getCharacterStream();
+            if (entityReader == null) {
+                InputStream ips = entitySource.getByteStream();
+                if (ips == null) {
+                    String entitySystemId = entitySource.getSystemId();
+                    ips = Connector.openInputStream(entitySystemId);
+                    if (ips == null) {
+                        throw new IOException();
+                    }
+                }
+                entityReader = new InputStreamReader(ips);
+            }
+
+            StringBuffer replaceTextBuffer = new StringBuffer();
+            char[] buffer = new char[256];
+            int length;
+            while (((length = entityReader.read(buffer)) != -1)) {
+                replaceTextBuffer.append(buffer, 0, length);
+            }
+            reader.addString(replaceTextBuffer.toString());
+        }
+
+    }
+
+    private void parsePi() throws Exception {
+        skipWhitespace();
+        String target = readIdentifier();
+        skipWhitespace();
+        if (target.equals("xml")) {
+            closeInstructionTag();
+            handler.startDocument();
+        }
+        else {
+            String data = closeInstructionTag();
+            handler.processingInstruction(target, data);
+        }
+    }
+
+    protected void parseSpecialTag(boolean allowCdata) throws Exception {
+        String str = readToken('&');
+        char ch = str.charAt(0);
+
+        if (ch == '&') {
+            handler.fatalError(new SAXParseException("No entity reference is expected here (" + str + ")", locator));
+        }
+
+        switch (ch) {
+            case '[' :
+                if (allowCdata) {
+                    parseCdata();
+                }
+                else {
+                    handler.fatalError(new SAXParseException("No CDATA section is expected here", locator));
+                }
+
+                return;
+
+            case 'D' :
+                parseDocType();
+                return;
+
+            case '-' :
+                skipComment();
+                return;
+        }
+    }
+
+    private void parseTag(boolean allowCdata) throws Exception {
+        String token = readToken('&');
+        char leading = token.charAt(0);
+        if (leading == '&') {
+            handler.fatalError(new SAXParseException("No entity reference is expected here (" + token + ")", locator));
+        }
+        switch (leading) {
+            case '?' :
+                parsePi();
+                break;
+
+            case '!' :
+                parseSpecialTag(allowCdata);
+                break;
+
+            default :
+                reader.unread();
+                parseElement();
+        }
+
+    }
+
+    private char[] parseWhitespace() throws Exception {
+        char ch;
+        StringBuffer whitespaces = new StringBuffer();
+        do {
+            ch = reader.read();
+            switch (ch) {
+                case '\t' :
+                    whitespaces.append(ch);
+                    break;
+                case '\r' :
+                    break;
+                case '\n' :
+                    whitespaces.append(ch);
+                    break;
+                case ' ' :
+                    whitespaces.append(ch);
+                    break;
+                default :
+                    reader.unread();
+            }
+        }
+        while ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\r'));
+        return whitespaces.toString().toCharArray();
+    }
+
+    private char readChar(char entityChar) throws Exception {
+        String str = readToken(entityChar);
+        char ch = str.charAt(0);
+
+        if (ch == entityChar) {
+            handler.fatalError(new SAXParseException("No entity reference is expected here (" + str + ")", locator));
+        }
+
+        return ch;
+    }
+
+    private String readPublicId(StringBuffer publicId) throws Exception {
+        if (!checkLiteral("UBLIC")) {
+            return null;
+        }
+
+        skipWhitespace();
+        publicId.append(readString('\0', null));
+        skipWhitespace();
+        return readString('\0', null);
+    }
+
+    private String readString(char entityChar, EntityResolver entityResolver) throws Exception {
+        StringBuffer result = new StringBuffer();
+        char delim = reader.read();
+
+        if ((delim != '\'') && (delim != '"')) {
+            handler.fatalError(new SAXParseException("delimitor expected", locator));
+        }
+
+        for (;;) {
+            String str = readToken(entityChar);
+            char ch = str.charAt(0);
+
+            // time to normalize
+
+            if (ch == entityChar) {
+                if (str.charAt(1) == '#') {
+                    result.append(parseCharLiteral(str));
+                }
+                else {
+                    parseEntity(str, entityResolver);
+                }
+            }
+            else if (ch == '&') {
+                if (str.charAt(1) == '#') {
+                    result.append(parseCharLiteral(str));
+                }
+                else {
+                    result.append(str);
+                }
+            }
+            else if (ch == delim) {
+                break;
+            }
+            else {
+                result.append(ch);
+            }
+        }
+
+        return result.toString();
+    }
+
+    private String readAttributeValue(boolean isNotCdata, EntityResolver entityResolver) throws Exception {
+        StringBuffer resultBuffer = new StringBuffer();
+        boolean wasSpace = false;
+        char delim = reader.read();
+
+        if ((delim != '\'') && (delim != '"')) {
+            handler.fatalError(new SAXParseException("delimitor expected", locator));
+        }
+
+        for (;;) {
+            String str = readToken('&');
+            char ch = str.charAt(0);
+
+            // end of line normalization
+            if (ch == '\r') {
+                str = readToken('&');
+                ch = str.charAt(0);
+                if (ch != '\n') {
+                    ch = '\n';
+                }
+            }
+
+            if (ch == '&') {
+                if (str.charAt(1) == '#') {
+                    resultBuffer.append(parseCharLiteral(str));
+                }
+                else {
+                    parseEntity(str, entityResolver);
+                }
+            }
+            else if (ch == delim) {
+                break;
+            }
+            else {
+                if (ch == '\n' || ch == '\t') {
+                    ch = ' ';
+                }
+                if (ch == ' ' && isNotCdata && wasSpace) {
+                    continue;
+                }
+                resultBuffer.append(ch);
+                if (ch == ' ' && isNotCdata && !wasSpace) {
+                    wasSpace = true;
+                }
+                if (ch != ' ' && isNotCdata && wasSpace) {
+                    wasSpace = false;
+                }
+            }
+        }
+
+        String result = resultBuffer.toString();
+        if (isNotCdata) {
+            result = result.trim();
+        }
+        return result;
+    }
+
+    private String readSystemId() throws Exception {
+        if (!checkLiteral("YSTEM")) {
+            return null;
+        }
+
+        skipWhitespace();
+        return readString('\0', null);
+    }
+
+    private String readToken(char entityChar) throws Exception {
+        char ch = reader.read();
+        StringBuffer buf = new StringBuffer();
+        buf.append(ch);
+
+        if (ch == entityChar) {
+            while (ch != ';') {
+                ch = reader.read();
+                buf.append(ch);
+            }
+        }
+
+        return buf.toString();
+    }
+    private String readIdentifier() throws Exception {
+        StringBuffer result = new StringBuffer();
+
+        for (;;) {
+            char ch = reader.read();
+
+            if ((ch == '_')
+                || (ch == ':')
+                || (ch == '-')
+                || (ch == '.')
+                || ((ch >= 'a') && (ch <= 'z'))
+                || ((ch >= 'A') && (ch <= 'Z'))
+                || ((ch >= '0') && (ch <= '9'))
+                || (ch > '\u007E')) {
+                result.append(ch);
+            }
+            else {
+                reader.unread();
+                break;
+            }
+        }
+
+        return result.toString();
+    }
+
+    private void skipComment() throws Exception {
+        if (reader.read() != '-') {
+            handler.fatalError(new SAXParseException("'<!--' expected", locator));
+        }
+
+        int dashesRead = 0;
+
+        for (;;) {
+            char ch = reader.read();
+
+            switch (ch) {
+                case '-' :
+                    dashesRead++;
+                    break;
+
+                case '>' :
+                    if (dashesRead == 2) {
+                        return;
+                    }
+
+                default :
+                    dashesRead = 0;
+            }
+        }
+    }
+
+    private void skipTag() throws Exception {
+        int level = 1;
+
+        while (level > 0) {
+            char ch = reader.read();
+
+            switch (ch) {
+                case '<' :
+                    ++level;
+                    break;
+
+                case '>' :
+                    --level;
+                    break;
+            }
+        }
+    }
+
+    private void skipWhitespace() throws Exception {
+        char ch;
+        do {
+            ch = reader.read();
+            switch (ch) {
+                case '\t' :
+                    break;
+                case '\r' :
+                    break;
+                case '\n' :
+                    break;
+                case ' ' :
+                    break;
+                default :
+                    reader.unread();
+            }
+        }
+        while ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\r'));
+    }
+
+}

Added: webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/PushBackReader.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/PushBackReader.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/PushBackReader.java (added)
+++ webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/PushBackReader.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mirae.j2me.xml;
+
+import java.io.IOException;
+import java.io.Reader;
+
+import org.apache.mirae.j2me.xml.sax.LocatorImpl;
+
+/**
+ * This is designed to work for CLDC just like PushbackReader of CDC and J2SE
+ * @author Ias (iasandcb@tmax.co.kr)
+ */
+public class PushBackReader {
+
+    /** default buffer size */
+	public static final int DEFAULT_BUFFER_SIZE = 1024;
+	private Reader reader;
+	private char[] buffer;
+	private int pointer;
+	private int length;
+	private boolean eof;
+	private LocatorImpl locator;
+	
+    /** 
+     * Constructor with reader and locator
+     * @param reader
+     * @param locator
+     */
+	public PushBackReader(Reader reader, LocatorImpl locator) {
+		this.reader = reader;
+		this.locator = locator;
+		buffer = new char[DEFAULT_BUFFER_SIZE];
+	}
+	
+    /**
+     * Read a single character.
+     */
+	public char read() throws IOException {
+		char result;
+		if (pointer == length) {
+			length = reader.read(buffer);
+			if (length == -1) {
+				eof = true;
+				return (char) length;
+			}
+			pointer = 0;			
+		}
+		result = buffer[pointer];
+		pointer++;
+		switch (result) {
+			case '\t':
+				locator.addColumnNumber(8);
+				break;
+			case '\n':
+				locator.incrementLineNumber();
+				break;
+			default:
+				locator.incrementColumnNumber();
+		}
+		return result;
+	}
+	
+    /**
+     * Push a String to this reader
+     * @param insertString
+     */
+	public void addString(String insertString) {
+		int insertStringLength = insertString.length();
+		int bufferLength = buffer.length;
+		char[] enlargedBuffer = new char[bufferLength + insertStringLength];
+		System.arraycopy(buffer, 0, enlargedBuffer, 0, pointer);
+		System.arraycopy(insertString.toCharArray(), 0, enlargedBuffer, pointer, insertStringLength);
+		System.arraycopy(buffer, pointer, enlargedBuffer, pointer + insertStringLength, bufferLength - pointer - insertStringLength);
+		buffer = enlargedBuffer;
+		length += insertStringLength;
+	}
+	
+    /**
+     * Push back a single character.
+     *
+     */
+	public void unread() {
+		pointer--;
+		switch (buffer[pointer]) {
+			case '\t':
+				locator.addColumnNumber(-8);
+				break;
+			case '\n':
+				locator.decrementLineNumber();
+				break;
+			default:
+				locator.addColumnNumber(-1);
+		}
+	}
+
+    /**
+     * check out whether this reader reaches End Of File
+     * @return a boolean value indicating the result
+     */
+	public boolean isEof() {
+		return eof;
+	}
+}

Added: webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/SAXParserFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/SAXParserFactoryImpl.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/SAXParserFactoryImpl.java (added)
+++ webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/SAXParserFactoryImpl.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mirae.j2me.xml;
+
+import java.util.Hashtable;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+/**
+ * This is an implementation of javax.xml.parsers.SAXParserFactory
+ * @author Ias (iasandcb@tmax.co.kr)
+ * 
+ */
+public class SAXParserFactoryImpl extends SAXParserFactory {
+
+	/** SAX feature prefix ("http://xml.org/sax/features/"). */
+	public static final String SAX_FEATURE_PREFIX = "http://xml.org/sax/features/";
+
+	/** Namespaces feature ("namespaces"). */
+	public static final String NAMESPACES_FEATURE = "namespaces";
+
+	/** Namespace prefixes feature ("namespace-prefixes"). */
+	public static final String NAMESPACE_PREFIXES_FEATURE = "namespace-prefixes";
+
+
+	private Hashtable features;
+
+    /**
+     * a default constructor
+     */
+	public SAXParserFactoryImpl() {
+		features = new Hashtable();
+		features.put(SAX_FEATURE_PREFIX + NAMESPACES_FEATURE, new Boolean(true));
+		features.put(SAX_FEATURE_PREFIX + NAMESPACE_PREFIXES_FEATURE, new Boolean(false));
+	}
+	/**
+	 * @see javax.xml.parsers.SAXParserFactory#setFeature(java.lang.String, boolean)
+	 */
+	public void setFeature(String name, boolean value)
+		throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
+		features.put(name, value ? new Boolean(true) : new Boolean(false));
+	}
+
+	/**
+	 * @see javax.xml.parsers.SAXParserFactory#getFeature(java.lang.String)
+	 */
+	public boolean getFeature(String name)
+		throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
+		Boolean value = (Boolean) features.get(name);
+		return value.booleanValue();
+	}
+
+	/**
+	 * @see javax.xml.parsers.SAXParserFactory#newSAXParser()
+	 */
+	public SAXParser newSAXParser() throws ParserConfigurationException, SAXException {
+		return new SAXParserImpl(this);
+	}
+}

Added: webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/SAXParserImpl.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/SAXParserImpl.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/SAXParserImpl.java (added)
+++ webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/SAXParserImpl.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mirae.j2me.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * This is an implementation of javax.xml.parsers.SAXParser
+ * @author Ias (iasandcb@tmax.co.kr)
+ * 
+ */
+public class SAXParserImpl extends SAXParser {
+
+	private SAXParserFactory factory;
+	
+	public SAXParserImpl(SAXParserFactory factory) {
+		this.factory = factory;
+	}
+
+    /**
+     * @see javax.xml.parsers.SAXParser#parse(InputStream, DefaultHandler)
+     */
+	public void parse(InputStream is, DefaultHandler dh) throws SAXException, IOException {
+		
+		if (is == null) {
+			throw new IllegalArgumentException("InputStream cannot be null");
+		}
+
+		InputSource input = new InputSource(is);
+		this.parse(input, dh);
+	}
+
+    /**
+     * @see javax.xml.parsers.SAXParser#parse(InputSource, DefaultHandler)
+     */
+	public void parse(InputSource is, DefaultHandler handler) throws SAXException, IOException {
+		
+		
+		if (is == null) {
+			throw new IllegalArgumentException("InputSource cannot be null");
+		}
+		NonValidatingParser parser = new NonValidatingParser(is, handler,this);
+		parser.parse();
+	}
+
+	/**
+	 * @see javax.xml.parsers.SAXParser#isNamespaceAware()
+	 */
+	public boolean isNamespaceAware() {
+		boolean namespaceAware = true;
+		try {
+			namespaceAware = factory.getFeature(SAXParserFactoryImpl.SAX_FEATURE_PREFIX + SAXParserFactoryImpl.NAMESPACE_PREFIXES_FEATURE);
+		} catch (SAXNotRecognizedException e) {
+			e.printStackTrace();
+		} catch (SAXNotSupportedException e) {
+			e.printStackTrace();
+		} catch (ParserConfigurationException e) {
+			e.printStackTrace();
+		}
+		return namespaceAware;
+	}
+
+    /** 
+     * This additional feature should be supported by SAX2
+     * @return a boolean value indicating whether the feature is on or off
+     */
+	public boolean isNamespacePrefixAware() {
+		boolean namespacePrefixAware = false;
+		try {
+			namespacePrefixAware = factory.getFeature(SAXParserFactoryImpl.SAX_FEATURE_PREFIX + SAXParserFactoryImpl.NAMESPACE_PREFIXES_FEATURE);
+		} catch (SAXNotRecognizedException e) {
+			e.printStackTrace();
+		} catch (SAXNotSupportedException e) {
+			e.printStackTrace();
+		} catch (ParserConfigurationException e) {
+			e.printStackTrace();
+		}
+		return namespacePrefixAware;
+	}
+
+	/**
+	 * @see javax.xml.parsers.SAXParser#isValidating()
+	 */
+	public boolean isValidating() {
+	    // this implementation is not supporting validation
+		return false; 
+	}
+
+}

Added: webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/sax/AttributesImpl.java
URL: http://svn.apache.org/viewcvs/webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/sax/AttributesImpl.java?view=auto&rev=151149
==============================================================================
--- webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/sax/AttributesImpl.java (added)
+++ webservices/mirae/trunk/src/mirae/jaxp/org/apache/mirae/j2me/xml/sax/AttributesImpl.java Thu Feb  3 04:39:48 2005
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mirae.j2me.xml.sax;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.xml.sax.Attributes;
+
+/**
+ * This is an implementation of org.xml.sax.Attributes
+ * @author Ias (iasandcb@tmax.co.kr)
+ * 
+ */
+public class AttributesImpl implements Attributes {
+
+	private Vector keys;
+	private Vector values;
+	private Vector types;
+	private Hashtable namespaces;
+	private Hashtable typeDeclarations;
+
+    /**
+     * The concrete constructor for Attributes
+     * @param namespaces
+     * @param defaultValues
+     * @param typeDefinitions
+     */
+	public AttributesImpl(Hashtable namespaces, Hashtable defaultValues, Hashtable typeDefinitions) {
+		this.namespaces = namespaces;
+		keys = new Vector();
+		values = new Vector();
+		types = new Vector();
+		this.typeDeclarations = typeDefinitions;
+		if (defaultValues != null) {
+			Enumeration enum = defaultValues.keys();
+
+			while (enum.hasMoreElements()) {
+				String key = (String) enum.nextElement();
+				add(key, getTypeFromDeclaration(key), (String) defaultValues.get(key));
+			}
+		}
+	}
+	
+	public String getTypeFromDeclaration(String key) {
+		String type = null;
+		if (typeDeclarations != null) {
+			type = (String) typeDeclarations.get(key);
+		}
+		if (type == null) {
+			type = "CDATA";
+		}
+		return type;
+	}
+	
+	public void add(String key, String type, String value) {
+		keys.addElement(key);
+		values.addElement(value);
+		types.addElement(type);
+	}
+	/**
+	 * @see org.xml.sax.Attributes#getLength()
+	 */
+	public int getLength() {
+		return keys.size();
+	}
+
+	private String getPrefix(String qName) {
+		String prefix;
+		int colonIndex = qName.indexOf(":");
+		if (colonIndex < 0) {
+			prefix = "";
+		} else {
+			prefix = qName.substring(0, colonIndex);
+		}
+		return prefix;
+	}
+
+	private String getLocalName(String qName) {
+		String localName;
+		int colonIndex = qName.indexOf(":");
+		if (colonIndex < 0) {
+			localName = qName;
+		} else {
+			localName = qName.substring(colonIndex + 1);
+		}
+		return localName;
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getURI(int)
+	 */
+	public String getURI(int index) {
+		if (index >= keys.size()) {
+			return null;
+		}
+		String key = (String) keys.elementAt(index);
+		String uri = (String) namespaces.get(getPrefix(key));
+		if (uri == null) {
+			uri = "";
+		}
+		return uri;
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getLocalName(int)
+	 */
+	public String getLocalName(int index) {
+		return getLocalName((String) keys.elementAt(index));
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getQName(int)
+	 */
+	public String getQName(int index) {
+		return (String) keys.elementAt(index);
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getType(int)
+	 */
+	public String getType(int index) {
+		return (String) types.elementAt(index);
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getValue(int)
+	 */
+	public String getValue(int index) {
+		return (String) values.elementAt(index);
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getIndex(java.lang.String, java.lang.String)
+	 */
+	public int getIndex(String uri, String localName) {
+		String prefix = null;
+		for (Enumeration uris = namespaces.elements(), prefixes = namespaces.keys(); uris.hasMoreElements();) {
+			String namespaceUri = (String) uris.nextElement();
+			String namespacePrefix = (String) prefixes.nextElement();
+			if (namespaceUri.equals(uri)) {
+				prefix = namespacePrefix;
+				break;
+			}
+		}
+		if (prefix == null) {
+			return -1;
+		}
+		String qName;
+		if (prefix.equals("")) {
+			qName = localName;
+		} else {
+			qName = prefix + ":" + localName;
+		}
+		return getIndex(qName);
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getIndex(java.lang.String)
+	 */
+	public int getIndex(String qName) {
+		return keys.indexOf(qName);
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getType(java.lang.String, java.lang.String)
+	 */
+	public String getType(String uri, String localName) {
+		return (String) types.elementAt(getIndex(uri, localName));
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getType(java.lang.String)
+	 */
+	public String getType(String qName) {
+		return (String) types.elementAt(getIndex(qName));
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getValue(java.lang.String, java.lang.String)
+	 */
+	public String getValue(String uri, String localName) {
+		return (String) values.elementAt(getIndex(uri, localName));
+	}
+
+	/**
+	 * @see org.xml.sax.Attributes#getValue(java.lang.String)
+	 */
+	public String getValue(String qName) {
+		return (String) values.elementAt(getIndex(qName));
+	}
+
+}