Class ResultParser

java.lang.Object
com.google.zxing.client.result.ResultParser
Direct Known Subclasses:
AbstractDoCoMoResultParser, AddressBookAUResultParser, EmailAddressResultParser, ExpandedProductResultParser, GeoResultParser, ISBNResultParser, ProductResultParser, SMSMMSResultParser, SMSTOMMSTOResultParser, SMTPResultParser, TelResultParser, URIResultParser, URLTOResultParser, VCardResultParser, VEventResultParser, VINResultParser, WifiResultParser

public abstract class ResultParser extends Object

Abstract class representing the result of decoding a barcode, as more than a String -- as some type of structured data. This might be a subclass which represents a URL, or an e-mail address. parseResult(Result) will turn a raw decoded string into the most appropriate type of structured representation.

Thanks to Jeff Griffin for proposing rewrite of these classes that relies less on exception-based mechanisms during parsing.

  • Field Details

    • PARSERS

      private static final ResultParser[] PARSERS
    • DIGITS

      private static final Pattern DIGITS
    • AMPERSAND

      private static final Pattern AMPERSAND
    • EQUALS

      private static final Pattern EQUALS
    • BYTE_ORDER_MARK

      private static final String BYTE_ORDER_MARK
      See Also:
    • EMPTY_STR_ARRAY

      static final String[] EMPTY_STR_ARRAY
  • Constructor Details

    • ResultParser

      public ResultParser()
  • Method Details

    • parse

      public abstract ParsedResult parse(Result theResult)
      Attempts to parse the raw Result's contents as a particular type of information (email, URL, etc.) and return a ParsedResult encapsulating the result of parsing.
      Parameters:
      theResult - the raw Result to parse
      Returns:
      ParsedResult encapsulating the parsing result
    • getMassagedText

      protected static String getMassagedText(Result result)
    • parseResult

      public static ParsedResult parseResult(Result theResult)
    • maybeAppend

      protected static void maybeAppend(String value, StringBuilder result)
    • maybeAppend

      protected static void maybeAppend(String[] value, StringBuilder result)
    • maybeWrap

      protected static String[] maybeWrap(String value)
    • unescapeBackslash

      protected static String unescapeBackslash(String escaped)
    • parseHexDigit

      protected static int parseHexDigit(char c)
    • isStringOfDigits

      protected static boolean isStringOfDigits(CharSequence value, int length)
    • isSubstringOfDigits

      protected static boolean isSubstringOfDigits(CharSequence value, int offset, int length)
    • parseNameValuePairs

      static Map<String,String> parseNameValuePairs(String uri)
    • appendKeyValue

      private static void appendKeyValue(CharSequence keyValue, Map<String,String> result)
    • urlDecode

      static String urlDecode(String encoded)
    • matchPrefixedField

      static String[] matchPrefixedField(String prefix, String rawText, char endChar, boolean trim)
    • countPrecedingBackslashes

      private static int countPrecedingBackslashes(CharSequence s, int pos)
    • matchSinglePrefixedField

      static String matchSinglePrefixedField(String prefix, String rawText, char endChar, boolean trim)