SimpleMarkupParser
public interface ISimpleMarkupParser
Interface to be implemented by all simple Markup Parsers.
Default implementation is SimpleMarkupParser
.
AttoParser simple markup parsers work as SAX-style parsers that need
a markup handler object for handling parsing events. These handlers implement
the ISimpleMarkupHandler
interface, and are normally developed by
users in order to perform the operations they require for their applications.
See the documentation of the ISimpleMarkupHandler
interface for more
information on the event handler methods.
Note that this parser interface and its corresponding handlers are actually a simplified
version of the full-blown IMarkupParser
infrastructure.
Sample usage:
// Obtain a java.io.Reader on the document to be parsed
final Reader documentReader = ...;
// Create the handler instance. Extending the no-op AbstractSimpleMarkupHandler is a good start
final ISimpleMarkupHandler handler = new AbstractSimpleMarkupHandler() {
... // some events implemented
};
// Create or obtain the parser instance (can be reused). Example uses the default configuration for HTML
final ISimpleMarkupParser parser = new SimpleMarkupParser(ParseConfiguration.htmlConfiguration());
// Parse it!
parser.parse(documentReader, handler);
Note that implementations of this interface should be thread-safe, and therefore parsers should be reusable through several parsing operations and any number of concurrent threads.
Modifier and Type | Method | Description |
---|---|---|
void |
parse(char[] document,
int offset,
int len,
ISimpleMarkupHandler handler) |
Parse a document using the specified
ISimpleMarkupHandler . |
void |
parse(char[] document,
ISimpleMarkupHandler handler) |
Parse a document using the specified
ISimpleMarkupHandler . |
void |
parse(java.io.Reader reader,
ISimpleMarkupHandler handler) |
Parse a document using the specified
ISimpleMarkupHandler . |
void |
parse(String document,
ISimpleMarkupHandler handler) |
Parse a document using the specified
ISimpleMarkupHandler . |
void parse(String document, ISimpleMarkupHandler handler) throws ParseException
Parse a document using the specified ISimpleMarkupHandler
.
document
- the document to be parsed, as a String.handler
- the handler to be used, an ISimpleMarkupHandler
implementation.ParseException
- if the document cannot be parsed.void parse(char[] document, ISimpleMarkupHandler handler) throws ParseException
Parse a document using the specified ISimpleMarkupHandler
.
document
- the document to be parsed, as a char[].handler
- the handler to be used, an ISimpleMarkupHandler
implementation.ParseException
- if the document cannot be parsed.void parse(char[] document, int offset, int len, ISimpleMarkupHandler handler) throws ParseException
Parse a document using the specified ISimpleMarkupHandler
.
document
- the document to be parsed, as a char[].offset
- the offset to be applied on the char[] document to determine the
start of the document contents.len
- the length (in chars) of the document stored in the char[].handler
- the handler to be used, an ISimpleMarkupHandler
implementation.ParseException
- if the document cannot be parsed.void parse(java.io.Reader reader, ISimpleMarkupHandler handler) throws ParseException
Parse a document using the specified ISimpleMarkupHandler
.
Implementations of this interface must close the provided Reader
object after parsing.
reader
- a Reader on the document.handler
- the handler to be used, an ISimpleMarkupHandler
implementation.ParseException
- if the document cannot be parsed.Copyright © 2018 The ATTOPARSER team. All rights reserved.