Java 类org.hibernate.engine.jdbc.internal.CharacterStreamImpl 实例源码

项目:lams    文件:CharacterArrayTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
@Override
public <X> X unwrap(Character[] value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Character[].class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( String.class.isAssignableFrom( type ) ) {
        return (X) new String( unwrapChars( value ) );
    }
    if ( Clob.class.isAssignableFrom( type ) ) {
        return (X) options.getLobCreator().createClob( new String( unwrapChars( value ) ) );
    }
    if ( Reader.class.isAssignableFrom( type ) ) {
        return (X) new StringReader( new String( unwrapChars( value ) ) );
    }
    if ( CharacterStream.class.isAssignableFrom( type ) ) {
        return (X) new CharacterStreamImpl( new String( unwrapChars( value ) ) );
    }
    throw unknownUnwrap( type );
}
项目:lams    文件:StringTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(String value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( String.class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( Reader.class.isAssignableFrom( type ) ) {
        return (X) new StringReader( value );
    }
    if ( CharacterStream.class.isAssignableFrom( type ) ) {
        return (X) new CharacterStreamImpl( value );
    }
    if ( Clob.class.isAssignableFrom( type ) ) {
        return (X) options.getLobCreator().createClob( value );
    }
    if ( DataHelper.isNClob( type ) ) {
        return (X) options.getLobCreator().createNClob( value );
    }

    throw unknownUnwrap( type );
}
项目:lams    文件:PrimitiveCharacterArrayTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(char[] value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( char[].class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( String.class.isAssignableFrom( type ) ) {
        return (X) new String( value );
    }
    if ( Clob.class.isAssignableFrom( type ) ) {
        return (X) options.getLobCreator().createClob( new String( value ) );
    }
    if ( Reader.class.isAssignableFrom( type ) ) {
        return (X) new StringReader( new String( value ) );
    }
    if ( CharacterStream.class.isAssignableFrom( type ) ) {
        return (X) new CharacterStreamImpl( new String( value ) );
    }
    throw unknownUnwrap( type );
}
项目:hibernate-semantic-query    文件:PrimitiveCharacterArrayJavaDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(char[] value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( char[].class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( String.class.isAssignableFrom( type ) ) {
        return (X) new String( value );
    }
    if ( Clob.class.isAssignableFrom( type ) ) {
        return (X) options.getLobCreator().createClob( new String( value ) );
    }
    if ( Reader.class.isAssignableFrom( type ) ) {
        return (X) new StringReader( new String( value ) );
    }
    if ( CharacterStream.class.isAssignableFrom( type ) ) {
        return (X) new CharacterStreamImpl( new String( value ) );
    }
    throw unknownUnwrap( type );
}
项目:hibernate-semantic-query    文件:CharacterArrayJavaDescriptor.java   
@SuppressWarnings({ "unchecked" })
@Override
public <X> X unwrap(Character[] value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Character[].class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( String.class.isAssignableFrom( type ) ) {
        return (X) new String( unwrapChars( value ) );
    }
    if ( Clob.class.isAssignableFrom( type ) ) {
        return (X) options.getLobCreator().createClob( new String( unwrapChars( value ) ) );
    }
    if ( Reader.class.isAssignableFrom( type ) ) {
        return (X) new StringReader( new String( unwrapChars( value ) ) );
    }
    if ( CharacterStream.class.isAssignableFrom( type ) ) {
        return (X) new CharacterStreamImpl( new String( unwrapChars( value ) ) );
    }
    throw unknownUnwrap( type );
}
项目:hibernate-semantic-query    文件:StringJavaDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(String value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( String.class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( Reader.class.isAssignableFrom( type ) ) {
        return (X) new StringReader( value );
    }
    if ( CharacterStream.class.isAssignableFrom( type ) ) {
        return (X) new CharacterStreamImpl( value );
    }
    if ( Clob.class.isAssignableFrom( type ) ) {
        return (X) options.getLobCreator().createClob( value );
    }
    if ( DataHelper.isNClob( type ) ) {
        return (X) options.getLobCreator().createNClob( value );
    }

    throw unknownUnwrap( type );
}
项目:lams    文件:ClobTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(final Clob value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }

    try {
        if ( CharacterStream.class.isAssignableFrom( type ) ) {
            if ( ClobImplementer.class.isInstance( value ) ) {
                // if the incoming Clob is a wrapper, just pass along its CharacterStream
                return (X) ( (ClobImplementer) value ).getUnderlyingStream();
            }
            else {
                // otherwise we need to build a CharacterStream...
                return (X) new CharacterStreamImpl( DataHelper.extractString( value.getCharacterStream() ) );
            }
        }
        else if (Clob.class.isAssignableFrom( type )) {
            final Clob clob =  WrappedClob.class.isInstance( value )
                    ? ( (WrappedClob) value ).getWrappedClob()
                    : value;
            return (X) clob;
        }
    }
    catch ( SQLException e ) {
        throw new HibernateException( "Unable to access clob stream", e );
    }

    throw unknownUnwrap( type );
}
项目:lams    文件:NClobTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(final NClob value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }

    try {
        if ( CharacterStream.class.isAssignableFrom( type ) ) {
            if ( NClobImplementer.class.isInstance( value ) ) {
                // if the incoming NClob is a wrapper, just pass along its BinaryStream
                return (X) ( (NClobImplementer) value ).getUnderlyingStream();
            }
            else {
                // otherwise we need to build a BinaryStream...
                return (X) new CharacterStreamImpl( DataHelper.extractString( value.getCharacterStream() ) );
            }
        }
        else if (NClob.class.isAssignableFrom( type )) {
            final NClob nclob =  WrappedNClob.class.isInstance( value )
                    ? ( (WrappedNClob) value ).getWrappedNClob()
                    : value;
            return (X) nclob;
        }
    }
    catch ( SQLException e ) {
        throw new HibernateException( "Unable to access nclob stream", e );
    }

    throw unknownUnwrap( type );
}
项目:hibernate-semantic-query    文件:ClobJavaDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(final Clob value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }

    try {
        if ( CharacterStream.class.isAssignableFrom( type ) ) {
            if ( ClobImplementer.class.isInstance( value ) ) {
                // if the incoming Clob is a wrapper, just pass along its CharacterStream
                return (X) ( (ClobImplementer) value ).getUnderlyingStream();
            }
            else {
                // otherwise we need to build a CharacterStream...
                return (X) new CharacterStreamImpl( DataHelper.extractString( value.getCharacterStream() ) );
            }
        }
        else if (Clob.class.isAssignableFrom( type )) {
            final Clob clob =  WrappedClob.class.isInstance( value )
                    ? ( (WrappedClob) value ).getWrappedClob()
                    : value;
            return (X) clob;
        }
    }
    catch ( SQLException e ) {
        throw new HibernateException( "Unable to access clob stream", e );
    }

    throw unknownUnwrap( type );
}
项目:hibernate-semantic-query    文件:NClobJavaDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(final NClob value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }

    try {
        if ( CharacterStream.class.isAssignableFrom( type ) ) {
            if ( NClobImplementer.class.isInstance( value ) ) {
                // if the incoming Clob is a wrapper, just pass along its CharacterStream
                return (X) ( (NClobImplementer) value ).getUnderlyingStream();
            }
            else {
                // otherwise we need to build a CharacterStream...
                return (X) new CharacterStreamImpl( DataHelper.extractString( value.getCharacterStream() ) );
            }
        }
        else if (Clob.class.isAssignableFrom( type )) {
            final Clob clob =  WrappedClob.class.isInstance( value )
                    ? ( (WrappedClob) value ).getWrappedClob()
                    : value;
            return (X) clob;
        }
    }
    catch ( SQLException e ) {
        throw new HibernateException( "Unable to access clob stream", e );
    }

    throw unknownUnwrap( type );
}
项目:cosmo    文件:CosmoCalendarTypeDescriptor.java   
@Override
public <X> X unwrap(Calendar value, Class<X> type, WrapperOptions options) {
    if (value == null) {
        return null;
    }
    if (Calendar.class.isAssignableFrom(type)) {
        return (X) value;
    }
    if (CharacterStream.class.isAssignableFrom(type)) {
            return (X) new CharacterStreamImpl(value.toString());
    }
    throw unknownUnwrap(type);
}
项目:lams    文件:ClobProxy.java   
/**
 * Constructor used to build {@link Clob} from string data.
 *
 * @param string The byte array
 * @see #generateProxy(String)
 */
protected ClobProxy(String string) {
    this.characterStream = new CharacterStreamImpl( string );
}
项目:lams    文件:ClobProxy.java   
/**
 * Constructor used to build {@link Clob} from a reader.
 *
 * @param reader The character reader.
 * @param length The length of the reader stream.
 * @see #generateProxy(java.io.Reader, long)
 */
protected ClobProxy(Reader reader, long length) {
    this.characterStream = new CharacterStreamImpl( reader, length );
}