类 SentenceValidator
java.lang.Object
net.sf.marineapi.nmea.sentence.SentenceValidator
SentenceValidator for detecting and validation of sentence Strings.
- 作者:
- Kimmo Tuukkanen
-
方法概要
修饰符和类型方法说明static booleanisSentence(String nmea) Tells if the specified String matches the NMEA 0183 sentence format.static booleanTells if the specified String is a valid NMEA 0183 sentence.
-
方法详细资料
-
isSentence
Tells if the specified String matches the NMEA 0183 sentence format.
String is considered as a sentence if it meets the following criteria:
- First character is '$' or '!'
- Begin char is followed by upper-case sentence ID (3 to 10 chars)
- Sentence ID is followed by a comma and an arbitrary number of printable ASCII characters (payload data)
- Data is followed by '*' and a two-char hex checksum (may be omitted)
Notice that format matching is not strict; although NMEA 0183 defines a maximum length of 80 chars, the sentence length is not checked. This is due to fact that it seems quite common that devices violate this rule, some perhaps deliberately, some by mistake. Thus, assuming the formatting is otherwise valid, it is not feasible to strictly validate length and discard sentences that just exceed the 80 chars limit.
- 参数:
nmea- String to inspect- 返回:
- true if recognized as sentence, otherwise false.
-
isValid
Tells if the specified String is a valid NMEA 0183 sentence. String is considered as valid sentence if it passes theisSentence(String)test and contains correct checksum. Sentences without checksum are validated only by checking the general sentence characteristics.- 参数:
nmea- String to validate- 返回:
trueif valid, otherwisefalse.
-