private static class ConfigBuilder.Loader extends DefaultHandler
Modifier and Type | Field and Description |
---|---|
private Stack<Config> |
stack
Keep track of nested configuration objects.
|
private StringBuilder |
textBuilder
String builder for text content.
|
Modifier | Constructor and Description |
---|---|
private |
Loader() |
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length)
Load characters into text builder.
|
void |
endElement(String uri,
String localName,
String qName)
If text builder is not empty set text content to last configuration object from stack.
|
Config |
getConfig()
Get configuration object loaded from XML source.
|
void |
startElement(String uri,
String localName,
String qName,
Attributes attributes)
Create configuration object with tag name and initialize its attributes.
|
private static String |
value(Attributes attributes,
String attributeName)
Get named attribute value throwing exception if not attribute found.
|
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
private StringBuilder textBuilder
public Config getConfig()
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
property
add new
property to last configuration object from stack. In any case reset text builder.startElement
in interface ContentHandler
startElement
in class DefaultHandler
SAXException
public void endElement(String uri, String localName, String qName) throws SAXException
property
pop most recent configuration object from stack.endElement
in interface ContentHandler
endElement
in class DefaultHandler
SAXException
public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
characters
in class DefaultHandler
SAXException
private static String value(Attributes attributes, String attributeName) throws SAXException
attributes
- attributes list,attributeName
- name of attribute to retrieve.SAXException
- if there is no attribute with requested name.Copyright © 2018. All rights reserved.