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

        int size = 0;

        if ( byteStream != null )
        {
            size = byteStream.size();
        }

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

        if ( size > 0 )
        {
            byteStream.writeTo ( toStream );
        }
    }
/**
     *  Writes a byte output stream to another stream
     *
     * @param toStream The stream to append the data to
     * @param byteStream The buffer stream whose content should be written
     * @param fieldId ID of the field to store in the header
     *
     * @throws IOException Thrown by OutputStream.write, CodecException
     **/
Writes a byte output stream to another stream
@param toStream The stream to append the data to
@param byteStream The buffer stream whose content should be written
@param fieldId ID of the field to store in the header


Writes a byte output stream to another stream @param toStream The stream to append the data to @param byteStream The buffer stream whose content should be written @param fieldId ID of the field to store in the header
public static void appendField ( OutputStream toStream, ByteArrayOutputStream byteStream, int fieldId )
    throws IOException, CodecException
    {
        if ( fieldId < 0 )
        {
            throw new CodecException ( ErrorCode.InvalidParameter );
        }
        int size = 0;
        if ( byteStream != null )
        {
            size = byteStream.size();
        }
        appendFieldHeader ( toStream, fieldId, getWireTypeForSize ( size ), size );
        if ( size > 0 )
        {
            byteStream.writeTo ( toStream );
        }
    }
public static void appendField ( OutputStream toStream , ByteArrayOutputStream byteStream , int fieldId ) throws IOException , CodecException { if ( fieldId < 0 ) { throw new CodecException ( ErrorCode . InvalidParameter ) ; } int size = 0 ; if ( byteStream != null ) { size = byteStream . size ( ) ; } appendFieldHeader ( toStream , fieldId , getWireTypeForSize ( size ) , size ) ; if ( size > 0 ) { byteStream . writeTo ( toStream ) ; } }
Writes a byte output stream to another stream
 @param toStream The stream to append the data to
 @param byteStream The buffer stream whose content should be written
 @param fieldId ID of the field to store in the header
Writes a byte output stream to another stream @param toStream The stream to append the data to @param byteStream The buffer stream whose content should be written @param fieldId ID of the field to store in the header