Author: remm
Date: Fri Feb 10 07:20:44 2006
New Revision: 376730

URL: http://svn.apache.org/viewcvs?rev=376730&view=rev
Log:
- Have CharCHunk implement CharSequence, so that a CharChunk can be given to a 
Java 5 regexp matcher
  without having to do a useless toString on it first. Typically, it would be 
the URL.
- For some reason Costin refused this a while ago. Maybe there was a 
misunderstanding as to what
  the proposed change was about, as there's no functional change to CharChunk. 
  Is this change still refused ?

Modified:
    tomcat/connectors/trunk/util/java/org/apache/tomcat/util/buf/CharChunk.java

Modified: 
tomcat/connectors/trunk/util/java/org/apache/tomcat/util/buf/CharChunk.java
URL: 
http://svn.apache.org/viewcvs/tomcat/connectors/trunk/util/java/org/apache/tomcat/util/buf/CharChunk.java?rev=376730&r1=376729&r2=376730&view=diff
==============================================================================
--- tomcat/connectors/trunk/util/java/org/apache/tomcat/util/buf/CharChunk.java 
(original)
+++ tomcat/connectors/trunk/util/java/org/apache/tomcat/util/buf/CharChunk.java 
Fri Feb 10 07:20:44 2006
@@ -30,7 +30,7 @@
  * @author Costin Manolache
  * @author Remy Maucherat
  */
-public final class CharChunk implements Cloneable, Serializable {
+public final class CharChunk implements Cloneable, Serializable, CharSequence {
 
     // Input interface, used when the buffer is emptied.
     public static interface CharInputChannel {
@@ -695,4 +695,26 @@
        return b;
     }
 
+    // Char sequence impl
+    
+    public char charAt(int index) {
+        return buff[index + start];
+    }
+    
+    public CharSequence subSequence(int start, int end) {
+        try {
+            CharChunk result = (CharChunk) this.clone();
+            result.setOffset(this.start + start);
+            result.setEnd(this.start + end);
+            return result;
+        } catch (CloneNotSupportedException e) {
+            // Cannot happen
+            return null;
+        }
+    }
+    
+    public int length() {
+        return end - start;
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to