|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
com.interstarinc.xmedius.sendfax.XMLBuilder.MetaDocHandler
public class XMLBuilder.MetaDocHandler
This class defines the SAX parser callback methods.
It creates a DOM tree with text nodes values picked up from a java beans graph
according to meta-attributes found in a meta-document.
| Field Summary | |
|---|---|
private DOMImplementation |
impl
The DOMImplementation to be used. |
private List |
metaAttList
The meta-attributes names retrieved from the processing instruction meta-att-list. |
private Object |
model
The model from which to pick up the DOM tree text node values. |
private boolean |
nameSpaceAware
Is the meta-document namespace aware? |
private Node |
parent
The parent node of a newly created element. |
private String |
skippedElement
Holds the meta-document element name to be skipped. |
static String |
XMB_NAME_SPACE
A namespace aware meta-document must declare this namespace URI on its root element and qualified all meta-attributes. |
private Document |
xmlDoc
The document object model tree produced by the XMLBuilder. |
| Constructor Summary | |
|---|---|
XMLBuilder.MetaDocHandler(Object model)
|
|
| Method Summary | |
|---|---|
private void |
addAttributes(Element element,
Attributes atts)
Adds attributes to an element created in the startElement method. |
private void |
addNodes(Node aListItem,
String currentIndex)
This method adds a node element that maps to a model list entry. |
private Attributes |
createAttributes(NamedNodeMap map,
String currentIndex)
Creates the attributes to be passed to startElement. |
void |
endDocument()
|
void |
endElement(String nameSpaceUri,
String localName,
String qName)
This callback method adds a text node value to an element. |
private String |
getAttributeValue(Attributes atts,
String attName)
Returns an element meta-attribute value, whether or not the meta-document is namespace aware. |
private String |
getAttributeValue(Element elem,
String attName)
Returns an element meta-attribute value, whether or not the meta-document is namespace aware. |
Document |
getXmlDoc()
|
private boolean |
isInstructionDataValid(String data)
This methods validates a processing instruction value. |
void |
processingInstruction(String target,
String data)
This callback method handles the processing instructions. |
private void |
removeMetaAttributes(Element element)
Whenever the parser reaches the end of the meta-document, this method is called to remove all meta-attributes from the created DOM tree. |
void |
startDocument()
This callback is used to create the DOM implementor. |
void |
startElement(String nameSpaceUri,
String localName,
String qName,
Attributes atts)
This callback method creates the document and its elements. |
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
|---|
characters, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String XMB_NAME_SPACE
private DOMImplementation impl
private Document xmlDoc
XMLBuilder.
private Node parent
private String skippedElement
private Object model
private List metaAttList
meta-att-list.
processingInstruction(String, String),
isInstructionDataValid(String)private boolean nameSpaceAware
| Constructor Detail |
|---|
public XMLBuilder.MetaDocHandler(Object model)
model - The java beans graph used to set text node values.| Method Detail |
|---|
public Document getXmlDoc()
public void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in class DefaultHandlerSAXException - if the DOM implementor cannot be created.DocumentBuilderFactory,
DocumentBuilder
public void startElement(String nameSpaceUri,
String localName,
String qName,
Attributes atts)
throws SAXException
startElement in interface ContentHandlerstartElement in class DefaultHandlernameSpaceUri - The element namespace uri, if the meta-document is namespace aware.localName - The element local name, if the meta-document is namespace aware.qName - The qualified element name.atts - The element attributes
SAXExceptionaddAttributes(Element, Attributes),
getAttributeValue(Attributes, String),
PropertyUtils.getProperty(java.lang.Object, java.lang.String)
private String getAttributeValue(Attributes atts,
String attName)
atts - The element attributes.attName - The meta-attribute to look up in atts.
private String getAttributeValue(Element elem,
String attName)
elem - The element to be queried.attName - The meta-attribute to look up in elem.
public void endElement(String nameSpaceUri,
String localName,
String qName)
throws SAXException
endElement in interface ContentHandlerendElement in class DefaultHandlernameSpaceUri - The element namespace uri, if the meta-document is namespace aware.localName - The element local name, if the meta-document is namespace aware.qName - The qualified element name.
SAXExceptiongetAttributeValue(Element, String),
addNodes(Node, String),
PropertyUtils.getProperty(java.lang.Object, java.lang.String)
private void addNodes(Node aListItem,
String currentIndex)
throws SAXException
aListItem and its children.startElement and then, calls itself for each aListItem children.
Whenever backtracking occurs this method calls endElement.
aListItem - The meta-document element that maps to a model list entry.currentIndex - The current model list entry.
SAXExceptionstartElement(String, String, String, Attributes),
endElement(String, String, String),
createAttributes(NamedNodeMap, String)
private Attributes createAttributes(NamedNodeMap map,
String currentIndex)
startElement.
map - The element attributes map used to creates the attribute list.currentIndex - This parameter is used to update the meta-attribute index when iterating over an indexed model property.
startElementstartElement(String, String, String, Attributes),
addNodes(Node, String)
public void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in class DefaultHandlerSAXExceptionremoveMetaAttributes(Element)
private void removeMetaAttributes(Element element)
throws SAXException
element - The created document root element.
SAXExceptionendDocument()
private void addAttributes(Element element,
Attributes atts)
throws SAXException
startElement method.
startElement method.
The meta-attributes are also added in order to handle the indexed model properties.
They will be removed from the document whenever the parsing is completed.
element - The element created in the startElement method.atts - The attributes list used to create the element's attributes.
SAXExceptionstartElement(String, String, String, Attributes),
removeMetaAttributes(Element)
public void processingInstruction(String target,
String data)
throws SAXException
meta-att-list, this method validates its value.
If the value is valid, this method initializes the instance variable metaAttList from
the processing instruction value. Otherwise, it throws a SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in class DefaultHandlertarget - The processing instruction name.data - The processing instruction value.
SAXExceptionprivate boolean isInstructionDataValid(String data)
data - A processing instruction value to be validated.
true if the processing instruction value is valid, false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||