Class TabCrLfEncoderDecoder

java.lang.Object
net.sf.basedb.util.encode.TabCrLfEncoderDecoder
All Implemented Interfaces:
EncoderDecoder

public class TabCrLfEncoderDecoder
extends Object
implements EncoderDecoder
Symmetrical encoder/decoder implementation that replaces newline, carriage return, tab and backslash with \n, \r, \t and \\. This encoder is suitable for use with tab-separated text files.
Since:
2.15
Author:
Nicklas
  • Field Details

    • nullIsEmptyString

      private final boolean nullIsEmptyString
  • Constructor Details

    • TabCrLfEncoderDecoder

      public TabCrLfEncoderDecoder​(boolean nullIsEmptyString)
      Creates a new encoder/decoder.
      Parameters:
      nullIsEmptyString - TRUE to encode null as empty string, FALSE to not encode null. NOTE! If TRUE, this encoder is no longer symmetrical
  • Method Details

    • isSymmetrical

      public boolean isSymmetrical()
      Specified by:
      isSymmetrical in interface EncoderDecoder
      Returns:
      TRUE if the encoder is symmetrical, FALSE if not
    • decode

      public String decode​(String s)
      Specified by:
      decode in interface EncoderDecoder
      Parameters:
      s - The string to decode
      Returns:
      The decoded string
    • encode

      public String encode​(String s)
      Specified by:
      encode in interface EncoderDecoder
      Parameters:
      s - The string to encode
      Returns:
      The encoded string