org.apache.commons.lang
クラス RandomStringUtils

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

public class RandomStringUtils
extends Object

Operations for random Strings.

導入されたバージョン:
1.0
バージョン:
$Id: RandomStringUtils.java,v 1.1.1.1 2004/02/13 10:02:05 hioki Exp $
作成者:
GenerationJava Core library, Henri Yandell, Steven Caswell, Stephen Colebourne, Gary Gregory, Phil Steitz

コンストラクタの概要
RandomStringUtils()
          RandomStringUtils instances should NOT be constructed in standard programming.
 
メソッドの概要
static String random(int count)
          Creates a random string whose length is the number of characters specified.
static String random(int count, boolean letters, boolean numbers)
          Creates a random string whose length is the number of characters specified.
static String random(int count, char[] chars)
          Creates a random string whose length is the number of characters specified.
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.
static String random(int count, int start, int end, boolean letters, boolean numbers, char[] chars)
          Creates a random string based on a variety of options, using default source of randomness.
static String random(int count, int start, int end, boolean letters, boolean numbers, char[] chars, Random random)
          Creates a random string based on a variety of options, using supplied source of randomness.
static String random(int count, String chars)
          Creates a random string whose length is the number of characters specified.
static String randomAlphabetic(int count)
          Creates a random string whose length is the number of characters specified.
static String randomAlphanumeric(int count)
          Creates a random string whose length is the number of characters specified.
static String randomAscii(int count)
          Creates a random string whose length is the number of characters specified.
static String randomNumeric(int count)
          Creates a random string whose length is the number of characters specified.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

RandomStringUtils

public RandomStringUtils()

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 - the length of random string to create
戻り値:
the random string

randomAscii

public static String randomAscii(int count)

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 126 (inclusive).

パラメータ:
count - the 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 - the 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 - the 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 - the 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 - the length of random string to create
letters - if true, generated string will include alphabetic characters
numbers - 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 - the length of random string to create
start - the position in set of chars to start at
end - the position in set of chars to end before
letters - if true, generated string will include alphabetic characters
numbers - if true, generated string will include numeric characters
戻り値:
the random string

random

public static String random(int count,
                            int start,
                            int end,
                            boolean letters,
                            boolean numbers,
                            char[] chars)

Creates a random string based on a variety of options, using default source of randomness.

This method has exactly the same semantics as random(int,int,int,boolean,boolean,char[],Random), but instead of using an externally supplied source of randomness, it uses the internal static Random instance.

パラメータ:
count - the length of random string to create
start - the position in set of chars to start at
end - the position in set of chars to end before
letters - only allow letters?
numbers - only allow numbers?
chars - the set of chars to choose randoms from. If null, then it will use the set of all chars.
戻り値:
the random string
例外:
ArrayIndexOutOfBoundsException - if there are not (end - start) + 1 characters in the set array.

random

public static String random(int count,
                            int start,
                            int end,
                            boolean letters,
                            boolean numbers,
                            char[] chars,
                            Random random)

Creates a random string based on a variety of options, using supplied source of randomness.

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.

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

This method accepts a user-supplied Random instance to use as a source of randomness. By seeding a single Random instance with a fixed seed and using it for each call, the same random sequence of strings can be generated repeatedly and predictably.

パラメータ:
count - the length of random string to create
start - the position in set of chars to start at
end - the position in set of chars to end before
letters - only allow letters?
numbers - only allow numbers?
chars - the set of chars to choose randoms from. If null, then it will use the set of all chars.
random - a source of randomness.
戻り値:
the random string
例外:
ArrayIndexOutOfBoundsException - if there are not (end - start) + 1 characters in the set array.
IllegalArgumentException - if count < 0.
導入されたバージョン:
2.0

random

public static String random(int count,
                            String chars)

Creates a random string whose length is the number of characters specified.

Characters will be chosen from the set of characters specified.

パラメータ:
count - the length of random string to create
chars - the String containing the set of characters to use, may be null
戻り値:
the random string
例外:
IllegalArgumentException - if count < 0.

random

public static String random(int count,
                            char[] chars)

Creates a random string whose length is the number of characters specified.

Characters will be chosen from the set of characters specified.

パラメータ:
count - the length of random string to create
chars - the character array containing the set of characters to use, may be null
戻り値:
the random string
例外:
IllegalArgumentException - if count < 0.


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