fipaos.parser.xml
Class XMLContentHandler


public class XMLContentHandler
implements DocumentHandler, DTDHandler, EntityResolver, ErrorHandler, Parser

Converts between XML messages and Content objects.

XML particular Content object implementation details:




Field Summary
 final static StringXML_ATTR_CLOSE
           
 final static StringXML_ATTR_OPEN
           
 final static StringXML_CDATA_CLOSE
           
 final static StringXML_CDATA_CLOSE_REPLACE
           
 final static StringXML_CDATA_START
           
 final static StringXML_DTD_END
           
 final static StringXML_DTD_MIDDLE
           
 final static StringXML_DTD_START
           
 final static StringXML_HEADER
          The tag found at the start of every XML document
 final static StringXML_SPACE
           
 final static StringXML_TAG_CLOSE
           
 final static StringXML_TAG_CLOSE_END
           
 final static StringXML_TAG_OPEN
           
 final static StringXML_TAG_OPEN_END
           

Constructor Summary
XMLContentHandler()
          Default constructor for this Parser.

Method Summary
 booleancanParse(String content)
          Determines if the Parser implementation can parse the given content
 voidcharacters(char[] ch, int start, int length)
          Receive notification of character data inside an element.
 Stringdeparse(Content content)
          This method converts a Content object into a document which is of a format determined by the Parser implementation.
 voidendDocument()
          Receive notification of the end of the document.
 voidendElement(String name)
          Receive notification of the end of an element.
 voiderror(SAXParseException e)
          Receive notification of a recoverable parser error.
 voidfatalError(SAXParseException e)
          Report a fatal XML parsing error.
 static StringgetNormalisedForm(String non_normalised)
          If necessary converts the given String into a format suitable for placing within an XML tags (i.e.
 StringgetParserType()
          Returns the type of content language that the Parser implementation handles.
 voidignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable whitespace in element content.
 static booleanisXML(String content)
          Indicates if the given content is an XML document
 static voidmain(String[] args)
           
 voidnotationDecl(String p1, String p2, String p3)
          Receive notification of a notation declaration.
 Contentparse(String content)
          This method converts a content String into a set of Content objects
 voidprocessingInstruction(String target, String data)
          Receive notification of a processing instruction.
 InputSourceresolveEntity(String publicId, String systemId)
          Resolve an external entity.
 voidsetDocumentLocator(Locator locator)
          Receive a Locator object for document events.
 voidstartDocument()
          Receive notification of the beginning of the document.
 voidstartElement(String name, AttributeList attributes)
          Receive notification of the start of an element.
 voidunparsedEntityDecl(String p1, String p2, String p3, String p4)
          Receive notification of an unparsed entity declaration.
 voidwarning(SAXParseException e)
          Receive notification of a parser warning.

Field Detail

XML_ATTR_CLOSE

public final static String XML_ATTR_CLOSE

XML_ATTR_OPEN

public final static String XML_ATTR_OPEN

XML_CDATA_CLOSE

public final static String XML_CDATA_CLOSE

XML_CDATA_CLOSE_REPLACE

public final static String XML_CDATA_CLOSE_REPLACE

XML_CDATA_START

public final static String XML_CDATA_START

XML_DTD_END

public final static String XML_DTD_END

XML_DTD_MIDDLE

public final static String XML_DTD_MIDDLE

XML_DTD_START

public final static String XML_DTD_START

XML_HEADER

public final static String XML_HEADER
The tag found at the start of every XML document

XML_SPACE

public final static String XML_SPACE

XML_TAG_CLOSE

public final static String XML_TAG_CLOSE

XML_TAG_CLOSE_END

public final static String XML_TAG_CLOSE_END

XML_TAG_OPEN

public final static String XML_TAG_OPEN

XML_TAG_OPEN_END

public final static String XML_TAG_OPEN_END
Constructor Detail

XMLContentHandler

public XMLContentHandler()
Default constructor for this Parser. Used buy the ParserFactory
Method Detail

canParse

public boolean canParse(String content)
Determines if the Parser implementation can parse the given content
Parameters:
content - The content to be tested
Returns: True if the Parser implementation can parse the given String

characters

public void characters(char[] ch, int start, int length)
throws SAXException
Receive notification of character data inside an element.
Parameters:
ch - The characters.
start - The start position in the character array.
length - The number of characters to use from the character array.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.DocumentHandler#characters

deparse

public String deparse(Content content)
This method converts a Content object into a document which is of a format determined by the Parser implementation.
Parameters:
content - The Content object to deparse
Returns: The Stringified representation of the Content object

endDocument

public void endDocument()
throws SAXException
Receive notification of the end of the document.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.DocumentHandler#endDocument

endElement

public void endElement(String name)
throws SAXException
Receive notification of the end of an element.
Parameters:
name - The element type name.
attributes - The specified or defaulted attributes.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.DocumentHandler#endElement

error

public void error(SAXParseException e)
throws SAXException
Receive notification of a recoverable parser error.
Parameters:
e - The warning information encoded as an exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.ErrorHandler#warning, org.xml.sax.SAXParseException

fatalError

public void fatalError(SAXParseException e)
throws SAXException
Report a fatal XML parsing error.
Parameters:
e - The error information encoded as an exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.ErrorHandler#fatalError, org.xml.sax.SAXParseException

getNormalisedForm

public static String getNormalisedForm(String non_normalised)
If necessary converts the given String into a format suitable for placing within an XML tags (i.e. appropriate characters extracted and replaced to ensure unambiguous parsing)
Parameters:
non_normalised - String to be correctly formatted
Returns: A String representing the same information as the original String, but in an XML-friendly format

getParserType

public String getParserType()
Returns the type of content language that the Parser implementation handles.
Returns: A String representation of the content format (e.g. RDF, SL)

ignorableWhitespace

public void ignorableWhitespace(char[] ch, int start, int length)
throws SAXException
Receive notification of ignorable whitespace in element content.
Parameters:
ch - The whitespace characters.
start - The start position in the character array.
length - The number of characters to use from the character array.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.DocumentHandler#ignorableWhitespace

isXML

public static boolean isXML(String content)
Indicates if the given content is an XML document
Parameters:
content - The content to check
Returns: True if the content is XML

main

public static void main(String[] args)
throws java.lang.Exception

notationDecl

public void notationDecl(String p1, String p2, String p3)
throws SAXException
Receive notification of a notation declaration.
Parameters:
name - The notation name.
publicId - The notation public identifier, or null if not available.
systemId - The notation system identifier.
See Also:
org.xml.sax.DTDHandler#notationDecl

parse

public Content parse(String content)
This method converts a content String into a set of Content objects
Parameters:
content - The String to parse into Content objects
Returns: A Content object representing the content String given.

processingInstruction

public void processingInstruction(String target, String data)
throws SAXException
Receive notification of a processing instruction.
Parameters:
target - The processing instruction target.
data - The processing instruction data, or null if none is supplied.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.DocumentHandler#processingInstruction

resolveEntity

public InputSource resolveEntity(String publicId, String systemId)
throws SAXException
Resolve an external entity.
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:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.EntityResolver#resolveEntity

setDocumentLocator

public void setDocumentLocator(Locator locator)
Receive a Locator object for document events.
Parameters:
locator - A locator for all SAX document events.
See Also:
org.xml.sax.DocumentHandler#setDocumentLocator, org.xml.sax.Locator

startDocument

public void startDocument()
throws SAXException
Receive notification of the beginning of the document.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.DocumentHandler#startDocument

startElement

public void startElement(String name, AttributeList attributes)
throws SAXException
Receive notification of the start of an element.
Parameters:
name - The element type name.
attributes - The specified or defaulted attributes.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.DocumentHandler#startElement

unparsedEntityDecl

public void unparsedEntityDecl(String p1, String p2, String p3, String p4)
throws SAXException
Receive notification of an unparsed entity declaration.
Parameters:
name - The entity name.
publicId - The entity public identifier, or null if not available.
systemId - The entity system identifier.
notationName - The name of the associated notation.
See Also:
org.xml.sax.DTDHandler#unparsedEntityDecl

warning

public void warning(SAXParseException e)
throws SAXException
Receive notification of a parser warning.
Parameters:
e - The warning information encoded as an exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
org.xml.sax.ErrorHandler#warning, org.xml.sax.SAXParseException

Association Links

to Class java.lang.String

The tag found at the start of every XML document

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class fipaos.agent.conversation.content.Content

During parsing (which places a mutex lock on this) this contains the Root content object into which the XML document is being parsed

to Class java.util.Stack

A Stack of Content objects currently being produced (the top-most being the most recently created, the next being its parent etc..)