Package org.jvnet.hk2.config
Class ConfigParser
- java.lang.Object
-
- org.jvnet.hk2.config.ConfigParser
-
public class ConfigParser extends Object
Parses configuration files, buildsInhabitant
s, and add them toHabitat
.This class also maintains the model of various elements in the configuration file.
This class can be sub-classed to create a
ConfigParser
with a custom non-standard behavior.- Author:
- Kohsuke Kawaguchi
-
-
Field Summary
Fields Modifier and Type Field Description protected org.glassfish.hk2.api.ServiceLocator
habitat
This is where we put parsed inhabitants into.
-
Constructor Summary
Constructors Constructor Description ConfigParser(org.glassfish.hk2.api.ServiceLocator habitat)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Dom
handleElement(XMLStreamReader in, DomDocument document, Dom parent)
Parses a whole XML tree and builds aDom
tree.protected Dom
handleElement(XMLStreamReader in, DomDocument document, Dom parent, ConfigModel model)
Parses a whole XML tree and builds aDom
tree, by using the given model for the top-level element.DomDocument
parse(URL source)
DomDocument
parse(URL source, DomDocument document)
DomDocument
parse(URL source, DomDocument document, Dom parent)
DomDocument
parse(XMLStreamReader in)
void
parse(XMLStreamReader in, DomDocument document)
void
parse(XMLStreamReader in, DomDocument document, Dom parent)
-
-
-
Method Detail
-
parse
public DomDocument parse(XMLStreamReader in) throws XMLStreamException
- Throws:
XMLStreamException
-
parse
public void parse(XMLStreamReader in, DomDocument document) throws XMLStreamException
- Throws:
XMLStreamException
-
parse
public void parse(XMLStreamReader in, DomDocument document, Dom parent) throws XMLStreamException
- Throws:
XMLStreamException
-
parse
public DomDocument parse(URL source)
-
parse
public DomDocument parse(URL source, DomDocument document)
-
parse
public DomDocument parse(URL source, DomDocument document, Dom parent)
-
handleElement
protected Dom handleElement(XMLStreamReader in, DomDocument document, Dom parent) throws XMLStreamException
Parses a whole XML tree and builds aDom
tree.This is the entry point for the root element of a configuration tree.
- Parameters:
in
- pre-condition: 'in' is at the start element. post-condition: 'in' is at the end element.document
- The document that we are building right now. Newly createdDom
will belong to this document.parent
- The parent element- Returns:
- Null if the XML element didn't yield anything (which can happen if the element is skipped.)
Otherwise fully parsed valid
Dom
object. - Throws:
XMLStreamException
-
handleElement
protected Dom handleElement(XMLStreamReader in, DomDocument document, Dom parent, ConfigModel model) throws XMLStreamException
Parses a whole XML tree and builds aDom
tree, by using the given model for the top-level element.This is the entry point for recursively parsing inside a configuration tree. Since not every element is global, you don't always want to infer the model just from the element name (as is the case with
handleElement(XMLStreamReader, DomDocument, Dom)
.- Parameters:
in
- pre-condition: 'in' is at the start element. post-condition: 'in' is at the end element.document
- The document that we are building right now. Newly createdDom
will belong to this document.parent
- The parent element- Returns:
- Null if the XML element didn't yield anything (which can happen if the element is skipped.)
Otherwise fully parsed valid
Dom
object. - Throws:
XMLStreamException
-
-