You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2001/04/30 07:24:17 UTC
cvs commit: xml-axis/java/src/org/apache/axis/message SAXAdapter.java DOMBody.java DebugHeader.java MessageElement.java RPCParam.java
gdaniels 01/04/29 22:24:17
Modified: java/src/org/apache/axis/message DOMBody.java
DebugHeader.java MessageElement.java RPCParam.java
Added: java/src/org/apache/axis/message SAXAdapter.java
Log:
Various...
DebugHeader.java:
Fix namespace of the header.
DOMBody.java:
Serialize attributes.
MessageElement.java:
Clean up attribute-handling code.
RPCParam.java:
Return a String instead of a StringBuffer from getValue() when
using an ElementRecorder's output.
SAXAdapter.java:
New file. This SOAPSAXHandler child class just parses the whole
message at once, and doesn't use another thread.
Revision Changes Path
1.2 +4 -0 xml-axis/java/src/org/apache/axis/message/DOMBody.java
Index: DOMBody.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/DOMBody.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOMBody.java 2001/04/27 15:29:48 1.1
+++ DOMBody.java 2001/04/30 05:24:16 1.2
@@ -30,6 +30,10 @@
if (attrMap.getLength() > 0) {
attributes = new AttributesImpl();
for (int i = 0; i < attrMap.getLength(); i++) {
+ Attr attr = (Attr)attrMap.item(i);
+
+ attributes.addAttribute("", attr.getName(), attr.getName(),
+ "CDATA", attr.getValue());
}
}
1.2 +3 -0 xml-axis/java/src/org/apache/axis/message/DebugHeader.java
Index: DebugHeader.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/DebugHeader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DebugHeader.java 2001/04/26 22:53:39 1.1
+++ DebugHeader.java 2001/04/30 05:24:16 1.2
@@ -3,6 +3,7 @@
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
+import org.apache.axis.Constants;
import org.apache.axis.message.events.*;
import org.apache.axis.encoding.*;
import org.apache.axis.utils.QName;
@@ -52,6 +53,7 @@
public DebugHeader(int debugLevel)
{
this.name = "Debug";
+ this.namespaceURI = Constants.URI_DEBUG;
this.debugLevel = debugLevel;
}
@@ -70,6 +72,7 @@
public void output(SerializationContext context)
throws IOException
{
+ //context.registerPrefixForURI("m", namespaceURI);
context.startElement(new QName(this.getNamespaceURI(), this.getName()), null);
context.writeString(new Integer(debugLevel).toString());
context.endElement();
1.8 +9 -20 xml-axis/java/src/org/apache/axis/message/MessageElement.java
Index: MessageElement.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- MessageElement.java 2001/04/27 18:53:19 1.7
+++ MessageElement.java 2001/04/30 05:24:16 1.8
@@ -108,17 +108,11 @@
this.namespaceURI = namespace;
this.name = localPart;
this.context = context;
- this.attributes = new AttributesImpl();
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- this.attributes.addAttribute(attributes.getURI(i),
- attributes.getLocalName(i),
- attributes.getQName(i),
- "CDATA",
- attributes.getValue(i));
- }
-
+ if (attributes == null) {
+ this.attributes = new AttributesImpl();
+ } else {
+ this.attributes = new AttributesImpl(attributes);
String rootVal = attributes.getValue(Constants.URI_SOAP_ENV, Constants.ATTR_ROOT);
// !!! This currently defaults to false... should it default to true?
if (rootVal != null)
@@ -213,22 +207,15 @@
return;
}
- AttributesImpl attrs = new AttributesImpl();
+ AttributesImpl attrs;
Object val = getValue();
if (val != null) {
if (typeQName == null)
typeQName = context.getQNameForClass(val.getClass());
- if (attributes != null) {
- // Must be writing a message we parsed earlier, so just put out
- // what's already there.
- for (int i = 0; i < attributes.getLength(); i++) {
- attrs.addAttribute(attributes.getURI(i), attributes.getLocalName(i),
- attributes.getQName(i), "CDATA",
- attributes.getValue(i));
- }
- } else {
+ if (attributes == null) {
+ attrs = new AttributesImpl();
// Writing a message from memory out to XML...
// !!! How do we set other attributes when serializing??
@@ -244,6 +231,8 @@
if (val == null)
attrs.addAttribute(Constants.URI_SCHEMA_XSI, "null", "xsi:null",
"CDATA", "1");
+ } else {
+ attrs = new AttributesImpl(attributes);
}
context.startElement(new QName(getNamespaceURI(), getName()), attrs);
1.5 +1 -1 xml-axis/java/src/org/apache/axis/message/RPCParam.java
Index: RPCParam.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCParam.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RPCParam.java 2001/04/28 17:15:06 1.4
+++ RPCParam.java 2001/04/30 05:24:16 1.5
@@ -170,7 +170,7 @@
if (DEBUG_LOG) e.printStackTrace();
return null;
}
- return xml.getBuffer();
+ return xml.getBuffer().toString();
}
if (deserializer != null) {
1.1 xml-axis/java/src/org/apache/axis/message/SAXAdapter.java
Index: SAXAdapter.java
===================================================================
package org.apache.axis.message;
import org.xml.sax.*;
/** This class is an adapter for the Axis SAX-event system
* which uses a SAX parser to parse on its own thread, synchronizing
* when appropriate with the control thread.
*
* @author Glen Daniels (gdaniels@macromedia.com)
*/
public class SAXAdapter extends SOAPSAXHandler
{
private static final boolean DEBUG_LOG = false;
private XMLReader _parser;
InputSource inputSource;
public SAXAdapter(XMLReader parser, InputSource inputSource)
{
_parser = new org.apache.xerces.parsers.SAXParser();
_parser.setContentHandler(this);
this.inputSource = inputSource;
}
/*******************************************************************
* Threading stuff
*/
public void parse()
{
try {
_parser.parse(inputSource);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
/** Called by the control thread; let the parsing thread
* continue.
*
*/
protected void continueParsing()
{
}
/** Called by the parse thread once it hits a desired
* event (found the element the control thread is looking
* for, finished parsing the headers, etc). Suspend
* execution until we're told to go again.
*/
protected void pauseParsing() throws SAXException
{
}
}