requiredLengths[i] = Integer.parseInt(splts[i]); return new Strlen(requiredLengths);
/** * Constructs a new <tt>Strlen</tt> processor, which ensures that the input String has a length equal to any of the * supplied lengths. * * @param requiredLengths * one or more required lengths * @throws NullPointerException * if requiredLengths is null * @throws IllegalArgumentException * if requiredLengths is empty or contains a negative length */ public Strlen(final int... requiredLengths) { super(); checkPreconditions(requiredLengths); checkAndAddLengths(requiredLengths); }
/** * {@inheritDoc} * * @throws SuperCsvCellProcessorException * if value is null * @throws SuperCsvConstraintViolationException * if the length of value isn't one of the required lengths */ public Object execute(final Object value, final CsvContext context) { validateInputNotNull(value, context); final String stringValue = value.toString(); final int length = stringValue.length(); if( !requiredLengths.contains(length) ) { throw new SuperCsvConstraintViolationException(String.format("the length (%d) of value '%s' not any of the required lengths", length, stringValue), context, this); } return next.execute(value, context); }
/** * Constructs a new <tt>Strlen</tt> 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. * * @param requiredLengths * one or more required lengths * @param next * the next processor in the chain * @throws NullPointerException * if requiredLengths or next is null * @throws IllegalArgumentException * if requiredLengths is empty or contains a negative length */ public Strlen(final int[] requiredLengths, final CellProcessor next) { super(next); checkPreconditions(requiredLengths); checkAndAddLengths(requiredLengths); }
cellProcessor = new StrRegEx(pattern); } else if (strLen != null) { cellProcessor = new Strlen(strLen); } else if (maxLength != null || minLength != null) { Long min = minLength == null ? 0L : minLength;
cellProcessor = new StrRegEx(pattern); } else if (strLen != null) { cellProcessor = new Strlen(strLen); } else if (maxLength != null || minLength != null) { Long min = minLength == null ? 0L : minLength;
requiredLengths[i] = Integer.parseInt(splts[i]); return new Strlen(requiredLengths);