Class AddIndexStrategy
- java.lang.Object
-
- com.itextpdf.forms.fields.merging.AddIndexStrategy
-
- All Implemented Interfaces:
OnDuplicateFormFieldNameStrategy
public class AddIndexStrategy extends java.lang.Object implements OnDuplicateFormFieldNameStrategy
AOnDuplicateFormFieldNameStrategyimplementation that adds an index to the field name of the second field
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap<java.lang.String,java.lang.Integer>countMapprivate static java.lang.StringDEFAULT_SEPARATORprivate java.lang.StringregexStringprivate java.lang.Stringseparator
-
Constructor Summary
Constructors Constructor Description AddIndexStrategy()Creates a newAddIndexStrategyinstance.AddIndexStrategy(java.lang.String separator)Creates a newAddIndexStrategyinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanexecute(PdfFormField firstField, PdfFormField secondField, boolean throwExceptionOnError)Renames the second field by adding an index to its name.(package private) intgetNextIndex(java.lang.String name)
-
-
-
Field Detail
-
DEFAULT_SEPARATOR
private static final java.lang.String DEFAULT_SEPARATOR
- See Also:
- Constant Field Values
-
separator
private final java.lang.String separator
-
countMap
private final java.util.HashMap<java.lang.String,java.lang.Integer> countMap
-
regexString
private final java.lang.String regexString
-
-
Constructor Detail
-
AddIndexStrategy
public AddIndexStrategy(java.lang.String separator)
Creates a newAddIndexStrategyinstance.- Parameters:
separator- the separator that will be used to separate the original field name and the index
-
AddIndexStrategy
public AddIndexStrategy()
Creates a newAddIndexStrategyinstance. The default separator will be used to separate the original field name and the index. the default separator is "_"
-
-
Method Detail
-
execute
public boolean execute(PdfFormField firstField, PdfFormField secondField, boolean throwExceptionOnError)
Renames the second field by adding an index to its name.- Specified by:
executein interfaceOnDuplicateFormFieldNameStrategy- Parameters:
firstField- the first fieldsecondField- the second fieldthrowExceptionOnError- if true, an exception will be thrown- Returns:
- returns
falsevalue, sinceAddIndexStrategynever merges fields.
-
getNextIndex
int getNextIndex(java.lang.String name)
-
-