Package org.bson.json

Class JsonWriterSettings.Builder

  • Enclosing class:
    JsonWriterSettings

    public static final class JsonWriterSettings.Builder
    extends java.lang.Object
    A builder for JsonWriterSettings
    Since:
    3.5
    • Method Detail

      • build

        public JsonWriterSettings build()
        Build a JsonWriterSettings instance.
        Returns:
        a JsonWriterSettings instance
      • indent

        public JsonWriterSettings.Builder indent​(boolean indent)
        Sets whether indentation is enabled, which defaults to false.
        Parameters:
        indent - whether indentation is enabled
        Returns:
        this
      • newLineCharacters

        public JsonWriterSettings.Builder newLineCharacters​(java.lang.String newLineCharacters)
        Sets the new line character string to use when indentation is enabled, which defaults to System.getProperty("line.separator").
        Parameters:
        newLineCharacters - the non-null new line character string
        Returns:
        this
      • indentCharacters

        public JsonWriterSettings.Builder indentCharacters​(java.lang.String indentCharacters)
        Sets the indent character string to use when indentation is enabled, which defaults to two spaces.
        Parameters:
        indentCharacters - the non-null indent character string
        Returns:
        this
      • maxLength

        public JsonWriterSettings.Builder maxLength​(int maxLength)
        Sets the maximum length of the JSON string. The string will be truncated at this length.
        Parameters:
        maxLength - the maximum length, which must be >= 0 where 0 indicate no maximum length
        Returns:
        the maximum length of the JSON string
        Since:
        3.7
      • stringConverter

        public JsonWriterSettings.Builder stringConverter​(Converter<java.lang.String> stringConverter)
        Sets the converter from BSON String values to JSON.
        Parameters:
        stringConverter - the converter
        Returns:
        this
      • dateTimeConverter

        public JsonWriterSettings.Builder dateTimeConverter​(Converter<java.lang.Long> dateTimeConverter)
        Sets the converter from BSON DateTime values to JSON.
        Parameters:
        dateTimeConverter - the converter
        Returns:
        this
      • booleanConverter

        public JsonWriterSettings.Builder booleanConverter​(Converter<java.lang.Boolean> booleanConverter)
        Sets the converter from BSON Boolean values to JSON.
        Parameters:
        booleanConverter - the converter
        Returns:
        this
      • doubleConverter

        public JsonWriterSettings.Builder doubleConverter​(Converter<java.lang.Double> doubleConverter)
        Sets the converter from BSON Double values to JSON.
        Parameters:
        doubleConverter - the converter
        Returns:
        this
      • int32Converter

        public JsonWriterSettings.Builder int32Converter​(Converter<java.lang.Integer> int32Converter)
        Sets the converter from BSON Int32 values to JSON.
        Parameters:
        int32Converter - the converter
        Returns:
        this
      • int64Converter

        public JsonWriterSettings.Builder int64Converter​(Converter<java.lang.Long> int64Converter)
        Sets the converter from BSON Int64 values to JSON.
        Parameters:
        int64Converter - the converter
        Returns:
        this
      • decimal128Converter

        public JsonWriterSettings.Builder decimal128Converter​(Converter<Decimal128> decimal128Converter)
        Sets the converter from BSON Decimal128 values to JSON.
        Parameters:
        decimal128Converter - the converter
        Returns:
        this
      • objectIdConverter

        public JsonWriterSettings.Builder objectIdConverter​(Converter<ObjectId> objectIdConverter)
        Sets the converter from BSON ObjectId values to JSON.
        Parameters:
        objectIdConverter - the converter
        Returns:
        this
      • timestampConverter

        public JsonWriterSettings.Builder timestampConverter​(Converter<BsonTimestamp> timestampConverter)
        Sets the converter from BSON Timestamp values to JSON.
        Parameters:
        timestampConverter - the converter
        Returns:
        this
      • regularExpressionConverter

        public JsonWriterSettings.Builder regularExpressionConverter​(Converter<BsonRegularExpression> regularExpressionConverter)
        Sets the converter from BSON Regular Expression values to JSON.
        Parameters:
        regularExpressionConverter - the converter
        Returns:
        this
      • symbolConverter

        public JsonWriterSettings.Builder symbolConverter​(Converter<java.lang.String> symbolConverter)
        Sets the converter from BSON Symbol values to JSON.
        Parameters:
        symbolConverter - the converter
        Returns:
        this
      • undefinedConverter

        public JsonWriterSettings.Builder undefinedConverter​(Converter<BsonUndefined> undefinedConverter)
        Sets the converter from BSON Undefined values to JSON.
        Parameters:
        undefinedConverter - the converter
        Returns:
        this
      • javaScriptConverter

        public JsonWriterSettings.Builder javaScriptConverter​(Converter<java.lang.String> javaScriptConverter)
        Sets the converter from BSON JavaScript values to JSON.
        Parameters:
        javaScriptConverter - the converter
        Returns:
        this