net.sf.marineapi.nmea.sentence
Interface Sentence

All Known Subinterfaces:
APBSentence, BODSentence, DateSentence, DBTSentence, DepthSentence, DPTSentence, DTMSentence, GGASentence, GLLSentence, GSASentence, GSVSentence, HDGSentence, HDMSentence, HDTSentence, HeadingSentence, MTASentence, MTWSentence, MWVSentence, PositionSentence, RMBSentence, RMCSentence, ROTSentence, RPMSentence, RSASentence, RTESentence, TimeSentence, TTMSentence, VDRSentence, VHWSentence, VLWSentence, VTGSentence, WPLSentence, XDRSentence, XTESentence, ZDASentence
All Known Implementing Classes:
SentenceParser

public interface Sentence

Base interface and constants for NMEA 0183 sentences.

Author:
Kimmo Tuukkanen

Field Summary
static char ALTERNATIVE_BEGIN_CHAR
          Alternative sentence begin character used in VDO and VDM sentences.
static char BEGIN_CHAR
          Sentence begin character
static char CHECKSUM_DELIMITER
          Checksum field delimiter char
static char FIELD_DELIMITER
          Sentence data fields delimiter char
static int MAX_LENGTH
          Maximum length of NMEA 0183 sentences, including BEGIN_CHAR and TERMINATOR.
static String TERMINATOR
          Sentence terminator <CR><LF>.
 
Method Summary
 char getBeginChar()
          Get the sentence begin character.
 int getFieldCount()
          Returns the current number of data fields in sentence, excluding ID field and checksum.
 String getSentenceId()
          Get the sentence ID that specifies the sentence type and data it holds.
 TalkerId getTalkerId()
          Gets the talker ID of the sentence.
 boolean isProprietary()
          Tells if the sentence is of proprietary format.
 boolean isValid()
          Tells if the sentence formatting matches NMEA 0183 format.
 void reset()
          Resets the sentence contents, i.e. removes all existing values from data fields.
 void setBeginChar(char ch)
          Set the sentence begin character.
 void setTalkerId(TalkerId id)
          Set the talker ID of the sentence.
 String toSentence()
          Formats and validates the String representation of sentence.
 String toSentence(int maxLength)
          Formats and validates the sentence like toSentence(), but checks also that resulting String does not exceed specified length.
 String toString()
          Returns the String representation of the sentence, without line terminator CR/LR.
 

Field Detail

ALTERNATIVE_BEGIN_CHAR

static final char ALTERNATIVE_BEGIN_CHAR
Alternative sentence begin character used in VDO and VDM sentences.

See Also:
Constant Field Values

BEGIN_CHAR

static final char BEGIN_CHAR
Sentence begin character

See Also:
Constant Field Values

CHECKSUM_DELIMITER

static final char CHECKSUM_DELIMITER
Checksum field delimiter char

See Also:
Constant Field Values

FIELD_DELIMITER

static final char FIELD_DELIMITER
Sentence data fields delimiter char

See Also:
Constant Field Values

MAX_LENGTH

static final int MAX_LENGTH
Maximum length of NMEA 0183 sentences, including BEGIN_CHAR and TERMINATOR.

See Also:
Constant Field Values

TERMINATOR

static final String TERMINATOR
Sentence terminator <CR><LF>.

See Also:
Constant Field Values
Method Detail

getBeginChar

char getBeginChar()
Get the sentence begin character. Although most of the sentences start with '$', some of them use '!' as begin character.

Returns:
Sentence begin char, e.g. "$" or "!".

getFieldCount

int getFieldCount()
Returns the current number of data fields in sentence, excluding ID field and checksum.

Returns:
Data field count

getSentenceId

String getSentenceId()
Get the sentence ID that specifies the sentence type and data it holds. ID is the last three characters in address field. For example, in case of $GPGGA the method returns SentenceId.GGA.

Returns:
Sentence id String, e.g. "GLL" or "GGA".
See Also:
SentenceId

getTalkerId

TalkerId getTalkerId()
Gets the talker ID of the sentence. Talker ID is the next two characters after $ in sentence address field. For example, in case of $GPGGA, the method returns TalkerId.GP.

Returns:
Talker id enum.

isProprietary

boolean isProprietary()
Tells if the sentence is of proprietary format.

Returns:
True if proprietary, otherwise false.

isValid

boolean isValid()
Tells if the sentence formatting matches NMEA 0183 format.

Returns:
True if validly formatted, otherwise false.

reset

void reset()
Resets the sentence contents, i.e. removes all existing values from data fields. After resetting, address field remains as is and checksum is calculated according to empty data fields.


setBeginChar

void setBeginChar(char ch)
Set the sentence begin character. Although most of the sentences start with '$', some of them use '!' as begin character.

Parameters:
ch - Sentence begin char to set ('$' or '!')
See Also:
BEGIN_CHAR, ALTERNATIVE_BEGIN_CHAR

setTalkerId

void setTalkerId(TalkerId id)
Set the talker ID of the sentence. Typically, the ID might be changed if the sentence is to be sent from a computer to an NMEA device.

Parameters:
id - TalkerId to set

toSentence

String toSentence()
Formats and validates the String representation of sentence. Throws an exception if result is not considered a valid sentence. As validation is done by SentenceValidator, notice that resulting sentence length is not checked. To also validate the length, use toSentence(int).

Returns:
Sentence as String, equal to toString().
Throws:
IllegalStateException - If formatting results in invalid sentence.
See Also:
toString()

toSentence

String toSentence(int maxLength)
Formats and validates the sentence like toSentence(), but checks also that resulting String does not exceed specified length.

Returns:
Sentence as String, equal to toString().
Throws:
IllegalStateException - If formatting results in invalid sentence or specified maximum length is exceeded.
See Also:
toSentence(), MAX_LENGTH

toString

String toString()
Returns the String representation of the sentence, without line terminator CR/LR. Checksum is calculated and appended at the end of the sentence, but no validation is done. Use toSentence() to also validate the result.

Overrides:
toString in class Object
Returns:
String representation of sentence


Copyright (C) 2010-2014 Java Marine API authors. All Rights Reserved.