public final class PictureFmt extends Object
import com.adobe.xfa.ut.PictureFmt;
...
StringBufer sResult = new StringBuilder();
PictureFmt oFmt = new PictureFmt("en");
if (oFmt.parse("28/2/2000", "D/M/YYYY", sResult))
oFmt.format(sResult.toString(), "EEEE', the 'D' of 'MMMM', 'YYYY", sResult)
...
PictureFmt also defines methods to validate picture patterns. Specifically, the methods
isDatePictureValid(String)
,
isTimePictureValid(String)
,
isNumericPictureValid(String)
,
isTextPictureValid(String)
,
isZeroPictureValid(String)
, and,
isNullPictureValid(String)
.
are used for validating the syntax of the given source for each of the
six categories of pictures. This includes validating the well-formedness of
patterns like
category{subpicture}
and
category(locale){subpicture}
,
validating the well-formedness of literals, and ensuring the given source
symbols all belong to one category of picture. As an example,
the time picture pattern:
h:MM:SS 'o'clock 'A X
is syntactically invalid - a quote is missing and X is not a valid time
picture symbol.
PictureFmt also defines methods to semantically validate picture patterns. The methods
are used for semantially validating the given picture. This means that the combination of XFA symbols constitutes a valid XFA picture pattern. A time picture pattern like:
h:MM:SS 'o''clock 'Z
is semantically invalid when used to parse time input -- requesting a time
from a 12-hour clock without the meridiem could never yield a correct time
value. A date picture pattern like: EEEE, MMMM YYYY is semantically invalid
when used to parse date input -- requesting a date without the day of the
month could never yield a correct date value.
Do note however, that semantically invalid pictures patterns are used in output formatting in acceptable circumstances. So apply these method with discretion.
Constructor and Description |
---|
PictureFmt(String sLocale)
Instantiates an PictureFmt object.
|
Modifier and Type | Method and Description |
---|---|
static String |
FF99ToXFA(String sPicture)
Converts a F99 picture to an equivalent XFA picture.
|
boolean |
format(String sSource,
String sPicture,
StringBuilder sResult)
Formats a given data source according to the given picture.
|
static boolean |
formatCompound(String sSource,
String sPicture,
String sLocale,
StringBuilder sResult)
Formats a given data source according to the given compound picture
under the given locale.
|
static boolean |
formatDate(String sSource,
String sPicture,
String sLocale,
StringBuilder sResult,
boolean bAsLocal)
Formats a given data source according to the given date picture
under the given locale.
|
static boolean |
formatDateTime(String sSource,
String sPicture,
String sDateMask,
String sTimeMask,
String sLocale,
StringBuilder sResult,
boolean bAsLocal)
Formats a given data source according to the given datetime picture
under the given locale.
|
static boolean |
formatNull(String sSource,
String sPicture,
String sLocale,
StringBuilder sResult)
Formats a given data source according to the given null picture
under the given locale.
|
static boolean |
formatNumeric(String sSource,
String sPicture,
String sLocale,
StringBuilder sResult)
Formats a given data source according to the given numeric picture
under the given locale.
|
static boolean |
formatText(String sSource,
String sPicture,
String sLocale,
StringBuilder sResult)
Formats a given data source according to the given text picture
under the given locale.
|
static boolean |
formatTime(String sSource,
String sPicture,
String sLocale,
StringBuilder sResult,
boolean bAsLocal)
Formats a given data source according to the given time picture
under the given locale.
|
static boolean |
formatZero(String sSource,
String sPicture,
String sLocale,
StringBuilder sResult)
Formats a given data source according to the given zero picture
under the given locale.
|
static boolean |
getAlternates(String sSource,
List<String> oAlternates)
Gets all the picture alternatives.
|
static boolean |
getLocaleFromPicture(String sPicture,
String sCategory,
StringBuilder sLocale)
Gets the locale given a valid picture and category.
|
static boolean |
hasSubPicture(String sPicture,
int nPictIndex,
StringBuilder sCategory,
StringBuilder sLocale,
StringBuilder sSubMask)
Determines if the given picture has a sub-picture.
|
static boolean |
isDatePicture(String sPicture)
Determines if the given picture is a date picture.
|
static boolean |
isDatePictureValid(String sPicture)
Determines if the given date picture is (semantically) valid.
|
static boolean |
isDateTimePicture(String sPicture,
StringBuilder sDateMask,
StringBuilder sTimeMask)
Determines if the given picture is a date time picture.
|
static boolean |
isDateTimePictureValid(String sPicture)
Determimes if the given datetime picture is (semantically) valid.
|
static boolean |
isEmptyPicture(String sPicture)
Determines if the given picture is an empty picture.
|
static boolean |
isNullPicture(String sPicture)
Determines if the given picture is a null picture.
|
static boolean |
isNullPictureValid(String sPicture)
Determimes if the given null picture is (semantically) valid.
|
static boolean |
isNumericPicture(String sPicture)
Determimes if the given picture is a numeric picture.
|
static boolean |
isNumericPictureValid(String sPicture)
Determimes if the given numeric picture is (semantically) valid.
|
static boolean |
isSubPicture(String sPicture,
int nPictIndex,
StringBuilder sCategory,
StringBuilder sLocale,
StringBuilder sSubMask)
Determimes if the given picture has a sub-picture,
and if so, returns the picture's category, locale, and sub-picture.
|
static boolean |
isTextPicture(String sPicture)
Determines if the given picture is a text picture.
|
static boolean |
isTextPictureValid(String sPicture)
Determines if the given text picture is (semantically) valid.
|
static boolean |
isTimePicture(String sPicture)
Determines if the given picture is a time picture.
|
static boolean |
isTimePictureValid(String sPicture)
Determines if the given time picture is (semantically) valid.
|
static boolean |
isZeroPicture(String sPicture)
Determines if the given picture is a zero picture.
|
static boolean |
isZeroPictureValid(String sPicture)
Determines if the given zero picture is (semantically) valid.
|
String |
parse(String sSource,
String sPicture,
BooleanHolder pbSuccess)
Parses a given data source according to the given picture.
|
static boolean |
parseCompound(String sSource,
String sPicture,
String sLocale,
StringHolder sResult)
Parses a given data source according to the given compound picture
under the given locale.
|
static boolean |
parseDate(String sSource,
String sPicture,
String sLocale,
StringHolder sResult,
boolean bAsLocal)
Parses a given data source according to the given date picture
under the given locale.
|
static boolean |
parseDateTime(String sSource,
String sPicture,
String sDateMask,
String sTimeMask,
String sLocale,
StringHolder sResult,
boolean bAsLocal)
Parses a given data source according to the given datetime picture
under the given locale.
|
static boolean |
parseNull(String sSource,
String sPicture,
String sLocale,
StringHolder sResult)
Parses a given data source according to the given null picture
under the given locale.
|
static boolean |
parseNumeric(String sSource,
String sPicture,
String sLocale,
StringHolder sResult)
Parses a given data source according to the given numeric picture
under the given locale.
|
static boolean |
parseText(String sSource,
String sPicture,
String sLocale,
StringHolder sResult)
Parses a given data source according to the given text picture
under the given locale.
|
static boolean |
parseTime(String sSource,
String sPicture,
String sLocale,
StringHolder sResult,
boolean bAsLocal)
Parses a given data source according to the given time picture
under the given locale.
|
static boolean |
parseZero(String sSource,
String sPicture,
String sLocale,
StringHolder sResult)
Parses a given data source according to the given zero picture
under the given locale.
|
static Point |
resolveRange(String s,
int startIndex,
int endIndex) |
public PictureFmt(String sLocale)
sLocale
- the locale name.public boolean format(String sSource, String sPicture, StringBuilder sResult)
sSource
- the source data in canonical format.sPicture
- the formatting picture.sResult
- the resulting string, which may be empty upon error.public String parse(String sSource, String sPicture, BooleanHolder pbSuccess)
sSource
- the source data.sPicture
- the parsing picture.pbSuccess
- the canonical result.public static String FF99ToXFA(String sPicture)
sPicture
- the source picture.public static boolean formatCompound(String sSource, String sPicture, String sLocale, StringBuilder sResult)
sSource
- the source data.sPicture
- the compound picture.sLocale
- the locale name.sResult
- the resulting string, which may be empty upon error.public static boolean formatDate(String sSource, String sPicture, String sLocale, StringBuilder sResult, boolean bAsLocal)
sSource
- the source data.sPicture
- the date picture.sLocale
- the locale name.sResult
- the resulting string, which may be empty upon error.bAsLocal
- interpret the source data as a local date when true,
and a GMT date when false.public static boolean formatDateTime(String sSource, String sPicture, String sDateMask, String sTimeMask, String sLocale, StringBuilder sResult, boolean bAsLocal)
sSource
- the source data.sPicture
- the datetime picture.sDateMask
- the date sub-picture.sTimeMask
- the time sub-picture.sLocale
- the locale name.sResult
- the resulting string, which may be empty upon error.bAsLocal
- interpret the data source as locale datetime when true,
and GMT datetime when false.public static boolean formatNull(String sSource, String sPicture, String sLocale, StringBuilder sResult)
sSource
- the source data.sPicture
- the null picture.sLocale
- the locale name.sResult
- the resulting string, which may be empty upon error.public static boolean formatNumeric(String sSource, String sPicture, String sLocale, StringBuilder sResult)
sSource
- the source data.sPicture
- the numeric picture.sLocale
- the locale name.sResult
- the resulting string, which may be empty upon error.public static boolean formatText(String sSource, String sPicture, String sLocale, StringBuilder sResult)
sSource
- the source data.sPicture
- the text picture.sLocale
- the locale name.sResult
- the resulting string, which may be empty upon error.public static boolean formatTime(String sSource, String sPicture, String sLocale, StringBuilder sResult, boolean bAsLocal)
sSource
- the source data.sPicture
- the time picture.sLocale
- the locale name.sResult
- the resulting string, which may be empty upon error.bAsLocal
- interpret the data source as local time when true,
and a GMT time when false.public static boolean formatZero(String sSource, String sPicture, String sLocale, StringBuilder sResult)
sSource
- the source data. It must be empty or zero!sPicture
- the zero picture.sLocale
- the locale name.sResult
- the resulting string, which may be empty upon error.public static boolean getAlternates(String sSource, List<String> oAlternates)
sSource
- the source picture. Alternate pictures are each
separated by the vertical bar '|' character.oAlternates
- the object to be populated with all the alternate
pictures found in the source.public static boolean getLocaleFromPicture(String sPicture, String sCategory, StringBuilder sLocale)
sPicture
- the valid picture.sCategory
- the picture category: one of "date", "time", "num", "text",
"null" or "zero".sLocale
- the returned locale.public static boolean hasSubPicture(String sPicture, int nPictIndex, StringBuilder sCategory, StringBuilder sLocale, StringBuilder sSubMask)
category{subpicture}
or
category(locale){subpicture}
.sPicture
- the picture.nPictIndex
- the starting picture index.sCategory
- the picture's category.sLocale
- the picture's locale.sSubMask
- the picture's sub-picture.public static boolean isDatePicture(String sPicture)
sPicture
- the source picture.public static boolean isDatePictureValid(String sPicture)
sPicture
- the date picture.public static boolean isDateTimePicture(String sPicture, StringBuilder sDateMask, StringBuilder sTimeMask)
sPicture
- the source picture.sDateMask
- the returned date picture found in the given source picture.sTimeMask
- the returned time picture found in the given source picture.public static boolean isDateTimePictureValid(String sPicture)
sPicture
- the datetime picture.public static boolean isNullPicture(String sPicture)
sPicture
- the source picture.public static boolean isEmptyPicture(String sPicture)
sPicture
- the source picture.public static boolean isNullPictureValid(String sPicture)
sPicture
- the null picture.public static boolean isNumericPicture(String sPicture)
sPicture
- the source picture.public static boolean isNumericPictureValid(String sPicture)
sPicture
- the numeric picture.public static boolean isSubPicture(String sPicture, int nPictIndex, StringBuilder sCategory, StringBuilder sLocale, StringBuilder sSubMask)
sPicture
- the source picture.nPictIndex
- the starting character index within the given source picture.sCategory
- the picture's category.sLocale
- the picture's locale.sSubMask
- the picture's sub-picture.public static boolean isTextPicture(String sPicture)
sPicture
- the source picture.public static boolean isTextPictureValid(String sPicture)
sPicture
- the text picture.public static boolean isTimePicture(String sPicture)
sPicture
- the source picture.public static boolean isTimePictureValid(String sPicture)
sPicture
- the time picture.public static boolean isZeroPicture(String sPicture)
sPicture
- the source picture.public static boolean isZeroPictureValid(String sPicture)
sPicture
- the zero picture.public static boolean parseCompound(String sSource, String sPicture, String sLocale, StringHolder sResult)
sSource
- the source data.sPicture
- the compound picture.sLocale
- the locale name.sResult
- the resulting canonical string, which may be empty upon error.public static boolean parseDate(String sSource, String sPicture, String sLocale, StringHolder sResult, boolean bAsLocal)
sSource
- the source data.sPicture
- the date picture.sLocale
- the locale name.sResult
- the resulting canonical string, which may be empty upon error.bAsLocal
- return the canonical result as a local date when true,
and as a GMT date when false.public static boolean parseDateTime(String sSource, String sPicture, String sDateMask, String sTimeMask, String sLocale, StringHolder sResult, boolean bAsLocal)
sSource
- the source data.sPicture
- the datetime picture.sDateMask
- the date sub-picture.sTimeMask
- the time sub-picture.sLocale
- the locale name.sResult
- the resulting canonical string, which may be empty upon error.bAsLocal
- return the canonical result as a local datetime when true,
and as a GMT datetime value when false.public static boolean parseNull(String sSource, String sPicture, String sLocale, StringHolder sResult)
sSource
- the source data.sPicture
- the null picture.sLocale
- the locale name.sResult
- the resulting canonical string, which may be empty upon error.public static boolean parseNumeric(String sSource, String sPicture, String sLocale, StringHolder sResult)
sSource
- the source data.sPicture
- the numeric picture.sLocale
- the locale name.sResult
- the resulting canonical string, which may be empty upon error.public static boolean parseText(String sSource, String sPicture, String sLocale, StringHolder sResult)
sSource
- the source data.sPicture
- the text picture.sLocale
- the locale name.sResult
- the resulting canonical string, which may be empty upon error.public static boolean parseTime(String sSource, String sPicture, String sLocale, StringHolder sResult, boolean bAsLocal)
sSource
- the source data.sPicture
- the time picture.sLocale
- the locale name.sResult
- the resulting canonical string, which may be empty upon error.public static boolean parseZero(String sSource, String sPicture, String sLocale, StringHolder sResult)
sSource
- the source data.sPicture
- the zero picture.sLocale
- the locale name.sResult
- the resulting canonical string, which may be empty upon error.Copyright © 2010 - 2020 Adobe. All Rights Reserved