/** * Converts a simple value into the low-level <code><AttributeValue/code> * representation. * * @param value the given value which can be one of the followings: * <ul> * <li>String</li> * <li>Set<String></li> * <li>Number (including any subtypes and primitive types)</li> * <li>Set<Number></li> * <li>byte[]</li> * <li>Set<byte[]></li> * <li>ByteBuffer</li> * <li>Set<ByteBuffer></li> * <li>Boolean or boolean</li> * <li>null</li> * <li>Map<String,T>, where T can be any type on this list but must not * induce any circular reference</li> * <li>List<T>, where T can be any type on this list but must not induce * any circular reference</li> * </ul> * @return a non-null low level representation of the input object value * @throws UnsupportedOperationException if the input object type is not supported */ public static AttributeValue toAttributeValue(Object value) { return ItemUtils.toAttributeValue(value); }
/** * Converts a map of string to simple objects into the low-level * representation; or null if the input is null. */ public static Map<String, AttributeValue> fromSimpleMap( Map<String, Object> map) { if (map == null) return null; // row with multiple attributes Map<String, AttributeValue> result = new LinkedHashMap<String, AttributeValue>(); for (Map.Entry<String, Object> entry : map.entrySet()) result.put(entry.getKey(), toAttributeValue(entry.getValue())); return result; }
/** * Converts an <code>Item</code> into the low-level representation; * or null if the input is null. */ public static Map<String, AttributeValue> toAttributeValues(Item item) { if (item == null) return null; // row with multiple attributes Map<String, AttributeValue> result = new LinkedHashMap<String, AttributeValue>(); for (Map.Entry<String, Object> entry : item.attributes()) result.put(entry.getKey(), toAttributeValue(entry.getValue())); return result; }
List<AttributeValue> out = new ArrayList<AttributeValue>(); for (Object v : in) { out.add(toAttributeValue(v)); if (in.size() > 0) { for (Map.Entry<String, Object> e : in.entrySet()) { result.addMEntry(e.getKey(), toAttributeValue(e.getValue()));
/** * Converts a list of <code>AttributeUpdate</code> into the low-level * representation; or null if the input is null. */ public static Map<String, AttributeValueUpdate> toAttributeValueUpdate( List<AttributeUpdate> attributesToUpdate) { if (attributesToUpdate == null) return null; Map<String, AttributeValueUpdate> result = new LinkedHashMap<String, AttributeValueUpdate>(); for (AttributeUpdate attribute : attributesToUpdate) { AttributeValueUpdate attributeToUpdate = new AttributeValueUpdate() .withAction(attribute.getAction()); if (attribute.getValue() != null) { attributeToUpdate.withValue(toAttributeValue(attribute .getValue())); } else if (attribute.getAttributeValues() != null) { attributeToUpdate.withValue(toAttributeValue(attribute .getAttributeValues())); } result.put(attribute.getAttributeName(), attributeToUpdate); } return result; }
/** * Converts a simple value into the low-level <code><AttributeValue/code> * representation. * * @param value the given value which can be one of the followings: * <ul> * <li>String</li> * <li>Set<String></li> * <li>Number (including any subtypes and primitive types)</li> * <li>Set<Number></li> * <li>byte[]</li> * <li>Set<byte[]></li> * <li>ByteBuffer</li> * <li>Set<ByteBuffer></li> * <li>Boolean or boolean</li> * <li>null</li> * <li>Map<String,T>, where T can be any type on this list but must not * induce any circular reference</li> * <li>List<T>, where T can be any type on this list but must not induce * any circular reference</li> * </ul> * @return a non-null low level representation of the input object value * @throws UnsupportedOperationException if the input object type is not supported */ public static AttributeValue toAttributeValue(Object value) { return ItemUtils.toAttributeValue(value); }
/** * Converts a map of string to simple objects into the low-level * representation; or null if the input is null. */ public static Map<String, AttributeValue> fromSimpleMap( Map<String, Object> map) { if (map == null) return null; // row with multiple attributes Map<String, AttributeValue> result = new LinkedHashMap<String, AttributeValue>(); for (Map.Entry<String, Object> entry : map.entrySet()) result.put(entry.getKey(), toAttributeValue(entry.getValue())); return result; }
/** * Converts an <code>Item</code> into the low-level representation; * or null if the input is null. */ public static Map<String, AttributeValue> toAttributeValues(Item item) { if (item == null) return null; // row with multiple attributes Map<String, AttributeValue> result = new LinkedHashMap<String, AttributeValue>(); for (Map.Entry<String, Object> entry : item.attributes()) result.put(entry.getKey(), toAttributeValue(entry.getValue())); return result; }
/** * Converts a list of <code>AttributeUpdate</code> into the low-level * representation; or null if the input is null. */ public static Map<String, AttributeValueUpdate> toAttributeValueUpdate( List<AttributeUpdate> attributesToUpdate) { if (attributesToUpdate == null) return null; Map<String, AttributeValueUpdate> result = new LinkedHashMap<String, AttributeValueUpdate>(); for (AttributeUpdate attribute : attributesToUpdate) { AttributeValueUpdate attributeToUpdate = new AttributeValueUpdate() .withAction(attribute.getAction()); if (attribute.getValue() != null) { attributeToUpdate.withValue(toAttributeValue(attribute .getValue())); } else if (attribute.getAttributeValues() != null) { attributeToUpdate.withValue(toAttributeValue(attribute .getAttributeValues())); } result.put(attribute.getAttributeName(), attributeToUpdate); } return result; }
List<AttributeValue> out = new ArrayList<AttributeValue>(); for (Object v : in) { out.add(toAttributeValue(v)); if (in.size() > 0) { for (Map.Entry<String, Object> e : in.entrySet()) { result.addMEntry(e.getKey(), toAttributeValue(e.getValue()));