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 Summary
Fields Modifier and Type Field Description private java.util.regex.Patternpattern
-
Constructor Summary
Constructors Constructor Description StarRegexPathElement(java.lang.String key)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringescapeMetacharsIfAny(java.lang.String key)+java.lang.StringgetCanonicalForm()Get the canonical form of this PathElement.private static java.util.regex.PatternmakePattern(java.lang.String key)MatchedElementmatch(java.lang.String dataKey, WalkedPath walkedPath)See if this PathElement matches the given dataKey.booleanstringMatch(java.lang.String literal)Method to see if a candidate key would match this PathElement.-
Methods inherited from class com.bazaarvoice.jolt.common.pathelement.BasePathElement
getRawKey, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.bazaarvoice.jolt.common.pathelement.PathElement
getRawKey
-
-
-
-
Method Detail
-
makePattern
private static java.util.regex.Pattern makePattern(java.lang.String key)
-
escapeMetacharsIfAny
private static java.lang.String escapeMetacharsIfAny(java.lang.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(java.lang.String literal)
Description copied from interface:StarPathElementMethod to see if a candidate key would match this PathElement.- Specified by:
stringMatchin interfaceStarPathElement- 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(java.lang.String dataKey, WalkedPath walkedPath)
Description copied from interface:MatchablePathElementSee 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:
matchin interfaceMatchablePathElement- Parameters:
dataKey- String key value from the input datawalkedPath- "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 java.lang.String getCanonicalForm()
Description copied from interface:PathElementGet the canonical form of this PathElement. Really only interesting for the Reference Path element, where it will expand "&" to "&0(0)".- Specified by:
getCanonicalFormin interfacePathElement- Returns:
- canonical String version of this PathElement
-
-