You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2007/10/22 22:45:36 UTC

svn commit: r587243 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java

Author: mbenson
Date: Mon Oct 22 13:45:35 2007
New Revision: 587243

URL: http://svn.apache.org/viewvc?rev=587243&view=rev
Log:
add convenience isMatch(char[] buffer, int pos) that delegates using the entire buffer as bounds

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java?rev=587243&r1=587242&r2=587243&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrMatcher.java Mon Oct 22 13:45:35 2007
@@ -243,6 +243,30 @@
      */
     public abstract int isMatch(char[] buffer, int pos, int bufferStart, int bufferEnd);
 
+    /**
+     * Returns the number of matching characters, zero for no match.
+     * <p>
+     * This method is called to check for a match.
+     * The parameter <code>pos</code> represents the current position to be
+     * checked in the string <code>buffer</code> (a character array which must
+     * not be changed).
+     * The API guarantees that <code>pos</code> is a valid index for <code>buffer</code>.
+     * <p>
+     * The matching code may check one character or many.
+     * It may check characters preceeding <code>pos</code> as well as those after.
+     * <p>
+     * It must return zero for no match, or a positive number if a match was found.
+     * The number indicates the number of characters that matched.
+     *
+     * @param buffer  the text content to match against, do not change
+     * @param pos  the starting position for the match, valid for buffer
+     * @return the number of matching characters, zero for no match
+     * @since Commons Lang 2.4
+     */
+    public int isMatch(char[] buffer, int pos) {
+        return isMatch(buffer, pos, 0, buffer.length);
+    }
+
     //-----------------------------------------------------------------------
     /**
      * Class used to define a set of characters for matching purposes.