Class AddIndexStrategy

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.HashMap<java.lang.String,​java.lang.Integer> countMap  
      private static java.lang.String DEFAULT_SEPARATOR  
      private java.lang.String regexString  
      private java.lang.String separator  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean execute​(PdfFormField firstField, PdfFormField secondField, boolean throwExceptionOnError)
      Renames the second field by adding an index to its name.
      (package private) int getNextIndex​(java.lang.String name)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 new AddIndexStrategy instance.
        Parameters:
        separator - the separator that will be used to separate the original field name and the index
      • AddIndexStrategy

        public AddIndexStrategy()
        Creates a new AddIndexStrategy instance. 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:
        execute in interface OnDuplicateFormFieldNameStrategy
        Parameters:
        firstField - the first field
        secondField - the second field
        throwExceptionOnError - if true, an exception will be thrown
        Returns:
        true if the second field was renamed successfully, false otherwise
      • getNextIndex

        int getNextIndex​(java.lang.String name)