FileDocCategorySizeDatePackage
SerializableEntity.javaAPI DocAndroid 1.5 API3491Wed May 06 22:41:10 BST 2009org.apache.http.entity

SerializableEntity

public class SerializableEntity extends AbstractHttpEntity

Fields Summary
private byte[]
objSer
private Serializable
objRef
Constructors Summary
public SerializableEntity(Serializable ser, boolean bufferize)

        super();
        if (ser == null) {
            throw new IllegalArgumentException("Source object may not be null");
        }
        
        if (bufferize) {
            createBytes(ser);
        } else {
            this.objRef = ser;
        }
    
Methods Summary
private voidcreateBytes(java.io.Serializable ser)

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(baos);
        out.writeObject(ser);
        out.flush();	
        this.objSer = baos.toByteArray();
    
public java.io.InputStreamgetContent()

        if (this.objSer == null) {
            createBytes(this.objRef);
        }
        return new ByteArrayInputStream(this.objSer);
    
public longgetContentLength()

        if (this.objSer ==  null) { 
            return -1;
        } else {
            return this.objSer.length;
        }
    
public booleanisRepeatable()

        return true;
    
public booleanisStreaming()

        return this.objSer == null;
    
public voidwriteTo(java.io.OutputStream outstream)

        if (outstream == null) {
            throw new IllegalArgumentException("Output stream may not be null");
        }
        
        if (this.objSer == null) {
            ObjectOutputStream out = new ObjectOutputStream(outstream);
            out.writeObject(this.objRef);
            out.flush();
        } else {
            outstream.write(this.objSer);
            outstream.flush();
        }