summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-05-20 17:58:16 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-05-20 17:58:16 -0400
commit40a9d99496e098562f090fb7ffce9e749011b131 (patch)
tree437df24d65470582e943e494a52db8ed65a881ae /projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java
parentff072dfe782f6f22123cd4ba050828d35c0d0fbd (diff)
Formatting pass
Diffstat (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java')
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java146
1 files changed, 68 insertions, 78 deletions
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java
index 8da71fe..54658c0 100644
--- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java
+++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java
@@ -32,83 +32,73 @@ import net.wotonomy.foundation.xml.XMLDecoder;
import org.xml.sax.SAXException;
/**
-* An implementation of XMLDecoder that reads objects from
-* XMLRPC format.
-* This implementation is not thread-safe, so a new instances
-* should be created to accomodate multiple threads.
-*/
-public class XMLRPCDecoder implements XMLDecoder
-{
- XMLRPCDecoderHelper helper = new XMLRPCDecoderHelper();
-
- /**
- * Decodes an object in XML-RPC format from the specified input stream.
- * @param anInputStream The input stream from which to read.
- * The stream will be read fully.
- * @param aDescription A description to accompany error messages
- * for the stream, typically a file name.
- * @param aURL A URL against which relative references within the
- * XML will be resolved.
- * @return The object that was constructed from the XML content,
- * or null if no object could be constructed.
- */
- public Object decode(
- InputStream anInputStream, String aDescription, URL aURL )
- {
- Object result = null;
-
- try {
- SAXParser sparser = SAXParserFactory.newInstance().newSAXParser();
- sparser.parse(anInputStream,helper,aURL.toExternalForm());
- result = helper.getResult();
- } catch (ParserConfigurationException e) {
- throw new WotonomyException("Problem in parser configuration", e );
- } catch (IOException e) {
- throw new WotonomyException("IOException thrown while parsing", e );
- } catch (SAXException e) {
- throw new WotonomyException("SAXException thrown while parsing", e );
- }
- helper.reset();
- return result;
- }
+ * An implementation of XMLDecoder that reads objects from XMLRPC format. This
+ * implementation is not thread-safe, so a new instances should be created to
+ * accomodate multiple threads.
+ */
+public class XMLRPCDecoder implements XMLDecoder {
+ XMLRPCDecoderHelper helper = new XMLRPCDecoderHelper();
+
+ /**
+ * Decodes an object in XML-RPC format from the specified input stream.
+ *
+ * @param anInputStream The input stream from which to read. The stream will be
+ * read fully.
+ * @param aDescription A description to accompany error messages for the
+ * stream, typically a file name.
+ * @param aURL A URL against which relative references within the XML
+ * will be resolved.
+ * @return The object that was constructed from the XML content, or null if no
+ * object could be constructed.
+ */
+ public Object decode(InputStream anInputStream, String aDescription, URL aURL) {
+ Object result = null;
+
+ try {
+ SAXParser sparser = SAXParserFactory.newInstance().newSAXParser();
+ sparser.parse(anInputStream, helper, aURL.toExternalForm());
+ result = helper.getResult();
+ } catch (ParserConfigurationException e) {
+ throw new WotonomyException("Problem in parser configuration", e);
+ } catch (IOException e) {
+ throw new WotonomyException("IOException thrown while parsing", e);
+ } catch (SAXException e) {
+ throw new WotonomyException("SAXException thrown while parsing", e);
+ }
+ helper.reset();
+ return result;
+ }
+
+ /**
+ * Decodes an XML-RPC message from the specified input stream. Stand-alone
+ * values not wrapped in "methodCall" or "param" tags will be treated as a
+ * response.
+ *
+ * @param anInputStream The input stream from which to read. The stream will be
+ * read fully.
+ * @param aReceiver an XMLRPCReceiver that will be invoked with the
+ * appropriate method: request, response, or fault.
+ */
+ public void decode(InputStream anInputStream, XMLRPCReceiver aReceiver) {
+ try {
+ SAXParser sparser = SAXParserFactory.newInstance().newSAXParser();
+ sparser.parse(anInputStream, helper);
- /**
- * Decodes an XML-RPC message from the specified input stream.
- * Stand-alone values not wrapped in "methodCall" or "param"
- * tags will be treated as a response.
- * @param anInputStream The input stream from which to read.
- * The stream will be read fully.
- * @param aReceiver an XMLRPCReceiver that will be invoked with
- * the appropriate method: request, response, or fault.
- */
- public void decode(
- InputStream anInputStream, XMLRPCReceiver aReceiver )
- {
- try
- {
- SAXParser sparser = SAXParserFactory.newInstance().newSAXParser();
- sparser.parse(anInputStream,helper);
-
- if ( helper.isRequest() )
- {
- aReceiver.request( helper.getMethodName(), helper.getParameters() );
- }
- else
- if ( helper.isFault() )
- {
- aReceiver.fault( helper.getFaultCode(), helper.getFaultString() );
- }
- else // all else is considered a response
- {
- aReceiver.response( helper.getResult() );
- }
- } catch (ParserConfigurationException e) {
- throw new WotonomyException("Problem in parser configuration", e );
- } catch (IOException e) {
- throw new WotonomyException("IOException thrown while parsing", e );
- } catch (SAXException e) {
- throw new WotonomyException("SAXException thrown while parsing", e );
- }
- helper.reset();
- }
+ if (helper.isRequest()) {
+ aReceiver.request(helper.getMethodName(), helper.getParameters());
+ } else if (helper.isFault()) {
+ aReceiver.fault(helper.getFaultCode(), helper.getFaultString());
+ } else // all else is considered a response
+ {
+ aReceiver.response(helper.getResult());
+ }
+ } catch (ParserConfigurationException e) {
+ throw new WotonomyException("Problem in parser configuration", e);
+ } catch (IOException e) {
+ throw new WotonomyException("IOException thrown while parsing", e);
+ } catch (SAXException e) {
+ throw new WotonomyException("SAXException thrown while parsing", e);
+ }
+ helper.reset();
+ }
}