org.xsocket
Class DataConverter

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

public final class DataConverter
extends java.lang.Object

a data converter utilities class


Constructor Summary
DataConverter()
           
 
Method Summary
static java.nio.ByteBuffer toByteBuffer(java.nio.ByteBuffer[] buffers)
          merges a ByteBuffer array into a (direct) ByteBuffer
static java.nio.ByteBuffer toByteBuffer(java.lang.String s, java.lang.String encoding)
          converts the given String into a ByteBuffer
static byte[] toBytes(java.nio.ByteBuffer buffer)
          converts a ByteBuffer into a byte array
static byte[] toBytes(java.nio.ByteBuffer[] buffers)
          converts a ByteBuffer array to a byte array
static byte[] toBytes(java.util.List<java.nio.ByteBuffer> buffers)
          converts a list of ByteBuffer to a byte array
static java.lang.String toByteString(java.nio.ByteBuffer buffer)
          converts the given ByteBuffer into a hex string
static java.lang.String toFormatedBytesSize(long bytes)
          converts the given byte size in a textual representation
static java.lang.String toFormatedDate(long time)
          converts the given time in a textual representation
static java.lang.String toFormatedDuration(long duration)
          converts the given duration in a textual representation
static java.lang.String toHexString(byte[] buffers, int maxOutSize)
          print the byte array as a hex string
static java.lang.String toHexString(java.nio.ByteBuffer[] buffers, int maxOutSize)
          print the bytebuffer as a hex string
static java.lang.String toString(java.nio.ByteBuffer buffer)
          converts the given ByteBuffer into String by using UTF-8 encoding
static java.lang.String toString(java.nio.ByteBuffer[] buffer)
          converts the given ByteBuffer array into String by using UTF-8 encoding
static java.lang.String toString(java.nio.ByteBuffer[] buffers, java.lang.String encoding)
          converts the given array of ByteBuffers into String
static java.lang.String toString(java.nio.ByteBuffer[] buffers, java.lang.String encoding, int maxOutSize)
          print the bytebuffer as limited string
static java.lang.String toString(java.nio.ByteBuffer buffer, java.lang.String encoding)
          converts the given ByteBuffer into String repesentation
static java.lang.String toString(java.util.List<java.nio.ByteBuffer> buffers, java.lang.String encoding)
          converts the given list of ByteBuffers into a String
static java.lang.String toTextAndHexString(java.nio.ByteBuffer[] buffers, java.lang.String encoding, int maxOutSize)
           
static java.lang.String toTextOrHexString(java.nio.ByteBuffer[] buffers, java.lang.String encoding, int maxOutSize)
          convert the ByteBuffer array into a hex or text string (deping on content)
static java.lang.String toTextOrHexString(java.nio.ByteBuffer buffer, java.lang.String encoding, int maxOutSize)
          convert the ByteBuffer into a hex or text string (deping on content)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataConverter

public DataConverter()
Method Detail

toFormatedBytesSize

public static java.lang.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 java.lang.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

toFormatedDuration

public static java.lang.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 java.nio.ByteBuffer toByteBuffer(java.lang.String s,
                                               java.lang.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 java.lang.String toString(java.nio.ByteBuffer buffer)
                                 throws java.io.UnsupportedEncodingException
converts the given ByteBuffer into String by using UTF-8 encoding

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

toString

public static java.lang.String toString(java.nio.ByteBuffer[] buffer)
                                 throws java.io.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:
java.io.UnsupportedEncodingException

toString

public static java.lang.String toString(java.nio.ByteBuffer buffer,
                                        java.lang.String encoding)
                                 throws java.io.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:
java.io.UnsupportedEncodingException

toByteString

public static java.lang.String toByteString(java.nio.ByteBuffer buffer)
converts the given ByteBuffer into a hex string

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

toString

public static java.lang.String toString(java.util.List<java.nio.ByteBuffer> buffers,
                                        java.lang.String encoding)
                                 throws java.io.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:
java.io.UnsupportedEncodingException

toString

public static java.lang.String toString(java.nio.ByteBuffer[] buffers,
                                        java.lang.String encoding)
                                 throws java.io.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:
java.io.UnsupportedEncodingException

toString

public static java.lang.String toString(java.nio.ByteBuffer[] buffers,
                                        java.lang.String encoding,
                                        int maxOutSize)
                                 throws java.io.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:
java.io.UnsupportedEncodingException

toByteBuffer

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

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

toBytes

public static byte[] toBytes(java.util.List<java.nio.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(java.nio.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(java.nio.ByteBuffer buffer)
converts a ByteBuffer into a byte array

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

toHexString

public static java.lang.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 java.lang.String toHexString(java.nio.ByteBuffer[] buffers,
                                           int maxOutSize)
print the bytebuffer 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 java.lang.String toTextOrHexString(java.nio.ByteBuffer buffer,
                                                 java.lang.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 java.lang.String toTextOrHexString(java.nio.ByteBuffer[] buffers,
                                                 java.lang.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 java.lang.String toTextAndHexString(java.nio.ByteBuffer[] buffers,
                                                  java.lang.String encoding,
                                                  int maxOutSize)