Holger's
Java API

com.antelmann.util
Class Strings

java.lang.Object
  extended by com.antelmann.util.Strings

public final class Strings
extends Object

A utility class with some useful functions to manipulate String objects.

Author:
Holger Antelmann

Field Summary
static String COPYRIGHT
          represents the symbol for use in HTML or XML
static String EURO
          represents the Euro currency symbol
static String fs
          convenient access to the platform dependent file separator
static String lb
          convenient access to the platform dependent line separator
static String LEFT_DOUBLE_QUOTE
          represents the symbol for use in HTML or XML
static String REGISTERED_TM
          represents the symbol for use in HTML or XML
static String RIGHT_DOUBLE_QUOTE
          represents the symbol for use in HTML or XML
static String TRADEMARK
          represents the symbol for use in HTML or XML
static String XML_HEADER
          xml header line with utf8
 
Method Summary
static String asPercent(double d)
           
static boolean containsIgnoreCase(String text, String pattern)
          returns indexOfIgnoreCase(text, pattern) >= 0
static int count(String text, String pattern)
          counts how many times the given pattern occurs in the given text.
static int countIgnoreCase(String text, String pattern)
          counts how many times the given pattern occurs in the given text.
static String decode64(String s)
          decodes the given String using Base64 assuming ASCII character set
static String decodeURL(String s)
          uses URLEncoder using UTF8
static String decodeXML(String text)
          decodes an HTML or XML text sequence into human readable form using the translateArray
static String encode64(String s)
          encodes the given String using Base64 with ASCII
static String encodeURL(String s)
          uses URLEncoder using UTF8
static String encodeXML(String text)
          encodes a text string to use as text in an HTML or XML document using the translateArray
static String hash(String s)
          returns a human readable digest of the given string based on MD5 and ASCII encoding
static String hexString(byte... bytes)
           
static byte[] hexToBytes(String s)
           
static int indexOfIgnoreCase(String textToSearch, String pattern)
          calls the method with the same name adding index 0
static int indexOfIgnoreCase(String textToSearch, String pattern, int fromIndex)
           
static String mapAsString(Map map)
           
static String mapAsString(Map map, String fieldSeparator, String lineSeparator)
           
static String replaceAll(String original, String oldSubString, String newSubString)
          Deprecated. as of Java version 1.5
static String replaceAllIgnoreCase(String original, String oldSubString, String newSubString)
          replaces every occurrence of oldSubString (ignoring case) with newSubString within the original String and returns the resulting string (no regular expressions are used)
static boolean same(String s1, String s2)
          returns true only if the the both strings are equal or null, false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lb

public static final String lb
convenient access to the platform dependent line separator


fs

public static final String fs
convenient access to the platform dependent file separator


EURO

public static final String EURO
represents the Euro currency symbol

See Also:
Constant Field Values

XML_HEADER

public static final String XML_HEADER
xml header line with utf8

See Also:
Constant Field Values

LEFT_DOUBLE_QUOTE

public static final String LEFT_DOUBLE_QUOTE
represents the symbol for use in HTML or XML

See Also:
Constant Field Values

RIGHT_DOUBLE_QUOTE

public static final String RIGHT_DOUBLE_QUOTE
represents the symbol for use in HTML or XML

See Also:
Constant Field Values

TRADEMARK

public static final String TRADEMARK
represents the symbol for use in HTML or XML

See Also:
Constant Field Values

REGISTERED_TM

public static final String REGISTERED_TM
represents the symbol for use in HTML or XML

See Also:
Constant Field Values

COPYRIGHT

public static final String COPYRIGHT
represents the symbol for use in HTML or XML

See Also:
Constant Field Values
Method Detail

hash

public static String hash(String s)
returns a human readable digest of the given string based on MD5 and ASCII encoding


replaceAll

@Deprecated
public static String replaceAll(String original,
                                           String oldSubString,
                                           String newSubString)
Deprecated. as of Java version 1.5

replaces every occurrence of oldSubString with newSubString within the original String and returns the resulting string (no regular expressions are used). This method is obsolete since Java version 1.5

See Also:
String.replace(CharSequence, CharSequence)

replaceAllIgnoreCase

public static String replaceAllIgnoreCase(String original,
                                          String oldSubString,
                                          String newSubString)
replaces every occurrence of oldSubString (ignoring case) with newSubString within the original String and returns the resulting string (no regular expressions are used)


indexOfIgnoreCase

public static int indexOfIgnoreCase(String textToSearch,
                                    String pattern)
calls the method with the same name adding index 0


indexOfIgnoreCase

public static int indexOfIgnoreCase(String textToSearch,
                                    String pattern,
                                    int fromIndex)

count

public static int count(String text,
                        String pattern)
counts how many times the given pattern occurs in the given text. Example: count("ababababab", "abab") returns 2.


countIgnoreCase

public static int countIgnoreCase(String text,
                                  String pattern)
counts how many times the given pattern occurs in the given text. Example: count("aBabABabab", "aBAb") returns 2.


containsIgnoreCase

public static boolean containsIgnoreCase(String text,
                                         String pattern)
returns indexOfIgnoreCase(text, pattern) >= 0


encodeXML

public static String encodeXML(String text)
encodes a text string to use as text in an HTML or XML document using the translateArray


decodeXML

public static String decodeXML(String text)
decodes an HTML or XML text sequence into human readable form using the translateArray


encodeURL

public static String encodeURL(String s)
uses URLEncoder using UTF8


decodeURL

public static String decodeURL(String s)
uses URLEncoder using UTF8


mapAsString

public static String mapAsString(Map map)

mapAsString

public static String mapAsString(Map map,
                                 String fieldSeparator,
                                 String lineSeparator)

asPercent

public static String asPercent(double d)

hexString

public static String hexString(byte... bytes)
See Also:
hexToBytes(String)

hexToBytes

public static byte[] hexToBytes(String s)
                         throws NumberFormatException
Throws:
NumberFormatException - if the String cannot be parsed properly
See Also:
hexToBytes(String)

encode64

public static String encode64(String s)
encodes the given String using Base64 with ASCII


decode64

public static String decode64(String s)
                       throws IOException
decodes the given String using Base64 assuming ASCII character set

Throws:
IOException

same

public static boolean same(String s1,
                           String s2)
returns true only if the the both strings are equal or null, false otherwise. This method may be deprecated in the future, as it is really replaced by the more general com.antelmann.util.Misc.same(Object, Object).

See Also:
Misc.same(Object, Object)


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads