|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.text.Format
net.sf.japaki.text.EnumFormat
public class EnumFormat
A format for a finite set of objects. Every object is stored with its string.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.text.Format |
|---|
Format.Field |
| Field Summary | |
|---|---|
static Object |
DUMMY
A dummy object used by getInstanceFor(String) |
| Constructor Summary | |
|---|---|
EnumFormat(Map<Object,String> map)
Constructs a new EnumFormat. |
|
EnumFormat(T[] keys,
String[] values)
Constructs a new EnumFormat. |
|
| Method Summary | ||
|---|---|---|
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
|
|
static
|
fromBundle(Class<T> type,
ResourceBundle bundle)
Constructs an enum format from an enum type and a resource bundle. |
|
Format.Field |
getField()
Returns the field used by this format. |
|
static Format |
getInstanceFor(String value)
Creates a format that recognizes only a single string and parses it as DUMMY. |
|
Object |
parseObject(String source,
ParsePosition pos)
|
|
void |
setField(Format.Field field)
Sets the field used by this format. |
|
| Methods inherited from class java.text.Format |
|---|
clone, format, formatToCharacterIterator, parseObject |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Object DUMMY
getInstanceFor(String)
| Constructor Detail |
|---|
public EnumFormat(Map<Object,String> map)
EnumFormat.
map - a map that contains the string representation of every
allowed value
NullPointerException - if map is null.
public EnumFormat(T[] keys,
String[] values)
EnumFormat.
keys - a list of objects known by this formatvalues - texts to be associated to the key values
NullPointerException - if keys or values is
null.
ArrayIndexOutOfBoundsException - if keys and values do not have
the same length| Method Detail |
|---|
public static Format getInstanceFor(String value)
DUMMY.
value - the text linked to the dummy value
public static <T extends Enum<T>> EnumFormat fromBundle(Class<T> type,
ResourceBundle bundle)
null will be used
as a key.
type - enum typebundle - a resource bundle
NullPointerException - if any parameter is nullpublic Format.Field getField()
public void setField(Format.Field field)
field - the field to be compared in format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) used by this
format.
public Object parseObject(String source,
ParsePosition pos)
parseObject in class FormatNullPointerException - if source or pos is
null.
public StringBuffer format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
format in class Formatobj - the object to formattoAppendTo - where the text is to be appendedpos - the position of the result in the buffer after formatting
toAppendTo,
with formatted text appended
IllegalArgumentException - if the given object is not a member
of the enumeration
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||