public class GeneralFormat
Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Use a document builder to insert a field that displays a result with no format applied.
Field field = builder.insertField("= 2 + 3");
Assert.assertEquals("= 2 + 3", field.getFieldCode());
Assert.assertEquals("5", field.getResult());
// We can apply a format to a field's result using the field's attributes.
// Below are three types of formats that we can apply to a field's result.
// 1 - Numeric format:
FieldFormat format = field.getFormat();
format.setNumericFormat("$###.00");
field.update();
Assert.assertEquals("= 2 + 3 \\# $###.00", field.getFieldCode());
Assert.assertEquals("$ 5.00", field.getResult());
// 2 - Date/time format:
field = builder.insertField("DATE");
format = field.getFormat();
format.setDateTimeFormat("dddd, MMMM dd, yyyy");
field.update();
Assert.assertEquals("DATE \\@ \"dddd, MMMM dd, yyyy\"", field.getFieldCode());
System.out.println("Today's date, in {format.DateTimeFormat} format:\n\t{field.Result}");
// 3 - General format:
field = builder.insertField("= 25 + 33");
format = field.getFormat();
format.getGeneralFormats().add(GeneralFormat.LOWERCASE_ROMAN);
format.getGeneralFormats().add(GeneralFormat.UPPER);
field.update();
int index = 0;
Iterator<Integer> generalFormatEnumerator = format.getGeneralFormats().iterator();
while (generalFormatEnumerator.hasNext()) {
int value = generalFormatEnumerator.next();
System.out.println(MessageFormat.format("General format index {0}: {1}", index++, value));
}
Assert.assertEquals("= 25 + 33 \\* roman \\* Upper", field.getFieldCode());
Assert.assertEquals("LVIII", field.getResult());
Assert.assertEquals(2, format.getGeneralFormats().getCount());
Assert.assertEquals(GeneralFormat.LOWERCASE_ROMAN, format.getGeneralFormats().get(0));
// We can remove our formats to revert the field's result to its original form.
format.getGeneralFormats().remove(GeneralFormat.LOWERCASE_ROMAN);
format.getGeneralFormats().removeAt(0);
Assert.assertEquals(0, format.getGeneralFormats().getCount());
field.update();
Assert.assertEquals("= 25 + 33 ", field.getFieldCode());
Assert.assertEquals("58", field.getResult());
Assert.assertEquals(0, format.getGeneralFormats().getCount());
Field Summary | ||
---|---|---|
static final int | NONE | |
Used to specify a missing general format.
|
||
static final int | AIUEO | |
Numeric formatting. Formats a numeric result using hiragana characters in the traditional a-i-u-e-o order.
|
||
static final int | UPPERCASE_ALPHABETIC | |
Numeric formatting. Formats a numeric result as one or more occurrences of an uppercase alphabetic Latin character.
|
||
static final int | LOWERCASE_ALPHABETIC | |
Numeric formatting. Formats a numeric result as one or more occurrences of an lowercase alphabetic Latin character.
|
||
static final int | ARABIC | |
Numeric formatting. Formats a numeric result using Arabic cardinal numerals.
|
||
static final int | ARABIC_ABJAD | |
Numeric formatting. Formats a numeric result using ascending Abjad numerals.
|
||
static final int | ARABIC_ALPHA | |
Numeric formatting. Formats a numeric result using characters in the Arabic alphabet.
|
||
static final int | ARABIC_DASH | |
Numeric formatting. Formats a numeric result using Arabic cardinal numerals, with a prefix of "- " and a suffix of " -".
|
||
static final int | BAHT_TEXT | |
Numeric formatting. Formats a numeric result in the Thai counting system.
|
||
static final int | CARD_TEXT | |
Numeric formatting. Cardinal text (One, Two, Three, ...).
|
||
static final int | CHINESE_NUM_1 | |
Numeric formatting. Formats a numeric result using ascending numbers from the appropriate counting system.
|
||
static final int | CHINESE_NUM_2 | |
Numeric formatting. Formats a numeric result using sequential numbers from the appropriate legal format.
|
||
static final int | CHINESE_NUM_3 | |
Numeric formatting. Formats a numeric result using sequential numbers from the appropriate counting thousand system.
|
||
static final int | CHOSUNG | |
Numeric formatting. Formats a numeric result using sequential numbers from the Korean Chosung format.
|
||
static final int | CIRCLE_NUM | |
Numeric formatting. Formats a numeric result using decimal numbering enclosed in a circle, using the
enclosed alphanumeric glyph character for numbers in the range 1–20.
|
||
static final int | DB_CHAR | |
Numeric formatting. Formats a numeric result using double-byte Arabic numbering.
|
||
static final int | DB_NUM_1 | |
Numeric formatting. Formats a numeric result using sequential digital ideographs, using the appropriate character.
|
||
static final int | DB_NUM_2 | |
Numeric formatting. Formats a numeric result using sequential numbers from the appropriate counting system.
|
||
static final int | DB_NUM_3 | |
Numeric formatting. Formats a numeric result using sequential numbers from the appropriate legal counting system.
|
||
static final int | DB_NUM_4 | |
Numeric formatting. Formats a numeric result using sequential numbers from the appropriate digital counting system.
|
||
static final int | DOLLAR_TEXT | |
Numeric formatting. Dollar text (One, Two, Three, ... + AND 55/100).
|
||
static final int | GANADA | |
Numeric formatting. Formats a numeric result using sequential numbers from the Korean Ganada format.
|
||
static final int | GB_1 | |
Numeric formatting. Formats a numeric result using decimal numbering followed by a period, using
the enclosed alphanumeric glyph character.
|
||
static final int | GB_2 | |
Numeric formatting. Formats a numeric result using decimal numbering enclosed in parenthesis,
using the enclosed alphanumeric glyph character.
|
||
static final int | GB_3 | |
Numeric formatting. Formats a numeric result using decimal numbering enclosed in a circle, using the
enclosed alphanumeric glyph character.
|
||
static final int | GB_4 | |
Numeric formatting. Formats a numeric result using decimal numbering enclosed in a circle, using the
enclosed alphanumeric glyph character.
|
||
static final int | HEBREW_1 | |
Numeric formatting. Formats a numeric result using Hebrew numerals.
|
||
static final int | HEBREW_2 | |
Numeric formatting. Formats a numeric result using the Hebrew alphabet.
|
||
static final int | HEX | |
Numeric formatting. Formats the numeric result using uppercase hexadecimal digits.
|
||
static final int | HINDI_ARABIC | |
Numeric formatting. Formats a numeric result using Hindi numbers.
|
||
static final int | HINDI_CARD_TEXT | |
Numeric formatting. Formats a numeric result using sequential numbers from the Hindi counting system.
|
||
static final int | HINDI_LETTER_1 | |
Numeric formatting. Formats a numeric result using Hindi vowels.
|
||
static final int | HINDI_LETTER_2 | |
Numeric formatting. Formats a numeric result using Hindi consonants.
|
||
static final int | IROHA | |
Numeric formatting. Formats a numeric result using the Japanese iroha.
|
||
static final int | KANJI_NUM_1 | |
Numeric formatting. Formats a numeric result using a Japanese style using the appropriate counting system.
|
||
static final int | KANJI_NUM_2 | |
Numeric formatting. Formats a numeric result using the appropriate counting system.
|
||
static final int | KANJI_NUM_3 | |
Numeric formatting. Formats a numeric result using the appropriate counting system.
|
||
static final int | ORDINAL | |
Numeric formatting. Ordinal (1st, 2nd, 3rd, ...).
|
||
static final int | ORD_TEXT | |
Numeric formatting. Ordinal text (First, Second, Third, ...).
|
||
static final int | UPPERCASE_ROMAN | |
Numeric formatting. Uppercase Roman (I, II, III, ...).
|
||
static final int | LOWERCASE_ROMAN | |
Numeric formatting. Lowercase Roman (i, ii, iii, ...).
|
||
static final int | SB_CHAR | |
Numeric formatting. Formats a numeric result using single-byte Arabic numbering.
|
||
static final int | THAI_ARABIC | |
Numeric formatting. Formats a numeric result using Thai numbers.
|
||
static final int | THAI_CARD_TEXT | |
Numeric formatting. Formats a numeric result using sequential numbers from the Thai counting system.
|
||
static final int | THAI_LETTER | |
Numeric formatting. Formats a numeric result using Thai letters.
|
||
static final int | VIET_CARD_TEXT | |
Numeric formatting. Formats a numeric result using Vietnamese numerals.
|
||
static final int | ZODIAC_1 | |
Numeric formatting. Formats a numeric result using sequential numerical traditional ideographs.
|
||
static final int | ZODIAC_2 | |
Numeric formatting. Formats a numeric result using sequential zodiac ideographs.
|
||
static final int | ZODIAC_3 | |
Numeric formatting. Formats a numeric result using sequential traditional zodiac ideographs.
|
||
static final int | CAPS | |
Text formatting. Capitalizes the first letter of each word.
|
||
static final int | FIRST_CAP | |
Text formatting. Capitalizes the first letter of the first word.
|
||
static final int | LOWER | |
Text formatting. All letters are lowercase.
|
||
static final int | UPPER | |
Text formatting. All letters are uppercase.
|
||
static final int | CHAR_FORMAT | |
Field result formatting. The CHARFORMAT instruction.
|
||
static final int | MERGE_FORMAT | |
Field result formatting. The MERGEFORMAT instruction.
|
||
static final int | MERGE_FORMAT_INET | |
Field result formatting. The MERGEFORMATINET instruction.
|
public static final int NONE
public static final int AIUEO
public static final int UPPERCASE_ALPHABETIC
public static final int LOWERCASE_ALPHABETIC
public static final int ARABIC
public static final int ARABIC_ABJAD
public static final int ARABIC_ALPHA
public static final int ARABIC_DASH
public static final int BAHT_TEXT
public static final int CARD_TEXT
public static final int CHINESE_NUM_1
public static final int CHINESE_NUM_2
public static final int CHINESE_NUM_3
public static final int CHOSUNG
public static final int CIRCLE_NUM
public static final int DB_CHAR
public static final int DB_NUM_1
public static final int DB_NUM_2
public static final int DB_NUM_3
public static final int DB_NUM_4
public static final int DOLLAR_TEXT
public static final int GANADA
public static final int GB_1
public static final int GB_2
public static final int GB_3
public static final int GB_4
public static final int HEBREW_1
public static final int HEBREW_2
public static final int HEX
public static final int HINDI_ARABIC
public static final int HINDI_CARD_TEXT
public static final int HINDI_LETTER_1
public static final int HINDI_LETTER_2
public static final int IROHA
public static final int KANJI_NUM_1
public static final int KANJI_NUM_2
public static final int KANJI_NUM_3
public static final int ORDINAL
public static final int ORD_TEXT
public static final int UPPERCASE_ROMAN
public static final int LOWERCASE_ROMAN
public static final int SB_CHAR
public static final int THAI_ARABIC
public static final int THAI_CARD_TEXT
public static final int THAI_LETTER
public static final int VIET_CARD_TEXT
public static final int ZODIAC_1
public static final int ZODIAC_2
public static final int ZODIAC_3
public static final int CAPS
public static final int FIRST_CAP
public static final int LOWER
public static final int UPPER
public static final int CHAR_FORMAT
public static final int MERGE_FORMAT
public static final int MERGE_FORMAT_INET