com.greenpineyu.fel.common
类 StringUtils

java.lang.Object
  继承者 com.greenpineyu.fel.common.StringUtils

public class StringUtils
extends Object


字段摘要
static int INDEX_NOT_FOUND
          Represents a failed index search.
 
构造方法摘要
StringUtils()
           
 
方法摘要
static boolean equals(CharSequence cs1, CharSequence cs2)
          Compares two CharSequences, returning true if they are equal.
static boolean isEmpty(CharSequence cs)
           
static boolean isNotEmpty(CharSequence cs)
          Checks if a CharSequence is not empty ("") and not null.
static String remove(String str, char remove)
          Removes all occurrences of a character from within the source string.
static String replace(String text, String searchString, String replacement)
          Replaces all occurrences of a String within another String.
static String replace(String text, String searchString, String replacement, int max)
          Replaces a String with another String inside a larger String, for the first max values of the search String.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

INDEX_NOT_FOUND

public static final int INDEX_NOT_FOUND
Represents a failed index search.

从以下版本开始:
2.1
另请参见:
常量字段值
构造方法详细信息

StringUtils

public StringUtils()
方法详细信息

isEmpty

public static boolean isEmpty(CharSequence cs)

isNotEmpty

public static boolean isNotEmpty(CharSequence cs)

Checks if a CharSequence is not empty ("") and not null.

 StringUtils.isNotEmpty(null)      = false
 StringUtils.isNotEmpty("")        = false
 StringUtils.isNotEmpty(" ")       = true
 StringUtils.isNotEmpty("bob")     = true
 StringUtils.isNotEmpty("  bob  ") = true
 

参数:
cs - the CharSequence to check, may be null
返回:
true if the CharSequence is not empty and not null
从以下版本开始:
3.0 Changed signature from isNotEmpty(String) to isNotEmpty(CharSequence)

replace

public static String replace(String text,
                             String searchString,
                             String replacement)

Replaces all occurrences of a String within another String.

A null reference passed to this method is a no-op.

 StringUtils.replace(null, *, *)        = null
 StringUtils.replace("", *, *)          = ""
 StringUtils.replace("any", null, *)    = "any"
 StringUtils.replace("any", *, null)    = "any"
 StringUtils.replace("any", "", *)      = "any"
 StringUtils.replace("aba", "a", null)  = "aba"
 StringUtils.replace("aba", "a", "")    = "b"
 StringUtils.replace("aba", "a", "z")   = "zbz"
 

参数:
text - text to search and replace in, may be null
searchString - the String to search for, may be null
replacement - the String to replace it with, may be null
返回:
the text with any replacements processed, null if null String input
另请参见:
replace(String text, String searchString, String replacement, int max)

replace

public static String replace(String text,
                             String searchString,
                             String replacement,
                             int max)

Replaces a String with another String inside a larger String, for the first max values of the search String.

A null reference passed to this method is a no-op.

 StringUtils.replace(null, *, *, *)         = null
 StringUtils.replace("", *, *, *)           = ""
 StringUtils.replace("any", null, *, *)     = "any"
 StringUtils.replace("any", *, null, *)     = "any"
 StringUtils.replace("any", "", *, *)       = "any"
 StringUtils.replace("any", *, *, 0)        = "any"
 StringUtils.replace("abaa", "a", null, -1) = "abaa"
 StringUtils.replace("abaa", "a", "", -1)   = "b"
 StringUtils.replace("abaa", "a", "z", 0)   = "abaa"
 StringUtils.replace("abaa", "a", "z", 1)   = "zbaa"
 StringUtils.replace("abaa", "a", "z", 2)   = "zbza"
 StringUtils.replace("abaa", "a", "z", -1)  = "zbzz"
 

参数:
text - text to search and replace in, may be null
searchString - the String to search for, may be null
replacement - the String to replace it with, may be null
max - maximum number of values to replace, or -1 if no maximum
返回:
the text with any replacements processed, null if null String input

remove

public static String remove(String str,
                            char remove)

Removes all occurrences of a character from within the source string.

A null source string will return null. An empty ("") source string will return the empty string.

 StringUtils.remove(null, *)       = null
 StringUtils.remove("", *)         = ""
 StringUtils.remove("queued", 'u') = "qeed"
 StringUtils.remove("queued", 'z') = "queued"
 

参数:
str - the source String to search, may be null
remove - the char to search for and remove, may be null
返回:
the substring with the char removed if found, null if null String input
从以下版本开始:
2.1

equals

public static boolean equals(CharSequence cs1,
                             CharSequence cs2)

Compares two CharSequences, returning true if they are equal.

nulls are handled without exceptions. Two null references are considered to be equal. The comparison is case sensitive.

 StringUtils.equals(null, null)   = true
 StringUtils.equals(null, "abc")  = false
 StringUtils.equals("abc", null)  = false
 StringUtils.equals("abc", "abc") = true
 StringUtils.equals("abc", "ABC") = false
 

参数:
cs1 - the first CharSequence, may be null
cs2 - the second CharSequence, may be null
返回:
true if the CharSequences are equal, case sensitive, or both null
从以下版本开始:
3.0 Changed signature from equals(String, String) to equals(CharSequence, CharSequence)
另请参见:
String.equals(Object)


Copyright © 2013. All Rights Reserved.