org.apache.commons.lang
クラス CharSetUtils

java.lang.Object
  拡張org.apache.commons.lang.CharSetUtils

public class CharSetUtils
extends Object

Operations on CharSets.

This class handles null input gracefully. An exception will not be thrown for a null input. Each method documents its behaviour in more detail.

導入されたバージョン:
1.0
バージョン:
$Id: CharSetUtils.java,v 1.1.1.1 2004/02/13 10:02:05 hioki Exp $
作成者:
Henri Yandell, Stephen Colebourne, Phil Steitz, Gary Gregory
関連項目:
CharSet

コンストラクタの概要
CharSetUtils()
          CharSetUtils instances should NOT be constructed in standard programming.
 
メソッドの概要
static int count(String str, String set)
          Takes an argument in set-syntax, see evaluateSet, and returns the number of characters present in the specified string.
static int count(String str, String[] set)
          Takes an argument in set-syntax, see evaluateSet, and returns the number of characters present in the specified string.
static String delete(String str, String set)
          Takes an argument in set-syntax, see evaluateSet, and deletes any of characters present in the specified string.
static String delete(String str, String[] set)
          Takes an argument in set-syntax, see evaluateSet, and deletes any of characters present in the specified string.
static CharSet evaluateSet(String[] set)
          推奨されていません。 Use CharSet.getInstance(String). Method will be removed in Commons Lang 3.0.
static String keep(String str, String set)
          Takes an argument in set-syntax, see evaluateSet, and keeps any of characters present in the specified string.
static String keep(String str, String[] set)
          Takes an argument in set-syntax, see evaluateSet, and keeps any of characters present in the specified string.
static String squeeze(String str, String set)
          Squeezes any repititions of a character that is mentioned in the supplied set.
static String squeeze(String str, String[] set)
          Squeezes any repititions of a character that is mentioned in the supplied set.
static String translate(String str, String searchChars, String replaceChars)
          推奨されていません。 Use StringUtils.replaceChars(String, String, String). Method will be removed in Commons Lang 3.0.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

CharSetUtils

public CharSetUtils()

CharSetUtils instances should NOT be constructed in standard programming. Instead, the class should be used as CharSetUtils.evaluateSet(null);.

This constructor is public to permit tools that require a JavaBean instance to operate.

メソッドの詳細

evaluateSet

public static CharSet evaluateSet(String[] set)
推奨されていません。 Use CharSet.getInstance(String). Method will be removed in Commons Lang 3.0.

Creates a CharSet instance which allows a certain amount of set logic to be performed.

The syntax is:

 CharSetUtils.evaluateSet(null)    = null
 CharSetUtils.evaluateSet([])      = CharSet matching nothing
 CharSetUtils.evaluateSet(["a-e"]) = CharSet matching a,b,c,d,e
 

パラメータ:
set - the set, may be null
戻り値:
a CharSet instance, null if null input

squeeze

public static String squeeze(String str,
                             String set)

Squeezes any repititions of a character that is mentioned in the supplied set.

 CharSetUtils.squeeze(null, *)        = null
 CharSetUtils.squeeze("", *)          = ""
 CharSetUtils.squeeze(*, null)        = *
 CharSetUtils.squeeze(*, "")          = *
 CharSetUtils.squeeze("hello", "k-p") = "helo"
 CharSetUtils.squeeze("hello", "a-e") = "hello"
 

パラメータ:
str - the string to squeeze, may be null
set - the character set to use for manipulation, may be null
戻り値:
modified String, null if null string input
関連項目:
for set-syntax.

squeeze

public static String squeeze(String str,
                             String[] set)

Squeezes any repititions of a character that is mentioned in the supplied set.

An example is:

パラメータ:
str - the string to squeeze, may be null
set - the character set to use for manipulation, may be null
戻り値:
modified String, null if null string input
関連項目:
for set-syntax.

count

public static int count(String str,
                        String set)

Takes an argument in set-syntax, see evaluateSet, and returns the number of characters present in the specified string.

 CharSetUtils.count(null, *)        = 0
 CharSetUtils.count("", *)          = 0
 CharSetUtils.count(*, null)        = 0
 CharSetUtils.count(*, "")          = 0
 CharSetUtils.count("hello", "k-p") = 3
 CharSetUtils.count("hello", "a-e") = 1
 

パラメータ:
str - String to count characters in, may be null
set - String set of characters to count, may be null
戻り値:
character count, zero if null string input
関連項目:
for set-syntax.

count

public static int count(String str,
                        String[] set)

Takes an argument in set-syntax, see evaluateSet, and returns the number of characters present in the specified string.

An example would be:

パラメータ:
str - String to count characters in, may be null
set - String[] set of characters to count, may be null
戻り値:
character count, zero if null string input
関連項目:
for set-syntax.

keep

public static String keep(String str,
                          String set)

Takes an argument in set-syntax, see evaluateSet, and keeps any of characters present in the specified string.

 CharSetUtils.keep(null, *)        = null
 CharSetUtils.keep("", *)          = ""
 CharSetUtils.keep(*, null)        = ""
 CharSetUtils.keep(*, "")          = ""
 CharSetUtils.keep("hello", "hl") = "hll"
 CharSetUtils.keep("hello", "le") = "ell"
 

パラメータ:
str - String to keep characters from, may be null
set - String set of characters to keep, may be null
戻り値:
modified String, null if null string input
導入されたバージョン:
2.0
関連項目:
for set-syntax.

keep

public static String keep(String str,
                          String[] set)

Takes an argument in set-syntax, see evaluateSet, and keeps any of characters present in the specified string.

An example would be:

パラメータ:
str - String to keep characters from, may be null
set - String[] set of characters to keep, may be null
戻り値:
modified String, null if null string input
導入されたバージョン:
2.0
関連項目:
for set-syntax.

delete

public static String delete(String str,
                            String set)

Takes an argument in set-syntax, see evaluateSet, and deletes any of characters present in the specified string.

 CharSetUtils.delete(null, *)        = null
 CharSetUtils.delete("", *)          = ""
 CharSetUtils.delete(*, null)        = *
 CharSetUtils.delete(*, "")          = *
 CharSetUtils.delete("hello", "hl") = "hll"
 CharSetUtils.delete("hello", "le") = "ell"
 

パラメータ:
str - String to delete characters from, may be null
set - String set of characters to delete, may be null
戻り値:
modified String, null if null string input
関連項目:
for set-syntax.

delete

public static String delete(String str,
                            String[] set)

Takes an argument in set-syntax, see evaluateSet, and deletes any of characters present in the specified string.

An example would be:

パラメータ:
str - String to delete characters from, may be null
set - String[] set of characters to delete, may be null
戻り値:
modified String, null if null string input
関連項目:
for set-syntax.

translate

public static String translate(String str,
                               String searchChars,
                               String replaceChars)
推奨されていません。 Use StringUtils.replaceChars(String, String, String). Method will be removed in Commons Lang 3.0.

Translate characters in a String. This is a multi character search and replace routine.

An example is:

If the length of characters to search for is greater than the length of characters to replace, then the last character is used.

 CharSetUtils.translate(null, *, *) = null
 CharSetUtils.translate("", *, *) = ""
 

パラメータ:
str - String to replace characters in, may be null
searchChars - a set of characters to search for, must not be null
replaceChars - a set of characters to replace, must not be null or empty ("")
戻り値:
translated String, null if null string input
例外:
NullPointerException - if with or repl is null
ArrayIndexOutOfBoundsException - if with is empty ("")


このドキュメントは、Ja-Jakartaにより訳されました。 コメントがある場合は report@jajakarta.orgまでお願いします。
Translated into Japanese by jajakarta.org. The original page is here.
Copyright (c) 2002-2003 - Apache Software Foundation