Class 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.
    • 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 strings
      protected java.util.ArrayList replaceStrings
      This is the set of replace strings
    • Constructor Summary

      Constructors 
      Constructor Description
      MatchMap()
      Constructor.
      MatchMap​(java.lang.String stringForm)
      Constructor.
      MatchMap​(java.util.ArrayList matchStrings, java.util.ArrayList replaceStrings)
      Constructor.
    • 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 pair
      void 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 pair
      protected static void escape​(java.lang.StringBuilder output, java.lang.String input)
      Escape a string so it is verbatim
      int getMatchCount()
      Get the number of match/replace strings
      java.lang.String getMatchString​(int index)
      Get a specific match string
      java.lang.String getReplaceString​(int index)
      Get a specific replace string
      void insertMatchPair​(int index, java.lang.String match, java.lang.String replace)
      Insert a match/replace string pair
      protected static void stuff​(java.lang.StringBuilder sb, java.lang.String value)
      Stuff characters
      java.lang.String toString()
      Convert the matchmap to string form.
      java.lang.String translate​(java.lang.String input)
      Perform a translation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • 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 class java.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