Class Strlen

    • Constructor Summary

      Constructors 
      Constructor Description
      Strlen​(int... requiredLengths)
      Constructs a new Strlen processor, which ensures that the input String has a length equal to any of the supplied lengths.
      Strlen​(int[] requiredLengths, CellProcessor next)
      Constructs a new Strlen processor, which ensures that the input String has a length equal to any of the supplied lengths, then calls the next processor in the chain.
      Strlen​(int requiredLength, CellProcessor next)
      Constructs a new Strlen processor, which ensures that the input String has a length equal to the supplied length, then calls the next processor in the chain.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void checkAndAddLengths​(int... requiredLengths)
      Adds each required length, ensuring it isn't negative.
      private static void checkPreconditions​(int... requiredLengths)
      Checks the preconditions for creating a new Strlen processor.
      java.lang.Object execute​(java.lang.Object value, CsvContext context)
      This method is invoked by the framework when the processor needs to process data or check constraints.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • requiredLengths

        private final java.util.Set<java.lang.Integer> requiredLengths
    • Constructor Detail

      • Strlen

        public Strlen​(int... requiredLengths)
        Constructs a new Strlen processor, which ensures that the input String has a length equal to any of the supplied lengths.
        Parameters:
        requiredLengths - one or more required lengths
        Throws:
        java.lang.NullPointerException - if requiredLengths is null
        java.lang.IllegalArgumentException - if requiredLengths is empty or contains a negative length
      • Strlen

        public Strlen​(int requiredLength,
                      CellProcessor next)
        Constructs a new Strlen processor, which ensures that the input String has a length equal to the supplied length, then calls the next processor in the chain.
        Parameters:
        requiredLength - the required length
        next - the next processor in the chain
        Throws:
        java.lang.NullPointerException - if next is null
        java.lang.IllegalArgumentException - if requiredLength is negative
      • Strlen

        public Strlen​(int[] requiredLengths,
                      CellProcessor next)
        Constructs a new Strlen processor, which ensures that the input String has a length equal to any of the supplied lengths, then calls the next processor in the chain.
        Parameters:
        requiredLengths - one or more required lengths
        next - the next processor in the chain
        Throws:
        java.lang.NullPointerException - if requiredLengths or next is null
        java.lang.IllegalArgumentException - if requiredLengths is empty or contains a negative length
    • Method Detail

      • checkPreconditions

        private static void checkPreconditions​(int... requiredLengths)
        Checks the preconditions for creating a new Strlen processor.
        Parameters:
        requiredLengths - one or more required lengths
        Throws:
        java.lang.NullPointerException - if requiredLengths is null
        java.lang.IllegalArgumentException - if requiredLengths is empty
      • checkAndAddLengths

        private void checkAndAddLengths​(int... requiredLengths)
        Adds each required length, ensuring it isn't negative.
        Parameters:
        requiredLengths - one or more required lengths
        Throws:
        java.lang.IllegalArgumentException - if a supplied length is negative
      • execute

        public java.lang.Object execute​(java.lang.Object value,
                                        CsvContext context)
        This method is invoked by the framework when the processor needs to process data or check constraints.
        Specified by:
        execute in interface CellProcessor
        Parameters:
        value - the value to be processed
        context - the CSV context
        Returns:
        the result of cell processor execution
        Throws:
        SuperCsvCellProcessorException - if value is null
        SuperCsvConstraintViolationException - if the length of value isn't one of the required lengths