/** * <p> * Decode a byte array which had been encoded as a string. * </p> */ public static byte[] fromString( String objString ) { char[] chars = objString.toCharArray(); int count = chars.length; byte[] bytes = new byte[ count / 2 ]; int byteIdx = 0; for ( int i = 0; i < count; i = i + 2 ) { int lowNibble = decodeNibble( chars[ i ] ); int highNibble = decodeNibble( chars[ i + 1 ] ); bytes[ byteIdx++ ] = (byte) ( ( highNibble << NIBBLE_SHIFT ) | lowNibble ); } return bytes; }
/** * <p> * Encode a byte array as a string. * </p> */ public static String toString( byte[] written, int count ) { char[] chars = new char[ count * 2 ]; int charIdx = 0; for ( int i = 0; i < count; i++ ) { int current = written[ i ] & BYTE_MASK; int lowNibble = current & NIBBLE_MASK; int highNibble = current >>> NIBBLE_SHIFT; chars[ charIdx++ ] = encodeNibble( lowNibble ); chars[ charIdx++ ] = encodeNibble( highNibble ); } return new String( chars ); }
/** TransactionId method */ public int getMaxStoredSize() { return FormatIdUtil.getFormatIdByteLength(StoredFormatIds.RAW_STORE_XACT_ID) + CompressedNumber.MAX_LONG_STORED_SIZE; }
/** @see java.io.Externalizable#readExternal */ public void readExternal(ObjectInput in) throws IOException { format_id = FormatIdUtil.readFormatIdInteger(in); } public void readExternalFromArray(ArrayInputStream in) throws IOException
public void writeExternal(ObjectOutput out) throws IOException { FormatIdUtil.writeFormatIdInteger(out, format_id); }
t, FormatIdUtil.formatIdToString(fmtId), className); throw StandardException.newException(SQLState.REGISTERED_CLASS_NONE, FormatIdUtil.formatIdToString(fmtId));
/** * <p> * Deserialize a type descriptor from a string. * </p> */ private TypeDescriptor thawReturnType( String ice ) throws StandardException { try { byte[] bytes = FormatIdUtil.fromString( ice ); ByteArrayInputStream bais = new ByteArrayInputStream( bytes ); FormatIdInputStream fiis = new FormatIdInputStream( bais ); TypeDescriptor td = (TypeDescriptor) fiis.readObject(); return td; } catch (Throwable t) { throw StandardException.unexpectedUserException( t ); } }
/** * Serialize a row multi set as a string. */ private String freezeReturnType( TypeDescriptor td ) throws StandardException { try { DynamicByteArrayOutputStream dbaos = new DynamicByteArrayOutputStream(); FormatIdOutputStream fios = new FormatIdOutputStream( dbaos ); fios.writeObject( td ); dbaos.flush(); byte[] rawResult = dbaos.getByteArray(); int count = dbaos.getUsed(); String retval = FormatIdUtil.toString( rawResult, count ); return retval; } catch (Throwable t) { throw StandardException.unexpectedUserException( t ); } }
/** @see java.io.Externalizable#readExternal */ public void readExternal(ObjectInput in) throws IOException { format_id = FormatIdUtil.readFormatIdInteger(in); } public void readExternalFromArray(ArrayInputStream in) throws IOException
public void writeExternal(ObjectOutput out) throws IOException { FormatIdUtil.writeFormatIdInteger(out, format_id); }
t, FormatIdUtil.formatIdToString(fmtId), className); throw StandardException.newException(SQLState.REGISTERED_CLASS_NONE, FormatIdUtil.formatIdToString(fmtId));
/** * <p> * Deserialize a type descriptor from a string. * </p> */ private TypeDescriptor thawReturnType( String ice ) throws StandardException { try { byte[] bytes = FormatIdUtil.fromString( ice ); ByteArrayInputStream bais = new ByteArrayInputStream( bytes ); FormatIdInputStream fiis = new FormatIdInputStream( bais ); TypeDescriptor td = (TypeDescriptor) fiis.readObject(); return td; } catch (Throwable t) { throw StandardException.unexpectedUserException( t ); } }
/** * Serialize a row multi set as a string. */ private String freezeReturnType( TypeDescriptor td ) throws StandardException { try { DynamicByteArrayOutputStream dbaos = new DynamicByteArrayOutputStream(); FormatIdOutputStream fios = new FormatIdOutputStream( dbaos ); fios.writeObject( td ); dbaos.flush(); byte[] rawResult = dbaos.getByteArray(); int count = dbaos.getUsed(); String retval = FormatIdUtil.toString( rawResult, count ); return retval; } catch (Throwable t) { throw StandardException.unexpectedUserException( t ); } }
/** @see java.io.Externalizable#readExternal */ public void readExternal(ObjectInput in) throws IOException { format_id = FormatIdUtil.readFormatIdInteger(in); } public void readExternalFromArray(ArrayInputStream in) throws IOException
public void writeExternal(ObjectOutput out) throws IOException { FormatIdUtil.writeFormatIdInteger(out, format_id); }
/** TransactionId method */ public int getMaxStoredSize() { return FormatIdUtil.getFormatIdByteLength(StoredFormatIds.RAW_STORE_XACT_ID) + CompressedNumber.MAX_LONG_STORED_SIZE; }
t, FormatIdUtil.formatIdToString(fmtId), className); throw StandardException.newException(SQLState.REGISTERED_CLASS_NONE, FormatIdUtil.formatIdToString(fmtId));
/** * <p> * Encode a byte array as a string. * </p> */ public static String toString( byte[] written, int count ) { char[] chars = new char[ count * 2 ]; int charIdx = 0; for ( int i = 0; i < count; i++ ) { int current = written[ i ] & BYTE_MASK; int lowNibble = current & NIBBLE_MASK; int highNibble = current >>> NIBBLE_SHIFT; chars[ charIdx++ ] = encodeNibble( lowNibble ); chars[ charIdx++ ] = encodeNibble( highNibble ); } return new String( chars ); }
/** * <p> * Deserialize a type descriptor from a string. * </p> */ private TypeDescriptor thawReturnType( String ice ) throws StandardException { try { byte[] bytes = FormatIdUtil.fromString( ice ); ByteArrayInputStream bais = new ByteArrayInputStream( bytes ); FormatIdInputStream fiis = new FormatIdInputStream( bais ); TypeDescriptor td = (TypeDescriptor) fiis.readObject(); return td; } catch (Throwable t) { throw StandardException.unexpectedUserException( t ); } }
/** * <p> * Decode a byte array which had been encoded as a string. * </p> */ public static byte[] fromString( String objString ) { char[] chars = objString.toCharArray(); int count = chars.length; byte[] bytes = new byte[ count / 2 ]; int byteIdx = 0; for ( int i = 0; i < count; i = i + 2 ) { int lowNibble = decodeNibble( chars[ i ] ); int highNibble = decodeNibble( chars[ i + 1 ] ); bytes[ byteIdx++ ] = (byte) ( ( highNibble << NIBBLE_SHIFT ) | lowNibble ); } return bytes; }