Package org.apache.poi.ss.formula
Class EvaluationConditionalFormatRule
- java.lang.Object
-
- org.apache.poi.ss.formula.EvaluationConditionalFormatRule
-
- All Implemented Interfaces:
Comparable<EvaluationConditionalFormatRule>
public class EvaluationConditionalFormatRule extends Object implements Comparable<EvaluationConditionalFormatRule>
Abstracted and cached version of a Conditional Format rule for use with aConditionalFormattingEvaluator
. This references a rule, its owningConditionalFormatting
, its priority order (lower index = higher priority in Excel), and the information needed to evaluate the rule for a given cell.Having this all combined and cached avoids repeated access calls to the underlying structural objects, XSSF CT* objects and HSSF raw byte structures. Those objects can be referenced from here. This object will be out of sync if anything modifies the referenced structures' evaluation properties.
The assumption is that consuming applications will read the display properties once and create whatever style objects they need, caching those at the application level. Thus this class only caches values needed for evaluation, not display.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
EvaluationConditionalFormatRule.ValueAndFormat
Note: this class has a natural ordering that is inconsistent with equals.
-
Constructor Summary
Constructors Constructor Description EvaluationConditionalFormatRule(WorkbookEvaluator workbookEvaluator, Sheet sheet, ConditionalFormatting formatting, int formattingIndex, ConditionalFormattingRule rule, int ruleIndex, CellRangeAddress[] regions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(EvaluationConditionalFormatRule o)
Per Excel Help, XSSF rule priority is sheet-wide, not just within the owning ConditionalFormatting object.boolean
equals(Object obj)
Defined as equal sheet name and formatting and rule indexesSet<EvaluationConditionalFormatRule.ValueAndFormat>
evaluateDuplicateValues(List<EvaluationConditionalFormatRule.ValueAndFormat> allValues)
ConditionalFormatting
getFormatting()
int
getFormattingIndex()
String
getFormula1()
String
getFormula2()
ExcelNumberFormat
getNumberFormat()
org.apache.poi.ss.formula.OperatorEnum
getOperator()
int
getPriority()
CellRangeAddress[]
getRegions()
ConditionalFormattingRule
getRule()
int
getRuleIndex()
Sheet
getSheet()
String
getText()
ConditionType
getType()
int
hashCode()
-
-
-
Constructor Detail
-
EvaluationConditionalFormatRule
public EvaluationConditionalFormatRule(WorkbookEvaluator workbookEvaluator, Sheet sheet, ConditionalFormatting formatting, int formattingIndex, ConditionalFormattingRule rule, int ruleIndex, CellRangeAddress[] regions)
- Parameters:
formattingIndex
- for priority, zero basedruleIndex
- for priority, zero based, if this is an HSSF rule. Unused for XSSF rulesregions
- could be read from formatting, but every call creates new objects in a new array. this allows calling it once per formatting instance, and re-using the array.
-
-
Method Detail
-
getSheet
public Sheet getSheet()
- Returns:
- sheet
-
getFormatting
public ConditionalFormatting getFormatting()
- Returns:
- the formatting
-
getFormattingIndex
public int getFormattingIndex()
- Returns:
- conditional formatting index
-
getNumberFormat
public ExcelNumberFormat getNumberFormat()
- Returns:
- Excel number format string to apply to matching cells, or null to keep the cell default
-
getRule
public ConditionalFormattingRule getRule()
- Returns:
- the rule
-
getRuleIndex
public int getRuleIndex()
- Returns:
- rule index
-
getRegions
public CellRangeAddress[] getRegions()
- Returns:
- the regions
-
getPriority
public int getPriority()
- Returns:
- the priority
-
getFormula1
public String getFormula1()
- Returns:
- the formula1
-
getFormula2
public String getFormula2()
- Returns:
- the formula2
-
getText
public String getText()
- Returns:
- condition text if any, or null
-
getOperator
public org.apache.poi.ss.formula.OperatorEnum getOperator()
- Returns:
- the operator
-
getType
public ConditionType getType()
- Returns:
- the type
-
equals
public boolean equals(Object obj)
Defined as equal sheet name and formatting and rule indexes
-
compareTo
public int compareTo(EvaluationConditionalFormatRule o)
Per Excel Help, XSSF rule priority is sheet-wide, not just within the owning ConditionalFormatting object. This can be seen by creating 4 rules applying to two different ranges and examining the XML.HSSF priority is based on definition/persistence order.
- Specified by:
compareTo
in interfaceComparable<EvaluationConditionalFormatRule>
- Returns:
- comparison based on sheet name, formatting index, and rule priority
-
evaluateDuplicateValues
public Set<EvaluationConditionalFormatRule.ValueAndFormat> evaluateDuplicateValues(List<EvaluationConditionalFormatRule.ValueAndFormat> allValues)
-
-