Class CssCounterManager
java.lang.Object
com.itextpdf.html2pdf.css.resolve.func.counter.CssCounterManager
Class that manages counters (e.g. for list symbols).
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTargetCounterIfRequired
(com.itextpdf.styledxmlparser.node.IElementNode node) Adds counter value to every counter in the Map corresponding to a node ID.void
addTargetCountersIfRequired
(com.itextpdf.styledxmlparser.node.IElementNode node) Adds counters value to every counter in the Map corresponding to a node ID.void
Clears information about counters.void
incrementCounter
(String counterName) Increments the counter.void
incrementCounter
(String counterName, int incrementValue) Increments the counter.void
popEveryCounterFromCounters
(com.itextpdf.styledxmlparser.node.IElementNode element) Pops every given counter from stack of counters.void
pushEveryCounterToCounters
(com.itextpdf.styledxmlparser.node.IElementNode element) Pushes every current non-null counter to stack of counters.void
resetCounter
(String counterName) Resets the counter.void
resetCounter
(String counterName, int value) Resets the counter.resolveCounter
(String counterName, CounterDigitsGlyphStyle listSymbolType) Resolves a counter.resolveCounters
(String counterName, String counterSeparatorStr, CounterDigitsGlyphStyle listSymbolType) Resolves counters.resolveTargetCounter
(String id, String counterName, CounterDigitsGlyphStyle listSymbolType) Gets target-counter value for specified ID and counterName.resolveTargetCounters
(String id, String counterName, String counterSeparatorStr, CounterDigitsGlyphStyle listSymbolType) Gets target-counter value for specified ID and counterName.
-
Constructor Details
-
CssCounterManager
public CssCounterManager()Creates a newCssCounterManager
instance.
-
-
Method Details
-
clearManager
public void clearManager()Clears information about counters. Target-counter(s) information remains. -
pushEveryCounterToCounters
public void pushEveryCounterToCounters(com.itextpdf.styledxmlparser.node.IElementNode element) Pushes every current non-null counter to stack of counters. This method should be called when we are about to process child nodes.- Parameters:
-
element
- the element which counters shall be pushed
-
popEveryCounterFromCounters
public void popEveryCounterFromCounters(com.itextpdf.styledxmlparser.node.IElementNode element) Pops every given counter from stack of counters. This method should be called when we have finished processing child nodes.- Parameters:
-
element
- the element which counters shall be popped
-
resolveTargetCounter
public String resolveTargetCounter(String id, String counterName, CounterDigitsGlyphStyle listSymbolType) Gets target-counter value for specified ID and counterName. Value is converted according to listSymbolType.- Parameters:
-
id
- ID of the element. The first call adds ID to the Map, which means we require its value. The second call returns corresponding value if we already encountered corresponding element -
counterName
- name of the counter. The first call adds counterName to the Map, which means we require its value. The second call returns corresponding value if we already encountered corresponding element -
listSymbolType
- the list symbol type to convert counter's value. null if conversion is not required. - Returns:
- target-counter value.
-
resolveTargetCounters
public String resolveTargetCounters(String id, String counterName, String counterSeparatorStr, CounterDigitsGlyphStyle listSymbolType) Gets target-counter value for specified ID and counterName. Value is converted according to listSymbolType.- Parameters:
-
id
- ID of the element. The first call adds ID at the Map, which means we require its value. The second call returns corresponding value if we already encountered this element -
counterName
- name of the counter. The first call adds name at the Map, which means we require its value. The second call returns corresponding value if we already encountered this element -
counterSeparatorStr
- separator to separate counters values. -
listSymbolType
- the list symbol type to convert counter's value. null if conversion is not required. - Returns:
- target-counter value.
-
addTargetCounterIfRequired
public void addTargetCounterIfRequired(com.itextpdf.styledxmlparser.node.IElementNode node) Adds counter value to every counter in the Map corresponding to a node ID.- Parameters:
-
node
- node to take ID and scope from
-
addTargetCountersIfRequired
public void addTargetCountersIfRequired(com.itextpdf.styledxmlparser.node.IElementNode node) Adds counters value to every counter in the Map corresponding to a node ID.- Parameters:
-
node
- node to take ID and scope from
-
resolveCounter
Resolves a counter.- Parameters:
-
counterName
- the counter name -
listSymbolType
- the list symbol type - Returns:
-
the counter value as a
String
-
resolveCounters
public String resolveCounters(String counterName, String counterSeparatorStr, CounterDigitsGlyphStyle listSymbolType) Resolves counters.- Parameters:
-
counterName
- the counter name -
counterSeparatorStr
- the counter separator -
listSymbolType
- the list symbol type - Returns:
-
the counters as a
String
-
resetCounter
Resets the counter.- Parameters:
-
counterName
- the counter name
-
resetCounter
Resets the counter.- Parameters:
-
counterName
- the counter name -
value
- the new value
-
incrementCounter
Increments the counter.- Parameters:
-
counterName
- the counter name
-
incrementCounter
Increments the counter.- Parameters:
-
counterName
- the counter name -
incrementValue
- the increment value
-