|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ilog.rules.bom.util.IlrFormat
public final class IlrFormat
Instances of this class are literal formats: they are used by the
object model and rule parser to read objects from strings and to print them into strings.
An instance of this class maintains a list of Java formats and
selects one of them to use according to the IlrType
of the object, or
according to the Java class.
Initially, a SimpleDateFormat
is created using the
pattern M/d/yyyy H:mm
. The locale provided by the
engine resource mechanism. This format is associated with the Java class
java.util.Date
.
Constructor Summary | |
---|---|
IlrFormat(IlrObjectModel objectModel)
|
Method Summary | |
---|---|
void |
applyDatePattern(String pattern)
Changes the pattern of the simple date format used to parse and write the date literals. |
String |
format(IlrType type,
Object obj)
Prints an object to a string. |
String |
format(Object obj)
Prints an object to a string. |
String |
formatWithClassname(Object obj)
|
Format |
getFormat(Class aclass)
Gets the Java format for a Java class. |
Format |
getFormat(IlrType type)
Gets the Java format for an IlrType . |
Format[] |
getFormats()
Gets all the Java formats currently known by this instance. |
Class |
getInheritedNativeClass(IlrType type)
|
boolean |
isSupported(Class aclass)
|
boolean |
isSupported(IlrType type)
Returns true if the objects of
type can be formatted. |
Object |
parse(Class aclass,
String source)
Parses a string and constructs an object of the specified class. |
Object |
parse(IlrType type,
String source)
Parses a string and constructs an object. |
void |
setFormat(Class aclass,
Format format)
Associates a format object with a Java class. |
void |
setFormat(IlrType type,
Format format)
Associates a format object with an IlrType . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IlrFormat(IlrObjectModel objectModel)
Method Detail |
---|
public Format getFormat(IlrType type)
IlrType
.
type
- An IlrType
.
null
if no format can be obtained of the
instances of the passed class.public void setFormat(IlrType type, Format format)
IlrType
. Later on, the format
will be used to convert instances of this type into strings and
vice versa.
type
- An IlrType
.format
- A Java format.public Format getFormat(Class aclass)
aclass
- A Java class.
null
if no format can be
obtained of the instances of the passed class.public void setFormat(Class aclass, Format format)
aclass
- A Java class.format
- A Java format.public Format[] getFormats()
public void applyDatePattern(String pattern)
SimpleDateFormat
.
pattern
- The new pattern used to read and write date literals.public Object parse(IlrType type, String source) throws ParseException
IlrType.getNativeClass()
,
the format for the native type is used.
If no format is found, an exception is thrown.
If exceptions are encountered during parsing, a ParseException
is thrown.
IlrMissingFormatException
- If no format is found for the
requested class.
ParseException
- If the passed string raises parsing errors.type
- The type of the object to be constructed.source
- A string to be parsed using a format.
public boolean isSupported(IlrType type)
true
if the objects of
type
can be formatted.
public boolean isSupported(Class aclass)
public Class getInheritedNativeClass(IlrType type)
public Object parse(Class aclass, String source) throws ParseException
ParseException
is thrown.
IlrMissingFormatException
- If no format is found for the
requested class.
ParseException
- If the passed string raises parsing errors.
NumberFormatException
- If the passed string was considered but cannot be parsed as a number.aclass
- The class of the object to be constructed.source
- A string to be parsed using a format.
public String format(IlrType type, Object obj)
toString()
on the object and returns the result.
type
- The type used to select a format.obj
- The object to format.
public String formatWithClassname(Object obj)
public String format(Object obj)
toString()
on the object and returns the result.
obj
- The object to format.
|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |