Class MapValue
- All Implemented Interfaces:
Comparable<FieldValue>
,Iterable<Map.Entry<String,
FieldValue>>
FieldValue
objects which
may be atomic types or embedded MapValue or ArrayValue
instances,
creating a structured row.
MapValue is also used to represent key values used in get operations as well as nested maps or records within a row.
Field names in a MapValue follow the same rules as Java Map
,
meaning that they are case-sensitive string values with no duplicates.
On input MapValues of any structure can be created, but when put into a
table they must conform to the schema of the target table or an exception
will be thrown. Note that in the context of a RECORD field in a table
schema field names are treated as case-insensitive. If a MapValue
represents JSON, field names are case-sensitive.
NullValue
instance using
"put(fieldName, NullValue.getInstance())"
When a MapValue is received on output the value will always conform to the schema of the table from which the value was received or the implied schema of a query projection.
-
Nested Class Summary
Nested classes/interfaces inherited from class oracle.nosql.driver.values.FieldValue
FieldValue.Type
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddAll
(Iterator<Map.Entry<String, FieldValue>> iter) Inserts all of the entries in the specified iterator into the map.addAll
(Stream<Map.Entry<String, FieldValue>> stream) Inserts all of the entries in the specified stream into the map.int
compareTo
(FieldValue other) boolean
Returns true if the specified field exists in the mapentrySet()
Returns aSet
of entries based on the underlying map that holds the values.boolean
Returns the field the specified name, or null if the field does not exist.byte[]
Gets the named field as a binary valueboolean
getBoolean
(String name) Gets the named field as a booleandouble
Gets the named field as a doubleint
Gets the named field as an integerlong
Gets the named field as a longgetMap()
Returns a liveMap
of the MapValue state.Gets the named field as a BigDecimalGets the named field as a StringgetTimestamp
(String name) Gets the named field as a long timestamp representing the milliseconds since January 1, 1970getType()
Returns the type of the objectReturns the type of the field with the specified name, or null if the field does not exist.int
hashCode()
iterator()
Returns an iterator over the entry set.Sets the named field as a BooleanValue.Sets the named field as a BinaryValue.Sets the named field as a DoubleValue.Sets the named field as an IntegerValue.Sets the named field as a LongValue.Sets the named field as a StringValue.put
(String name, BigDecimal value) Sets the named field as a NumberValue.Sets the named field as a TimestampValue.put
(String name, FieldValue value) Sets the named field.putFromJson
(String name, String jsonString, JsonOptions options) Sets the named field based on the JSON string provided.Removes the named field if it exists.int
size()
Returns the number of entries in the map.values()
Returns aCollection
ofFieldValue
instances contained in this map.Methods inherited from class oracle.nosql.driver.values.FieldValue
asArray, asBinary, asBoolean, asDouble, asInteger, asJsonNull, asLong, asMap, asNull, asNumber, asString, asTimestamp, castAsDouble, createFromJson, createFromJson, createFromJson, getBinary, getBoolean, getDouble, getInt, getLong, getNumber, getSerializedSize, getString, getTimestamp, isAnyNull, isArray, isAtomic, isBinary, isBoolean, isDouble, isInteger, isJsonNull, isLong, isMap, isNull, isNumber, isNumeric, isString, isTimestamp, toJson, toJson, toString
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
MapValue
public MapValue()Creates an empty MapValue instance -
MapValue
public MapValue(boolean keepInsertionOrder, int size) Creates an empty MapValue instance- Parameters:
keepInsertionOrder
- if true a map is created that maintains insertion order. This is the default for get and query results.size
- the initial capacity of the map
-
MapValue
public MapValue(int size) Creates an empty MapValue instance using the specified initial capacity- Parameters:
size
- the initial capacity
-
-
Method Details
-
getType
Description copied from class:FieldValue
Returns the type of the object- Specified by:
getType
in classFieldValue
- Returns:
- the type
-
getMap
Returns a liveMap
of the MapValue state.- Returns:
- the map
-
entrySet
Returns aSet
of entries based on the underlying map that holds the values.- Returns:
- the set
-
iterator
Returns an iterator over the entry set.- Specified by:
iterator
in interfaceIterable<Map.Entry<String,
FieldValue>> - Returns:
- the iterator
- Since:
- 5.4
-
size
public int size()Returns the number of entries in the map.- Returns:
- the size
-
values
Returns aCollection
ofFieldValue
instances contained in this map.- Returns:
- the values
-
addAll
Inserts all of the entries in the specified iterator into the map.- Parameters:
iter
- the iterator- Returns:
- this
-
addAll
Inserts all of the entries in the specified stream into the map.- Parameters:
stream
- the stream- Returns:
- this
-
getType
Returns the type of the field with the specified name, or null if the field does not exist.- Parameters:
name
- the name of the field- Returns:
- the type of the field, or null if it does not exist.
-
get
Returns the field the specified name, or null if the field does not exist.- Parameters:
name
- the name of the field- Returns:
- the field, or null if it does not exist.
-
contains
Returns true if the specified field exists in the map- Parameters:
name
- the name of the field- Returns:
- true if the field exists, false if not
- Since:
- 5.4
-
put
Sets the named field. Any existing entry is silently overwritten.- Parameters:
name
- the name of the fieldvalue
- the value to set- Returns:
- this
-
put
Sets the named field as an IntegerValue. Any existing entry is silently overwritten.- Parameters:
name
- the name of the fieldvalue
- the value to set- Returns:
- this
-
put
Sets the named field as a LongValue. Any existing entry is silently overwritten.- Parameters:
name
- the name of the fieldvalue
- the value to set- Returns:
- this
-
put
Sets the named field as a DoubleValue. Any existing entry is silently overwritten.- Parameters:
name
- the name of the fieldvalue
- the value to set- Returns:
- this
-
put
Sets the named field as a NumberValue. Any existing entry is silently overwritten.- Parameters:
name
- the name of the fieldvalue
- the value to set- Returns:
- this
-
put
Sets the named field as a StringValue. Any existing entry is silently overwritten.- Parameters:
name
- the name of the fieldvalue
- the value to set- Returns:
- this
-
put
Sets the named field as a BooleanValue. Any existing entry is silently overwritten.- Parameters:
name
- the name of the fieldvalue
- the value to set- Returns:
- this
-
put
Sets the named field as a BinaryValue. Any existing entry is silently overwritten.- Parameters:
name
- the name of the fieldvalue
- the value to set- Returns:
- this
-
put
Sets the named field as a TimestampValue. Any existing entry is silently overwritten.- Parameters:
name
- the name of the fieldvalue
- the value to set- Returns:
- this
-
putFromJson
Sets the named field based on the JSON string provided. Any existing entry is silently overridden. The type of the field created is inferred from the JSON.- Parameters:
name
- the name of the fieldjsonString
- a JSON formatted Stringoptions
- configurable options used to affect the JSON output format of some data types. May be null.- Returns:
- this
- Throws:
IllegalArgumentException
- if the string is not valid JSON
-
remove
Removes the named field if it exists.- Parameters:
name
- the name of the field- Returns:
- the previous value if it existed, otherwise null
-
getInt
Gets the named field as an integer- Parameters:
name
- the name of the field- Returns:
- the integer value
- Throws:
IllegalArgumentException
- if the field does not exist.ClassCastException
- if the field cannot be cast to the required type
-
getLong
Gets the named field as a long- Parameters:
name
- the name of the field- Returns:
- the long value
- Throws:
IllegalArgumentException
- if the field does not exist.ClassCastException
- if the field cannot be cast to the required type
-
getDouble
Gets the named field as a double- Parameters:
name
- the name of the field- Returns:
- the double value
- Throws:
IllegalArgumentException
- if the field does not exist.ClassCastException
- if the field cannot be cast to the required type
-
getNumber
Gets the named field as a BigDecimal- Parameters:
name
- the name of the field- Returns:
- the BigDecimal value
- Throws:
IllegalArgumentException
- if the field does not exist.ClassCastException
- if the field cannot be cast to the required type
-
getString
Gets the named field as a String- Parameters:
name
- the name of the field- Returns:
- the String value
- Throws:
IllegalArgumentException
- if the field does not exist.ClassCastException
- if the field cannot be cast to the required type
-
getBoolean
Gets the named field as a boolean- Parameters:
name
- the name of the field- Returns:
- the boolean value
- Throws:
IllegalArgumentException
- if the field does not exist.ClassCastException
- if the field cannot be cast to the required type
-
getBinary
Gets the named field as a binary value- Parameters:
name
- the name of the field- Returns:
- the binary value
- Throws:
IllegalArgumentException
- if the field does not exist.ClassCastException
- if the field cannot be cast to the required type
-
getTimestamp
Gets the named field as a long timestamp representing the milliseconds since January 1, 1970- Parameters:
name
- the name of the field- Returns:
- the timestamp value
- Throws:
IllegalArgumentException
- if the field does not exist.ClassCastException
- if the field cannot be cast to the required type
-
compareTo
- Specified by:
compareTo
in interfaceComparable<FieldValue>
-
equals
-
hashCode
public int hashCode()
-