Package org.apache.poi.ss.format
Class CellFormatPart
- java.lang.Object
-
- org.apache.poi.ss.format.CellFormatPart
-
public class CellFormatPart extends Object
Objects of this class represent a single part of a cell format expression. Each cell can have up to four of these for positive, zero, negative, and text values.Each format part can contain a color, a condition, and will always contain a format specification. For example
"[Red][>=10]#"has a color ([Red]), a condition (>=10) and a format specification (#).This class also contains patterns for matching the subparts of format specification. These are used internally, but are made public in case other code has use for them.
-
-
Field Summary
Fields Modifier and Type Field Description static intCOLOR_GROUPWithinFORMAT_PAT, the group number for the matched color.static PatternCOLOR_PATPattern for the color part of a cell format part.static intCONDITION_OPERATOR_GROUPWithinFORMAT_PAT, the group number for the operator in the condition.static PatternCONDITION_PATPattern for the condition part of a cell format part.static intCONDITION_VALUE_GROUPWithinFORMAT_PAT, the group number for the value in the condition.static PatternCURRENCY_PATPattern for the currency symbol part of a cell format partstatic PatternFORMAT_PATPattern for an entire cell single part.static intLOCALE_GROUPWithinFORMAT_PAT, the group number for the matched locale code.static PatternLOCALE_PATstatic intSPECIFICATION_GROUPWithinFORMAT_PAT, the group number for the format specification.static PatternSPECIFICATION_PATPattern for the format specification part of a cell format part.
-
Constructor Summary
Constructors Constructor Description CellFormatPart(String desc)Create an object to represent a format part.CellFormatPart(Locale locale, String desc)Create an object to represent a format part.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapplies(Object valueObject)Returnstrueif this format part applies to the given value.CellFormatResultapply(Object value)Apply this format part to the given value.CellFormatResultapply(JLabel label, Object value)Apply this format part to the given value, applying the result to the given label.static Stringgroup(Matcher m, int g)Returns the string from the group, or""if the group isnull.static StringBufferparseFormat(String fdesc, CellFormatType type, org.apache.poi.ss.format.CellFormatPart.PartHandler partHandler)protected voidsetSectionFourTextFormat(boolean sectionFour)StringtoString()
-
-
-
Field Detail
-
COLOR_PAT
public static final Pattern COLOR_PAT
Pattern for the color part of a cell format part.
-
CONDITION_PAT
public static final Pattern CONDITION_PAT
Pattern for the condition part of a cell format part.
-
SPECIFICATION_PAT
public static final Pattern SPECIFICATION_PAT
Pattern for the format specification part of a cell format part.
-
CURRENCY_PAT
public static final Pattern CURRENCY_PAT
Pattern for the currency symbol part of a cell format part
-
FORMAT_PAT
public static final Pattern FORMAT_PAT
Pattern for an entire cell single part.
-
LOCALE_PAT
public static final Pattern LOCALE_PAT
-
LOCALE_GROUP
public static final int LOCALE_GROUP
WithinFORMAT_PAT, the group number for the matched locale code.
-
COLOR_GROUP
public static final int COLOR_GROUP
WithinFORMAT_PAT, the group number for the matched color.
-
CONDITION_OPERATOR_GROUP
public static final int CONDITION_OPERATOR_GROUP
WithinFORMAT_PAT, the group number for the operator in the condition.
-
CONDITION_VALUE_GROUP
public static final int CONDITION_VALUE_GROUP
WithinFORMAT_PAT, the group number for the value in the condition.
-
SPECIFICATION_GROUP
public static final int SPECIFICATION_GROUP
WithinFORMAT_PAT, the group number for the format specification.
-
-
Constructor Detail
-
CellFormatPart
public CellFormatPart(String desc)
Create an object to represent a format part.- Parameters:
desc- The string to parse.
-
-
Method Detail
-
applies
public boolean applies(Object valueObject)
Returnstrueif this format part applies to the given value. If the value is a number and this is part has a condition, returnstrueonly if the number passes the condition. Otherwise, this always returntrue.- Parameters:
valueObject- The value to evaluate.- Returns:
trueif this format part applies to the given value.
-
apply
public CellFormatResult apply(Object value)
Apply this format part to the given value. This returns aCellFormatResultobject with the results.- Parameters:
value- The value to apply this format part to.- Returns:
- A
CellFormatResultobject containing the results of applying the format to the value.
-
apply
public CellFormatResult apply(JLabel label, Object value)
Apply this format part to the given value, applying the result to the given label.- Parameters:
label- The labelvalue- The value to apply this format part to.- Returns:
trueif the
-
parseFormat
public static StringBuffer parseFormat(String fdesc, CellFormatType type, org.apache.poi.ss.format.CellFormatPart.PartHandler partHandler)
-
group
public static String group(Matcher m, int g)
Returns the string from the group, or""if the group isnull.- Parameters:
m- The matcher.g- The group number.- Returns:
- The group or
"".
-
setSectionFourTextFormat
protected void setSectionFourTextFormat(boolean sectionFour)
-
-