com.mooapi.common.command
Class CodecUtils

java.lang.Object
  extended by com.mooapi.common.command.CodecUtils

public class CodecUtils
extends java.lang.Object

Encoders and decoders for components of commands.

Author:
Steve Taylor

Constructor Summary
CodecUtils()
           
 
Method Summary
static byte[] decodeBytes(org.apache.mina.common.ByteBuffer buffer)
          Parse an input buffer, extracting a byte array.
static java.lang.String decodeText(org.apache.mina.common.ByteBuffer buffer)
          Parse an input buffer, extracting a character string.
static org.apache.mina.common.ByteBuffer encodeBytes(byte[] bytes)
          Encode the specified byte array to a new ByteBuffer.
static org.apache.mina.common.ByteBuffer encodeText(java.lang.String text)
          Encode the specified string to a new ByteBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodecUtils

public CodecUtils()
Method Detail

decodeBytes

public static byte[] decodeBytes(org.apache.mina.common.ByteBuffer buffer)
Parse an input buffer, extracting a byte array. The byte array's length is determined by the integer encoded in the first four bytes.

Parameters:
buffer - An input buffer.
Returns:
The byte array extracted from the input buffer.
Throws:
java.nio.BufferUnderflowException - if the buffer has insufficient data to decode.

encodeBytes

public static org.apache.mina.common.ByteBuffer encodeBytes(byte[] bytes)
Encode the specified byte array to a new ByteBuffer.

Parameters:
bytes - The byte array.
Returns:
The byte buffer.

decodeText

public static java.lang.String decodeText(org.apache.mina.common.ByteBuffer buffer)
Parse an input buffer, extracting a character string.

Parameters:
buffer - An input buffer.
Returns:
The character string extracted from the input buffer.
Throws:
java.nio.BufferUnderflowException - if the buffer has insufficient data to decode.

encodeText

public static org.apache.mina.common.ByteBuffer encodeText(java.lang.String text)
Encode the specified string to a new ByteBuffer.

Parameters:
text - The string.
Returns:
The byte buffer.


Copyright © 2009. All Rights Reserved.