FileDocCategorySizeDatePackage
StringContent.javaAPI DocSun JDK 1.5.0 Example3184Sat Jan 08 15:08:43 GMT 2005None

StringContent

public class StringContent extends Object implements Content
A Content type that provides for transferring Strings.
author
Mark Reinhold
author
Brad R. Wetmore
version
1.2, 04/07/26

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 voidencode()


       
	if (bb == null)
	    bb = ascii.encode(CharBuffer.wrap(content));
    
public longlength()

	encode();
	return bb.remaining();
    
public voidprepare()

	encode();
	bb.rewind();
    
public voidrelease()

    
public booleansend(ChannelIO cio)

	if (bb == null)
	    throw new IllegalStateException();
	cio.write(bb);

	return bb.hasRemaining();
    
public java.lang.Stringtype()

	return type;