com.streambase.sb

## Class Tuple.DefaultTupleFormatter

- java.lang.Object
- - com.streambase.sb.Tuple.DefaultTupleFormatter

- All Implemented Interfaces:
    Tuple.TupleFormatter
  Enclosing class:
    Tuple

      public static class Tuple.DefaultTupleFormatter
      extends Object
      implements Tuple.TupleFormatter

  A default formatter that converts each type to String using Java default String conversions. The intent of this formatter is human consumption, not CSV parsing. Special formatting is performed for:
  - Timestamp, via `Timestamp.toString()`
  - Blobs, displayed in their entirety as Strings (using US-ASCII characters, or the charset declared via the `streambase.tuple-charset` system property)
  - Tuples, displayed as a comma-separated string of each of its field's stringification using this formatter
  - Lists, displayed as a [] enclosed string of each element stringified using this formatter, delimited by comma
  - Functions, displayed using a JSON syntax
  - Null values, returned as `Tuple.NULL_STRING`

  A shared instance is available at `Tuple.getTupleFormatter()`.

  Since:
    7.1 this formatter is now used recursively for list elements and tuple sub-fields

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultTupleFormatter()` See the class documentation for `Tuple.DefaultTupleFormatter` for details

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `CharSequence` | `formatBlob(ByteArrayView blob)` Return a string representation of the given StreamBase blob value
    `CharSequence` | `formatBool(Boolean b)` Return a string representation of the given StreamBase boolean value
    `CharSequence` | `formatDouble(Double d)` Return a string representation of the given StreamBase double value
    `CharSequence` | `formatFunction(Function f)` Return a string representation of the given StreamBase function
    `CharSequence` | `formatInt(Integer i)` Return a string representation of the given StreamBase integer value
    `CharSequence` | `formatList(CompleteDataType elementType, List<?> l)` Return a string representation of the given StreamBase list
    `CharSequence` | `formatLong(Long l)` Return a string representation of the given StreamBase long value
    `CharSequence` | `formatString(String s)` Return a string representation of the given StreamBase string value
    `CharSequence` | `formatTimestamp(Timestamp t)` Return a string representation of the given StreamBase timestamp value
    `CharSequence` | `formatTuple(Tuple t)` Return a string representation of the given StreamBase Tuple value
    `protected String` | `getNullString()` This value will be returned by this formatter when any null field value is asked to be formatted.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultTupleFormatter

          public DefaultTupleFormatter()

      See the class documentation for `Tuple.DefaultTupleFormatter` for details

  - ### Method Detail

    - #### getNullString

          protected String getNullString()

      This value will be returned by this formatter when any null field value is asked to be formatted. Clients may override.
      Returns:
        by default, this implementation returns `Tuple.NULL_STRING`

    - #### formatBlob

          public CharSequence formatBlob(ByteArrayView blob)

      Description copied from interface: `Tuple.TupleFormatter`
      Return a string representation of the given StreamBase blob value
      Specified by:
        `formatBlob` in interface `Tuple.TupleFormatter`
      Parameters:
        `blob` - may be null
      Returns:
        a non-null string representation of the value given

    - #### formatTimestamp

          public CharSequence formatTimestamp(Timestamp t)

      Description copied from interface: `Tuple.TupleFormatter`
      Return a string representation of the given StreamBase timestamp value
      Specified by:
        `formatTimestamp` in interface `Tuple.TupleFormatter`
      Parameters:
        `t` - may be null
      Returns:
        a non-null string representation of the value given

    - #### formatString

          public CharSequence formatString(String s)

      Description copied from interface: `Tuple.TupleFormatter`
      Return a string representation of the given StreamBase string value
      Specified by:
        `formatString` in interface `Tuple.TupleFormatter`
      Parameters:
        `s` - may be null
      Returns:
        a non-null string representation of the value given

    - #### formatInt

          public CharSequence formatInt(Integer i)

      Description copied from interface: `Tuple.TupleFormatter`
      Return a string representation of the given StreamBase integer value
      Specified by:
        `formatInt` in interface `Tuple.TupleFormatter`
      Parameters:
        `i` - may be null
      Returns:
        a non-null string representation of the value given

    - #### formatDouble

          public CharSequence formatDouble(Double d)

      Description copied from interface: `Tuple.TupleFormatter`
      Return a string representation of the given StreamBase double value
      Specified by:
        `formatDouble` in interface `Tuple.TupleFormatter`
      Parameters:
        `d` - may be null
      Returns:
        a non-null string representation of the value given

    - #### formatLong

          public CharSequence formatLong(Long l)

      Description copied from interface: `Tuple.TupleFormatter`
      Return a string representation of the given StreamBase long value
      Specified by:
        `formatLong` in interface `Tuple.TupleFormatter`
      Parameters:
        `l` - may be null
      Returns:
        a non-null string representation of the value given

    - #### formatBool

          public CharSequence formatBool(Boolean b)

      Description copied from interface: `Tuple.TupleFormatter`
      Return a string representation of the given StreamBase boolean value
      Specified by:
        `formatBool` in interface `Tuple.TupleFormatter`
      Parameters:
        `b` - may be null
      Returns:
        a non-null string representation of the value given

    - #### formatTuple

          public CharSequence formatTuple(Tuple t)

      Description copied from interface: `Tuple.TupleFormatter`
      Return a string representation of the given StreamBase Tuple value
      Specified by:
        `formatTuple` in interface `Tuple.TupleFormatter`
      Parameters:
        `t` - may be null
      Returns:
        a non-null string representation of the value given

    - #### formatList

          public CharSequence formatList(CompleteDataType elementType,
                                         List<?> l)

      Description copied from interface: `Tuple.TupleFormatter`
      Return a string representation of the given StreamBase list
      Specified by:
        `formatList` in interface `Tuple.TupleFormatter`
      Parameters:
        `elementType` - the data type of all list elements
        `l` - may be null
      Returns:
        a non-null string representation of the value given

    - #### formatFunction

          public CharSequence formatFunction(Function f)

      Description copied from interface: `Tuple.TupleFormatter`
      Return a string representation of the given StreamBase function
      Specified by:
        `formatFunction` in interface `Tuple.TupleFormatter`
      Parameters:
        `f` - may be null
      Returns:
        a non-null string representation of the value given

Copyright © 2015–2018 Cloud Software Group, Inc.. All rights reserved.