de.fhg.igd.gps
Class NMEA183Sentence

java.lang.Object
  extended byde.fhg.igd.gps.NMEA183Sentence
Direct Known Subclasses:
NMEA183GGASentence, NMEA183GLLSentence, NMEA183GSASentence, NMEA183GSVSentence, NMEA183RMCSentence, NMEA183VTGSentence

public class NMEA183Sentence
extends Object

This class represents a generic NMEA183 sentence.

Author:
Dennis Bartussek

Field Summary
protected  byte checksum_
          The checksum of this sentence.
protected  List fields_
           
protected  String sentenceId_
           
protected  String sentenceId_desc_
           
protected  String talkerId_
           
protected  String talkerId_desc_
           
 
Constructor Summary
NMEA183Sentence()
          Constructs a new NMEA183Sentence.
NMEA183Sentence(String talkerId)
          Constructs a new NMEA183Sentence with the specified talkerId.
NMEA183Sentence(String talkerId, String sentenceId)
          Constructs a new NMEA183Sentence with the specified talkerId and sentenceId.
 
Method Summary
protected  String bodyToString()
          Returns the body part of this sentence's string representation.
protected  byte computeChecksum()
          Computes the checksum that is valid for this NMEA183Sentence.
protected  Date getDateField(int index)
          Returns the element of fields_ at the specified index, transformed into a Date object.
protected  double getFloatField(int index)
          Returns the element of fields_ at the specified index, transformed into a double value.
protected  int getIntegerField(int index)
          Returns the element of fields_ at the specified index, transformed into an int value.
protected  Latitude getLatitudeField(int index)
          Returns the element of fields_ at the specified index, transformed into a Latitude object.
protected  Longitude getLongitudeField(int index)
          Returns the element of fields_ at the specified index, transformed into a Longitude object.
 String getSentenceId()
          Returns the sentence id of this NMEA183Sentence.
protected  String getStringField(int index)
          Returns the element of fields_ at the specified index as a String object.
 boolean hasChecksum()
          Tests whether a checksum has been specified for this NMEA183Sentence or not.
protected  String headerToString()
          Returns the header part of this sentence's string representation, which consists of: the talker id the sentence id the checksum
private  String lookupTalkerId(String id)
          Returns the description of the specified talker id.
 void parse(NMEA183Tokenizer tokenizer)
          Reads and parses a NMEA183 sentence from tokenizer.
protected  byte[] rebuildSentence()
          Builds a nmea sentence string based on fields_.
 String toString()
          Returns the string representation of this NMEA183Sentence.
 boolean valid()
          Tests whether the specified checksum is valid for this NMEA183Sentence or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sentenceId_desc_

protected String sentenceId_desc_

talkerId_desc_

protected String talkerId_desc_

sentenceId_

protected String sentenceId_

talkerId_

protected String talkerId_

fields_

protected List fields_

checksum_

protected byte checksum_
The checksum of this sentence. A value of 0 indicates that a checksum has not been specified for this sentence.

Constructor Detail

NMEA183Sentence

public NMEA183Sentence()
Constructs a new NMEA183Sentence.


NMEA183Sentence

public NMEA183Sentence(String talkerId)
Constructs a new NMEA183Sentence with the specified talkerId.

Parameters:
talkerId - the talker id of this NMEA183Sentence

NMEA183Sentence

public NMEA183Sentence(String talkerId,
                       String sentenceId)
Constructs a new NMEA183Sentence with the specified talkerId and sentenceId.

Parameters:
talkerId - the talker id of this NMEA183Sentence
sentenceId - the sentence id of this NMEA183Sentence
Method Detail

hasChecksum

public boolean hasChecksum()
Tests whether a checksum has been specified for this NMEA183Sentence or not.

Returns:
true if a checksum has been specified; otherwise false

valid

public boolean valid()
Tests whether the specified checksum is valid for this NMEA183Sentence or not.

Returns:
true if checksum is valid for this sentence or if checksum has not been specified, false if checksum is invalid for this NMEA183Sentence.

parse

public void parse(NMEA183Tokenizer tokenizer)
           throws NMEA183SentenceFormatException
Reads and parses a NMEA183 sentence from tokenizer.

Parameters:
tokenizer - the NMEA183Tokenizer to read from
Throws:
NMEA183SentenceFormatException - if the read sentence does not have the appropriate format

getSentenceId

public String getSentenceId()
Returns the sentence id of this NMEA183Sentence.

Returns:
the sentence id of this NMEA183Sentence.

toString

public String toString()
Returns the string representation of this NMEA183Sentence.

Returns:
the string representation of this NMEA183Sentence.

lookupTalkerId

private String lookupTalkerId(String id)
Returns the description of the specified talker id. If id is not known the String "unknown" is returned.

Parameters:
id - the talker id to query
Returns:
the description of the specified talker id.

getDateField

protected Date getDateField(int index)
                     throws IndexOutOfBoundsException
Returns the element of fields_ at the specified index, transformed into a Date object. The index argument is expected to be more than 0 and less than fields_.size().

Parameters:
index - the index of the element to get
Throws:
IndexOutOfBoundsException - if index is less than 0 or more than fields_.size()

getFloatField

protected double getFloatField(int index)
                        throws IndexOutOfBoundsException,
                               NumberFormatException
Returns the element of fields_ at the specified index, transformed into a double value. The index argument is expected to be more than 0 and less than fields_.size().

Parameters:
index - the index of the element to get
Throws:
IndexOutOfBoundsException - if index is less than 0 or more than fields_.size()
NumberFormatException - if the element at the given index does not have the appropriate format

getIntegerField

protected int getIntegerField(int index)
                       throws IndexOutOfBoundsException,
                              NumberFormatException
Returns the element of fields_ at the specified index, transformed into an int value. The index argument is expected to be more than 0 and less than fields_.size().

Parameters:
index - the index of the element to get
Throws:
IndexOutOfBoundsException - if index is less than 0 or more than fields_.size()
NumberFormatException - if the element at the given index does not have the appropriate format

getLatitudeField

protected Latitude getLatitudeField(int index)
                             throws IndexOutOfBoundsException,
                                    AngularDistanceFormatException
Returns the element of fields_ at the specified index, transformed into a Latitude object. The index argument is expected to be more than 0 and less than fields_.size() - 1.

Note: This method actually reads 2 elements, at index and index+1

Parameters:
index - the starting index of the elements to get
Throws:
IndexOutOfBoundsException - if index is less than 0 or more than fields_.size() - 1
AngularDistanceFormatException - if the element at the given index does not have the appropriate format

getLongitudeField

protected Longitude getLongitudeField(int index)
                               throws IndexOutOfBoundsException,
                                      AngularDistanceFormatException
Returns the element of fields_ at the specified index, transformed into a Longitude object. The index argument is expected to be more than 0 and less than fields_.size() - 1.

Note: This method actually reads 2 elements, at index and index+1

Parameters:
index - the starting index of the elements to get
Throws:
IndexOutOfBoundsException - if index is less than 0 or more than fields_.size() - 1
AngularDistanceFormatException - if the element at the given index does not have the appropriate format

getStringField

protected String getStringField(int index)
                         throws IndexOutOfBoundsException
Returns the element of fields_ at the specified index as a String object. The index argument is expected to be more than 0 and less than fields_.size().

Parameters:
index - the index of the element to get
Throws:
IndexOutOfBoundsException - if index is less than 0 or more than fields_.size()

bodyToString

protected String bodyToString()
Returns the body part of this sentence's string representation.

Returns:
the body part of this sentence's string representation.
See Also:
toString()

headerToString

protected String headerToString()
Returns the header part of this sentence's string representation, which consists of:

Returns:
the header part of this sentence's string representation
See Also:
toString()

rebuildSentence

protected byte[] rebuildSentence()
Builds a nmea sentence string based on fields_.

Returns:
the rebuild nmea sentence

computeChecksum

protected byte computeChecksum()
Computes the checksum that is valid for this NMEA183Sentence. The calculation is based on the rebuild sentence returned by the rebuildSentence method.

Returns:
the checksum that is valid for this NMEA183Sentence


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.