Interface MapValue

  • All Superinterfaces:
    java.lang.Comparable<FieldValue>, FieldValue

    public interface MapValue
    extends FieldValue
    MapValue extends FieldValue to define a container object that holds a map of FieldValue objects all of the same type. The getters and setters use the same semantics as Java Map. Map keys are case-sensitive.
    Since:
    3.0
    • Field Detail

      • ANONYMOUS

        static final java.lang.String ANONYMOUS
        A constant used as a key for a map value when the value is used as part of an IndexKey when there is an index on the value of a map's element or a nested value within the element if the element is a record.
        See Also:
        Constant Field Values
    • Method Detail

      • clone

        MapValue clone()
        Returns a deep copy of this object.
        Specified by:
        clone in interface FieldValue
        Returns:
        a deep copy of this object
      • toString

        java.lang.String toString()
        Returns a String representation of the value. The value is returned is a JSON string, and is the same as that returned by FieldValue.toJsonString(boolean).
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation of the value
      • getDefinition

        MapDef getDefinition()
        Returns the MapDef that defines the content of this map.
        Specified by:
        getDefinition in interface FieldValue
        Returns:
        the MapDef
      • size

        int size()
        Returns the size of the map.
        Returns:
        the size
      • getFields

        java.util.Map<java.lang.String,​FieldValue> getFields()
        Returns an unmodifiable view of the MapValue state. The type of all fields is the same and is defined by the MapDef returned by getDefinition().
        Returns:
        the map
        Since:
        3.0.6
      • remove

        FieldValue remove​(java.lang.String fieldName)
        Remove the named field if it exists.
        Parameters:
        fieldName - the name of the field to remove
        Returns:
        the FieldValue if it existed, otherwise null
      • get

        FieldValue get​(java.lang.String fieldName)
        Returns the FieldValue with the specified name if it appears in the map.
        Parameters:
        fieldName - the name of the desired field.
        Returns:
        the value for the field or null if the name does not exist in the map.
      • putJsonNull

        MapValue putJsonNull​(java.lang.String fieldName)
        Puts a JSON null value in the named field, silently overwriting existing values. This operation is only valid for maps of type JSON.
        Parameters:
        fieldName - name of the desired field
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if this map is not of type JSON
        Since:
        4.3
      • put

        MapValue put​(java.lang.String fieldName,
                     int value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
      • put

        MapValue put​(java.lang.String fieldName,
                     long value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
      • put

        MapValue put​(java.lang.String fieldName,
                     java.lang.String value)
        Set the named field. Any existing entry is silently overwritten. This method is used to put a string into a map of type String. The String value is not parsed or interpreted. The methods putJson(java.lang.String, java.lang.String) and putEnum(java.lang.String, java.lang.String) exist to put String values of those types.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
      • put

        MapValue put​(java.lang.String fieldName,
                     double value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
      • putNumber

        MapValue putNumber​(java.lang.String fieldName,
                           int value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
        Since:
        4.4
      • putNumber

        MapValue putNumber​(java.lang.String fieldName,
                           long value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
        Since:
        4.4
      • putNumber

        MapValue putNumber​(java.lang.String fieldName,
                           float value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
        Since:
        4.4
      • putNumber

        MapValue putNumber​(java.lang.String fieldName,
                           double value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
        Since:
        4.4
      • putNumber

        MapValue putNumber​(java.lang.String fieldName,
                           java.math.BigDecimal value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
        Since:
        4.4
      • put

        MapValue put​(java.lang.String fieldName,
                     float value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
      • put

        MapValue put​(java.lang.String fieldName,
                     boolean value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
      • put

        MapValue put​(java.lang.String fieldName,
                     byte[] value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
      • putFixed

        MapValue putFixed​(java.lang.String fieldName,
                          byte[] value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
      • putEnum

        MapValue putEnum​(java.lang.String fieldName,
                         java.lang.String value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
      • put

        MapValue put​(java.lang.String fieldName,
                     java.sql.Timestamp value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
        Since:
        4.3
      • put

        MapValue put​(java.lang.String fieldName,
                     FieldValue value)
        Set the named field. Any existing entry is silently overwritten.
        Parameters:
        fieldName - name of the desired field
        value - the value to set
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type does not match the input type
      • putRecord

        RecordValue putRecord​(java.lang.String fieldName)
        Puts a Record into the map. Existing values are silently overwritten.
        Parameters:
        fieldName - the field to use for the map key
        Returns:
        an uninitialized RecordValue that matches the type definition for the map
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type is not a RecordDef
      • putMap

        MapValue putMap​(java.lang.String fieldName)
        Puts a Map into the map. Existing values are silently overwritten.
        Parameters:
        fieldName - the field to use for the map key
        Returns:
        an uninitialized MapValue that matches the type definition for the map
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type is not a MapDef
      • putArray

        ArrayValue putArray​(java.lang.String fieldName)
        Puts an Array into the map. Existing values are silently overwritten.
        Parameters:
        fieldName - the field to use for the map key
        Returns:
        an uninitialized ArrayValue that matches the type definition for the map
        Throws:
        java.lang.IllegalArgumentException - if the definition of the map type is not an ArrayDef
      • putJson

        MapValue putJson​(java.lang.String fieldName,
                         java.lang.String jsonInput)
        Puts arbitrary JSON into this map in the specified field. Existing values are silently overwritten.
        Parameters:
        fieldName - the field to use for the map key
        jsonInput - a JSON string
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if this map is not of type JSON or the JSON input is invalid.
        Since:
        4.2
      • putJson

        MapValue putJson​(java.lang.String fieldName,
                         java.io.Reader jsonReader)
        Puts arbitrary JSON into this map in the specified field. Existing values are silently overwritten.
        Parameters:
        fieldName - the field to use for the map key
        jsonReader - a Reader
        Returns:
        this
        Throws:
        java.lang.IllegalArgumentException - if this map is not of type JSON or the JSON input is invalid.
        Since:
        4.2