Java 类org.hibernate.type.descriptor.java.DataHelper 实例源码

项目:hibernate-ogm-redis    文件:Base64ByteArrayTypeDescriptor.java   
@Override
public <X> byte[] wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Byte[].class.isInstance( value ) ) {
        return unwrapBytes( (Byte[]) value );
    }
    if ( byte[].class.isInstance( value ) ) {
        return (byte[]) value;
    }
    if ( InputStream.class.isInstance( value ) ) {
        return DataHelper.extractBytes( (InputStream) value );
    }
    if ( Blob.class.isInstance( value ) || DataHelper.isNClob( value.getClass() ) ) {
        try {
            return DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() );
        }
        catch (SQLException e) {
            throw new HibernateException( "Unable to access lob stream", e );
        }
    }

    throw unknownWrap( value.getClass() );
}
项目:lams    文件:BlobProxy.java   
@Override
public byte[] getBytes() {
    if ( bytes == null ) {
        bytes = DataHelper.extractBytes( stream );
    }
    return bytes;
}
项目:lams    文件:CharacterStreamImpl.java   
@Override
public String asString() {
    if ( string == null ) {
        string = DataHelper.extractString( reader );
    }
    return string;
}
项目:spring-data-jpa-extra    文件:JSONType.java   
private static String extractString(Object value) {
    if (value == null) {
        return null;
    }
    if (value instanceof String) {
        return (String) value;
    }
    if (value instanceof Reader) {
        return DataHelper.extractString((Reader) value);
    }
    if (value instanceof Clob) {
        return DataHelper.extractString((Clob) value);
    }
    return null;
}
项目:cosmo    文件:BufferedContentTypeDescriptor.java   
@Override
public <X> X unwrap(BufferedContent value, Class<X> type,
        WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( BufferedContent.class.isAssignableFrom(type)){
        return (X) value;
    }
    if ( BinaryStream.class.isAssignableFrom(type)) {
            return (X) new BinaryStreamImpl(DataHelper.extractBytes(value.getInputStream()));
    }
    throw unknownUnwrap( type );
}
项目:cosmo    文件:BufferedContentTypeDescriptor.java   
@Override
public String toString(BufferedContent value) {
    final byte[] bytes;
    bytes = DataHelper.extractBytes( value.getInputStream());
    return PrimitiveByteArrayTypeDescriptor.INSTANCE.toString( bytes );
}