public abstract class Parser extends Object
This class provides the foundation for parsing XML documents from various sources including URLs, files, and strings. It includes security measures specific to I2P to prevent access to localhost and private networks.
Key features:
| Constructor and Description |
|---|
Parser()
Creates a new Parser instance.
|
| Modifier and Type | Method and Description |
|---|---|
Node |
parse(File descriptionFile)
Parses XML content from the specified file.
|
abstract Node |
parse(InputStream inStream)
Parses XML content from the specified input stream.
|
Node |
parse(String descr)
Parses XML content from the specified string.
|
Node |
parse(URL locationURL)
Parses XML content from the specified URL.
|
public Node parse(File descriptionFile) throws ParserException
descriptionFile - the file containing XML content to parseParserException - if file reading fails or parsing failspublic abstract Node parse(InputStream inStream) throws ParserException
This is the core parsing method that must be implemented by subclasses. The implementation should parse the XML content and return the root node of the parsed XML document.
inStream - the input stream containing XML contentParserException - if parsing failspublic Node parse(String descr) throws ParserException
The string is assumed to contain UTF-8 encoded XML content.
descr - the string containing XML content to parseParserException - if parsing failspublic Node parse(URL locationURL) throws ParserException
This method includes I2P-specific security checks to prevent access to localhost and private networks. Only HTTP URLs are supported.
locationURL - the URL to fetch and parse XML content fromParserException - if URL validation fails, HTTP request fails, or parsing fails