org.simantics.databoard.util.binary
Class UTF8

java.lang.Object
  extended by org.simantics.databoard.util.binary.UTF8

public class UTF8
extends java.lang.Object

Utils for handling Standard-UTF8 and Modified-UTF8 Strings.

The differences between standard UTF8 and Modified are the following:


Field Summary
static java.nio.charset.Charset CHARSET
           
 
Constructor Summary
UTF8()
           
 
Method Summary
static int getModifiedUTF8EncodingByteLength(java.lang.String str)
          Get the number of bytes in an Modified-UTF-8 encoding of a string
static int getUTF8EncodingByteLength(java.lang.String string)
          Get the number of bytes in an UTF-8 encoding of a string
static java.lang.String readModifiedUTF(java.io.DataInput in, int utflen)
          Read Modified-UTF8 from a stream
static java.lang.String readUTF(java.io.DataInput in, int len)
          Read Standard-UTF8 from a stream
static void writeModifiedUTF(java.io.DataOutput out, java.lang.String str)
          Write Modified-UTF8 to a stream.
static void writeUTF(java.io.DataOutput out, java.lang.String str)
          Write Standard-UTF8 to a stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHARSET

public static final java.nio.charset.Charset CHARSET
Constructor Detail

UTF8

public UTF8()
Method Detail

getUTF8EncodingByteLength

public static int getUTF8EncodingByteLength(java.lang.String string)
Get the number of bytes in an UTF-8 encoding of a string

Parameters:
string -
Returns:
byte length

getModifiedUTF8EncodingByteLength

public static int getModifiedUTF8EncodingByteLength(java.lang.String str)
Get the number of bytes in an Modified-UTF-8 encoding of a string

Parameters:
str -
Returns:
byte length

writeModifiedUTF

public static void writeModifiedUTF(java.io.DataOutput out,
                                    java.lang.String str)
                             throws java.io.IOException
Write Modified-UTF8 to a stream.

Parameters:
out - output stream
str - string
Throws:
java.io.IOException

readModifiedUTF

public static java.lang.String readModifiedUTF(java.io.DataInput in,
                                               int utflen)
                                        throws java.io.IOException,
                                               java.io.UTFDataFormatException
Read Modified-UTF8 from a stream

Parameters:
in - input
utflen - number of bytes
Returns:
string
Throws:
java.io.IOException
java.io.UTFDataFormatException

writeUTF

public static void writeUTF(java.io.DataOutput out,
                            java.lang.String str)
                     throws java.io.IOException
Write Standard-UTF8 to a stream.

Parameters:
str -
out -
Throws:
java.io.IOException

readUTF

public static java.lang.String readUTF(java.io.DataInput in,
                                       int len)
                                throws java.io.IOException
Read Standard-UTF8 from a stream

Parameters:
in - input
len - number of bytes
Returns:
string
Throws:
java.io.IOException