com.sapportals.wcm.protocol.ice.protocol

Class ICEInput

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.sapportals.wcm.protocol.ice.protocol.ICEInput
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class ICEInput
extends org.xml.sax.helpers.DefaultHandler

Decodes an ICE payload from an input stream using a SAX parser. The SAX events of the ICE payload are transformed into events to the registered handlers. The respones are send to the output.

See Also:
IICEComRequestHandler, IICESynRequestHandler, IICESubRequestHandler, IICEResponseHandler, IICEExtensionRequestHandler,

Copyright 2004 SAP AG


Field Summary
static String HEADER_TAGNAME
           
static String PAYLOAD_TAGNAME
           
static String USERAGENT_TAGNAME
           
 
Constructor Summary
ICEInput(InputStream is, ICEOutput output)
          Creates a new instance for processing an ICE payload contained in the specified input stream.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receives notification of character data.
 void endElement(String uri, String localName, String qName)
          Receives notifications of the end of elements in the ICE payload (XML document).
 void error(SAXParseException e)
          Receives notification of a recoverable parser error.
 void fatalError(SAXParseException e)
          Receives notification of a fatal XML parsing error.
 void handle()
          Handles the incoming ICE payload using a SAX parser.
 boolean isUnsolicitedPending()
          Checks if there are unsolicited requests or responses pending.
 void processingInstruction(String target, String data)
          Receives notification of a processing instruction.
 InputSource resolveEntity(String publicID, String systemID)
          Resolves an external entity.
 void setComRequestHandler(IICEComRequestHandler handler)
          Sets a new handler for processing all request events common to syndicators and subscribers.
 void setExtensionRequestHandler(IICEExtensionRequestHandler handler)
          Sets a new handler for processing all request events corresponding to the CM specific extensions to ICE.
 void setPayloadHandler(IICEPayloadHandler handler)
          Sets a new handler for processing all payload related events.
 void setResponseHandler(IICEResponseHandler handler)
          Sets a new handler for processing all response events.
 void setSubRequestHandler(IICESubRequestHandler handler)
          Sets a new handler for processing all request events from a subscriber.
 void setSynRequestHandler(IICESynRequestHandler handler)
          Sets a new handler for processing all request events from a syndicator.
 void startElement(String uri, String localName, String qName, Attributes attributes)
          Receives notifications of the beginnings of elements in the ICE payload (XML document).
 void warning(SAXParseException e)
          Receives notification of a parser warning.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAYLOAD_TAGNAME

public static final String PAYLOAD_TAGNAME
See Also:
Constant Field Values

HEADER_TAGNAME

public static final String HEADER_TAGNAME
See Also:
Constant Field Values

USERAGENT_TAGNAME

public static final String USERAGENT_TAGNAME
See Also:
Constant Field Values
Constructor Detail

ICEInput

public ICEInput(InputStream is,
                ICEOutput output)
Creates a new instance for processing an ICE payload contained in the specified input stream. All responses will be put to the specified output.

Default handlers will be used to process the ICE payload. Special handlers must be registered with the appropriate methods of this class.

Parameters:
is - an input stream containing the ICE payload
output - the output receiving the responses
See Also:
DefaultICEComRequestHandler, DefaultICESynRequestHandler, DefaultICESubRequestHandler, DefaultICEResponseHandler, DefaultICEExtensionRequestHandler, DefaultICEPayloadHandler
Method Detail

setResponseHandler

public void setResponseHandler(IICEResponseHandler handler)
Sets a new handler for processing all response events. If null is provided, a default handler will be used instead.

Parameters:
handler - the new handler (may be null)
See Also:
IICEResponseHandler, DefaultICEResponseHandler

setComRequestHandler

public void setComRequestHandler(IICEComRequestHandler handler)
Sets a new handler for processing all request events common to syndicators and subscribers. If null is provided, a default handler will be used instead.

Parameters:
handler - the new handler (may be null)
See Also:
IICEComRequestHandler, DefaultICEComRequestHandler

setSynRequestHandler

public void setSynRequestHandler(IICESynRequestHandler handler)
Sets a new handler for processing all request events from a syndicator. If null is provided, a default handler will be used instead.

Parameters:
handler - the new handler (may be null)
See Also:
IICESynRequestHandler, DefaultICESynRequestHandler

setSubRequestHandler

public void setSubRequestHandler(IICESubRequestHandler handler)
Sets a new handler for processing all request events from a subscriber. If null is provided, a default handler will be used instead.

Parameters:
handler - the new handler (may be null)
See Also:
IICESubRequestHandler, DefaultICESubRequestHandler

setExtensionRequestHandler

public void setExtensionRequestHandler(IICEExtensionRequestHandler handler)
Sets a new handler for processing all request events corresponding to the CM specific extensions to ICE. If null is provided, a default handler will be used instead.

Parameters:
handler - the new handler (may be null)
See Also:
IICEExtensionRequestHandler, DefaultICEExtensionRequestHandler

setPayloadHandler

public void setPayloadHandler(IICEPayloadHandler handler)
Sets a new handler for processing all payload related events. If null is provided, a default handler will be used instead.

Parameters:
handler - the new handler (may be null)
See Also:
IICEPayloadHandler, DefaultICEPayloadHandler

isUnsolicitedPending

public boolean isUnsolicitedPending()
Checks if there are unsolicited requests or responses pending.

Returns:
true if there are unsolicited requests or responses pending false otherwise

handle

public void handle()
Handles the incoming ICE payload using a SAX parser. The SAX parser will direct its events (start/end of elements, warnings, errors, ...) to this instance of ICEInput using the appropriate callback methods.


startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
Receives notifications of the beginnings of elements in the ICE payload (XML document). The parser will invoke this method at the beginning of EVERY element in the ICE payload; there will be a corresponding endElement event for every startElement event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement event.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - the namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed
localName - the local name (without prefix), or the empty string if namespace processing is not being performed
qName - the qualified name (with prefix), or the empty string if qualified names are not available
attributes - the attributes attached to the element or an empty Attribute object, if there are no attributes
Throws:
SAXException - on error (might wrap another exception)

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Receives notifications of the end of elements in the ICE payload (XML document). The parser will invoke this method at the end of EVERY element in the ICE payload (even when the element is empty); the corresponding startElement event has been reported before.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - the namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed
localName - the local name (without prefix), or the empty string if namespace processing is not being performed
qName - the qualified name (with prefix), or the empty string if qualified names are not available
Throws:
SAXException - on error (might wrap another exception)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Receives notification of character data. The parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks. However, all of the characters in any single event must come from the same external entity so that the locator provides useful information.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - the characters from the XML document.
start - the start position in the array.
length - the number of characters to read from the array.
Throws:
SAXException - on error (might wrap another exception)

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Receives notification of a processing instruction.

Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class org.xml.sax.helpers.DefaultHandler
Parameters:
target - the processing instruction target
data - the processing instruction data, or null if none is supplied
Throws:
SAXException - any SAX exception, possibly wrapping another exception
See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String)

resolveEntity

public InputSource resolveEntity(String publicID,
                                 String systemID)
                          throws SAXException
Resolves an external entity. If systemId ends with "ICE1_1.dtd", the ICE 1.1 DTD is read as resource stream from the jar file, so we do not have to download it every time from the net.

Specified by:
resolveEntity in interface EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler
Parameters:
publicID - the public identifer, or null if none is available
systemID - the system identifier provided in the XML document
Returns:
the new input source, or null to require the default behaviour
Throws:
SAXException - any SAX exception, possibly wrapping another exception
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)

warning

public void warning(SAXParseException e)
             throws SAXException
Receives notification of a parser warning.

Specified by:
warning in interface ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - the warning information encoded as an exception
Throws:
SAXException - any SAX exception, possibly wrapping another exception
See Also:
ErrorHandler.warning(org.xml.sax.SAXParseException), SAXParseException

error

public void error(SAXParseException e)
           throws SAXException
Receives notification of a recoverable parser error.

Specified by:
error in interface ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - the warning information encoded as an exception
Throws:
SAXException - any SAX exception, possibly wrapping another exception
See Also:
ErrorHandler.error(org.xml.sax.SAXParseException), SAXParseException

fatalError

public void fatalError(SAXParseException e)
                throws SAXException
Receives notification of a fatal XML parsing error.

Specified by:
fatalError in interface ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - the error information encoded as an exception
Throws:
SAXException - any SAX exception, possibly wrapping another exception
See Also:
ErrorHandler.fatalError(org.xml.sax.SAXParseException), SAXParseException
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] KMC-CM [sap.com] tc/km/frwk api EP-KM-CM
[sap.com] KMC-WPC [sap.com] tc/kmc/wpc/wpcfacade api EP-PIN-WPC-WCM


Copyright 2011 SAP AG Complete Copyright Notice