tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r376730 - /tomcat/connectors/trunk/util/java/org/apache/tomcat/util/buf/CharChunk.java
Date Fri, 10 Feb 2006 15:20:45 GMT
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message