Package org.docx4j.model.fields
Class FormattingSwitchHelper
java.lang.Object
org.docx4j.model.fields.FormattingSwitchHelper
Formats the string value of the field according to the three possible formatting switches:
+ date-and-time-formatting-switch: \@
+ numeric-formatting-switch: \#
+ general-formatting-switch: \*
Note that the general-formatting-switch arguments CHARFORMAT and MERGEFORMAT are not handled here.
It is the responsibility of the calling code to handle these.
- Author:
- alberto, jharrop
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ThreadLocal<Map<String,SimpleDateFormat>> static final intstatic final intprotected static final StringConversion of page number formats to fo as defined in w:fldSimple in w:pgNumType w:fmtprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringapplyFormattingSwitch(WordprocessingMLPackage wmlPackage, FldSimpleModel model, String value) static StringapplyFormattingSwitch(WordprocessingMLPackage wmlPackage, FldSimpleModel model, String value, String lang) static StringconvertDatePattern(String wordDatePattern) findAllSwitchValues(String switchDef, List<String> fldParameters) static StringfindFirstSwitchValue(String switchDef, List<String> fldParameters, boolean ignoreMergeformat) static intfindSwitch(String switchDef, int startPos, List<String> fldParameters) static StringformatDate(FldSimpleModel model) static StringformatDate(FldSimpleModel model, String format, Date date) static StringformatDate(FldSimpleModel model, Date date) static StringgetFldSimpleName(String instr) static intgetFoPageNumberDecoration(String wordName) Check if the page number format has a decoration (eg.static StringgetFoPageNumberFormat(String wordName) Conversion of the word page number format to the fo page number format.static StringgetSwitchValue(int pos, List<String> fldParameters) static boolean
-
Field Details
-
DATE_FORMATS
-
DEFAULT_FORMAT_PAGE_TO_FO
Conversion of page number formats to fo as defined- in w:fldSimple
- in w:pgNumType w:fmt
- See Also:
-
NONE_STRING
-
FORMAT_PAGE_TO_FO
-
DECORATION_NONE
public static final int DECORATION_NONE- See Also:
-
DECORATION_DASH
public static final int DECORATION_DASH- See Also:
-
MERGEFORMAT
- See Also:
-
FO_PAGENUMBER_DECIMAL
- See Also:
-
FO_PAGENUMBER_LOWERALPHA
- See Also:
-
FO_PAGENUMBER_UPPERALPHA
- See Also:
-
FO_PAGENUMBER_LOWERROMAN
- See Also:
-
FO_PAGENUMBER_UPPERROMAN
- See Also:
-
DATE_FORMAT_ITEMS_TO_JAVA
-
-
Constructor Details
-
FormattingSwitchHelper
public FormattingSwitchHelper()
-
-
Method Details
-
applyFormattingSwitch
public static String applyFormattingSwitch(WordprocessingMLPackage wmlPackage, FldSimpleModel model, String value) throws Docx4JException - Throws:
Docx4JException
-
applyFormattingSwitch
public static String applyFormattingSwitch(WordprocessingMLPackage wmlPackage, FldSimpleModel model, String value, String lang) throws Docx4JException - Throws:
Docx4JException
-
getFoPageNumberFormat
Conversion of the word page number format to the fo page number format.- Parameters:
wordName- word page number format- Returns:
- null if the wordName is null, the correspondig fo value if present or a default.
-
getFoPageNumberDecoration
Check if the page number format has a decoration (eg. dash).- Parameters:
wordName- word page number format- Returns:
- decoration type (one of the DECORATION_xxx constants).
-
getFldSimpleName
-
convertDatePattern
-
formatDate
-
formatDate
-
formatDate
-
hasSwitch
-
findFirstSwitchValue
-
getSwitchValue
-
findAllSwitchValues
-
findSwitch
-