Package com.gigaspaces.document
Class SpaceDocument
java.lang.Object
com.gigaspaces.document.SpaceDocument
- All Implemented Interfaces:
VirtualEntry,SmartExternalizable,Externalizable,Serializable
- Direct Known Subclasses:
CDCInfo,DeletedDocumentInfo
Represents a document which can be stored and retrieved from the space.
A document is a collection of properties (which are name-value pairs) associated with a type. A
property name is a string. A property value can be of any type, but it is usually either a scalar
(e.g. int, String, Date, etc.), a set of properties (either
Map or DocumentProperties), or an array/collection or scalars or maps.
Documents of the same type can have different properties, which provides more dynamic schema than
POJOs.- Since:
- 8.0
- Author:
- Niv Ingberg
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a space document of type java.lang.Object.SpaceDocument(String typeName) Creates a space document of the specified type.SpaceDocument(String typeName, Map<String, Object> properties) Creates a space document of the specified type with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionaddProperties(Map<String, Object> properties) Adds the specified properties to the document's current properties.booleancontainsProperty(String name) Returns true if this document contains the specified property.booleanReturns an unmodifiable view of the document's properties.<T> TgetProperty(String name) Gets a property's value by its name.intReturns the entry's version.inthashCode()voidinitFromDocument(SpaceDocument document) protected voidbooleanvoidThis method is required by theExternalizableinterface and should not be called directly.void<T> TremoveProperty(String name) Removes the property from the document (if it exists).setProperty(String name, Object value) Sets a property's value by its name.setTransient(boolean isTransient) Sets whether or not the entry is transient.setTypeName(String typeName) Sets the document type name.setVersion(int version) Sets the entry's version.toString()voidThis method is required by theExternalizableinterface and should not be called directly.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.gigaspaces.serialization.SmartExternalizable
enabledSmartExternalizableWithReference
-
Constructor Details
-
SpaceDocument
public SpaceDocument()Creates a space document of type java.lang.Object. -
SpaceDocument
Creates a space document of the specified type.- Parameters:
typeName- Name of document's type.
-
SpaceDocument
Creates a space document of the specified type with the specified properties.- Parameters:
typeName- Name of document's type.properties- Properties to set in document.
-
-
Method Details
-
initialize
protected void initialize() -
getTypeName
- Specified by:
getTypeNamein interfaceVirtualEntry- Returns:
- the type name.
-
setTypeName
Sets the document type name.- Specified by:
setTypeNamein interfaceVirtualEntry- Parameters:
typeName- Type name to set.- Returns:
- This document (used for fluent method chaining).
-
containsProperty
Returns true if this document contains the specified property.- Specified by:
containsPropertyin interfaceVirtualEntry- Parameters:
name- Name of property to look for.- Returns:
- Returns true if this document contains the specified property, false otherwise.
-
getProperty
Gets a property's value by its name. If the property does not exist in this document null is returned.- Specified by:
getPropertyin interfaceVirtualEntry- Parameters:
name- Name of property.- Returns:
- Value of property.
-
setProperty
Sets a property's value by its name. If the property is already defined in this document the existing value is overridden.- Specified by:
setPropertyin interfaceVirtualEntry- Parameters:
name- Name of propertyvalue- New value of property.- Returns:
- This document (used for fluent method chaining).
-
removeProperty
Removes the property from the document (if it exists).- Specified by:
removePropertyin interfaceVirtualEntry- Parameters:
name- Name of property to remove.- Returns:
- Previous value associated with specified property, or null if there was no such property.
-
getProperties
Returns an unmodifiable view of the document's properties. Attempts to modify the returned map, whether direct or via its collection views, result in an UnsupportedOperationException.- Specified by:
getPropertiesin interfaceVirtualEntry- Returns:
- Reference to document's properties map.
-
addProperties
Adds the specified properties to the document's current properties.- Specified by:
addPropertiesin interfaceVirtualEntry- Parameters:
properties- Properties to add.- Returns:
- This document (used for fluent method chaining).
-
getVersion
public int getVersion()Returns the entry's version.- Specified by:
getVersionin interfaceVirtualEntry- Returns:
- This document (used for fluent method chaining).
-
setVersion
Sets the entry's version.- Specified by:
setVersionin interfaceVirtualEntry- Returns:
- This document (used for fluent method chaining).
-
isTransient
public boolean isTransient()- Specified by:
isTransientin interfaceVirtualEntry- Returns:
- true if the entry is transient, false otherwise.
-
setTransient
Sets whether or not the entry is transient.- Specified by:
setTransientin interfaceVirtualEntry- Returns:
- This document (used for fluent method chaining).
-
toString
-
equals
-
hashCode
public int hashCode() -
writeExternal
This method is required by theExternalizableinterface and should not be called directly.- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
This method is required by theExternalizableinterface and should not be called directly.- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
readExternalV1
- Throws:
IOExceptionClassNotFoundException
-
initFromDocument
-