Class StarRegexPathElement

java.lang.Object
com.bazaarvoice.jolt.common.pathelement.BasePathElement
com.bazaarvoice.jolt.common.pathelement.StarRegexPathElement
All Implemented Interfaces:
MatchablePathElement, PathElement, StarPathElement

public class StarRegexPathElement extends BasePathElement implements StarPathElement
Non-greedy * based Path Element.
  • Field Details

    • pattern

      private final Pattern pattern
  • Constructor Details

    • StarRegexPathElement

      public StarRegexPathElement(String key)
  • Method Details

    • makePattern

      private static Pattern makePattern(String key)
    • escapeMetacharsIfAny

      private static String escapeMetacharsIfAny(String key)
      +
      Parameters:
      key - : String key that needs to be escaped before compiling into regex.
      Returns:
      : Metachar escaped key. Regex has some special meaning for the metachars [ .^$|*+?()[{\ ].If any of these metachars is present in the pattern key that was passed, it needs to be escaped so that it can be matched against literal.
    • stringMatch

      public boolean stringMatch(String literal)
      Description copied from interface: StarPathElement
      Method to see if a candidate key would match this PathElement.
      Specified by:
      stringMatch in interface StarPathElement
      Parameters:
      literal - test to see if the provided string will match this Element's regex
      Returns:
      true if the provided literal will match this Element's regex
    • match

      public MatchedElement match(String dataKey, WalkedPath walkedPath)
      Description copied from interface: MatchablePathElement
      See if this PathElement matches the given dataKey. If it does not match, this method returns null. If this PathElement does match, it returns a LiteralPathElement with subKeys filled in.
      Specified by:
      match in interface MatchablePathElement
      Parameters:
      dataKey - String key value from the input data
      walkedPath - "up the tree" list of LiteralPathElements, that may be used by this key as it is computing its match
      Returns:
      null or a matched LiteralPathElement
    • getCanonicalForm

      public String getCanonicalForm()
      Description copied from interface: PathElement
      Get the canonical form of this PathElement. Really only interesting for the Reference Path element, where it will expand "invalid input: '&'" to "invalid input: '&'0(0)".
      Specified by:
      getCanonicalForm in interface PathElement
      Returns:
      canonical String version of this PathElement