org.ungoverned.osgi.bundle.httpadmin.util
Class Text

java.lang.Object
  extended byorg.ungoverned.osgi.bundle.httpadmin.util.Text

public class Text
extends java.lang.Object

A simple utility class - helper for strings


Constructor Summary
Text()
           
 
Method Summary
static java.lang.String hexString(byte value)
          Creates hex string from byte value.
static java.lang.String hexString(int value)
          Creates hex string from int value.
static java.lang.String hexString(int value, int length)
          Hex string with the given mininum length.
static boolean isEmptyString(java.lang.String s)
          Checks if string is empty - either null or ""
static byte[] readResource(java.lang.Object obj, java.lang.String file)
          Simple file reader with non-blocking io.
static java.lang.String readTextResource(java.lang.Object obj, java.lang.String file)
          Simple file reader with non-blocking io.
static java.lang.String replaceString(java.lang.String source, java.lang.String find, java.lang.String replace)
          This static method is simple search and replace engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Text

public Text()
Method Detail

hexString

public static java.lang.String hexString(byte value)
Creates hex string from byte value. The result string is 2 chars long String.

Parameters:
value - byte to convert to hex string
Returns:
hex string

hexString

public static java.lang.String hexString(int value)
Creates hex string from int value. The result string is 4 chars long String.

Parameters:
value - int to convert to hex string
Returns:
hex string

hexString

public static java.lang.String hexString(int value,
                                         int length)
Hex string with the given mininum length. If needed, '0'(s) are add in front.

Parameters:
value - int to convert to hex string
length - the minimum length of returned string.
Returns:
hex string

replaceString

public static java.lang.String replaceString(java.lang.String source,
                                             java.lang.String find,
                                             java.lang.String replace)
This static method is simple search and replace engine. If looks for a certain string in source string and replaces it with another.

Parameters:
source - is the source string
find - is the search string to be replaced.
replace - is replaces string.

readResource

public static byte[] readResource(java.lang.Object obj,
                                  java.lang.String file)
Simple file reader with non-blocking io. This can be used without any troubles with jdk 1.1. It reads file bytes from (jar) file as resource. NOTE: do not use this method with non-text files.

Parameters:
obj - ANY object that can be used for base. template name is relative to that object. (see getResourceAsStream)
file - name of resource file.
Returns:
byte[] contents of resource

readTextResource

public static java.lang.String readTextResource(java.lang.Object obj,
                                                java.lang.String file)
Simple file reader with non-blocking io. This can be used without any troubles with jdk 1.1. It reads file bytes from (jar) file as resource. NOTE: do not use this method with non-text files.

Parameters:
obj - ANY object that can be used for base. template name is relative to that object. (see getResourceAsStream)
file - name of resource file.
Returns:
String with contents of file.

isEmptyString

public static boolean isEmptyString(java.lang.String s)
Checks if string is empty - either null or ""

Returns:
true if the string is null or ""