abstract public void writeMethod()

in hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractHessianOutput.java [178:407]


    abstract public void writeMethod(String method)
            throws IOException;

    /**
     * Completes the method call:
     *
     * <code><pre>
     * </pre></code>
     */
    abstract public void completeCall()
            throws IOException;

    /**
     * Writes a boolean value to the stream.  The boolean will be written
     * with the following syntax:
     *
     * <code><pre>
     * T
     * F
     * </pre></code>
     *
     * @param value the boolean value to write.
     */
    abstract public void writeBoolean(boolean value)
            throws IOException;

    /**
     * Writes an integer value to the stream.  The integer will be written
     * with the following syntax:
     *
     * <code><pre>
     * I b32 b24 b16 b8
     * </pre></code>
     *
     * @param value the integer value to write.
     */
    abstract public void writeInt(int value)
            throws IOException;

    /**
     * Writes a long value to the stream.  The long will be written
     * with the following syntax:
     *
     * <code><pre>
     * L b64 b56 b48 b40 b32 b24 b16 b8
     * </pre></code>
     *
     * @param value the long value to write.
     */
    abstract public void writeLong(long value)
            throws IOException;

    /**
     * Writes a double value to the stream.  The double will be written
     * with the following syntax:
     *
     * <code><pre>
     * D b64 b56 b48 b40 b32 b24 b16 b8
     * </pre></code>
     *
     * @param value the double value to write.
     */
    abstract public void writeDouble(double value)
            throws IOException;

    /**
     * Writes a date to the stream.
     *
     * <code><pre>
     * T  b64 b56 b48 b40 b32 b24 b16 b8
     * </pre></code>
     *
     * @param time the date in milliseconds from the epoch in UTC
     */
    abstract public void writeUTCDate(long time)
            throws IOException;

    /**
     * Writes a null value to the stream.
     * The null will be written with the following syntax
     *
     * <code><pre>
     * N
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeNull()
            throws IOException;

    /**
     * Writes a string value to the stream using UTF-8 encoding.
     * The string will be written with the following syntax:
     *
     * <code><pre>
     * S b16 b8 string-value
     * </pre></code>
     * <p>
     * If the value is null, it will be written as
     *
     * <code><pre>
     * N
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeString(String value)
            throws IOException;

    /**
     * Writes a string value to the stream using UTF-8 encoding.
     * The string will be written with the following syntax:
     *
     * <code><pre>
     * S b16 b8 string-value
     * </pre></code>
     * <p>
     * If the value is null, it will be written as
     *
     * <code><pre>
     * N
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeString(char[] buffer, int offset, int length)
            throws IOException;

    /**
     * Writes a byte array to the stream.
     * The array will be written with the following syntax:
     *
     * <code><pre>
     * B b16 b18 bytes
     * </pre></code>
     * <p>
     * If the value is null, it will be written as
     *
     * <code><pre>
     * N
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeBytes(byte[] buffer)
            throws IOException;

    /**
     * Writes a byte array to the stream.
     * The array will be written with the following syntax:
     *
     * <code><pre>
     * B b16 b18 bytes
     * </pre></code>
     * <p>
     * If the value is null, it will be written as
     *
     * <code><pre>
     * N
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeBytes(byte[] buffer, int offset, int length)
            throws IOException;

    /**
     * Writes a byte buffer to the stream.
     */
    abstract public void writeByteBufferStart()
            throws IOException;

    /**
     * Writes a byte buffer to the stream.
     *
     * <code><pre>
     * b b16 b18 bytes
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeByteBufferPart(byte[] buffer,
                                             int offset,
                                             int length)
            throws IOException;

    /**
     * Writes the last chunk of a byte buffer to the stream.
     *
     * <code><pre>
     * b b16 b18 bytes
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeByteBufferEnd(byte[] buffer,
                                            int offset,
                                            int length)
            throws IOException;

    /**
     * Writes a full output stream.
     */
    public void writeByteStream(InputStream is)
            throws IOException {
        writeByteBufferStart();

        if (_byteBuffer == null)
            _byteBuffer = new byte[1024];

        byte[] buffer = _byteBuffer;

        int len;
        while ((len = is.read(buffer, 0, buffer.length)) > 0) {
            if (len < buffer.length) {
                int len2 = is.read(buffer, len, buffer.length - len);

                if (len2 < 0) {
                    writeByteBufferEnd(buffer, 0, len);
                    return;
                }

                len += len2;
            }

            writeByteBufferPart(buffer, 0, len);
        }

        writeByteBufferEnd(buffer, 0, 0);
    }