public abstract class ParserFactory extends Object
Parser
s. ParserFactory
implemementations
can be registered in MimeLoolup
either for a specific
mime type or for all languages. The example below shows ParserFactory
registration for text/x-something
mime type in an XML layer.
<folder name="Editors"> <folder name="text"> <folder name="x-something"> <file name="org-some-module-MyParserFactory.instance" /> </folder> </folder> </folder>
Constructor and Description |
---|
ParserFactory() |
Modifier and Type | Method and Description |
---|---|
abstract Parser |
createParser(Collection<Snapshot> snapshots)
Creates a new instance of
Parser . |
public abstract Parser createParser(Collection<Snapshot> snapshots)
Parser
. In general parsers are created
for either one or several snapshots (ie. document sections), which are provided
to this method. It is guaranteed that all snapshots in the collection will be
of the same mime type and it will be the mime type, which this factory
was registered for (ie. in MimeLookup
). Typical factories won't
need the snapshots for creating a parser, but factories that serve multiple
languages (eg. in GSF or other language support frameworks) may find this useful.
It is important to remember that the snapshots are provided only
for the factory and they reflect document states at the time when the factory
is called. Since the parsing infrastructure may cache parser instances it
will provide a new snapshot when it asks Parser
s to do their job.
Therefore the snapshots here may only be used for the parser creation, but must
never be used for parsing!
snapshots
- Snaphots of documents, which the new parser will be asked
to parse.Parser
instance or null
if this
factory does not have a parser suitable for parsing this type of snapshots.