@Test public void testGetBinaryString() throws KettleValueException, UnknownHostException { ValueMetaInternetAddress vmInet = new ValueMetaInternetAddress(); final ValueMetaString vmString = new ValueMetaString(); vmInet.setStorageMetadata( vmString ); InetAddress inetAddress = InetAddress.getByName( "127.0.0.1" ); byte[] output = vmInet.getBinaryString( inetAddress ); assertNotNull( output ); assertArrayEquals( vmString.getBinaryString( "127.0.0.1" ), output ); assertEquals( inetAddress, vmInet.convertBinaryStringToNativeType( output ) ); vmInet.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING ); output = vmInet.getBinaryString( vmString.getBinaryString( "127.0.0.1" ) ); assertNotNull( output ); assertArrayEquals( vmString.getBinaryString( "127.0.0.1" ), output ); assertEquals( inetAddress, vmInet.convertBinaryStringToNativeType( output ) ); vmInet.setStorageType( ValueMetaInterface.STORAGE_TYPE_INDEXED ); vmInet.setIndex( new InetAddress[] { inetAddress } ); assertArrayEquals( vmString.getBinaryString( "127.0.0.1" ), vmInet.getBinaryString( 0 ) ); assertEquals( inetAddress, vmInet.convertBinaryStringToNativeType( output ) ); try { vmInet.getBinaryString( 1 ); fail(); } catch ( ArrayIndexOutOfBoundsException e ) { } }
@Override public byte[] getBinaryString( Object object ) throws KettleValueException { if ( isStorageBinaryString() && identicalFormat ) { return (byte[]) object; } if ( object == null ) { return null; } switch ( storageType ) { case STORAGE_TYPE_NORMAL: return convertStringToBinaryString( getString( object ) ); case STORAGE_TYPE_BINARY_STRING: return convertStringToBinaryString( getString( convertStringToInternetAddress( convertBinaryStringToString( (byte[]) object ) ) ) ); case STORAGE_TYPE_INDEXED: return convertStringToBinaryString( convertInternetAddressToString( (InetAddress) index[( (Integer) object )] ) ); default: throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." ); } }
ValueMetaInternetAddress extends ValueMetaDate { @Override public byte[] getBinaryString( Object object ) throws KettleValueException { if ( isStorageBinaryString() && identicalFormat ) { return (byte[]) object; } if ( object == null ) { return null; } switch ( storageType ) { case STORAGE_TYPE_NORMAL: return convertStringToBinaryString( getString( object ) ); case STORAGE_TYPE_BINARY_STRING: return convertStringToBinaryString( getString( convertStringToInternetAddress( convertBinaryStringToString( (byte[]) object ) ) ) ); case STORAGE_TYPE_INDEXED: return convertStringToBinaryString( convertInternetAddressToString( (InetAddress) index[( (Integer) object )] ) ); default: throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." ); } } }
ValueMetaInternetAddress extends ValueMetaDate { @Override public byte[] getBinaryString( Object object ) throws KettleValueException { if ( isStorageBinaryString() && identicalFormat ) { return (byte[]) object; } if ( object == null ) { return null; } switch ( storageType ) { case STORAGE_TYPE_NORMAL: return convertStringToBinaryString( getString( object ) ); case STORAGE_TYPE_BINARY_STRING: return convertStringToBinaryString( getString( convertStringToInternetAddress( convertBinaryStringToString( (byte[]) object ) ) ) ); case STORAGE_TYPE_INDEXED: return convertStringToBinaryString( convertInternetAddressToString( (InetAddress) index[( (Integer) object )] ) ); default: throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." ); } } ValueMetaInternetAddress();  ValueMetaInternetAddress( String name ); }
ValueMetaInternetAddress extends ValueMetaDate { @Override public byte[] getBinaryString( Object object ) throws KettleValueException { if ( isStorageBinaryString() && identicalFormat ) { return (byte[]) object; } if ( object == null ) { return null; } switch ( storageType ) { case STORAGE_TYPE_NORMAL: return convertStringToBinaryString( getString( object ) ); case STORAGE_TYPE_BINARY_STRING: return convertStringToBinaryString( getString( convertStringToInternetAddress( convertBinaryStringToString( (byte[]) object ) ) ) ); case STORAGE_TYPE_INDEXED: return convertStringToBinaryString( convertInternetAddressToString( (InetAddress) index[( (Integer) object )] ) ); default: throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." ); } } ValueMetaInternetAddress();  ValueMetaInternetAddress( String name ); @Override int compare( Object data1, Object data2 ); InetAddress getInternetAddress( Object object ); @Override Date getDate( Object object ); @Override Long getInteger( Object object ); @Override Double getNumber( Object object ); @Override BigDecimal getBigNumber( Object object ); @Override Boolean getBoolean( Object object ); @Override String getString( Object object ); @Override byte[] getBinaryString( Object object ); @Override Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,
    int trim_type ); @Override Object convertData( ValueMetaInterface meta2, Object data2 ); @Override Object cloneValueData( Object object ); @Override ValueMetaInterface getValueFromSQLType( DatabaseMeta databaseMeta, String name, ResultSetMetaData rm,
    int index, boolean ignoreLength, boolean lazyConversion ); @Override Object getValueFromResultSet( DatabaseInterface databaseInterface, ResultSet resultSet, int index ); @Override void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement,
    int index, Object data ); @Override String getDatabaseColumnTypeDefinition( DatabaseInterface databaseInterface, String tk, String pk,
    boolean use_autoinc, boolean add_fieldname, boolean add_cr ); @Override Class<?> getNativeDataTypeClass(); }
ValueMetaInternetAddress extends ValueMetaDate { @Override public byte[] getBinaryString( Object object ) throws KettleValueException { if ( isStorageBinaryString() && identicalFormat ) { return (byte[]) object; } if ( object == null ) { return null; } switch ( storageType ) { case STORAGE_TYPE_NORMAL: return convertStringToBinaryString( getString( object ) ); case STORAGE_TYPE_BINARY_STRING: return convertStringToBinaryString( getString( convertStringToInternetAddress( convertBinaryStringToString( (byte[]) object ) ) ) ); case STORAGE_TYPE_INDEXED: return convertStringToBinaryString( convertInternetAddressToString( (InetAddress) index[( (Integer) object )] ) ); default: throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." ); } } ValueMetaInternetAddress();  ValueMetaInternetAddress( String name ); @Override int compare( Object data1, Object data2 ); InetAddress getInternetAddress( Object object ); @Override Date getDate( Object object ); @Override Long getInteger( Object object ); @Override Double getNumber( Object object ); @Override BigDecimal getBigNumber( Object object ); @Override Boolean getBoolean( Object object ); @Override String getString( Object object ); @Override byte[] getBinaryString( Object object ); @Override Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,
    int trim_type ); @Override Object convertData( ValueMetaInterface meta2, Object data2 ); @Override Object cloneValueData( Object object ); @Override ValueMetaInterface getValueFromSQLType( DatabaseMeta databaseMeta, String name, ResultSetMetaData rm,
    int index, boolean ignoreLength, boolean lazyConversion ); @Override Object getValueFromResultSet( DatabaseInterface databaseInterface, ResultSet resultSet, int index ); @Override void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement,
    int index, Object data ); @Override String getDatabaseColumnTypeDefinition( DatabaseInterface databaseInterface, String tk, String pk,
    boolean use_autoinc, boolean add_fieldname, boolean add_cr ); @Override Class<?> getNativeDataTypeClass();  }