类 SentenceValidator

java.lang.Object
net.sf.marineapi.nmea.sentence.SentenceValidator

public final class SentenceValidator extends Object
SentenceValidator for detecting and validation of sentence Strings.
作者:
Kimmo Tuukkanen
  • 方法详细资料

    • isSentence

      public static boolean isSentence(String nmea)

      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

      public static boolean isValid(String nmea)
      Tells if the specified String is a valid NMEA 0183 sentence. String is considered as valid sentence if it passes the isSentence(String) test and contains correct checksum. Sentences without checksum are validated only by checking the general sentence characteristics.
      参数:
      nmea - String to validate
      返回:
      true if valid, otherwise false.