|
Media Authoring with Java API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttv.amwa.maj.io.xml.MasterContentHandler
public class MasterContentHandler
The master content handler is the root of all SAX content handlers used to deserialize XML documents and fragments into object instances of this AAF implementation. The SAX parser included with the core Java APIs provides an efficient, event-driven approach to parsing XML documents. This class and its subclasses provide content handlers that respond to the parser's generated events and create object instances. This content handler is designed so that every object that can be deserialized from a known XML element name can do so by first registering an appropriate handler.
To make use of the parsing capabilities of a master content handler, call
XMLBuilder.createFromXML(InputSource)
. This will create a master content handler,
parse the input source and return any resulting object.
registerHandler(Class)
. The handler must extend LocalHandler
,
which is in turn a direct subclass of this class. To intiialize all the XML handlers required to
parse AAF XML files, call registerCoreHandlers()
.
One approach that can be taken to providing an element specific handler is to implement a static inner class within the object to be created from the given element. For example:
public class VersionNumber { ... public final static class XMLHandler extends tv.amwa.maj.io.xml.LocalHandler implements org.xml.sax.ContentHandler.ContentHandler { ... } ... }
More information on how to do this is provided in the documentation for the LocalHandler
class.
Field Summary |
---|
Fields inherited from interface tv.amwa.maj.industry.SpecifiedClasses |
---|
abstractInterchangeable, abstractMeta, interchangeable, meta |
Method Summary | |
---|---|
void |
characters(char[] ch,
int start,
int length)
|
void |
endDocument()
Called at the end of the document represented by the input source of this master content handler. |
void |
endElement(String uri,
String localName,
String name)
Called if an end element event is sent by the SAX parser to a master content handler. |
void |
endPrefixMapping(String prefix)
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
|
void |
processingInstruction(String target,
String data)
|
static void |
registerCoreHandlers()
Registers handlers for the core elements of AAF XML. |
static boolean |
registerHandler(Class<? extends LocalHandler> handler)
Registers an XML handling class for a given element name. |
static void |
registerHandlersForClass(Class<?> containsHandler)
|
void |
setDocumentLocator(Locator locator)
|
void |
skippedEntity(String name)
|
void |
startDocument()
|
void |
startElement(String uri,
String localName,
String name,
Attributes atts)
Called by the SAX parser when the root element of the input source of this master content handler has been read. |
void |
startPrefixMapping(String prefix,
String uri)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
SAXException
ContentHandler.characters(char[], int, int)
public void endDocument() throws SAXException
Called at the end of the document represented by the input source of this master content handler. The result of the master content handler parse is the result of its only subelement.
endDocument
in interface ContentHandler
SAXException
ContentHandler.endDocument()
public void endElement(String uri, String localName, String name) throws SAXException
Called if an end element event is sent by the SAX parser to a master content handler. This should not happen and so an exception will be thrown.
endElement
in interface ContentHandler
SAXException
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public final void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
SAXException
ContentHandler.endPrefixMapping(java.lang.String)
public final void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
ignorableWhitespace
in interface ContentHandler
SAXException
ContentHandler.ignorableWhitespace(char[], int, int)
public final void processingInstruction(String target, String data) throws SAXException
processingInstruction
in interface ContentHandler
SAXException
ContentHandler.processingInstruction(java.lang.String, java.lang.String)
public final void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
ContentHandler.setDocumentLocator(org.xml.sax.Locator)
public final void skippedEntity(String name) throws SAXException
skippedEntity
in interface ContentHandler
SAXException
ContentHandler.skippedEntity(java.lang.String)
public final void startDocument() throws SAXException
startDocument
in interface ContentHandler
SAXException
ContentHandler.startDocument()
public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException
Called by the SAX parser when the root element of the input source of this master content handler has been read. A sub element content handler is created from the register of handlers and parsing of the document continues using this newly created handler.
startElement
in interface ContentHandler
SAXException
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public final void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping
in interface ContentHandler
SAXException
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)
public static final boolean registerHandler(Class<? extends LocalHandler> handler) throws NullPointerException, IllegalArgumentException
Registers an XML handling class for a given element name. The handler must be class
that extends LocalHandler
. If a handler is already registered for the given
element name, it is not replaced. This is to ensure that if registerCoreHandlers()
has been called, core handlers are not overridden. If the given handler is successfully
registered, true
is returned, otherwise false
.
handler
- Content handler for the given element name.
NullPointerException
- The handler argument is null
.
IllegalArgumentException
- The given handler does not contain an accessible
"elementName
" static string value.public static final void registerHandlersForClass(Class<?> containsHandler)
public static final void registerCoreHandlers()
Registers handlers for the core elements of AAF XML. To extend the range of elements
parsed by this master content handler, call registerHandler(Class)
.
|
Media Authoring with Java API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |