|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.informatica.text.ObjectFormat
public abstract class ObjectFormat
Base class for text formatting objects emulating popular C-Language
printf function.
Synopsis:
ObjectFormat of;
String formatted;
of = ObjectFormat.create("6d");
formatted = of.format(new Integer(3527));
[...]
of = ObjectFormat.create("-15s");
formatted = of.format("This is a test");
[...]
of = ObjectFormat.create("-5T");
formatted = of.format("This is another test");
Current supported formats are:
Subclasses must implement the setFormat method, and can implement its own setFlag method. Only in rare cases will need to override setFlags.
NumberFormat,
OctalFormat,
HexFormat,
IntegerFormat,
FloatFormat,
ExponentFormat,
StringFormat,
TextFormat| Field Summary |
|---|
| Fields inherited from interface info.informatica.doc.style.Alignable |
|---|
CENTER, JUSTIFY, LEFT, RIGHT, UNDETERMINED |
| Method Summary | |
|---|---|
void |
align(int i)
Sets the alignment of the object. |
static ObjectFormat |
create(Class clase,
int width,
int precision)
Creates the proper ObjectFormat object according to parameters, with a different default align for text and anything else. |
static ObjectFormat |
create(Class clase,
int width,
int precision,
boolean right_align)
Creates the proper ObjectFormat object according to parameters. |
static ObjectFormat |
create(String format)
Creates the proper ObjectFormat object according to format. |
abstract String |
format(Object o)
Formats an object according to the format specification set by setFormat. |
int |
getAlignment()
Gets the alignment. |
abstract Object |
sample()
Produce a sample of this format. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static ObjectFormat create(String format)
throws ParsingException
format - the format
format
ParsingException
public static ObjectFormat create(Class clase,
int width,
int precision)
throws ParsingException
clase - the class of the object to be formatted.
ParsingException
public static ObjectFormat create(Class clase,
int width,
int precision,
boolean right_align)
throws ParsingException
clase - the class of the object to be formatted.
ParsingExceptionpublic void align(int i)
Alignable
align in interface Alignablei - one of the public constants specifying the alignment.public int getAlignment()
Alignable
getAlignment in interface Alignablepublic abstract String format(Object o)
setFormat.
Must be overriden by subclasses.
public abstract Object sample()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||