com.pdfunit.validators

## Class SingleFieldValidator

- java.lang.Object
- - com.pdfunit.validators.AbstractValidator
  - - com.pdfunit.validators.SingleFieldValidator

-     @DoNotObfuscate
      public final class SingleFieldValidator
      extends com.pdfunit.validators.AbstractValidator

  Validator for a single field of an acro form in PDF documents.
  Since:
    2016.05
  Author:
    Carsten Siedentop, January 2016

- - ### Property Summary

    Properties
    Type | Property and Description
    --- | ---
    `FieldPropertyValidator` | `with` This method prepares the validator to check field properties.

  - ### Field Summary

    - ### Fields inherited from class com.pdfunit.validators.AbstractValidator

      `testDocument`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SingleFieldValidator(com.pdfunit.validators.AbstractValidator validator, org.apache.commons.collections4.multimap.ArrayListValuedHashMap<java.lang.String,com.pdfunit.internal.spi.IField> allFields)`
    `protected` | `SingleFieldValidator(DocumentValidator documentValidator)` Creating a validator for a single field of an acro form in PDF documents.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `SingleFieldValidator` | `containing(java.lang.String expectedContent)` Validating that the content of the current field contains the value given by the parameter.
    `SingleFieldValidator` | `endingWith(java.lang.String expectedEnd)` Validating that the content of the current field ends with the value given by the parameter.
    `SingleFieldValidator` | `equalsTo(java.lang.String expectedValue)` Validating that the content of the current field is equal to the given parameter.
    `SingleFieldValidator` | `hasField(java.lang.String expectedFieldName)` Verify that a field with the given name exists.
    `SingleFieldValidator` | `matchingRegex(java.lang.String regex)` Validating that the content of the current field matches the regular expression.
    `SingleFieldValidator` | `notContaining(java.lang.String notExpectedContent)` Validating that the content of the current field does NOT contain the value given by the parameter.
    `SingleFieldValidator` | `notMatchingRegex(java.lang.String regex)` Validating that the content of the current field does not match the regular expression.
    `SingleFieldValidator` | `ofType(FieldType expectedType)` This method checks the type of the current field.
    `SingleFieldValidator` | `startingWith(java.lang.String expectedStart)` Validating that the content of the current field starts with the value given by the parameter.
    `SingleFieldValidator` | `withHeight(int expectedHeight)` This method verifies that the current field has the width equals to the given parameter.
    `SingleFieldValidator` | `withHeight(int expectedHeight, FormatUnit formatUnit, int allowedDelta)` This method verifies that the current field has the width equals to the given parameter.
    `SingleFieldJavaScriptValidator` | `withJavaScript()` This method reads all JavaScript functions that are associated to the current field.
    `SingleFieldValidator` | `withoutTextOverflow()` This method validates that the content of the current field fits inside the size of the field.
    `FieldPropertyValidator` | `withProperty()` This method prepares the validator to check field properties.
    `SingleFieldValidator` | `withText()` This method checks whether a field has any text.
    `SingleFieldValidator` | `withWidth(int expectedWidth)` This method verifies that the current field has the width equals to the given parameter.
    `SingleFieldValidator` | `withWidth(int expectedWidth, FormatUnit formatUnit, int allowedDelta)` This method verifies that the current field has the width equals to the given parameter.

    - ### Methods inherited from class com.pdfunit.validators.AbstractValidator

      `closeDocument, equals, getDocument, hashCode`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Property Detail

    - #### with

      This method prepares the validator to check field properties.

  - ### Constructor Detail

    - #### SingleFieldValidator

          protected SingleFieldValidator(DocumentValidator documentValidator)

      Creating a validator for a single field of an acro form in PDF documents.

    - #### SingleFieldValidator

          protected SingleFieldValidator(com.pdfunit.validators.AbstractValidator validator,
                              org.apache.commons.collections4.multimap.ArrayListValuedHashMap<java.lang.String,com.pdfunit.internal.spi.IField> allFields)

  - ### Method Detail

    - #### containing

          @Guarded
          public SingleFieldValidator containing(java.lang.String expectedContent)

      Validating that the content of the current field contains the value given by the parameter.

    - #### endingWith

          @Guarded
          public SingleFieldValidator endingWith(java.lang.String expectedEnd)

      Validating that the content of the current field ends with the value given by the parameter.

    - #### hasField

          @Guarded
          public SingleFieldValidator hasField(java.lang.String expectedFieldName)

      Verify that a field with the given name exists. When a field is found, it is kept statefully for further validations.

      When the field not exists, an instance of PDFUnitValidationException or a subclass of it will be thrown.

    - #### equalsTo

          @Guarded
          public SingleFieldValidator equalsTo(java.lang.String expectedValue)

      Validating that the content of the current field is equal to the given parameter.

    - #### matchingRegex

          @Guarded
          public SingleFieldValidator matchingRegex(java.lang.String regex)

      Validating that the content of the current field matches the regular expression.

    - #### notContaining

          @Guarded
          public SingleFieldValidator notContaining(java.lang.String notExpectedContent)

      Validating that the content of the current field does NOT contain the value given by the parameter.

    - #### notMatchingRegex

          @Guarded
          public SingleFieldValidator notMatchingRegex(java.lang.String regex)

      Validating that the content of the current field does not match the regular expression. This method is provided, because regular expressions are designed to find something, but not to look for something that is not there.

    - #### ofType

          @Guarded
          public SingleFieldValidator ofType(FieldType expectedType)

      This method checks the type of the current field.
      See Also:
        `FieldType`

    - #### startingWith

          @Guarded
          public SingleFieldValidator startingWith(java.lang.String expectedStart)

      Validating that the content of the current field starts with the value given by the parameter.

    - #### withHeight

          @Guarded
          public SingleFieldValidator withHeight(int expectedHeight)

      This method verifies that the current field has the width equals to the given parameter. The format unit ars 'POINTS'.

    - #### withHeight

          @Guarded
          public SingleFieldValidator withHeight(int expectedHeight,
                                                FormatUnit formatUnit,
                                                int allowedDelta)

      This method verifies that the current field has the width equals to the given parameter. The value is of the unit of the second parameter.
      See Also:
        `FormatUnit`

    - #### withJavaScript

          public SingleFieldJavaScriptValidator withJavaScript()

      This method reads all JavaScript functions that are associated to the current field. If no associated JavaScript exist, an exception is thrown.

    - #### withProperty

          public FieldPropertyValidator withProperty()

      This method prepares the validator to check field properties.

    - #### withText

          public SingleFieldValidator withText()

      This method checks whether a field has any text.

    - #### withWidth

          @Guarded
          public SingleFieldValidator withWidth(int expectedWidth)

      This method verifies that the current field has the width equals to the given parameter. The format unit is 'POINTS'.

    - #### withWidth

          @Guarded
          public SingleFieldValidator withWidth(int expectedWidth,
                                               FormatUnit formatUnit,
                                               int allowedDelta)

      This method verifies that the current field has the width equals to the given parameter. The value is of the unit of the second parameter.
      See Also:
        `FormatUnit`

    - #### withoutTextOverflow

          public SingleFieldValidator withoutTextOverflow()

      This method validates that the content of the current field fits inside the size of the field.

      Only fields of type "button" and "text" are checked, no "choice" and no "sig". Also password fields are not checked.

Copyright (C) PDFUnit.com. See here for license.