Mercurial Hosting > luan
diff src/org/eclipse/jetty/io/AbstractBuffer.java @ 1038:b71ad168fe34
rename Buffer.length() to remaining()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 03 Nov 2016 22:16:11 -0600 |
parents | 3c4c7cc7904f |
children | a7319f14ba1e |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/AbstractBuffer.java Thu Nov 03 21:54:34 2016 -0600 +++ b/src/org/eclipse/jetty/io/AbstractBuffer.java Thu Nov 03 22:16:11 2016 -0600 @@ -63,12 +63,12 @@ public byte[] asArray() { - byte[] bytes = new byte[length()]; + byte[] bytes = new byte[remaining()]; byte[] array = array(); if (array != null) System.arraycopy(array, getIndex(), bytes, 0, bytes.length); else - peek(getIndex(), bytes, 0, length()); + peek(getIndex(), bytes, 0, remaining()); return bytes; } @@ -116,7 +116,7 @@ Buffer b = (Buffer) obj; // reject different lengths - if (b.length() != length()) return false; + if (b.remaining() != remaining()) return false; // reject AbstractBuffer with different hash value if (_hash != 0 && obj instanceof AbstractBuffer) @@ -145,7 +145,7 @@ public int get(byte[] b, int offset, int length) { int gi = getIndex(); - int l=length(); + int l=remaining(); if (l==0) return -1; @@ -222,7 +222,7 @@ return _access <= READONLY; } - public int length() + public int remaining() { return _put - _get; } @@ -270,7 +270,7 @@ { _hash=0; - int length=src.length(); + int length=src.remaining(); if (index + length > capacity()) { length=capacity()-index; @@ -396,14 +396,14 @@ public int skip(int n) { - if (length() < n) n = length(); + if (remaining() < n) n = remaining(); setGetIndex(getIndex() + n); return n; } public Buffer slice() { - return peek(getIndex(), length()); + return peek(getIndex(), remaining()); } public Buffer sliceFromMark() @@ -474,10 +474,10 @@ if (isImmutable()) { if (_string == null) - _string = new String(asArray(), 0, length()); + _string = new String(asArray(), 0, remaining()); return _string; } - return new String(asArray(), 0, length()); + return new String(asArray(), 0, remaining()); */ return toString("ISO-8859-1"); } @@ -494,14 +494,14 @@ { byte[] bytes=array(); if (bytes!=null) - return new String(bytes,getIndex(),length(),charset); - return new String(asArray(), 0, length(),charset); + return new String(bytes,getIndex(),remaining(),charset); + return new String(asArray(), 0, remaining(),charset); } catch(Exception e) { LOG.warn("",e); - return new String(asArray(), 0, length()); + return new String(asArray(), 0, remaining()); } } @@ -512,13 +512,13 @@ { byte[] bytes=array(); if (bytes!=null) - return new String(bytes,getIndex(),length(),charset); - return new String(asArray(), 0, length(),charset); + return new String(bytes,getIndex(),remaining(),charset); + return new String(asArray(), 0, remaining(),charset); } catch(Exception e) { LOG.warn("",e); - return new String(asArray(), 0, length()); + return new String(asArray(), 0, remaining()); } }