Methods Summary |
---|
public int | compare(java.lang.Object x, java.lang.Object y, org.hibernate.EntityMode entityMode)
byte[] xbytes = toInternalFormat(x);
byte[] ybytes = toInternalFormat(y);
if ( xbytes.length < ybytes.length ) return -1;
if ( xbytes.length > ybytes.length ) return 1;
for ( int i=0; i<xbytes.length; i++ ) {
if ( xbytes[i] < ybytes[i] ) return -1;
if ( xbytes[i] > ybytes[i] ) return 1;
}
return 0;
|
public int | compare(java.lang.Object o1, java.lang.Object o2)
return compare( o1, o2, null );
|
public java.lang.Object | deepCopyNotNull(java.lang.Object value)
byte[] bytes = toInternalFormat(value);
byte[] result = new byte[bytes.length];
System.arraycopy(bytes, 0, result, 0, bytes.length);
return toExternalFormat(result);
|
public java.lang.Object | fromStringValue(java.lang.String xml)
if (xml == null)
return null;
if (xml.length() % 2 != 0)
throw new IllegalArgumentException("The string is not a valid xml representation of a binary content.");
byte[] bytes = new byte[xml.length() / 2];
for (int i = 0; i < bytes.length; i++) {
String hexStr = xml.substring(i * 2, (i + 1) * 2);
bytes[i] = (byte) (Integer.parseInt(hexStr, 16) + Byte.MIN_VALUE);
}
return toExternalFormat(bytes);
|
public java.lang.Object | get(java.sql.ResultSet rs, java.lang.String name)
if ( Environment.useStreamsForBinary() ) {
InputStream inputStream = rs.getBinaryStream(name);
if (inputStream==null) return toExternalFormat( null ); // is this really necessary?
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048);
byte[] buffer = new byte[2048];
try {
while (true) {
int amountRead = inputStream.read(buffer);
if (amountRead == -1) {
break;
}
outputStream.write(buffer, 0, amountRead);
}
inputStream.close();
outputStream.close();
}
catch (IOException ioe) {
throw new HibernateException( "IOException occurred reading a binary value", ioe );
}
return toExternalFormat( outputStream.toByteArray() );
}
else {
return toExternalFormat( rs.getBytes(name) );
}
|
public java.util.Comparator | getComparator()
return this;
|
public int | getHashCode(java.lang.Object x, org.hibernate.EntityMode entityMode)
byte[] bytes = toInternalFormat(x);
int hashCode = 1;
for ( int j=0; j<bytes.length; j++ ) {
hashCode = 31 * hashCode + bytes[j];
}
return hashCode;
|
public abstract java.lang.String | getName()
|
public boolean | isEqual(java.lang.Object x, java.lang.Object y)
return x==y || ( x!=null && y!=null && java.util.Arrays.equals( toInternalFormat(x), toInternalFormat(y) ) );
|
public java.lang.Object | next(java.lang.Object current, org.hibernate.engine.SessionImplementor session)
return current;
|
public java.lang.Object | seed(org.hibernate.engine.SessionImplementor session)
return null;
|
public void | set(java.sql.PreparedStatement st, java.lang.Object value, int index)
byte[] internalValue = toInternalFormat( value );
if ( Environment.useStreamsForBinary() ) {
st.setBinaryStream( index, new ByteArrayInputStream( internalValue ), internalValue.length );
}
else {
st.setBytes( index, internalValue );
}
|
public int | sqlType()
return Types.VARBINARY;
|
protected abstract java.lang.Object | toExternalFormat(byte[] bytes)Convert the byte[] into the expected object type
|
protected abstract byte[] | toInternalFormat(java.lang.Object bytes)Convert the object into the internal byte[] representation
|
public java.lang.String | toString(java.lang.Object val)
byte[] bytes = toInternalFormat(val);
StringBuffer buf = new StringBuffer();
for ( int i=0; i<bytes.length; i++ ) {
String hexStr = Integer.toHexString( bytes[i] - Byte.MIN_VALUE );
if ( hexStr.length()==1 ) buf.append('0");
buf.append(hexStr);
}
return buf.toString();
|