Class TokenExtractor

java.lang.Object
com.pnfsoftware.jeb.util.format.TokenExtractor

public class TokenExtractor extends Object
A customizable string token extractor. Standard delimiters are provided: see DF_xxx objects.

Example: Consider the line "hello world". If you use a wsp token extractor, asking for which token is at:
- offset 0,1,2,3,4 would return "hello".
- offset 5 would return null (it falls on the space char).
- offset 6,7,8,9,10 would return "world".
- anywhere else, null would be returned.

  • Field Details

    • DF_WhiteSpace

      public static final TokenExtractor.IDelimiterFinder DF_WhiteSpace
      Delimiter= whitespace characters (per isWhitespace)
    • DF_CommonFullSymbolChars

      public static final TokenExtractor.IDelimiterFinder DF_CommonFullSymbolChars
      Delimiter= any character that is generally not legal in a symbol name, in particular:
      • any character allowed in java identifier
      • additional '/' character for java signature
      • additional '+' character for native relative signature
    • DF_CommonSymbolChars

      public static final TokenExtractor.IDelimiterFinder DF_CommonSymbolChars
      Delimiter= any character that is generally not legal in a symbol name, in particular:
      • any character allowed in java identifier
      • all other characters are delimiters
    • DF_NonAlphaNum

      public static final TokenExtractor.IDelimiterFinder DF_NonAlphaNum
      Delimiter= any character that is neither a letter nor a digit.
    • DF_Assignment

      public static final TokenExtractor.IDelimiterFinder DF_Assignment
      Delimiter= '=' character. In particular on decompilation comment with pattern when x=myvalue
  • Constructor Details

    • TokenExtractor

      public TokenExtractor(TokenExtractor.IDelimiterFinder delimiterFinder)
      Create a token extractor.
      Parameters:
      delimiterFinder - a delimiter finder; client code may either create their own or use one of the standard finders, see DF_*
  • Method Details

    • getGenericTokenList

      public static List<TokenExtractor> getGenericTokenList()
      Retrieve the generic list of Token Extractor, based on DF_* TokenExtractor.IDelimiterFinder. List is sorted from least to most restrictive.
      Returns:
      token extractor list
    • extract

      public String extract(String s, int o)
      Extract the token spanning over the provided offset of the input string.
      Parameters:
      s - input string
      o - start offset
      Returns:
      the token as a substring of s or null if not found.
    • extractCoordinates

      public int[] extractCoordinates(String s, int o)
      Extract the token spanning over the provided offset of the input string.
      Parameters:
      s - input string
      o - start offset
      Returns:
      an array with 2 indexes [start, end] of the token, or null if not found.
    • match

      protected boolean match(String s, int index)