StringContentpublic class StringContent extends Object implements ContentA Content type that provides for transferring Strings. |
Fields Summary |
---|
private static Charset | ascii | private String | type | private String | content | private ByteBuffer | bb |
Constructors Summary |
---|
StringContent(CharSequence c, String t)
content = c.toString();
if (!content.endsWith("\n"))
content += "\n";
type = t + "; charset=iso-8859-1";
| StringContent(CharSequence c)
this(c, "text/plain");
| StringContent(Exception x)
StringWriter sw = new StringWriter();
x.printStackTrace(new PrintWriter(sw));
type = "text/plain; charset=iso-8859-1";
content = sw.toString();
|
Methods Summary |
---|
private void | encode()
if (bb == null)
bb = ascii.encode(CharBuffer.wrap(content));
| public long | length()
encode();
return bb.remaining();
| public void | prepare()
encode();
bb.rewind();
| public void | release()
| public boolean | send(ChannelIO cio)
if (bb == null)
throw new IllegalStateException();
cio.write(bb);
return bb.hasRemaining();
| public java.lang.String | type()
return type;
|
|