Merge remote-tracking branch 'origin/jetty-9.4.x'

This commit is contained in:
Greg Wilkins 2017-10-19 20:45:40 +11:00
commit dde65f2633
2 changed files with 22 additions and 19 deletions

View File

@ -30,6 +30,10 @@ import org.eclipse.jetty.util.Utf8Appendable;
*/
public class Utf8CharBuffer extends Utf8Appendable
{
// TODO this class does not correctly implement the Appendable contract.
// The length is currently the capacity, but it should be the number of characters
// appended! It also violates the jetty standard of leaving buffers in flush mode.
/**
* Convenience method to wrap a ByteBuffer with a {@link Utf8CharBuffer}
*
@ -59,6 +63,13 @@ public class Utf8CharBuffer extends Utf8Appendable
{
buffer.append((char)c);
}
@Override
public void reset()
{
clear();
super.reset();
}
public void clear()
{
@ -96,6 +107,13 @@ public class Utf8CharBuffer extends Utf8Appendable
{
return buffer.remaining();
}
@Override
public String getPartialString()
{
return buffer.toString();
}
@Override
public String toString()
@ -109,4 +127,5 @@ public class Utf8CharBuffer extends Utf8Appendable
str.append("]");
return str.toString();
}
}

View File

@ -30,14 +30,13 @@ import org.eclipse.jetty.util.Utf8StringBuilder;
* A call to {@link #toPartialString(ByteBuffer)} will return the section of the String from the start to the last
* completed UTF8 sequence. Leaving incomplete sequences for a subsequent call to complete.
*/
@Deprecated
public class Utf8PartialBuilder
{
private StringBuilder str;
private Utf8Appendable utf8;
private final Utf8StringBuilder utf8 = new Utf8StringBuilder();
public Utf8PartialBuilder()
{
reset();
}
public String toPartialString(ByteBuffer buf)
@ -48,21 +47,6 @@ public class Utf8PartialBuilder
return "";
}
utf8.append(buf);
String ret = str.toString();
str.setLength(0);
return ret;
}
public void reset()
{
this.str = new StringBuilder();
this.utf8 = new Utf8Appendable(str)
{
@Override
public int length()
{
return str.length();
}
};
return utf8.takePartialString();
}
}