GeneralFormat

Inheritance: java.lang.Object

public class GeneralFormat

Specifies a general format that is applied to a numeric, text, or any field result. A field may have a combination of general formats.

Examples:

Shows how to format field results.


 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 properties.
 // 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 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());
 

Fields

FieldDescription
AIUEONumeric formatting.
ARABICNumeric formatting.
ARABIC_ABJADNumeric formatting.
ARABIC_ALPHANumeric formatting.
ARABIC_DASHNumeric formatting.
BAHT_TEXTNumeric formatting.
CAPSText formatting.
CARD_TEXTNumeric formatting.
CHAR_FORMATField result formatting.
CHINESE_NUM_1Numeric formatting.
CHINESE_NUM_2Numeric formatting.
CHINESE_NUM_3Numeric formatting.
CHOSUNGNumeric formatting.
CIRCLE_NUMNumeric formatting.
DB_CHAR
DB_NUM_1
DB_NUM_2
DB_NUM_3
DB_NUM_4
DOLLAR_TEXTNumeric formatting.
FIRST_CAPText formatting.
GANADANumeric formatting.
GB_1Numeric formatting.
GB_2Numeric formatting.
GB_3Numeric formatting.
GB_4Numeric formatting.
HEBREW_1Numeric formatting.
HEBREW_2Numeric formatting.
HEXNumeric formatting.
HINDI_ARABICNumeric formatting.
HINDI_CARD_TEXTNumeric formatting.
HINDI_LETTER_1Numeric formatting.
HINDI_LETTER_2Numeric formatting.
IROHANumeric formatting.
KANJI_NUM_1Numeric formatting.
KANJI_NUM_2Numeric formatting.
KANJI_NUM_3Numeric formatting.
LOWERText formatting.
LOWERCASE_ALPHABETICNumeric formatting.
LOWERCASE_ROMANNumeric formatting.
MERGE_FORMATField result formatting.
MERGE_FORMAT_INETField result formatting.
NONEUsed to specify a missing general format.
ORDINALNumeric formatting.
ORD_TEXTNumeric formatting.
SB_CHAR
THAI_ARABICNumeric formatting.
THAI_CARD_TEXTNumeric formatting.
THAI_LETTERNumeric formatting.
UPPERText formatting.
UPPERCASE_ALPHABETICNumeric formatting.
UPPERCASE_ROMANNumeric formatting.
VIET_CARD_TEXTNumeric formatting.
ZODIAC_1Numeric formatting.
ZODIAC_2Numeric formatting.
ZODIAC_3Numeric formatting.
length

Methods

MethodDescription
fromName(String generalFormatName)
getName(int generalFormat)
getValues()
toString(int generalFormat)

AIUEO

public static int AIUEO

Numeric formatting. Formats a numeric result using hiragana characters in the traditional a-i-u-e-o order.

ARABIC

public static int ARABIC

Numeric formatting. Formats a numeric result using Arabic cardinal numerals.

ARABIC_ABJAD

public static int ARABIC_ABJAD

Numeric formatting. Formats a numeric result using ascending Abjad numerals.

ARABIC_ALPHA

public static int ARABIC_ALPHA

Numeric formatting. Formats a numeric result using characters in the Arabic alphabet.

ARABIC_DASH

public static int ARABIC_DASH

Numeric formatting. Formats a numeric result using Arabic cardinal numerals, with a prefix of “- " and a suffix of " -”.

BAHT_TEXT

public static int BAHT_TEXT

Numeric formatting. Formats a numeric result in the Thai counting system.

CAPS

public static int CAPS

Text formatting. Capitalizes the first letter of each word.

CARD_TEXT

public static int CARD_TEXT

Numeric formatting. Cardinal text (One, Two, Three, …).

CHAR_FORMAT

public static int CHAR_FORMAT

Field result formatting. The CHARFORMAT instruction.

CHINESE_NUM_1

public static int CHINESE_NUM_1

Numeric formatting. Formats a numeric result using ascending numbers from the appropriate counting system.

CHINESE_NUM_2

public static int CHINESE_NUM_2

Numeric formatting. Formats a numeric result using sequential numbers from the appropriate legal format.

CHINESE_NUM_3

public static int CHINESE_NUM_3

Numeric formatting. Formats a numeric result using sequential numbers from the appropriate counting thousand system.

CHOSUNG

public static int CHOSUNG

Numeric formatting. Formats a numeric result using sequential numbers from the Korean Chosung format.

CIRCLE_NUM

public static 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\u201320.

DB_CHAR

public static int DB_CHAR

DB_NUM_1

public static int DB_NUM_1

DB_NUM_2

public static int DB_NUM_2

DB_NUM_3

public static int DB_NUM_3

DB_NUM_4

public static int DB_NUM_4

DOLLAR_TEXT

public static int DOLLAR_TEXT

Numeric formatting. Dollar text (One, Two, Three, … + AND 55/100).

FIRST_CAP

public static int FIRST_CAP

Text formatting. Capitalizes the first letter of the first word.

GANADA

public static int GANADA

Numeric formatting. Formats a numeric result using sequential numbers from the Korean Ganada format.

GB_1

public static int GB_1

Numeric formatting. Formats a numeric result using decimal numbering followed by a period, using the enclosed alphanumeric glyph character.

GB_2

public static int GB_2

Numeric formatting. Formats a numeric result using decimal numbering enclosed in parenthesis, using the enclosed alphanumeric glyph character.

GB_3

public static int GB_3

Numeric formatting. Formats a numeric result using decimal numbering enclosed in a circle, using the enclosed alphanumeric glyph character.

GB_4

public static int GB_4

Numeric formatting. Formats a numeric result using decimal numbering enclosed in a circle, using the enclosed alphanumeric glyph character.

HEBREW_1

public static int HEBREW_1

Numeric formatting. Formats a numeric result using Hebrew numerals.

HEBREW_2

public static int HEBREW_2

Numeric formatting. Formats a numeric result using the Hebrew alphabet.

HEX

public static int HEX

Numeric formatting. Formats the numeric result using uppercase hexadecimal digits.

HINDI_ARABIC

public static int HINDI_ARABIC

Numeric formatting. Formats a numeric result using Hindi numbers.

HINDI_CARD_TEXT

public static int HINDI_CARD_TEXT

Numeric formatting. Formats a numeric result using sequential numbers from the Hindi counting system.

HINDI_LETTER_1

public static int HINDI_LETTER_1

Numeric formatting. Formats a numeric result using Hindi vowels.

HINDI_LETTER_2

public static int HINDI_LETTER_2

Numeric formatting. Formats a numeric result using Hindi consonants.

IROHA

public static int IROHA

Numeric formatting. Formats a numeric result using the Japanese iroha.

KANJI_NUM_1

public static int KANJI_NUM_1

Numeric formatting. Formats a numeric result using a Japanese style using the appropriate counting system.

KANJI_NUM_2

public static int KANJI_NUM_2

Numeric formatting. Formats a numeric result using the appropriate counting system.

KANJI_NUM_3

public static int KANJI_NUM_3

Numeric formatting. Formats a numeric result using the appropriate counting system.

LOWER

public static int LOWER

Text formatting. All letters are lowercase.

LOWERCASE_ALPHABETIC

public static int LOWERCASE_ALPHABETIC

Numeric formatting. Formats a numeric result as one or more occurrences of an lowercase alphabetic Latin character.

LOWERCASE_ROMAN

public static int LOWERCASE_ROMAN

Numeric formatting. Lowercase Roman (i, ii, iii, …).

MERGE_FORMAT

public static int MERGE_FORMAT

Field result formatting. The MERGEFORMAT instruction.

MERGE_FORMAT_INET

public static int MERGE_FORMAT_INET

Field result formatting. The MERGEFORMATINET instruction.

NONE

public static int NONE

Used to specify a missing general format.

ORDINAL

public static int ORDINAL

Numeric formatting. Ordinal (1st, 2nd, 3rd, …).

ORD_TEXT

public static int ORD_TEXT

Numeric formatting. Ordinal text (First, Second, Third, …).

SB_CHAR

public static int SB_CHAR

THAI_ARABIC

public static int THAI_ARABIC

Numeric formatting. Formats a numeric result using Thai numbers.

THAI_CARD_TEXT

public static int THAI_CARD_TEXT

Numeric formatting. Formats a numeric result using sequential numbers from the Thai counting system.

THAI_LETTER

public static int THAI_LETTER

Numeric formatting. Formats a numeric result using Thai letters.

UPPER

public static int UPPER

Text formatting. All letters are uppercase.

UPPERCASE_ALPHABETIC

public static int UPPERCASE_ALPHABETIC

Numeric formatting. Formats a numeric result as one or more occurrences of an uppercase alphabetic Latin character.

UPPERCASE_ROMAN

public static int UPPERCASE_ROMAN

Numeric formatting. Uppercase Roman (I, II, III, …).

VIET_CARD_TEXT

public static int VIET_CARD_TEXT

Numeric formatting. Formats a numeric result using Vietnamese numerals.

ZODIAC_1

public static int ZODIAC_1

Numeric formatting. Formats a numeric result using sequential numerical traditional ideographs.

ZODIAC_2

public static int ZODIAC_2

Numeric formatting. Formats a numeric result using sequential zodiac ideographs.

ZODIAC_3

public static int ZODIAC_3

Numeric formatting. Formats a numeric result using sequential traditional zodiac ideographs.

length

public static int length

fromName(String generalFormatName)

public static int fromName(String generalFormatName)

Parameters:

ParameterTypeDescription
generalFormatNamejava.lang.String

Returns: int

getName(int generalFormat)

public static String getName(int generalFormat)

Parameters:

ParameterTypeDescription
generalFormatint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int generalFormat)

public static String toString(int generalFormat)

Parameters:

ParameterTypeDescription
generalFormatint

Returns: java.lang.String