@Override public Blob createBlob(byte[] bytes) { return BlobProxy.generateProxy( bytes ); }
/** * Generates a BlobImpl using byte data. * * @param bytes The data to be created as a Blob. * * @return The BlobProxy instance to represent this data. */ public static Blob generateProxy(byte[] bytes) { return new BlobProxy( bytes ); }
@Override public InputStream getBinaryStream(final long start, final long length) throws SQLException { if ( start < 1 ) { throw new SQLException( "Start position 1-based; must be 1 or more." ); } if ( start > length() ) { throw new SQLException( "Start position [" + start + "] cannot exceed overall CLOB length [" + length() + "]" ); } if ( length > Integer.MAX_VALUE ) { throw new SQLException( "Can't deal with Blobs larger than Integer.MAX_VALUE" ); } final int intLength = (int)length; if ( intLength < 0 ) { // java docs specifically say for getBinaryStream(long,int) that the start+length must not exceed the // total length, however that is at odds with the getBytes(long,int) behavior. throw new SQLException( "Length must be great-than-or-equal to zero." ); } return DataHelper.subStream( getStream(), start-1, intLength ); }
/** * Generates a BlobImpl proxy using byte data. * * @param bytes The data to be created as a Blob. * * @return The generated proxy. */ public static Blob generateProxy(byte[] bytes) { return ( Blob ) Proxy.newProxyInstance( getProxyClassLoader(), PROXY_INTERFACES, new BlobProxy( bytes ) ); }
return Long.valueOf( getLength() ); return getStream(); throw new SQLException( "Start position 1-based; must be 1 or more." ); if ( start > getLength() ) { throw new SQLException( "Start position [" + start + "] cannot exceed overall CLOB length [" + getLength() + "]" ); return DataHelper.subStream( getStream(), start-1, length ); throw new SQLException( "Length must be great-than-or-equal to zero." ); return DataHelper.extractBytes( getStream(), start-1, length );
@Override public InputStream getBinaryStream() throws SQLException { return getStream(); }
@Override public int setBytes(long pos, byte[] bytes) { throw notSupported(); }
public BinaryStream getUnderlyingStream() throws SQLException { resetIfNeeded(); return binaryStream; }
private InputStream getStream() throws SQLException { return getUnderlyingStream().getInputStream(); }
/** * Generates a BlobImpl proxy using a given number of bytes from an InputStream. * * @param stream The input stream of bytes to be created as a Blob. * @param length The number of bytes from stream to be written to the Blob. * * @return The generated proxy. */ public static Blob generateProxy(InputStream stream, long length) { return ( Blob ) Proxy.newProxyInstance( getProxyClassLoader(), PROXY_INTERFACES, new BlobProxy( stream, length ) ); }
return Long.valueOf( getLength() ); return getStream(); throw new SQLException( "Start position 1-based; must be 1 or more." ); if ( start > getLength() ) { throw new SQLException( "Start position [" + start + "] cannot exceed overall CLOB length [" + getLength() + "]" ); return DataHelper.subStream( getStream(), start-1, length ); throw new SQLException( "Length must be great-than-or-equal to zero." ); return DataHelper.extractBytes( getStream(), start-1, length );
@Override public byte[] getBytes(final long start, final int length) throws SQLException { if ( start < 1 ) { throw new SQLException( "Start position 1-based; must be 1 or more." ); } if ( length < 0 ) { throw new SQLException( "Length must be great-than-or-equal to zero." ); } return DataHelper.extractBytes( getStream(), start-1, length ); }
@Override public void truncate(long len) { throw notSupported(); }
public BinaryStream getUnderlyingStream() throws SQLException { resetIfNeeded(); return binaryStream; }
private InputStream getStream() throws SQLException { return getUnderlyingStream().getInputStream(); }
@Override public Blob createBlob(InputStream stream, long length) { return BlobProxy.generateProxy( stream, length ); }
/** * Generates a BlobImpl proxy using byte data. * * @param bytes The data to be created as a Blob. * * @return The generated proxy. */ public static Blob generateProxy(byte[] bytes) { return ( Blob ) Proxy.newProxyInstance( getProxyClassLoader(), PROXY_INTERFACES, new BlobProxy( bytes ) ); }
@Override public InputStream getBinaryStream(final long start, final long length) throws SQLException { if ( start < 1 ) { throw new SQLException( "Start position 1-based; must be 1 or more." ); } if ( start > length() ) { throw new SQLException( "Start position [" + start + "] cannot exceed overall CLOB length [" + length() + "]" ); } if ( length > Integer.MAX_VALUE ) { throw new SQLException( "Can't deal with Blobs larger than Integer.MAX_VALUE" ); } final int intLength = (int)length; if ( intLength < 0 ) { // java docs specifically say for getBinaryStream(long,int) that the start+length must not exceed the // total length, however that is at odds with the getBytes(long,int) behavior. throw new SQLException( "Length must be great-than-or-equal to zero." ); } return LobStreamDataHelper.subStream( getStream(), start-1, intLength ); }
/** * Generates a BlobImpl proxy using a given number of bytes from an InputStream. * * @param stream The input stream of bytes to be created as a Blob. * @param length The number of bytes from stream to be written to the Blob. * * @return The BlobProxy instance to represent this data. */ public static Blob generateProxy(InputStream stream, long length) { return new BlobProxy( stream, length ); }
@Override public InputStream getBinaryStream() throws SQLException { return getStream(); }