FileDocCategorySizeDatePackage
Blob.javaAPI DocAndroid 1.5 API6145Wed May 06 22:41:06 BST 2009SQLite

BlobR

public class BlobR extends InputStream
Internal class implementing java.io.InputStream on SQLite 3.4.0 incremental blob I/O interface.

Fields Summary
private Blob
blob
Blob instance
private int
pos
Read position, file pointer.
Constructors Summary
BlobR(Blob blob)
Contruct InputStream from blob instance.

    this.blob = blob;
    this.pos = 0;
    
Methods Summary
public intavailable()
Return number of available bytes for reading.

return
available input bytes

    int ret = blob.size - pos;
    return (ret < 0) ? 0 : ret;
    
public voidclose()
Close this blob InputStream.

        blob.close();
    blob = null;
    pos = 0;
    
public voidmark(int limit)
Mark method; dummy to satisfy InputStream class.

    
public booleanmarkSupported()
Mark support; not for this class.

return
always false

    return false;
    
public intread(byte[] b, int off, int len)
Read slice of byte array from blob.

param
b byte array to be filled
param
off offset into byte array
param
len length to be read
return
number of bytes read

    if (off + len > b.length) {
        len = b.length - off;
    }
    if (len < 0) {
        return -1;
    }
    if (len == 0) {
        return 0;
    }
    int n = blob.read(b, off, pos, len);
    if (n > 0) {
        pos += n;
        return n;
    }
    return -1;
    
public intread()
Read single byte from blob.

return
byte read

    byte b[] = new byte[1];
    int n = blob.read(b, 0, pos, b.length);
    if (n > 0) {
        pos += n;
        return b[0];
    }
    return -1;
    
public intread(byte[] b)
Read byte array from blob.

param
b byte array to be filled
return
number of bytes read

    int n = blob.read(b, 0, pos, b.length);
    if (n > 0) {
        pos += n;
        return n;
    }
    return -1;
    
public voidreset()
Reset method; dummy to satisfy InputStream class.

    
public longskip(long n)
Skip over blob data.

    long ret = pos + n;
    if (ret < 0) {
        ret = 0;
        pos = 0;
    } else if (ret > blob.size) {
        ret = blob.size;
        pos = blob.size;
    } else {
        pos = (int) ret;
    }
    return ret;