Class PropertyContainer
- java.lang.Object
-
- com.google.appengine.api.datastore.PropertyContainer
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
- Direct Known Subclasses:
- EmbeddedEntity, Entity
public abstract class PropertyContainer extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable
A mutable property container.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.util.Map<java.lang.String,java.lang.Object>
getProperties()
Gets all of the properties belonging to this container.java.lang.Object
getProperty(java.lang.String propertyName)
Gets the property with the specified name.boolean
hasProperty(java.lang.String propertyName)
Returns true if a property has been set.boolean
isUnindexedProperty(java.lang.String propertyName)
Returns true ifpropertyName
has a value that will not be indexed.void
removeProperty(java.lang.String propertyName)
Removes any property with the specified name.void
setIndexedProperty(java.lang.String propertyName, java.lang.Object value)
Like {link #setProperty}, but requires that the value is indexable or a collection of indexable values.void
setPropertiesFrom(PropertyContainer src)
A convenience method that populates properties from those in the given container.void
setProperty(java.lang.String propertyName, java.lang.Object value)
Sets the property named,propertyName
, tovalue
.void
setUnindexedProperty(java.lang.String propertyName, java.lang.Object value)
Like#setProperty
, but doesn't index the property in the built-in single property indexes or the user-defined composite indexes.
-
-
-
Method Detail
-
getProperty
public java.lang.Object getProperty(java.lang.String propertyName)
Gets the property with the specified name. The value returned may not be the same type as originally set viasetProperty(java.lang.String, java.lang.Object)
.- Returns:
- the property corresponding to
propertyName
.
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Gets all of the properties belonging to this container.- Returns:
- an unmodifiable
Map
of properties.
-
hasProperty
public boolean hasProperty(java.lang.String propertyName)
Returns true if a property has been set. If a property has been explicitly set tonull
, this function will return true.- Returns:
- true iff the property named
propertyName
exists.
-
removeProperty
public void removeProperty(java.lang.String propertyName)
Removes any property with the specified name. If there is no property with this name set, simply does nothing.- Throws:
java.lang.NullPointerException
- IfpropertyName
is null.
-
setProperty
public void setProperty(java.lang.String propertyName, java.lang.Object value)
Sets the property named,propertyName
, tovalue
.As the value is stored in the datastore, it is converted to the datastore's native type. This may include widening, such as converting a
Short
to aLong
.If value is a
Collection
, the values will be stored in the datastore with the collection's iteration order with one caveat: all indexed values will come before all unindexed values (this can occur if theCollection
contains both values that are normally indexed like strings, and values that are never indexed likeBlob
,Text
andEmbeddedEntity
).Overrides any existing value for this property, whether indexed or unindexed.
Note that
Blob
,Text
andEmbeddedEntity
property values are never indexed. To store other types without being indexed, usesetUnindexedProperty(java.lang.String, java.lang.Object)
.- Parameters:
value
- may be one of the supported datatypes or a heterogeneousCollection
of one of the supported datatypes.- Throws:
java.lang.IllegalArgumentException
- If the value is not of a type that the data store supports.- See Also:
setUnindexedProperty(java.lang.String, java.lang.Object)
-
setIndexedProperty
public void setIndexedProperty(java.lang.String propertyName, java.lang.Object value)
Like {link #setProperty}, but requires that the value is indexable or a collection of indexable values.
-
setUnindexedProperty
public void setUnindexedProperty(java.lang.String propertyName, java.lang.Object value)
Like#setProperty
, but doesn't index the property in the built-in single property indexes or the user-defined composite indexes.- Parameters:
value
- may be one of the supported datatypes, or a heterogeneousCollection
of one of the supported datatypes.Overrides any existing value for this property, whether indexed or unindexed.
- Throws:
java.lang.IllegalArgumentException
- If the value is not of a type that the data store supports.- See Also:
setProperty(java.lang.String, java.lang.Object)
-
isUnindexedProperty
public boolean isUnindexedProperty(java.lang.String propertyName)
Returns true ifpropertyName
has a value that will not be indexed. This includesText
,Blob
, and any property added usingsetUnindexedProperty(java.lang.String, java.lang.Object)
.Note: The behavior of this method is not well defined in case of an indexed property whose value is a list that contains unindexable values.
-
setPropertiesFrom
public void setPropertiesFrom(PropertyContainer src)
A convenience method that populates properties from those in the given container.This method transfers information about unindexed properties and clones any mutable values.
- Parameters:
src
- The container from which we will populate ourself.
-
-