add missing @Override annotations, light refactoring
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
f9e544e394
commit
4dcfdb57e5
|
@ -67,6 +67,7 @@ public final class BlobProxy implements Blob, BlobImplementer {
|
||||||
return getUnderlyingStream().getInputStream();
|
return getUnderlyingStream().getInputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BinaryStream getUnderlyingStream() throws SQLException {
|
public BinaryStream getUnderlyingStream() throws SQLException {
|
||||||
resetIfNeeded();
|
resetIfNeeded();
|
||||||
return binaryStream;
|
return binaryStream;
|
||||||
|
@ -172,15 +173,14 @@ public final class BlobProxy implements Blob, BlobImplementer {
|
||||||
throw new SQLException( "Start position [" + start + "] cannot exceed overall CLOB length [" + length() + "]" );
|
throw new SQLException( "Start position [" + start + "] cannot exceed overall CLOB length [" + length() + "]" );
|
||||||
}
|
}
|
||||||
if ( length > Integer.MAX_VALUE ) {
|
if ( length > Integer.MAX_VALUE ) {
|
||||||
throw new SQLException( "Can't deal with Blobs larger than Integer.MAX_VALUE" );
|
throw new SQLException( "Can't deal with Blobs larger than 'Integer.MAX_VALUE'" );
|
||||||
}
|
}
|
||||||
final int intLength = (int)length;
|
if ( length < 0 ) {
|
||||||
if ( intLength < 0 ) {
|
// javadoc for getBinaryStream(long,int) specifies that the start+length must not exceed the
|
||||||
// java docs specifically say for getBinaryStream(long,int) that the start+length must not exceed the
|
// total length (this is at odds with the behavior of getBytes(long,int))
|
||||||
// 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." );
|
throw new SQLException( "Length must be great-than-or-equal to zero." );
|
||||||
}
|
}
|
||||||
return DataHelper.subStream( getStream(), start-1, intLength );
|
return DataHelper.subStream( getStream(), start-1, (int)length );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UnsupportedOperationException notSupported() {
|
private static UnsupportedOperationException notSupported() {
|
||||||
|
|
|
@ -92,34 +92,35 @@ public class ClobProxy implements Clob, ClobImplementer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long position(Clob searchstr, long start) throws SQLException {
|
public long position(Clob searchstr, long start) throws SQLException {
|
||||||
throw new UnsupportedOperationException("Clob may not be manipulated from creating session");
|
throw notSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int setString(long pos, String str) throws SQLException {
|
public int setString(long pos, String str) throws SQLException {
|
||||||
throw new UnsupportedOperationException("Clob may not be manipulated from creating session");
|
throw notSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int setString(long pos, String str, int offset, int len) throws SQLException {
|
public int setString(long pos, String str, int offset, int len) throws SQLException {
|
||||||
throw new UnsupportedOperationException("Clob may not be manipulated from creating session");
|
throw notSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutputStream setAsciiStream(long pos) {
|
public OutputStream setAsciiStream(long pos) {
|
||||||
throw new UnsupportedOperationException("Clob may not be manipulated from creating session");
|
throw notSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Writer setCharacterStream(long pos) {
|
public Writer setCharacterStream(long pos) {
|
||||||
throw new UnsupportedOperationException("Clob may not be manipulated from creating session");
|
throw notSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void truncate(long len) throws SQLException {
|
public void truncate(long len) throws SQLException {
|
||||||
throw new UnsupportedOperationException("Clob may not be manipulated from creating session");
|
throw notSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getSubString(long start, int length) throws SQLException {
|
public String getSubString(long start, int length) throws SQLException {
|
||||||
if ( start < 1 ) {
|
if ( start < 1 ) {
|
||||||
throw new SQLException( "Start position 1-based; must be 1 or more." );
|
throw new SQLException( "Start position 1-based; must be 1 or more." );
|
||||||
|
@ -143,8 +144,11 @@ public class ClobProxy implements Clob, ClobImplementer {
|
||||||
if ( start > length() + 1 ) {
|
if ( start > length() + 1 ) {
|
||||||
throw new SQLException( "Start position [" + start + "] cannot exceed overall CLOB length [" + 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 Clobs larger than 'Integer.MAX_VALUE'" );
|
||||||
|
}
|
||||||
if ( length < 0 ) {
|
if ( length < 0 ) {
|
||||||
// javadoc for getCharacterStream(long,int) specify that the start+length must not exceed the
|
// javadoc for getCharacterStream(long,int) specifies that the start+length must not exceed the
|
||||||
// total length (this is at odds with the behavior of getSubString(long,int))
|
// total length (this is at odds with the behavior of getSubString(long,int))
|
||||||
throw new SQLException( "Length must be greater than or equal to zero" );
|
throw new SQLException( "Length must be greater than or equal to zero" );
|
||||||
}
|
}
|
||||||
|
@ -190,4 +194,8 @@ public class ClobProxy implements Clob, ClobImplementer {
|
||||||
public static Clob generateProxy(Reader reader, long length) {
|
public static Clob generateProxy(Reader reader, long length) {
|
||||||
return new ClobProxy( reader, length );
|
return new ClobProxy( reader, length );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static UnsupportedOperationException notSupported() {
|
||||||
|
return new UnsupportedOperationException("Clob may not be manipulated from creating session");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue