org.seasar.framework.util
クラス StringUtil

java.lang.Object
  拡張org.seasar.framework.util.StringUtil

public final class StringUtil
extends Object

String用のユーティリティクラスです。

作成者:
higa

フィールドの概要
static String[] EMPTY_STRINGS
          空の文字列の配列です。
 
メソッドの概要
static void appendHex(StringBuffer buf, byte i)
          文字列に、数値を16進数に変換した文字列を追加します。
static void appendHex(StringBuffer buf, int i)
          文字列に、数値を16進数に変換した文字列を追加します。
static String camelize(String s)
          _記法をキャメル記法に変換します。
static String capitalize(String name)
          JavaBeansの仕様にしたがってキャピタライズを行ないます。
static boolean contains(String str, char ch)
          charを含んでいるかどうか返します。
static boolean contains(String s1, String s2)
          文字列を含んでいるかどうか返します。
static String decamelize(String s)
          キャメル記法を_記法に変換します。
static String decapitalize(String name)
          JavaBeansの仕様にしたがってデキャピタライズを行ないます。
static boolean endsWithIgnoreCase(String target1, String target2)
          ケースインセンシティブで特定の文字で終わっているのかどうかを返します。
static boolean equals(String target1, String target2)
          文字列同士が等しいかどうか返します。
static boolean equalsIgnoreCase(String target1, String target2)
          ケースインセンシティブで文字列同士が等しいかどうか返します。
static boolean isBlank(String str)
          ブランクかどうか返します。
static boolean isEmpty(String text)
          空かどうかを返します。
static boolean isNotBlank(String str)
          ブランクではないかどうか返します。
static boolean isNumber(String s)
          文字列が数値のみで構成されているかどうかを返します。
static String ltrim(String text)
          左側の空白を削ります。
static String ltrim(String text, String trimText)
          左側の指定した文字列を削ります。
static String replace(String text, String fromText, String toText)
          文字列を置き換えます。
static String rtrim(String text)
          右側の空白を削ります。
static String rtrim(String text, String trimText)
          右側の指定した文字列を削ります。
static String[] split(String str, String delim)
          文字列を分割します。
static boolean startsWith(String text, String fragment)
          推奨されていません。  
static boolean startsWithIgnoreCase(String target1, String target2)
          ケースインセンシティブで特定の文字ではじまっているのかどうかを返します。
static String substringFromLast(String str, String separator)
          文字列の最後から指定した文字列で始まっている部分より手前を返します。
static String substringToLast(String str, String separator)
          文字列の最後から指定した文字列で始まっている部分より後ろを返します。
static String toHex(byte[] bytes)
          16進数の文字列に変換します。
static String toHex(int i)
          16進数の文字列に変換します。
static String trimPrefix(String text, String prefix)
          プレフィックスを削ります。
static String trimSuffix(String text, String suffix)
          サフィックスを削ります。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

EMPTY_STRINGS

public static final String[] EMPTY_STRINGS
空の文字列の配列です。

メソッドの詳細

isEmpty

public static final boolean isEmpty(String text)
空かどうかを返します。

パラメータ:
text - 文字列
戻り値:
空かどうか

replace

public static final String replace(String text,
                                   String fromText,
                                   String toText)
文字列を置き換えます。

パラメータ:
text - テキスト
fromText - 置き換え対象のテキスト
toText - 置き換えるテキスト
戻り値:
結果

split

public static String[] split(String str,
                             String delim)
文字列を分割します。

パラメータ:
str - 文字列
delim - 分割するためのデリミタ
戻り値:
分割された文字列の配列

ltrim

public static final String ltrim(String text)
左側の空白を削ります。

パラメータ:
text - テキスト
戻り値:
結果の文字列

ltrim

public static final String ltrim(String text,
                                 String trimText)
左側の指定した文字列を削ります。

パラメータ:
text - テキスト
trimText - 削るテキスト
戻り値:
結果の文字列

rtrim

public static final String rtrim(String text)
右側の空白を削ります。

パラメータ:
text - テキスト
戻り値:
結果の文字列

rtrim

public static final String rtrim(String text,
                                 String trimText)
右側の指定した文字列を削ります。

パラメータ:
text - テキスト
trimText - 削る文字列
戻り値:
結果の文字列

trimSuffix

public static final String trimSuffix(String text,
                                      String suffix)
サフィックスを削ります。

パラメータ:
text - テキスト
suffix - サフィックス
戻り値:
結果の文字列

trimPrefix

public static final String trimPrefix(String text,
                                      String prefix)
プレフィックスを削ります。

パラメータ:
text - テキスト
prefix - プレフィックス
戻り値:
結果の文字列

decapitalize

public static String decapitalize(String name)
JavaBeansの仕様にしたがってデキャピタライズを行ないます。大文字が2つ以上続く場合は、小文字にならないので注意してください。

パラメータ:
name - 名前
戻り値:
結果の文字列

capitalize

public static String capitalize(String name)
JavaBeansの仕様にしたがってキャピタライズを行ないます。大文字が2つ以上続く場合は、大文字にならないので注意してください。

パラメータ:
name - 名前
戻り値:
結果の文字列

startsWith

public static boolean startsWith(String text,
                                 String fragment)
推奨されていません。  

ケースインセンシティブで特定の文字列で開始されているかどうかを返します。

パラメータ:
text - テキスト
fragment - 特定の文字列
戻り値:
ケースインセンシティブで特定の文字列で開始されているかどうか
関連項目:
startsWithIgnoreCase(String, String)

isBlank

public static boolean isBlank(String str)
ブランクかどうか返します。

パラメータ:
str - 文字列
戻り値:
ブランクかどうか

isNotBlank

public static boolean isNotBlank(String str)
ブランクではないかどうか返します。

パラメータ:
str - 文字列
戻り値:
ブランクではないかどうか
関連項目:
isBlank(String)

contains

public static boolean contains(String str,
                               char ch)
charを含んでいるかどうか返します。

パラメータ:
str - 文字列
ch - char
戻り値:
charを含んでいるかどうか

contains

public static boolean contains(String s1,
                               String s2)
文字列を含んでいるかどうか返します。

パラメータ:
s1 - 文字列
s2 - 比較する対象となる文字列
戻り値:
文字列を含んでいるかどうか

equals

public static boolean equals(String target1,
                             String target2)
文字列同士が等しいかどうか返します。どちらもnullの場合は、trueを返します。

パラメータ:
target1 - 文字列1
target2 - 文字列2
戻り値:
文字列同士が等しいかどうか

equalsIgnoreCase

public static boolean equalsIgnoreCase(String target1,
                                       String target2)
ケースインセンシティブで文字列同士が等しいかどうか返します。どちらもnullの場合は、trueを返します。

パラメータ:
target1 - 文字列1
target2 - 文字列2
戻り値:
ケースインセンシティブで文字列同士が等しいか

endsWithIgnoreCase

public static boolean endsWithIgnoreCase(String target1,
                                         String target2)
ケースインセンシティブで特定の文字で終わっているのかどうかを返します。

パラメータ:
target1 - テキスト
target2 - 比較する文字列
戻り値:
ケースインセンシティブで特定の文字で終わっているのかどうか

startsWithIgnoreCase

public static boolean startsWithIgnoreCase(String target1,
                                           String target2)
ケースインセンシティブで特定の文字ではじまっているのかどうかを返します。

パラメータ:
target1 - テキスト
target2 - 比較する文字列
戻り値:
ケースインセンシティブで特定の文字ではじまっているのかどうか

substringFromLast

public static String substringFromLast(String str,
                                       String separator)
文字列の最後から指定した文字列で始まっている部分より手前を返します。

パラメータ:
str - 文字列
separator - セパレータ
戻り値:
結果の文字列

substringToLast

public static String substringToLast(String str,
                                     String separator)
文字列の最後から指定した文字列で始まっている部分より後ろを返します。

パラメータ:
str - 文字列
separator - セパレータ
戻り値:
結果の文字列

toHex

public static String toHex(byte[] bytes)
16進数の文字列に変換します。

パラメータ:
bytes - バイトの配列
戻り値:
16進数の文字列

toHex

public static String toHex(int i)
16進数の文字列に変換します。

パラメータ:
i - int
戻り値:
16進数の文字列

appendHex

public static void appendHex(StringBuffer buf,
                             byte i)
文字列に、数値を16進数に変換した文字列を追加します。

パラメータ:
buf - 追加先の文字列
i - 数値

appendHex

public static void appendHex(StringBuffer buf,
                             int i)
文字列に、数値を16進数に変換した文字列を追加します。

パラメータ:
buf - 追加先の文字列
i - 数値

camelize

public static String camelize(String s)
_記法をキャメル記法に変換します。

パラメータ:
s - テキスト
戻り値:
結果の文字列

decamelize

public static String decamelize(String s)
キャメル記法を_記法に変換します。

パラメータ:
s - テキスト
戻り値:
結果の文字列

isNumber

public static boolean isNumber(String s)
文字列が数値のみで構成されているかどうかを返します。

パラメータ:
s - 文字列
戻り値:
数値のみで構成されている場合、true


Copyright ? 2004-2007 The Seasar Foundation. All Rights Reserved.