There is some javadoc documentation for this parser.
These instructions assume you are using the Java VM which understands the The Java Extension Mechanism. Other VMs may require a slightly different procedure.
the
<java-home>/lib/ext directory.
public class myclass implements ParserListener{
public myclass() {
Parser parser = new Parser(port.getInputStream(), this);
}
/** Handle notification of an event from the parser. */
public void parserOutput(ParsedSentence parsedSentence) {
// coordinate to fire if we ever get one...
NMEA0183Coordinate pos = null;
switch (parsedSentence.getSentenceID()) {
case Mappings.GLL:
GLL sentenceGLL = (GLL)parsedSentence;
if (sentenceGLL.isDataValid()) {
coord = sentenceGLL.getLocationOfFix();
}
break;
case Mappings.GGA:
GGA sentenceGGA = (GGA)parsedSentence;
if (sentenceGGA.getQualityOfFix() != GGA.NO_FIX) {
coord = sentenceGGA.getLocationOfFix();
}
break;
default:
System.err.println("GPSDevice, not handling ParsedSentence: "
+ parsedSentence.getSentenceType() + " "
+ parsedSentence.getSentenceID());
break;
}
if (coord != null) {
dispatchPosition(coord);
}
}
private void dispatchPosition(NMEA0183Coordinate c) {
// Handle position
}
}