com.myJava.util
Class Util

java.lang.Object
  extended by com.myJava.util.Util

public abstract class Util
extends java.lang.Object


Constructor Summary
Util()
           
 
Method Summary
static java.lang.String adjustSize(java.lang.String s, int size, char completion, boolean dockRight)
          Adjust the String's size to the requested size.
static byte[] base16Decode(java.lang.String input)
          Decode the base 16 representation passed as argument and return the corresponding byte[]
static java.lang.String base16Encode(byte[] data)
          Return a base 16 String representation of the byte[] passed as argument
static byte[] base64Decode(java.lang.String data)
          Decode the base 64 representation passed as argument and return the corresponding byte[]
static java.lang.String base64Encode(byte[] data)
          Return a base 64 String representation of the byte[] passed as argument
static java.lang.Short buildOptimizedShort(short s)
           
static int count(java.lang.String chaine, int startIndex, char c)
           
static int count(java.lang.String chaine, java.lang.String str)
           
static java.lang.String duplicate(java.lang.String s, int nb)
          Duplicates the first argument
static java.lang.String getClassName(java.lang.String path)
          Extract the classe's short name
static java.lang.String getContentList(java.util.Hashtable values)
          Return the keys of the HashTable as a single String.
static java.lang.String getContentList(java.util.Hashtable values, java.lang.String separator)
          Return the keys of the HashTable as a single String.
static double getRnd()
          Compute a random double between -1 and 1
static long getRndLong()
          Compute a random long
static java.lang.String gLTrim(java.lang.String str, char c)
          Generic left trim
static void logStreamContent(java.io.InputStream is)
          Write the whole content of a Stream
static void logThreadInformations()
           
static void logThreadInformations(java.lang.String header)
           
static java.io.File normalizeIfNotExists(java.io.File file, java.lang.String acceptedChars, char replacementChar)
          Call "normalizeString" on each non existing part of the file's path.
static java.lang.String normalizeString(java.lang.String s, java.lang.String acceptedChars, char replacementChar)
          Normalize the String passed as argument.
static boolean passFilter(java.lang.String s, java.lang.String[] filter)
          Return true if s equals one of the Strings contained in the "filter" array or if they start with one of them plus "/"
static int readLine(java.io.InputStream is, byte[] buff)
          Read the stream until a CRLF (13-10) is reached OR the buffer's limit is reached.
static byte[] readLineBA(java.io.InputStream is, int size)
          Read the stream until a CRLF (13-10) is reached OR the buffer's limit is reached.
static java.lang.String readLineString(java.io.InputStream is)
          Read the stream until a CRLF (13-10)
static java.lang.String replace(java.lang.String initialString, java.lang.String toReplace, java.lang.String replacement)
          Replace all occurences of "toReplace" in "initialString" by "replacement"
static java.util.Vector split(java.lang.String orig, java.lang.String pattern)
          Split a String in an array of Strings
static java.lang.String subString(java.lang.String orig, java.lang.String balise1, int offset, java.lang.String balise2)
          Return the String between the second and fourth arguments
static java.lang.String trimSlashes(java.lang.String orig)
          Remove all '/' in the beginning of the file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

buildOptimizedShort

public static java.lang.Short buildOptimizedShort(short s)

replace

public static java.lang.String replace(java.lang.String initialString,
                                       java.lang.String toReplace,
                                       java.lang.String replacement)
Replace all occurences of "toReplace" in "initialString" by "replacement"


count

public static int count(java.lang.String chaine,
                        java.lang.String str)

count

public static int count(java.lang.String chaine,
                        int startIndex,
                        char c)

logThreadInformations

public static void logThreadInformations()

logThreadInformations

public static void logThreadInformations(java.lang.String header)

getRnd

public static double getRnd()
Compute a random double between -1 and 1


getRndLong

public static long getRndLong()
Compute a random long


base64Encode

public static java.lang.String base64Encode(byte[] data)
Return a base 64 String representation of the byte[] passed as argument


base64Decode

public static byte[] base64Decode(java.lang.String data)
Decode the base 64 representation passed as argument and return the corresponding byte[]


base16Encode

public static java.lang.String base16Encode(byte[] data)
Return a base 16 String representation of the byte[] passed as argument


base16Decode

public static byte[] base16Decode(java.lang.String input)
Decode the base 16 representation passed as argument and return the corresponding byte[]


subString

public static java.lang.String subString(java.lang.String orig,
                                         java.lang.String balise1,
                                         int offset,
                                         java.lang.String balise2)
Return the String between the second and fourth arguments


split

public static java.util.Vector split(java.lang.String orig,
                                     java.lang.String pattern)
Split a String in an array of Strings


gLTrim

public static java.lang.String gLTrim(java.lang.String str,
                                      char c)
Generic left trim


getClassName

public static java.lang.String getClassName(java.lang.String path)
Extract the classe's short name


logStreamContent

public static void logStreamContent(java.io.InputStream is)
Write the whole content of a Stream


getContentList

public static java.lang.String getContentList(java.util.Hashtable values,
                                              java.lang.String separator)
Return the keys of the HashTable as a single String.
The separator passed as argument is used.
For instance, [1=toto 2=tutu 6=titi 9=tata] will give "1,2,6,9" if the separator is ",".


getContentList

public static java.lang.String getContentList(java.util.Hashtable values)
Return the keys of the HashTable as a single String.
Same as getContentList(values, ",")


adjustSize

public static java.lang.String adjustSize(java.lang.String s,
                                          int size,
                                          char completion,
                                          boolean dockRight)
Adjust the String's size to the requested size.
- If the size of the first argument is inferior to the second argument, the third argument is added until it reaches the requested size
- If the size of the first argument is superior to the second argument, it is truncated.

The fourth argument tells whether it is the left or right part of the first argument which is kept.


duplicate

public static java.lang.String duplicate(java.lang.String s,
                                         int nb)
Duplicates the first argument


normalizeString

public static java.lang.String normalizeString(java.lang.String s,
                                               java.lang.String acceptedChars,
                                               char replacementChar)
Normalize the String passed as argument.
All chars which are not in the second argument are replaced by the third argument.


trimSlashes

public static java.lang.String trimSlashes(java.lang.String orig)
Remove all '/' in the beginning of the file


passFilter

public static boolean passFilter(java.lang.String s,
                                 java.lang.String[] filter)
Return true if s equals one of the Strings contained in the "filter" array or if they start with one of them plus "/"


normalizeIfNotExists

public static java.io.File normalizeIfNotExists(java.io.File file,
                                                java.lang.String acceptedChars,
                                                char replacementChar)
Call "normalizeString" on each non existing part of the file's path.
Keep the existing parts unchenged.


readLine

public static int readLine(java.io.InputStream is,
                           byte[] buff)
                    throws java.io.IOException
Read the stream until a CRLF (13-10) is reached OR the buffer's limit is reached.
The actual number of bytes read (or -1 if the end of stream has been reached) is returned.

Throws:
java.io.IOException

readLineBA

public static byte[] readLineBA(java.io.InputStream is,
                                int size)
                         throws java.io.IOException
Read the stream until a CRLF (13-10) is reached OR the buffer's limit is reached.
The actual number of bytes read (or -1 if the end of stream has been reached) is returned.

Throws:
java.io.IOException

readLineString

public static java.lang.String readLineString(java.io.InputStream is)
                                       throws java.io.IOException
Read the stream until a CRLF (13-10)

Throws:
java.io.IOException