org.mortbay.io
Class BufferUtil

java.lang.Object
  extended by org.mortbay.io.BufferUtil

public class BufferUtil
extends Object

Buffer utility methods.

Author:
gregw

Field Summary
private static int[] decDivisors
           
(package private) static byte[] DIGIT
           
private static int[] hexDivisors
           
(package private) static byte MINUS
           
(package private) static byte SPACE
           
 
Constructor Summary
BufferUtil()
           
 
Method Summary
static boolean isPrefix(Buffer prefix, Buffer buffer)
           
static void prependHexInt(Buffer buffer, int n)
          Add hex integer BEFORE current getIndex.
static void putCRLF(Buffer buffer)
           
static void putDecInt(Buffer buffer, int n)
           
static void putDecLong(Buffer buffer, long n)
           
static void putHexInt(Buffer buffer, int n)
           
static Buffer toBuffer(long value)
           
static int toInt(Buffer buffer)
          Convert buffer to an integer.
static long toLong(Buffer buffer)
          Convert buffer to an long.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPACE

static final byte SPACE
See Also:
Constant Field Values

MINUS

static final byte MINUS
See Also:
Constant Field Values

DIGIT

static final byte[] DIGIT

decDivisors

private static int[] decDivisors

hexDivisors

private static int[] hexDivisors
Constructor Detail

BufferUtil

public BufferUtil()
Method Detail

toInt

public static int toInt(Buffer buffer)
Convert buffer to an integer. Parses up to the first non-numeric character. If no number is found an IllegalArgumentException is thrown

Parameters:
buffer - A buffer containing an integer. The position is not changed.
Returns:
an int

toLong

public static long toLong(Buffer buffer)
Convert buffer to an long. Parses up to the first non-numeric character. If no number is found an IllegalArgumentException is thrown

Parameters:
buffer - A buffer containing an integer. The position is not changed.
Returns:
an int

putHexInt

public static void putHexInt(Buffer buffer,
                             int n)

prependHexInt

public static void prependHexInt(Buffer buffer,
                                 int n)
Add hex integer BEFORE current getIndex.

Parameters:
buffer -
size -

putDecInt

public static void putDecInt(Buffer buffer,
                             int n)

putDecLong

public static void putDecLong(Buffer buffer,
                              long n)

toBuffer

public static Buffer toBuffer(long value)

putCRLF

public static void putCRLF(Buffer buffer)

isPrefix

public static boolean isPrefix(Buffer prefix,
                               Buffer buffer)