java/proto/src/main/java/com/pravala/protocol/Codec.java
public static void appendField ( OutputStream toStream, InetAddress value, int fieldId )
    throws IOException, CodecException
    {
        if ( fieldId < 0 )
        {
            throw new CodecException ( ErrorCode.InvalidParameter );
        }

        int dataSize = 0;

        if ( value == null )
        {
            dataSize = 0;
        }
        else if ( value instanceof Inet4Address )
        {
            dataSize = 4;
        }
        else if ( value instanceof Inet6Address )
        {
            dataSize = 16;
        }

        appendFieldHeader ( toStream, fieldId, getWireTypeForSize ( dataSize ), dataSize );

        if ( dataSize < 1 )
        {
            return;
        }

        byte[] data = value.getAddress();

        if ( data.length != dataSize )
        {
            throw new CodecException ( ErrorCode.InternalError );
        }

        toStream.write ( data );
    }
/**
     *  Writes a single value to the stream
     *
     * @param toStream The stream to append the data to
     * @param value The value to append to the stream
     * @param fieldId ID of the field to store in the header
     *
     * @throws IOException Thrown by OutputStream.write, CodecException
     **/
Writes a single value to the stream
@param toStream The stream to append the data to
@param value The value to append to the stream
@param fieldId ID of the field to store in the header


Writes a single value to the stream @param toStream The stream to append the data to @param value The value to append to the stream @param fieldId ID of the field to store in the header
public static void appendField ( OutputStream toStream, InetAddress value, int fieldId )
    throws IOException, CodecException
    {
        if ( fieldId < 0 )
        {
            throw new CodecException ( ErrorCode.InvalidParameter );
        }
        int dataSize = 0;
        if ( value == null )
        {
            dataSize = 0;
        }
        else if ( value instanceof Inet4Address )
        {
            dataSize = 4;
        }
        else if ( value instanceof Inet6Address )
        {
            dataSize = 16;
        }
        appendFieldHeader ( toStream, fieldId, getWireTypeForSize ( dataSize ), dataSize );
        if ( dataSize < 1 )
        {
            return;
        }
        byte[] data = value.getAddress();
        if ( data.length != dataSize )
        {
            throw new CodecException ( ErrorCode.InternalError );
        }
        toStream.write ( data );
    }
public static void appendField ( OutputStream toStream , InetAddress value , int fieldId ) throws IOException , CodecException { if ( fieldId < 0 ) { throw new CodecException ( ErrorCode . InvalidParameter ) ; } int dataSize = 0 ; if ( value == null ) { dataSize = 0 ; } else if ( value instanceof Inet4Address ) { dataSize = 4 ; } else if ( value instanceof Inet6Address ) { dataSize = 16 ; } appendFieldHeader ( toStream , fieldId , getWireTypeForSize ( dataSize ) , dataSize ) ; if ( dataSize < 1 ) { return ; } byte [ ] data = value . getAddress ( ) ; if ( data . length != dataSize ) { throw new CodecException ( ErrorCode . InternalError ) ; } toStream . write ( data ) ; }
Writes a single value to the stream
 @param toStream The stream to append the data to
 @param value The value to append to the stream
 @param fieldId ID of the field to store in the header
Writes a single value to the stream @param toStream The stream to append the data to @param value The value to append to the stream @param fieldId ID of the field to store in the header