org.littleshoot.util.mina
Class MinaCodecUtils

java.lang.Object
  extended by org.littleshoot.util.mina.MinaCodecUtils

public class MinaCodecUtils
extends Object

Taken from AsyncWeb. Utilies for SIP codec handling.


Field Summary
static byte AMP
          Ampersand character
static byte BACK_SLASH
          Back-slash character
static byte COLON
          Colon character
static byte COMMA
          Comma.
static byte CR
          Carriage return character
static String DEFAULT_CHARACTER_ENCODING
          The default charset we employ
static byte EQUALS
          Equals character
static byte FOWARD_SLASH
          Foward-slash character
static byte HT
          Horizontal tab character
static byte LF
          Line feed character
static byte PERCENT
          Percent character
static byte PLUS
          Plus character
static byte QS
          Question mark character
static byte QUOTE
          Quote character
static byte SEMI_COLON
          Semi-colon
static byte SPACE
          Space character
 
Constructor Summary
MinaCodecUtils()
           
 
Method Summary
static void appendCRLF(org.littleshoot.mina.common.ByteBuffer buffer)
          Appends a CR LF to the specified buffer
static void appendString(org.littleshoot.mina.common.ByteBuffer buffer, String string)
          Appends a string to a specified ByteBuffer.
static byte[] getAsciiBytes(String str)
          Returns the ASCII bytes for a specified string.
static int hexAsciiToDecimal(byte b)
          Obtains the decimal value for a hex value encoded in ASCII
static boolean isHex(byte b)
          Determines whether a specified (US-ASCII) character is a valid hex character: A..F a..f 0..9
static boolean isHttpControl(byte b)
          Determines whether a specified (US-ASCII) character is an HTTP control character
static boolean isHttpSeparator(byte b)
          Determines whether a specified (US-ASCII) character is an HTTP field separator
static boolean isWhiteSpace(byte b)
          Determines whether a specified (US-ASCII) character is an HTTP whitespace character (Space or Horizontal tab)
static void pushBack(org.littleshoot.mina.common.ByteBuffer buffer)
          "Pushes back" a byte on to the specified buffer, by rewinding the position by 1 byte
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CHARACTER_ENCODING

public static final String DEFAULT_CHARACTER_ENCODING
The default charset we employ

See Also:
Constant Field Values

AMP

public static final byte AMP
Ampersand character

See Also:
Constant Field Values

COLON

public static final byte COLON
Colon character

See Also:
Constant Field Values

CR

public static final byte CR
Carriage return character

See Also:
Constant Field Values

EQUALS

public static final byte EQUALS
Equals character

See Also:
Constant Field Values

LF

public static final byte LF
Line feed character

See Also:
Constant Field Values

SPACE

public static final byte SPACE
Space character

See Also:
Constant Field Values

PLUS

public static final byte PLUS
Plus character

See Also:
Constant Field Values

QS

public static final byte QS
Question mark character

See Also:
Constant Field Values

HT

public static final byte HT
Horizontal tab character

See Also:
Constant Field Values

PERCENT

public static final byte PERCENT
Percent character

See Also:
Constant Field Values

FOWARD_SLASH

public static final byte FOWARD_SLASH
Foward-slash character

See Also:
Constant Field Values

BACK_SLASH

public static final byte BACK_SLASH
Back-slash character

See Also:
Constant Field Values

QUOTE

public static final byte QUOTE
Quote character

See Also:
Constant Field Values

SEMI_COLON

public static final byte SEMI_COLON
Semi-colon

See Also:
Constant Field Values

COMMA

public static final byte COMMA
Comma.

See Also:
Constant Field Values
Constructor Detail

MinaCodecUtils

public MinaCodecUtils()
Method Detail

isHex

public static boolean isHex(byte b)
Determines whether a specified (US-ASCII) character is a valid hex character:

Parameters:
b - The character to check
Returns:
true iff the character is a valid hex character

isHttpSeparator

public static boolean isHttpSeparator(byte b)
Determines whether a specified (US-ASCII) character is an HTTP field separator

Parameters:
b - The US-ASCII character to check
Returns:
true iff the character is an HTTP field separator

isHttpControl

public static boolean isHttpControl(byte b)
Determines whether a specified (US-ASCII) character is an HTTP control character

Parameters:
b - The US-ASCII character to check
Returns:
true iff the character is an HTTP control character

isWhiteSpace

public static boolean isWhiteSpace(byte b)
Determines whether a specified (US-ASCII) character is an HTTP whitespace character (Space or Horizontal tab)

Parameters:
b - the US-ASCII character to check
Returns:
true iff the character is an HTTP whitespace character

pushBack

public static void pushBack(org.littleshoot.mina.common.ByteBuffer buffer)
"Pushes back" a byte on to the specified buffer, by rewinding the position by 1 byte

Parameters:
buffer - The buffer to "push back" to

hexAsciiToDecimal

public static int hexAsciiToDecimal(byte b)
Obtains the decimal value for a hex value encoded in ASCII

Parameters:
b - The ASCII encoded byte
Returns:
The decimal value - or -1 if the specified byte is not a valid ASCII hex character

getAsciiBytes

public static byte[] getAsciiBytes(String str)
Returns the ASCII bytes for a specified string.

Parameters:
str - The string
Returns:
The ASCII bytes making up the string

appendString

public static void appendString(org.littleshoot.mina.common.ByteBuffer buffer,
                                String string)
Appends a string to a specified ByteBuffer. This method assumes ascii encoding and is primarily used for encoding http header names and values.
Note that encoding header values this way is not stricly correct (character encodings). However, existing containers do it this way (e.g. Tomcat), and we're probably safer doing it a similar way for the time being

Parameters:
buffer - The buffer to append to
string - The string to append

appendCRLF

public static void appendCRLF(org.littleshoot.mina.common.ByteBuffer buffer)
Appends a CR LF to the specified buffer

Parameters:
buffer - The buffer


Copyright © 2013 LittleShoot. All Rights Reserved.