|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.marineapi.nmea.parser.SentenceFactory
public final class SentenceFactory
Factory for creating sentence parsers. Custom parsers may be registered using
the registerParser(String, Class)
method.
How-to create and register custom parsers:
XYZSentence
).
SentenceParser
,
(e.g. XYZParser
).
SentenceParser
to read
and write sentence fields.
SentenceParser.SentenceParser(String, String)
together with assumed
sentence id (e.g. "XYZ"
).
SentenceFactory
using the
registerParser(String, Class)
method.
createParser(String)
with
XYZ
sentence String and you should get an instance of
XYZSentence
interface.
Method Summary | |
---|---|
Sentence |
createParser(String nmea)
Creates a parser for specified NMEA sentence String. |
static SentenceFactory |
getInstance()
Returns the singleton instance of SentenceFactory . |
boolean |
hasParser(String type)
Tells if the factory is able to create parser for specified sentence type. |
void |
registerParser(String type,
Class<? extends SentenceParser> parser)
Register a sentence parser to factory. |
void |
unregisterParser(Class<? extends SentenceParser> parser)
Unregisters a parser class, regardless of sentence type(s) it is registered for. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public Sentence createParser(String nmea)
nmea
- NMEA 0183 sentence String
IllegalArgumentException
- If there is no parser registered for the
given sentence type
IllegalStateException
- If parser is found, but it does not
implement expected constructor with single String parameter.
RuntimeException
- If unable to find or access the parser.public boolean hasParser(String type)
SentenceId
enum values should result returning
true
at all times.
type
- Sentence type id, e.g. "GLL" or "GGA".
public void registerParser(String type, Class<? extends SentenceParser> parser)
createParser(String)
method can be used to obtain parsers for
registered type. All sentences supported by the library are registered by
default, and this method is provided mainly for registering custom
parsers that can be created by extending the SentenceParser
class.
type
- Sentence type id, e.g. "GGA" or "GLL".parser
- Parser implementation class for type
.public void unregisterParser(Class<? extends SentenceParser> parser)
parser
- Parser implementation class for type
.registerParser(String, Class)
public static SentenceFactory getInstance()
SentenceFactory
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |