Class PictureFmt


  • public final class PictureFmt
    extends java.lang.Object
    The PictureFmt class defines methods to parse and format data according to XFA picture patterns. Here's a snippet of code illustrating its use to format a date string:
    
         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

    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.