GigaSpaces XAP 10.0.1 API

com.gigaspaces.document
Class DocumentProperties

java.lang.Object
  extended by com.gigaspaces.document.DocumentProperties
All Implemented Interfaces:
Externalizable, Serializable, Map<String,Object>

public class DocumentProperties
extends Object
implements Map<String,Object>, Externalizable

An implementation of Map optimized for usage with SpaceDocument. DocumentProperties contains the following enhancements: 1. Usability: Fluent-styled setProperty method to enable fluent coding. 2. Serialization performance: Externalizable implementation with special optimization for properties names. 3. Memory footprint: Open-addressing algorithm is used to conserve memory usage.

Since:
8.0
Author:
Niv Ingberg
See Also:
SpaceDocument, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
DocumentProperties()
          Constructs a new DocumentProperties.
DocumentProperties(int initialCapacity)
          Constructs a new DocumentProperties with the specified initial capacity.
DocumentProperties(int initialCapacity, float loadFactor)
          Constructs a new DocumentProperties with the specified initial capacity and load factor.
DocumentProperties(Map<String,Object> properties)
          Constructs a new DocumentProperties with the same properties as the specified Map.
 
Method Summary
 void clear()
          
 boolean containsKey(Object key)
          
 boolean containsValue(Object value)
          
 Set<Map.Entry<String,Object>> entrySet()
          
 boolean equals(Object obj)
          Compares the specified object with this map for equality.
 Object get(Object key)
          
<T> T
getProperty(String name)
          Get document property value by name
 int hashCode()
          Returns the hash code value for this map.
 boolean isEmpty()
          
 Set<String> keySet()
          
 Object put(String key, Object value)
          
 void putAll(Map<? extends String,? extends Object> t)
          
 void readExternal(ObjectInput in)
          
 Object remove(Object key)
          
 DocumentProperties setProperty(String name, Object value)
          Set document property
 int size()
          
 String toString()
          
 Collection<Object> values()
          
 void writeExternal(ObjectOutput out)
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DocumentProperties

public DocumentProperties()
Constructs a new DocumentProperties.


DocumentProperties

public DocumentProperties(int initialCapacity)
Constructs a new DocumentProperties with the specified initial capacity.

Parameters:
initialCapacity - The initial capacity.

DocumentProperties

public DocumentProperties(int initialCapacity,
                          float loadFactor)
Constructs a new DocumentProperties with the specified initial capacity and load factor.

Parameters:
initialCapacity - The initial capacity.
loadFactor - The load factor.

DocumentProperties

public DocumentProperties(Map<String,Object> properties)
Constructs a new DocumentProperties with the same properties as the specified Map.

Parameters:
properties - The map whose mappings are to be copied.
Method Detail

getProperty

public <T> T getProperty(String name)
Get document property value by name

Parameters:
name - property name
Returns:
the property value

setProperty

public DocumentProperties setProperty(String name,
                                      Object value)
Set document property

Parameters:
name - property name
value - property value

size

public int size()

Specified by:
size in interface Map<String,Object>

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Map<String,Object>

containsKey

public boolean containsKey(Object key)

Specified by:
containsKey in interface Map<String,Object>

containsValue

public boolean containsValue(Object value)

Specified by:
containsValue in interface Map<String,Object>

get

public Object get(Object key)

Specified by:
get in interface Map<String,Object>

put

public Object put(String key,
                  Object value)

Specified by:
put in interface Map<String,Object>

remove

public Object remove(Object key)

Specified by:
remove in interface Map<String,Object>

putAll

public void putAll(Map<? extends String,? extends Object> t)

Specified by:
putAll in interface Map<String,Object>

clear

public void clear()

Specified by:
clear in interface Map<String,Object>

keySet

public Set<String> keySet()

Specified by:
keySet in interface Map<String,Object>

values

public Collection<Object> values()

Specified by:
values in interface Map<String,Object>

entrySet

public Set<Map.Entry<String,Object>> entrySet()

Specified by:
entrySet in interface Map<String,Object>

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException

Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException

Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

toString

public String toString()

Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Compares the specified object with this map for equality. Returns true if the given object is also a map and the two Maps represent the same mappings. More formally, two maps t1 and t2 represent the same mappings if t1.entrySet().equals(t2.entrySet()). This ensures that the equals method works properly across different implementations of the Map interface.

Specified by:
equals in interface Map<String,Object>
Overrides:
equals in class Object
Parameters:
obj - object to be compared for equality with this map.
Returns:
true if the specified object is equal to this map.

hashCode

public int hashCode()
Returns the hash code value for this map. The hash code of a map is defined to be the sum of the hashCodes of each entry in the map's entrySet view. This ensures that t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two maps t1 and t2, as required by the general contract of Object.hashCode.

Specified by:
hashCode in interface Map<String,Object>
Overrides:
hashCode in class Object
Returns:
the hash code value for this map.
See Also:
Object.hashCode(), Object.equals(Object), equals(Object)

GigaSpaces XAP 10.0.1 API

Copyright © GigaSpaces.