org.kuali.common.util
Class Str

java.lang.Object
  extended by org.kuali.common.util.Str

public class Str
extends Object

Operations on String that are null safe


Field Summary
static String CDATA_PREFIX
           
static String CDATA_SUFFIX
           
static String COMMA
           
static String CR
           
static String DOT
           
static char DOUBLE_QUOTE
           
static String EMPTY_STRING
           
static String FORWARD_SLASH
           
static String LF
           
static String SPACE
           
static String UTF8
           
 
Constructor Summary
Str()
           
 
Method Summary
static String cdata(String s)
          Turn the string into CDATA - http://en.wikipedia.org/wiki/CDATA
static boolean contains(List<String> tokens, String value, boolean caseSensitive)
           
static boolean equals(String s1, String s2, boolean caseSensitive)
           
static String flatten(String s)
          Replace carriage returns and linefeeds with a space
static String flatten(String s, String cr, String lf)
          Replace carriage returns with cr and linefeeds with lf.
static byte[] getBytes(String s, String encoding)
           
static String getPath(String s)
          Convert dots to forward slashes and trim.
static String getString(byte[] bytes, String encoding)
           
static byte[] getUTF8Bytes(String s)
           
static String quote(String s)
          Surround the string with double quotes.
static String removeSuffix(String s, String suffix)
          If s ends with suffix, remove it
static String[] split(String s, String separatorChars, boolean trim)
          Split the string into tokens using the indicated separator chars, optionally trimming the tokens.
static String[] splitAndTrim(String s, String separatorChars)
          Split the string into tokens using the indicated separator, trimming as we go.
static String[] splitAndTrimCSV(String csv)
          Split comma separated values into tokens, trimming as we go.
static String[] splitCSV(String csv, boolean trim)
          Split comma separated values into tokens, optionally trimming the tokens.
static String toEmpty(String s)
          If s is null return "" otherwise return s
static String toString(String[] tokens)
          Combine tokens into a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STRING

public static final String EMPTY_STRING
See Also:
Constant Field Values

UTF8

public static final String UTF8
See Also:
Constant Field Values

COMMA

public static final String COMMA
See Also:
Constant Field Values

SPACE

public static final String SPACE
See Also:
Constant Field Values

CR

public static final String CR
See Also:
Constant Field Values

LF

public static final String LF
See Also:
Constant Field Values

DOT

public static final String DOT
See Also:
Constant Field Values

FORWARD_SLASH

public static final String FORWARD_SLASH
See Also:
Constant Field Values

DOUBLE_QUOTE

public static final char DOUBLE_QUOTE
See Also:
Constant Field Values

CDATA_PREFIX

public static final String CDATA_PREFIX
See Also:
Constant Field Values

CDATA_SUFFIX

public static final String CDATA_SUFFIX
See Also:
Constant Field Values
Constructor Detail

Str

public Str()
Method Detail

cdata

public static final String cdata(String s)
Turn the string into CDATA - http://en.wikipedia.org/wiki/CDATA


removeSuffix

public static final String removeSuffix(String s,
                                        String suffix)
If s ends with suffix, remove it


toEmpty

public static final String toEmpty(String s)
If s is null return "" otherwise return s


getString

public static final String getString(byte[] bytes,
                                     String encoding)

getUTF8Bytes

public static final byte[] getUTF8Bytes(String s)

getBytes

public static final byte[] getBytes(String s,
                                    String encoding)

contains

public static final boolean contains(List<String> tokens,
                                     String value,
                                     boolean caseSensitive)

equals

public static final boolean equals(String s1,
                                   String s2,
                                   boolean caseSensitive)

toString

public static final String toString(String[] tokens)
Combine tokens into a String


getPath

public static final String getPath(String s)
Convert dots to forward slashes and trim.


quote

public static final String quote(String s)
Surround the string with double quotes.


splitCSV

public static final String[] splitCSV(String csv,
                                      boolean trim)
Split comma separated values into tokens, optionally trimming the tokens.


splitAndTrimCSV

public static final String[] splitAndTrimCSV(String csv)
Split comma separated values into tokens, trimming as we go.


splitAndTrim

public static final String[] splitAndTrim(String s,
                                          String separatorChars)
Split the string into tokens using the indicated separator, trimming as we go.


split

public static final String[] split(String s,
                                   String separatorChars,
                                   boolean trim)
Split the string into tokens using the indicated separator chars, optionally trimming the tokens.


flatten

public static final String flatten(String s)
Replace carriage returns and linefeeds with a space


flatten

public static final String flatten(String s,
                                   String cr,
                                   String lf)
Replace carriage returns with cr and linefeeds with lf.



Copyright © 2010-2013 The Kuali Foundation. All Rights Reserved.