Class TupleJSONUtil.SetTupleFromJSON

java.lang.Object
com.streambase.sb.TupleJSONUtil.SetTupleFromJSON
Enclosing class:
TupleJSONUtil

public static class TupleJSONUtil.SetTupleFromJSON extends Object
The Builder class which handles the setting of tuples from JSON Data. This has several parameters which can be specified using the respective builder methods. These builder methods are:
withParseStyle(com.streambase.sb.ParseStyle) whether to throw an exception when fields are missing from tuple's schema (ParseStyle.STRICT) or not (ParseStyle.LOOSE)
withTimestampStyle(com.streambase.sb.Timestamp.Type) timestampStyle Whether the numeric values in a timestamp field will be converted to an Timestamp.Type.INTERVAL or a Timestamp.Type.TIMESTAMP
withTimestampFormat(java.lang.String) the string representation of the timestamp format to use when converting
withEmptyStringValue(java.lang.String) the string specifying what an empty/null json field should evaluate to
Two static instances are provided: STRICT and LOOSE, which set all defaults except for the parseStyle, which instead corresponds to the instance name.
STRICT can be used as a plain default instance with no modifications.
  • Field Details

  • Method Details

    • withParseStyle

      public TupleJSONUtil.SetTupleFromJSON withParseStyle(ParseStyle style)
      Sets the parsestyle of a new SetTupleFromJSON and returns it.
      Parameters:
      style - the style to use.
      Returns:
      a new SetTupleFromJSON with parseStyle set.
    • withTimestampStyle

      public TupleJSONUtil.SetTupleFromJSON withTimestampStyle(Timestamp.Type style)
      Sets the timestampStyle of a new SetTupleFromJSON and returns it.
      Parameters:
      style - the style to use.
      Returns:
      a new SetTupleFromJSON with timestampStyle set.
    • withTimestampFormat

      public TupleJSONUtil.SetTupleFromJSON withTimestampFormat(String format)
      Sets the timestamp format of a new SetTupleFromJSON and returns it.
      Parameters:
      format - the format to use
      Returns:
      a new SetTupleFromJSON with timestampFormat set.
    • withEmptyStringValue

      public TupleJSONUtil.SetTupleFromJSON withEmptyStringValue(String value)
      Sets the emptyString value of a new SetTupleFromJSON and returns it.
      Parameters:
      value - the string to use
      Returns:
      a new SetTupleFromJSON with emptyStringJsonValue set.
    • process

      public TupleJSONUtil.SetTupleFromJSON process(String jsonVal, Tuple tuple) throws StreamBaseException
      Handles the processing of a JSON value into a tuple, replaces the deprecated setTupleFromJSON and setTuple methods in the API.
      Parameters:
      jsonVal - the JSON string; must have at least the fields of the tuple's schema
      tuple - the tuple to set
      Returns:
      this
      Throws:
      StreamBaseException - conversion to tuple error.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getEmptyStringJsonValue

      String getEmptyStringJsonValue()
      Getter for the emptyStringJsonValue
      Returns:
      the emptyStringJsonValue
    • getParseStyle

      ParseStyle getParseStyle()
      Getter for the parseStyle
      Returns:
      the parseStyle
    • getTimestampFormat

      String getTimestampFormat()
      Getter for the timestampFormat
      Returns:
      the timestampFormat
    • getTimeStyle

      Timestamp.Type getTimeStyle()
      Getter for the timeStyle
      Returns:
      the timeStyle