Class MatchMap
- java.lang.Object
-
- org.apache.manifoldcf.crawler.connectors.DCTM.MatchMap
-
public class MatchMap extends java.lang.Object
An instance of this class describes a "match map", which describes a translation of an input string using regexp technology. A match map consists of multiple clauses, which are fired in sequence. Each clause is a regexp search and replace, where the replace string can include references to the groups present in the search regexp. MatchMaps can be converted to strings in two different ways. The first way is to build a single string of the form "match1=replace1&match2=replace2...". Strings of this kind must escape & and = characters in the match and replace strings, where found. The second way is to generate an array of match strings and a corresponding array of replace strings. This method requires no escaping of the string contents.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
MatchMap.EvaluatorToken
Evaluator token.protected static class
MatchMap.EvaluatorTokenStream
Token stream.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
_rcsid
protected java.util.regex.Pattern[]
matchPatterns
This is the set of Pattern objects corresponding to the match regexp strings.protected java.util.ArrayList
matchStrings
This is the set of match regexp stringsprotected java.util.ArrayList
replaceStrings
This is the set of replace strings
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendMatchPair(java.lang.String match, java.lang.String replace)
Append a match/replace string pairvoid
appendOldstyleMatchPair(java.lang.String oldstyleMatch, java.lang.String oldstyleReplace)
Append old-style match/replace pair.void
deleteMatchPair(int index)
Delete a specified match/replace string pairprotected static void
escape(java.lang.StringBuilder output, java.lang.String input)
Escape a string so it is verbatimint
getMatchCount()
Get the number of match/replace stringsjava.lang.String
getMatchString(int index)
Get a specific match stringjava.lang.String
getReplaceString(int index)
Get a specific replace stringvoid
insertMatchPair(int index, java.lang.String match, java.lang.String replace)
Insert a match/replace string pairprotected static void
stuff(java.lang.StringBuilder sb, java.lang.String value)
Stuff charactersjava.lang.String
toString()
Convert the matchmap to string form.java.lang.String
translate(java.lang.String input)
Perform a translation.
-
-
-
Field Detail
-
_rcsid
public static final java.lang.String _rcsid
- See Also:
- Constant Field Values
-
matchStrings
protected java.util.ArrayList matchStrings
This is the set of match regexp strings
-
matchPatterns
protected java.util.regex.Pattern[] matchPatterns
This is the set of Pattern objects corresponding to the match regexp strings. It's null if the patterns have not been built yet.
-
replaceStrings
protected java.util.ArrayList replaceStrings
This is the set of replace strings
-
-
Constructor Detail
-
MatchMap
public MatchMap()
Constructor. Build an empty matchmap.
-
MatchMap
public MatchMap(java.lang.String stringForm)
Constructor. Build a matchmap from a single string.
-
MatchMap
public MatchMap(java.util.ArrayList matchStrings, java.util.ArrayList replaceStrings)
Constructor. Build a matchmap from two arraylists representing match and replace strings
-
-
Method Detail
-
getMatchCount
public int getMatchCount()
Get the number of match/replace strings
-
getMatchString
public java.lang.String getMatchString(int index)
Get a specific match string
-
getReplaceString
public java.lang.String getReplaceString(int index)
Get a specific replace string
-
deleteMatchPair
public void deleteMatchPair(int index)
Delete a specified match/replace string pair
-
insertMatchPair
public void insertMatchPair(int index, java.lang.String match, java.lang.String replace)
Insert a match/replace string pair
-
appendMatchPair
public void appendMatchPair(java.lang.String match, java.lang.String replace)
Append a match/replace string pair
-
appendOldstyleMatchPair
public void appendOldstyleMatchPair(java.lang.String oldstyleMatch, java.lang.String oldstyleReplace)
Append old-style match/replace pair. This method translates old-style regexp and group output form to the current style before adding to the map.
-
escape
protected static void escape(java.lang.StringBuilder output, java.lang.String input)
Escape a string so it is verbatim
-
toString
public java.lang.String toString()
Convert the matchmap to string form.- Overrides:
toString
in classjava.lang.Object
-
stuff
protected static void stuff(java.lang.StringBuilder sb, java.lang.String value)
Stuff characters
-
translate
public java.lang.String translate(java.lang.String input) throws org.apache.manifoldcf.core.interfaces.ManifoldCFException
Perform a translation.- Throws:
org.apache.manifoldcf.core.interfaces.ManifoldCFException
-
-