org.apache.commons.lang
クラス RandomStringUtils

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

public class RandomStringUtils
extends Object

共通的なランダムな String に対する処理ルーチンです。

Common random String manipulation routines.

オリジナルは GenerationJava コアライブラリです。

Originally from the GenerationJava Core library.

バージョン:
$Id: RandomStringUtils.java,v 1.1.1.1 2004/02/13 10:02:04 hioki Exp $
作成者:
Henri Yandell, Steven Caswell, Stephen Colebourne
翻訳者:
日置 聡
翻訳状況:
初稿(校正者募集中)
翻訳更新日:
2003/08/12

フィールドの概要
private static Random RANDOM
          random メソッドで使用される Random オブジェクト。.
 
コンストラクタの概要
RandomStringUtils()
          RandomStringUtils のインスタンスは一般的なプログラムからは生成すべきではありません。
 
メソッドの概要
static String random(int count)
          指定された長さを持つランダムな文字列を生成します。
static String random(int count, boolean letters, boolean numbers)
          指定された長さを持つランダムな文字列を生成します。
static String random(int count, char[] set)
          指定された長さを持つランダムな文字列を生成します。
static String random(int count, int start, int end, boolean letters, boolean numbers)
          指定された長さを持つランダムな文字列を生成します。
static String random(int count, int start, int end, boolean letters, boolean numbers, char[] set)
          指定されたオプションに従ってランダムな文字列を生成します。
static String random(int count, String set)
          指定された長さを持つランダムな文字列を生成します。
static String randomAlphabetic(int count)
          指定された長さを持つランダムな文字列を生成します。
static String randomAlphanumeric(int count)
          指定された長さを持つランダムな文字列を生成します。
static String randomAscii(int count)
          指定された長さを持つランダムな文字列を生成します。
static String randomNumeric(int count)
          指定された長さを持つランダムな文字列を生成します。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

RANDOM

private static final Random RANDOM
random メソッドで使用される Random オブジェクト。. This has to be not local このオブジェクトは同じミリセカンドで同じ値を返さないようにローカルには保持しません。
Random object used by random method. This has to be not local to the random method so as to not return the same value in the same millisecond.

コンストラクタの詳細

RandomStringUtils

public RandomStringUtils()
RandomStringUtils のインスタンスは一般的なプログラムからは生成すべきではありません。 代わりに RandomStringUtils.random(5); というように使用すべきです。 このコンストラクタは、処理に JavaBean インスタンスを必要とするツールのために public になっています。
RandomStringUtils instances should NOT be constructed in standard programming. Instead, the class should be used as RandomStringUtils.random(5);. This constructor is public to permit tools that require a JavaBean instance to operate.

メソッドの詳細

random

public static String random(int count)
指定された長さを持つランダムな文字列を生成します。 含まれる文字は全ての文字から選出されます。
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of all characters.

パラメータ:
count - 生成するランダムな文字列の長さ
length of random string to create
戻り値:
ランダムな文字列
the random string

randomAscii

public static String randomAscii(int count)
指定された長さを持つランダムな文字列を生成します。 含まれる文字は32からから127のASCIIの値から選出されます。
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of characters whose ASCII value is between 32 and 127 .

パラメータ:
count - 生成するランダムな文字列の長さ
length of random string to create
戻り値:
ランダムな文字列
the random string

randomAlphabetic

public static String randomAlphabetic(int count)
指定された長さを持つランダムな文字列を生成します。 含まれる文字はアルファベットから選出されます。
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alphabetic characters.

パラメータ:
count - 生成するランダムな文字列の長さ
length of random string to create
戻り値:
ランダムな文字列
the random string

randomAlphanumeric

public static String randomAlphanumeric(int count)
指定された長さを持つランダムな文字列を生成します。 含まれる文字はアルファベットと数字から選出されます。
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alpha-numeric characters.

パラメータ:
count - 生成するランダムな文字列の長さ
length of random string to create
戻り値:
ランダムな文字列
the random string

randomNumeric

public static String randomNumeric(int count)
指定された長さを持つランダムな文字列を生成します。 含まれる文字は数字から選出されます。
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of numeric characters.

パラメータ:
count - 生成するランダムな文字列の長さ
length of random string to create
戻り値:
ランダムな文字列
the random string

random

public static String random(int count,
                            boolean letters,
                            boolean numbers)
指定された長さを持つランダムな文字列を生成します。 含まれる文字は渡された引数に従ってアルファベットと数字から選出されます。
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alpha-numeric characters as indicated by the arguments.

パラメータ:
count - 生成するランダムな文字列の長さ
length of random string to create
letters - true の場合、生成される文字列はアルファベットを含む
if true, generated string will include alphabetic characters
numbers - true の場合、生成される文字列は数字を含む
if true, generatd string will include numeric characters
戻り値:
ランダムな文字列
the random string

random

public static String random(int count,
                            int start,
                            int end,
                            boolean letters,
                            boolean numbers)
指定された長さを持つランダムな文字列を生成します。 含まれる文字は渡された引数に従ってアルファベットと数字から選出されます。
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alpha-numeric characters as indicated by the arguments.

パラメータ:
count - 生成するランダムな文字列の長さ
length of random string to create
start - 使用する文字セットの開始位置
int position in set of chars to start at
end - 使用する文字セットの終了位置
int position in set of chars to end before
letters - true の場合、生成される文字列はアルファベットを含む
if true, generated string will include alphabetic characters
numbers - true の場合、生成される文字列は数字を含む
if true, generatd string will include numeric characters
戻り値:
ランダムな文字列
the random string

random

public static String random(int count,
                            int start,
                            int end,
                            boolean letters,
                            boolean numbers,
                            char[] set)
指定されたオプションに従ってランダムな文字列を生成します。 start と end が両方とも0だった場合には、letters と numbers が両方とも false でない限りASCIIで表示可能な ' ' と 'z' がセットされ使用されます。 letters と numbers が両方とも false の場合 start と end は 0 と Integer.MAX_VALUE になります。
Creates a random string based on a variety of options. If start and end are both 0, start and end are set to ' ' and 'z', the ASCII printable characters, will be used, unless letters and numbers are both false, in which case, start and end are set to 0 and Integer.MAX_VALUE.

set が null でない場合には start から end のインデックスのこの配列内から文字が選出されます。

If set is not null, characters between start and end are chosen.

パラメータ:
count - 生成するランダムな文字列の長さ
length of random string to create
start - 文字セットの開始位置
int position in set of chars to start at
end - 文字セットの終了位置
int position in set of chars to end before
letters - 文字だけを許可するか?
boolean only allow letters?
numbers - 数字だけを許可するか?
boolean only allow numbers?
set - ランダムな文字列を作成する際に使用される文字のセット、 null の場合全ての文字が使用される
char[] set of chars to choose randoms from. If null, then it will use the set of all chars.
戻り値:
ランダムな文字列
the random string
例外:
ArrayIndexOutOfBoundsException - 文字セットの配列が (end - start) + 1 の長さを持たなかった場合
if there are not (end - start) + 1 characters in the set array.

random

public static String random(int count,
                            String set)
指定された長さを持つランダムな文字列を生成します。 含まれる文字は指定された文字のセットから選出されます。
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of characters specified.

パラメータ:
count - 生成するランダムな文字列の長さ
length of random string to create
set - String containing the set of characters to use
戻り値:
ランダムな文字列
the random string

random

public static String random(int count,
                            char[] set)
指定された長さを持つランダムな文字列を生成します。 含まれる文字は指定された文字のセットから選出されます。
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of characters specified.

パラメータ:
count - 生成するランダムな文字列の長さ
length of random string to create
set - character array containing the set of characters to use
戻り値:
ランダムな文字列
the random string


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