java.lang.Object
net.i2p.jetty.JettyXmlConfigurationParser
Parses a Jetty XML configuration file. Copied from Jetty XmlConfiguration.java, where the parser is private.
Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic StringDe-Obfuscate a password from the XMLstatic StringgetValue(XmlParser.Node node, String name) Recursively go through the entire tree starting at node.private static XmlParserBuilds the XML parser used to read the jetty configuration.static StringObfuscate a password for storage in the XMLstatic XmlParser.NodeReads and parses the XML configuration file.static booleansetValue(XmlParser.Node node, String name, String value) Recursively go through the entire tree starting at node.static voidwrite(XmlParser.Node node, Writer out) Write out the XML.
Constructor Details
JettyXmlConfigurationParser
public JettyXmlConfigurationParser()Constructor. Each parse call builds its own SAX parser throughinitParser(), so an instance carries no state.
Method Details
initParser
Builds the XML parser used to read the jetty configuration.- Returns:
- the new parser
parse
Reads and parses the XML configuration file.- Parameters:
f- an XML configuration file- Returns:
- the parsed configuration tree, rooted at the document node
- Throws:
IOException- if the configuration could not be readSAXException- if the configuration could not be parsed
getValue
Recursively go through the entire tree starting at node. Return the value for the first node with the name set, e.g. [Set name="name"]value[/Set]- Parameters:
node- the node whose descendants are searched for the Setname- matched case-insensitively against a Set's name attribute- Returns:
- the text of the first Set node matching name, or null if none
setValue
Recursively go through the entire tree starting at node. Return the value for the first node with the name set, e.g. [Set name="name"]value[/Set]- Parameters:
node- the node whose descendants are searched for the Setname- matched case-insensitively against a Set's name attributevalue- the text to store as the new content of the matched Set- Returns:
- true if a matching Set was found and rewritten, false if the search reached the leaves without a match
write
Write out the XML. Adapted from Node.toString(). That synchronized method caused classpath issues when called from the webapp. Also add newlines here for readability.- Parameters:
node- the node to serialize, written with its tag, attributes and childrenout- the writer that receives the XML text- Throws:
IOException- if the writer rejects the data
obfuscate
deobfuscate