Class CsvValueDecorators.StringPrefixSuffixDecorator

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean _optional
      Whether existence of prefix and suffix decoration is optional (true) or required (false): if required and value does does not have decorations, deserialization (reading) will fail with an exception; if optional value is exposed as is.
      protected java.lang.String _prefix
      Decoration added before value being decorated: for example, if decorating with brackets, this would be opening bracket [ .
      protected java.lang.String _suffix
      Decoration added after value being decorated: for example, if decorating with brackets, this would be closing bracket ] .
    • Constructor Summary

      Constructors 
      Constructor Description
      StringPrefixSuffixDecorator​(java.lang.String prefix, java.lang.String suffix, boolean optional)  
    • Field Detail

      • _prefix

        protected final java.lang.String _prefix
        Decoration added before value being decorated: for example, if decorating with brackets, this would be opening bracket [ .
      • _suffix

        protected final java.lang.String _suffix
        Decoration added after value being decorated: for example, if decorating with brackets, this would be closing bracket ] .
      • _optional

        protected final boolean _optional
        Whether existence of prefix and suffix decoration is optional (true) or required (false): if required and value does does not have decorations, deserialization (reading) will fail with an exception; if optional value is exposed as is.
    • Constructor Detail

      • StringPrefixSuffixDecorator

        public StringPrefixSuffixDecorator​(java.lang.String prefix,
                                           java.lang.String suffix,
                                           boolean optional)
    • Method Detail

      • decorateValue

        public java.lang.String decorateValue​(CsvGenerator gen,
                                              java.lang.String plainValue)
                                       throws java.io.IOException
        Description copied from interface: CsvValueDecorator
        Method called during serialization when encoding a value, to produce "decorated" value to include in output (possibly escaped and/or quoted). Note that possible escaping and/or quoting (as per configuration of CsvSchema is applied on decorated value.
        Specified by:
        decorateValue in interface CsvValueDecorator
        Parameters:
        gen - Generator that will be used for actual serialization
        plainValue - Value to decorate
        Returns:
        Decorated value (which may be plainValue as-is) but Must Not be null
        Throws:
        java.io.IOException - if attempt to decorate the value somehow fails (typically a StreamWriteException)
      • undecorateValue

        public java.lang.String undecorateValue​(CsvParser parser,
                                                java.lang.String decoratedValue)
                                         throws java.io.IOException
        Description copied from interface: CsvValueDecorator
        Method called during deserialization, to remove possible decoration applied with CsvValueDecorator.decorateValue(com.fasterxml.jackson.dataformat.csv.CsvGenerator, java.lang.String). Call is made after textual value for a cell (column value) has been read using parser and after removing (decoding) possible quoting and/or escaping of the value. Value passed in has no escaping or quoting left.
        Specified by:
        undecorateValue in interface CsvValueDecorator
        Parameters:
        parser - Parser that was used to decode textual value from input
        decoratedValue - Value from which to remove decorations, if any (some decorators can allow optional decorations; others may fail if none found)
        Returns:
        Value after removing decorations, if any.
        Throws:
        java.io.IOException - if attempt to un-decorate the value fails (typically a StreamReadException)