org.xsocket
Class DataConverter

Package class diagram package DataConverter
java.lang.Object
  extended by org.xsocket.DataConverter

public final class DataConverter
extends Object

a data converter utilities class

Author:
grro@xsocket.org

Constructor Summary
DataConverter()
           
 
Method Summary
static ByteBuffer toByteBuffer(byte b)
          converts a single byte to a byte buffer
static ByteBuffer toByteBuffer(byte[] bytes)
          converts a byte array to a byte buffer
static ByteBuffer toByteBuffer(byte[] bytes, int offset, int length)
          converts a byte array to a byte buffer
static ByteBuffer toByteBuffer(ByteBuffer[] buffers)
          merges a ByteBuffer array into a (direct) ByteBuffer
static ByteBuffer toByteBuffer(double d)
          converts a double to a byte buffer
static ByteBuffer toByteBuffer(int i)
          converts a integer to a byte buffer
static ByteBuffer toByteBuffer(long l)
          converts a long to a byte buffer
static ByteBuffer toByteBuffer(short s)
          converts a short to a byte buffer
static ByteBuffer toByteBuffer(String s, String encoding)
          converts the given String into a ByteBuffer
static ByteBuffer[] toByteBuffers(ByteBuffer[] srcs, int offset, int length)
          copies a array of ByteBuffer based on offset length to a byte buffer array
static byte[] toBytes(ByteBuffer buffer)
          converts a ByteBuffer into a byte array
static byte[] toBytes(ByteBuffer[] buffers)
          converts a ByteBuffer array to a byte array
static byte[] toBytes(List<ByteBuffer> buffers)
          converts a list of ByteBuffer to a byte array
static Date toDate(String rfc822DateString)
          converts a RFC822 date string into a date object
static String toFormatedBytesSize(long bytes)
          converts the given byte size in a textual representation
static String toFormatedDate(long time)
          converts the given time in a textual representation
static String toFormatedDuration(long duration)
          converts the given duration in a textual representation
static String toFormatedRFC822Date(long time)
          converts the given time in a RFC822 conform date representation
static String toHexString(byte[] buffers, int maxOutSize)
          print the byte array as a hex string
static String toHexString(ByteBuffer buffer)
          converts the given ByteBuffer into a hex string
static String toHexString(ByteBuffer[] buffers, int maxOutSize)
          print the byte buffer as a hex string
static String toHexString(List<ByteBuffer> buffers, int maxOutSize)
          print the byte buffer as a hex string
static String toString(ByteBuffer buffer)
          converts the given ByteBuffer into String by using UTF-8 encoding
static String toString(ByteBuffer[] buffer)
          converts the given ByteBuffer array into String by using UTF-8 encoding
static String toString(ByteBuffer[] buffers, String encoding)
          converts the given array of ByteBuffers into String
static String toString(ByteBuffer[] buffers, String encoding, int maxOutSize)
          print the bytebuffer as limited string
static String toString(ByteBuffer buffer, String encoding)
          converts the given ByteBuffer into String repesentation
static String toString(List<ByteBuffer> buffers)
          converts the given list of ByteBuffers into a String by using UTF-8 encoding
static String toString(List<ByteBuffer> buffers, String encoding)
          converts the given list of ByteBuffers into a String
static String toString(Throwable t)
           
static String toTextAndHexString(ByteBuffer[] buffers, String encoding, int maxOutSize)
           
static String toTextOrHexString(ByteBuffer[] buffers, String encoding, int maxOutSize)
          convert the ByteBuffer array into a hex or text string (deping on content)
static String toTextOrHexString(ByteBuffer buffer, String encoding, int maxOutSize)
          convert the ByteBuffer into a hex or text string (deping on content)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataConverter

public DataConverter()
Method Detail

toFormatedBytesSize

public static String toFormatedBytesSize(long bytes)
converts the given byte size in a textual representation

Parameters:
bytes - the bytes to convert
Returns:
the formated String representation of the bytes

toFormatedDate

public static String toFormatedDate(long time)
converts the given time in a textual representation

Parameters:
time - the time to convert
Returns:
the formated String representation of the date

toFormatedRFC822Date

public static String toFormatedRFC822Date(long time)
converts the given time in a RFC822 conform date representation

Parameters:
time - the time to convert
Returns:
the formated String representation in a RFC822 conform date representation

toDate

public static Date toDate(String rfc822DateString)
converts a RFC822 date string into a date object

Parameters:
rfc822DateString - the rfc822 string
Returns:
the date object

toFormatedDuration

public static String toFormatedDuration(long duration)
converts the given duration in a textual representation

Parameters:
duration - the duration to convert
Returns:
the formated String representation of the duration

toByteBuffer

public static ByteBuffer toByteBuffer(String s,
                                      String encoding)
converts the given String into a ByteBuffer

Parameters:
s - the String to convert
encoding - the encoding to use
Returns:
the String as ByteBuffer

toString

public static String toString(ByteBuffer buffer)
                       throws UnsupportedEncodingException
converts the given ByteBuffer into String by using UTF-8 encoding

Parameters:
buffer - the ByteBuffer to convert
Returns:
the ByteByuffer as String
Throws:
UnsupportedEncodingException

toString

public static String toString(ByteBuffer[] buffer)
                       throws UnsupportedEncodingException
converts the given ByteBuffer array into String by using UTF-8 encoding

Parameters:
buffer - the ByteBuffer arrayto convert
Returns:
the ByteByuffer as String
Throws:
UnsupportedEncodingException

toString

public static String toString(ByteBuffer buffer,
                              String encoding)
                       throws UnsupportedEncodingException
converts the given ByteBuffer into String repesentation

Parameters:
buffer - the ByteBuffer to convert
encoding - the encoding to use
Returns:
the ByteByuffer as String
Throws:
UnsupportedEncodingException

toHexString

public static String toHexString(ByteBuffer buffer)
converts the given ByteBuffer into a hex string

Parameters:
buffer - the ByteBuffer to convert
Returns:
the hex string

toString

public static String toString(List<ByteBuffer> buffers)
                       throws UnsupportedEncodingException
converts the given list of ByteBuffers into a String by using UTF-8 encoding

Parameters:
buffers - the list of ByteBuffer to convert
Returns:
the ByteByuffer as String
Throws:
UnsupportedEncodingException

toString

public static String toString(List<ByteBuffer> buffers,
                              String encoding)
                       throws UnsupportedEncodingException
converts the given list of ByteBuffers into a String

Parameters:
buffers - the list of ByteBuffer to convert
encoding - the encoding to use
Returns:
the ByteByuffer as String
Throws:
UnsupportedEncodingException

toString

public static String toString(ByteBuffer[] buffers,
                              String encoding)
                       throws UnsupportedEncodingException
converts the given array of ByteBuffers into String

Parameters:
buffers - the array of ByteBuffer to convert
encoding - the encoding to use
Returns:
the ByteByuffer as String
Throws:
UnsupportedEncodingException

toString

public static String toString(ByteBuffer[] buffers,
                              String encoding,
                              int maxOutSize)
                       throws UnsupportedEncodingException
print the bytebuffer as limited string

Parameters:
buffers - the buffers to print
encoding - the encoding to use
maxOutSize - the max size to print
Returns:
the ByteBuffers as string representation
Throws:
UnsupportedEncodingException

toByteBuffer

public static ByteBuffer toByteBuffer(ByteBuffer[] buffers)
merges a ByteBuffer array into a (direct) ByteBuffer

Parameters:
buffers - the ByteBuffer array to merge
Returns:
the single ByteBuffer

toByteBuffer

public static ByteBuffer toByteBuffer(byte b)
converts a single byte to a byte buffer

Parameters:
b - the byte
Returns:
the ByteBuffer which contains the single byte

toByteBuffer

public static ByteBuffer toByteBuffer(byte[] bytes)
converts a byte array to a byte buffer

Parameters:
bytes - the byte array
Returns:
the ByteBuffer which contains the bytes

toByteBuffer

public static ByteBuffer toByteBuffer(byte[] bytes,
                                      int offset,
                                      int length)
converts a byte array to a byte buffer

Parameters:
bytes - the bytes
offset - the offset
length - the length
Returns:
the ByteBuffer which contains the single byte

toByteBuffer

public static ByteBuffer toByteBuffer(double d)
converts a double to a byte buffer

Parameters:
d - the double
Returns:
the ByteBuffer which contains the double

toByteBuffer

public static ByteBuffer toByteBuffer(long l)
converts a long to a byte buffer

Parameters:
l - the long
Returns:
the ByteBuffer which contains the long

toByteBuffer

public static ByteBuffer toByteBuffer(short s)
converts a short to a byte buffer

Parameters:
s - the short
Returns:
the ByteBuffer which contains the short

toByteBuffer

public static ByteBuffer toByteBuffer(int i)
converts a integer to a byte buffer

Parameters:
i - the int
Returns:
the ByteBuffer which contains the int

toByteBuffers

public static ByteBuffer[] toByteBuffers(ByteBuffer[] srcs,
                                         int offset,
                                         int length)
copies a array of ByteBuffer based on offset length to a byte buffer array

Parameters:
srcs - the buffers
offset - the offset
length - the length
Returns:
the ByteBuffer

toBytes

public static byte[] toBytes(List<ByteBuffer> buffers)
converts a list of ByteBuffer to a byte array

Parameters:
buffers - the ByteBuffer list to convert
Returns:
the byte array

toBytes

public static byte[] toBytes(ByteBuffer[] buffers)
converts a ByteBuffer array to a byte array

Parameters:
buffers - the ByteBuffer array to convert
Returns:
the byte array

toBytes

public static byte[] toBytes(ByteBuffer buffer)
converts a ByteBuffer into a byte array

Parameters:
buffer - the ByteBuffer to convert
Returns:
the byte array

toHexString

public static String toHexString(byte[] buffers,
                                 int maxOutSize)
print the byte array as a hex string

Parameters:
buffers - the buffers to print
maxOutSize - the max size to print
Returns:
the ByteBuffers as hex representation

toHexString

public static String toHexString(List<ByteBuffer> buffers,
                                 int maxOutSize)
print the byte buffer as a hex string

Parameters:
buffers - the buffers to print
maxOutSize - the max size to print
Returns:
the ByteBuffers as hex representation

toHexString

public static String toHexString(ByteBuffer[] buffers,
                                 int maxOutSize)
print the byte buffer as a hex string

Parameters:
buffers - the buffers to print
maxOutSize - the max size to print
Returns:
the ByteBuffers as hex representation

toTextOrHexString

public static String toTextOrHexString(ByteBuffer buffer,
                                       String encoding,
                                       int maxOutSize)
convert the ByteBuffer into a hex or text string (deping on content)

Parameters:
buffer - the buffers to print
maxOutSize - the max size to print
encoding - the encoding to use
Returns:
the converted ByteBuffer

toTextOrHexString

public static String toTextOrHexString(ByteBuffer[] buffers,
                                       String encoding,
                                       int maxOutSize)
convert the ByteBuffer array into a hex or text string (deping on content)

Parameters:
buffers - the buffers to print
maxOutSize - the max size to print
encoding - the encoding to use
Returns:
the converted ByteBuffer

toTextAndHexString

public static String toTextAndHexString(ByteBuffer[] buffers,
                                        String encoding,
                                        int maxOutSize)

toString

public static String toString(Throwable t)


Copyright 2008 xSocket.org