From 40a9d99496e098562f090fb7ffce9e749011b131 Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 20 May 2024 17:58:16 -0400 Subject: Formatting pass --- .../java/net/wotonomy/web/xml/XMLRPCDecoder.java | 146 ++++++++++----------- 1 file changed, 68 insertions(+), 78 deletions(-) (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/xml/XMLRPCDecoder.java') 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(); + } } -- cgit v1.2.3