public class Truncate extends CellProcessorAdaptor implements BoolCellProcessor, DateCellProcessor, DoubleCellProcessor, LongCellProcessor, StringCellProcessor
As of 2.0.0, this functionality was moved from the Trim
processor to this processor, to allow a clear
distinction between trimming and truncating.
next
Constructor and Description |
---|
Truncate(int maxSize)
Constructs a new Truncate processor, which truncates a String to ensure it is no longer than the
specified size.
|
Truncate(int maxSize,
String suffix)
Constructs a new Truncate processor, which truncates a String to ensure it is no longer than the
specified size, then appends the
suffix String to indicate that the String has been truncated. |
Truncate(int maxSize,
StringCellProcessor next)
Constructs a new Truncate processor, which truncates a String to ensure it is no longer than the
specified size, then calls the next processor in the chain.
|
Truncate(int maxSize,
String suffix,
StringCellProcessor next)
Constructs a new Truncate processor, which truncates a String to ensure it is no longer than the
specified size, then appends the
suffix String to indicate that the String has been truncated and
calls the next processor in the chain. |
Modifier and Type | Method and Description |
---|---|
Object |
execute(Object value,
CsvContext context)
This method is invoked by the framework when the processor needs to process data or check constraints.
|
toString, validateInputNotNull
public Truncate(int maxSize)
maxSize
- the maximum size of the StringIllegalArgumentException
- if maxSize <= 0
public Truncate(int maxSize, String suffix)
suffix
String to indicate that the String has been truncated.maxSize
- the maximum size of the Stringsuffix
- the String to append if the input is truncated (e.g. "...")IllegalArgumentException
- if maxSize <= 0
NullPointerException
- if suffix is nullpublic Truncate(int maxSize, String suffix, StringCellProcessor next)
suffix
String to indicate that the String has been truncated and
calls the next processor in the chain.maxSize
- the maximum size of the Stringsuffix
- the String to append if the input is truncated (e.g. "...")next
- the next processor in the chainIllegalArgumentException
- if maxSize <= 0
NullPointerException
- if suffix or next is nullpublic Truncate(int maxSize, StringCellProcessor next)
maxSize
- the maximum size of the Stringnext
- the next processor in the chainIllegalArgumentException
- if maxSize <= 0
NullPointerException
- if next is nullpublic Object execute(Object value, CsvContext context)
execute
in interface CellProcessor
value
- the value to be processedcontext
- the CSV contextSuperCsvCellProcessorException
- if value is nullCopyright © 2007–2015 Super CSV. All rights reserved.