public interface Parser
Parsers are typically used to create new LibraryObjects in the repository. For example, an XML Parser creates LibraryObjects based on XML input; a Multipart MIME Parser creates LibraryObjects based on multipart MIME input.
Generally, a given Parser can create objects of any LibraryObject subclass. For example, an XML Parser could create Folders, Documents, a mixture of these, or any other LibraryObject subclass. However, a specialized Parser capable of parsing only Documents (for example) could throw an exception if the InputStream or Reader described a DirectoryUser.
A Parser typically determines which LibraryObject subclass to create based
on the InputStream or Reader. However, some Parsers may allow or even
require this to be specified through the options
parameter
to the parse
method.
If the InputStream or Reader describes more than one LibraryObject, a parser may elect either to create each object as it goes or to create all objects upon reaching the end of the stream.
Choosing the correct Parser is the application's responsibility. An application might do this based on filename extension, MIME type, explicit user input, or any other mechanism appropriate for that application.
Parsers should provide a constructor with the following signature:
Parser(LibrarySession) throws IfsException
.
Modifier and Type | Field and Description |
---|---|
static String |
CURRENT_NAME_OPTION
Key for hashtable option which specifies the current working name.
|
static String |
CURRENT_PATH_OPTION
Key for hashtable option which specifies the current working folder path.
|
static String |
DOCUMENT_CHARSET_OPTION
Key for hashtable option which specifies the character set of a
document.
|
static String |
DOCUMENT_LANGUAGE_OPTION
Key for hashtable option which specifies the language of a
document.
|
static String |
LITERAL_DOCUMENT_OPTION
Key for hashtable option which specifies whether a parser should
create a literal document from the InputStream passed to the parser.
|
static String |
UPDATE_OBJECT_OPTION
Option which indicates the existing iFS object being updated
by this call to the Parser.
|
static String |
VALIDATE_DOCUMENT_OPTION
Key for hashtable option which specifies whether an XML document
should be validated against its corresponding DTD.
|
Modifier and Type | Method and Description |
---|---|
LibraryObject |
parse(InputStream stream,
ParserCallback callback,
Hashtable options)
Parses the specified InputStream.
|
LibraryObject |
parse(Reader reader,
ParserCallback callback,
Hashtable options)
Parses the specified Reader.
|
static final String CURRENT_PATH_OPTION
static final String CURRENT_NAME_OPTION
static final String VALIDATE_DOCUMENT_OPTION
static final String LITERAL_DOCUMENT_OPTION
static final String DOCUMENT_CHARSET_OPTION
static final String DOCUMENT_LANGUAGE_OPTION
static final String UPDATE_OBJECT_OPTION
LibraryObject parse(InputStream stream, ParserCallback callback, Hashtable options) throws IfsException
stream
- the InputStreamcallback
- an application object that interacts with the
the parsing process; optional, can be nulloptions
- any Parser-specific optionsIfsException
- (IFS-12601) if the operation failsLibraryObject parse(Reader reader, ParserCallback callback, Hashtable options) throws IfsException
reader
- the Readercallback
- an application object that interacts with the
the parsing process; optional, can be nulloptions
- any Parser-specific optionsIfsException
- (IFS-12602) if the operation failsCopyright © 2023. All rights reserved.