Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffer.java')
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffer.java56
1 files changed, 34 insertions, 22 deletions
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffer.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffer.java
index a656d16a53..397e5aa043 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffer.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffer.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.io;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.charset.Charset;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.Log;
@@ -505,43 +506,37 @@ public abstract class AbstractBuffer implements Buffer
public void setGetIndex(int getIndex)
{
- /* bounds checking */
- if (__boundsChecking)
- {
- if (isImmutable())
- throw new IllegalStateException(__IMMUTABLE);
- if (getIndex < 0)
- throw new IllegalArgumentException("getIndex<0: " + getIndex + "<0");
- if (getIndex > putIndex())
- throw new IllegalArgumentException("getIndex>putIndex: " + getIndex + ">" + putIndex());
- }
-
+ /* bounds checking
+ if (isImmutable())
+ throw new IllegalStateException(__IMMUTABLE);
+ if (getIndex < 0)
+ throw new IllegalArgumentException("getIndex<0: " + getIndex + "<0");
+ if (getIndex > putIndex())
+ throw new IllegalArgumentException("getIndex>putIndex: " + getIndex + ">" + putIndex());
+ */
_get = getIndex;
_hash=0;
}
public void setMarkIndex(int index)
{
-
+ /*
if (index>=0 && isImmutable())
throw new IllegalStateException(__IMMUTABLE);
-
+ */
_mark = index;
}
public void setPutIndex(int putIndex)
{
- if (__boundsChecking)
- {
- /* bounds checking */
- if (isImmutable())
- throw new IllegalStateException(__IMMUTABLE);
- if (putIndex > capacity())
+ /* bounds checking
+ if (isImmutable())
+ throw new IllegalStateException(__IMMUTABLE);
+ if (putIndex > capacity())
throw new IllegalArgumentException("putIndex>capacity: " + putIndex + ">" + capacity());
- if (getIndex() > putIndex)
+ if (getIndex() > putIndex)
throw new IllegalArgumentException("getIndex>putIndex: " + getIndex() + ">" + putIndex);
- }
-
+ */
_put = putIndex;
_hash=0;
}
@@ -651,6 +646,23 @@ public abstract class AbstractBuffer implements Buffer
}
/* ------------------------------------------------------------ */
+ public String toString(Charset charset)
+ {
+ try
+ {
+ byte[] bytes=array();
+ if (bytes!=null)
+ return new String(bytes,getIndex(),length(),charset);
+ return new String(asArray(), 0, length(),charset);
+ }
+ catch(Exception e)
+ {
+ LOG.warn(e);
+ return new String(asArray(), 0, length());
+ }
+ }
+
+ /* ------------------------------------------------------------ */
public String toDebugString()
{
return getClass()+"@"+super.hashCode();

Back to the top