java.lang.Object
com.amazonaws.services.dynamodbv2.document.Item

public class Item extends Object
An item in DynamoDB. An item is a collection of attributes. Each attribute has a name and a value. An attribute value can be one of the followings:
  • String
  • Set<String>
  • Number (including any subtypes and primitive types)
  • Set<Number>
  • byte[]
  • Set<byte[]>
  • ByteBuffer
  • Set<ByteBuffer>
  • Boolean or boolean
  • null
  • Map<String,T>, where T can be any type on this list but must not induce any circular reference
  • List<T>, where T can be any type on this list but must not induce any circular reference
For an Item to be successfully persisted in DynamoDB, at a minimum the respective attributes for the primary key must be specified.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns all attributes of the current item as a map.
    Returns all attributes of the current item.
    base64Decode(String... binaryAttrNames)
    Utility method to decode the designated binary attributes from base-64 encoding; converting binary lists into binary sets.
    convertListsToSets(String... listAttrNames)
    Utility method to converts the designated attributes from List into Set, throwing IllegalArgumentException should there be duplicate elements.
    boolean
     
    static Item
    Convenient factory method - instantiates an Item from the given JSON string.
    static Item
    fromMap(Map<String,Object> attributes)
    Convenient factory method - instantiates an Item from the given map.
    get(String attrName)
    Returns the value of the specified attribute in the current item as an object; or null if the attribute either doesn't exist or the attribute value is null.
    Returns the value of the specified attribute in the current item as an BigInteger; or null if the attribute doesn't exist.
    byte[]
    getBinary(String attrName)
    Returns the value of the specified attribute in the current item as a byte array; or null if the attribute either doesn't exist or the attribute value is null.
    Set<byte[]>
    getBinarySet(String attrName)
    Returns the value of the specified attribute in the current item as a set of byte arrays; or null if the attribute either doesn't exist or the attribute value is null.
    getBOOL(String attrName)
    Returns the value of the specified attribute in the current item as a non-null Boolean.
    boolean
    getBoolean(String attrName)
    Returns the value of the specified attribute in the current item as a primitive boolean.
    Returns the value of the specified attribute in the current item as a ByteBuffer; or null if the attribute either doesn't exist or the attribute value is null.
    Returns the value of the specified attribute in the current item as a set of ByteBuffer; or null if the attribute either doesn't exist or the attribute value is null.
    double
    getDouble(String attrName)
    Returns the value of the specified attribute in the current item as a double.
    float
    getFloat(String attrName)
    Returns the value of the specified attribute in the current item as a float.
    int
    getInt(String attrName)
    Returns the value of the specified attribute in the current item as an int.
    getJSON(String attrName)
    Returns the value of the specified attribute in the current item as a JSON string; or null if the attribute either doesn't exist or the attribute value is null.
    Returns the value of the specified attribute in the current item as a JSON string with pretty indentation; or null if the attribute either doesn't exist or the attribute value is null.
    <T> List<T>
    getList(String attrName)
    Returns the value of the specified attribute in the current item as a set of T's.; or null if the attribute either doesn't exist or the attribute value is null.
    long
    getLong(String attrName)
    Returns the value of the specified attribute in the current item as an long.
    <T> Map<String,T>
    getMap(String attrName)
    Returns the value of the specified attribute in the current item as a map of string-to-T's; or null if the attribute either doesn't exist or the attribute value is null.
    <T extends Number>
    Map<String,T>
    getMapOfNumbers(String attrName, Class<T> valueType)
    Convenient method to return the specified attribute in the current item as a (copy of) map of string-to-T's where T must be a subclass of Number; or null if the attribute doesn't exist.
    getNumber(String attrName)
    Returns the value of the specified attribute in the current item as a BigDecimal; or null if the attribute either doesn't exist or the attribute value is null.
    getNumberSet(String attrName)
    Returns the value of the specified attribute in the current item as a set of BigDecimal's; or null if the attribute either doesn't exist or the attribute value is null.
    getRawMap(String attrName)
    Convenient method to return the value of the specified attribute in the current item as a map of string-to-Object's; or null if the attribute either doesn't exist or the attribute value is null.
    short
    getShort(String attrName)
    Returns the value of the specified attribute in the current item as a short.
    getString(String attrName)
    Returns the value of the specified attribute in the current item as a string; or null if the attribute either doesn't exist or the attribute value is null.
    getStringSet(String attrName)
    Returns the value of the specified attribute in the current item as a set of strings; or null if the attribute either doesn't exist or the attribute value is null.
    getTypeOf(String attrName)
    Returns the type of the specified attribute in the current item; or null if the attribute either doesn't exist or the attribute value is null.
    boolean
    hasAttribute(String attrName)
    Returns true if this item has the specified attribute; false otherwise.
    int
     
    boolean
    isNull(String attrName)
    Returns true if the specified attribute exists with a null value; false otherwise.
    boolean
    isPresent(String attrName)
    Returns true if this item contains the specified attribute; false otherwise.
    int
    Returns the number of attributes of this item.
    Removes the specified attribute from the current item.
    Returns this item as a JSON string.
    Returns this item as a pretty JSON string.
     
    with(String attrName, Object val)
    Sets the value of the specified attribute to the given value.
    withBigDecimalSet(String attrName, BigDecimal... vals)
    Sets the value of the specified attribute in the current item to the given value.
    Sets the value of the specified attribute in the current item to the given value.
    Sets the value of the specified attribute in the current item to the given value.
    withBinary(String attrName, byte[] val)
    Sets the value of the specified attribute in the current item to the given value.
    withBinary(String attrName, ByteBuffer val)
    Sets the value of the specified attribute in the current item to the given value.
    withBinarySet(String attrName, byte[]... vals)
    Sets the value of the specified attribute in the current item to the given value.
    withBinarySet(String attrName, ByteBuffer... vals)
    Sets the value of the specified attribute in the current item to the given value.
    withBinarySet(String attrName, Set<byte[]> val)
    Sets the value of the specified attribute in the current item to the given value.
    withBoolean(String attrName, boolean val)
    Sets the value of the specified attribute in the current item to the boolean value.
    Sets the value of the specified attribute in the current item to the given value.
    withDouble(String attrName, double val)
    Sets the value of the specified attribute in the current item to the given value.
    withFloat(String attrName, float val)
    Sets the value of the specified attribute in the current item to the given value.
    withInt(String attrName, int val)
    Sets the value of the specified attribute in the current item to the given value.
    withJSON(String attrName, String json)
    Sets the value of the specified attribute in the current item to the given JSON document in the form of a string.
    withKeyComponent(String keyAttrName, Object keyAttrValue)
    Convenient methods - sets an attribute of this item for the specified key attribute name and value.
    Convenient methods - sets the attributes of this item from the specified key components.
    withList(String attrName, Object... vals)
    Sets the value of the specified attribute in the current item to the given values as a list.
    withList(String attrName, List<?> val)
    Sets the value of the specified attribute in the current item to the given value.
    withLong(String attrName, long val)
    Sets the value of the specified attribute in the current item to the given value.
    withMap(String attrName, Map<String,?> val)
    Sets the value of the specified attribute in the current item to the given value.
    withNull(String attrName)
    Sets the value of the specified attribute to null.
    withNumber(String attrName, Number val)
    Sets the value of the specified attribute in the current item to the given value.
    withNumber(String attrName, BigDecimal val)
    Sets the value of the specified attribute in the current item to the given value.
    withNumberSet(String attrName, Number... vals)
    Sets the value of the specified attribute in the current item to the given value.
    withNumberSet(String attrName, Set<Number> vals)
    Sets the value of the specified attribute in the current item to the given value.
    Convenient methods - sets the attributes of this item from the given key attributes.
    withPrimaryKey(String hashKeyName, Object hashKeyValue)
    Convenient method to set the attributes of this item from the given hash-only primary key name and value.
    withPrimaryKey(String hashKeyName, Object hashKeyValue, String rangeKeyName, Object rangeKeyValue)
    Convenient method to set the attributes of this item from the given hash and range primary key.
    withShort(String attrName, short val)
    Sets the value of the specified attribute in the current item to the given value.
    withString(String attrName, String val)
    Sets the value of the specified attribute in the current item to the given string value.
    withStringSet(String attrName, String... val)
    Sets the value of the specified attribute in the current item to the given value.
    withStringSet(String attrName, Set<String> val)
    Sets the value of the specified attribute in the current item to the given value.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait