hcrypto.cipher
Class AlphabetFactory
java.lang.Object
|
+--hcrypto.cipher.AlphabetFactory
- public class AlphabetFactory
- extends java.lang.Object
AlphabetFactory.java
This class written by Ralph Walde on 7/19/01 by modifying part of a class
named Alphabet written by Ralph Morelli.
This class defines static methods that describe the available Alphabet
objects and static methods that create a selected alphabet object.
Appropriate variable names are given to unique non-negative int
values as ID values for the alphabets.
This class can be modified to add new alphabets without having to modify
other classes that use the alphabets.
Method Summary |
static java.lang.String |
getDesc(int num)
Returns a String description that specifies the range of the alphabet |
static Alphabet |
getInstance(char[] ranges)
Returns an Alphabet instance, constructed from
an array subranges specified by their 16-bit Unicodes. |
static Alphabet |
getInstance(java.lang.Character.UnicodeBlock[] blocks)
Returns an Alphabet instance, constructed from an array of Unicode blocks |
static Alphabet |
getInstance(int rangeId)
Returns an Alphabet instance, constructed from a range identifier |
static Alphabet |
getInstance(java.lang.String alphaDesc)
Returns an Alphabet instance, constructed from the description given. |
static int |
getRangeId(java.lang.String alphDesc)
Returns the int ID for a given valid alphabet String descriptor and
returns -1 for an invalid descriptor. |
static char[] |
getRanges(java.lang.Character.UnicodeBlock[] blocks)
|
static char[] |
getRanges(int id)
|
static boolean |
isValidAlphabetSpec(java.lang.String spec)
Returns true iff its String parameter represents a valid alphabet ID. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MAX_ALPH_NUM
public static final int MAX_ALPH_NUM
- The Alphabets are are numbered 0 through MAX_ALPH_NUM.
This constant is increased as additional alphabets are defined.
MAX_CHARS
public static final int MAX_CHARS
ALPH_az
public static final int ALPH_az
ALPH_AZ
public static final int ALPH_AZ
ALPH_azAZ
public static final int ALPH_azAZ
ALPH_azAZ09
public static final int ALPH_azAZ09
ALPH_printable
public static final int ALPH_printable
ALPH_ascii
public static final int ALPH_ascii
ALPH_unicode
public static final int ALPH_unicode
ALPH_hebrew
public static final int ALPH_hebrew
AlphabetFactory
public AlphabetFactory()
getInstance
public static Alphabet getInstance(char[] ranges)
- Returns an Alphabet instance, constructed from
an array subranges specified by their 16-bit Unicodes.
- Parameters:
ranges
- -- an array of Unicode values specifying the
disjoint subranges of the Alphabet.
getInstance
public static Alphabet getInstance(java.lang.Character.UnicodeBlock[] blocks)
throws java.lang.Exception
- Returns an Alphabet instance, constructed from an array of Unicode blocks
- Parameters:
blocks
- -- an array of Unicode character blocks
getInstance
public static Alphabet getInstance(int rangeId)
throws java.lang.Exception
- Returns an Alphabet instance, constructed from a range identifier
- Parameters:
rangeId
- -- an int specifying one of the
disjoint subranges of the Alphabet.
getInstance
public static Alphabet getInstance(java.lang.String alphaDesc)
throws java.lang.Exception
- Returns an Alphabet instance, constructed from the description given.
- Parameters:
alphaDesc
- -- a String description of the alphabet
getRanges
public static char[] getRanges(java.lang.Character.UnicodeBlock[] blocks)
getRanges
public static char[] getRanges(int id)
getDesc
public static java.lang.String getDesc(int num)
- Returns a String description that specifies the range of the alphabet
- Parameters:
num
- is an int specifying the alphabet ID which should be between
0 and MAX_ALPH_NUM.
getRangeId
public static int getRangeId(java.lang.String alphDesc)
throws java.lang.Exception
- Returns the int ID for a given valid alphabet String descriptor and
returns -1 for an invalid descriptor.
- Parameters:
alphDesc
- a String specifying the descriptor, which should
be one of: az, AZ, azAZ, azAZ09, printable, ascii
isValidAlphabetSpec
public static boolean isValidAlphabetSpec(java.lang.String spec)
- Returns true iff its String parameter represents a valid alphabet ID.
- Parameters:
spec
- a String specifying the descriptor, which should
be one of: az, AZ, azAZ, azAZ09, printable, ascii