|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Root Document interface. A Document is the fundamental unit managed by a Storage. A Document may have an arbitrary number of named properties, each with one or more values. The numbers and types of values of various properties may be constrained by schema restrictions enforced for the Storage instance. A Document may have an arbitrary number of schemas enforced upon it, and the set of enforced schemas may be changed at any time. While a schema is enforced upon a Document, the implementation must guarantee that the document has all non-optional properties of the schema and that the schema restrictions on numbers and types of values are enforced. In the absence of any schema restrictions for a particular property, a document may have one or more values of the property and the values may be of any Serializable Java type. All values of a particular property on a particular document must have the same type. Having zero values of a property is equivalent to not having the property. Java null is never a legal property value. A Storage implementation has flexibility in how values are stored, and will not necessarily use the standard serialized representation in all cases, though it must be capable of restoring an equivalent value.
Note that it is possible to store an arbitrary serializable collection of Java objects as a value of a property. Such objects are always treated as opaque single values of a property and are not subject to any form of containment query.
A Document object obtained from a Storage implementation may be used as a property value to link documents.
For programmer convenience, methods are provided in the Document interface for simple access to single-valued properties. These methods may only be used in a single-valued context, meaning one of the following must hold:
Applications should use the single-valued interfaces only in those situations where the property is guaranteed to be single-valued, which is exactly when a schema enforces a maximum of 1 value.
| Method Summary | |
void |
addMultiValue(FieldDescriptor desc,
Serializable value)
Adds property value by field descriptor. |
void |
addMultiValue(String name,
Serializable value)
Adds property value. |
boolean |
clearProperty(FieldDescriptor desc)
Remove any and all values of a property by field descriptor. |
boolean |
clearProperty(String name)
Remove any and all values of a property. |
boolean |
conformsTo(Schema schema)
Determine whether the document conforms to the specified schema. |
boolean |
containsValue(FieldDescriptor desc,
Serializable val)
Determines whether specified value is one of the values of the property |
boolean |
containsValue(String name,
Serializable val)
Determines whether specified value is one of the values of the property |
void |
delete()
Delete the document. |
void |
enforceSchema(Schema schema)
Enforce the specified schema on the document. |
void |
enforceSchema(Schema schema,
Map props)
Enforce the specified schema on the document. |
void |
flush()
Force any recent changes to this document to be written to stable storage immediately. |
String[] |
get_all_property_names()
Get names of all set properties, including internal properties. |
FieldDescriptor[] |
getDescriptors(Schema schema)
Get descriptors of set properties from a schema. |
Schema[] |
getEnforcedSchemas()
Get all schemas enforced on the document. |
String |
getID()
Get the document's unique ID. |
Collection |
getMultiValues(FieldDescriptor desc)
Gets the values of a property by field descriptor. |
Collection |
getMultiValues(String name)
Gets the values of a property. |
String |
getName()
Return a canonical "name" value that can be displayed along with the document. |
String[] |
getPropertyNames()
Get names of set properties. |
String[] |
getPropertyNames(String prefix)
Get names of set properties with the supplied property name prefix. |
Object |
getPropertyValue(FieldDescriptor desc)
Returns the value of a single-valued property by field descriptor. |
Object |
getPropertyValue(String name)
Returns the value of a single-valued property if set, or null otherwise. |
Storage |
getStorage()
Return the storage object associated with this document. |
String[] |
getUnenforcedPropertyNames(String prefix)
Get names of set properties that do not belong to an enforced schema. |
boolean |
isEnforced(Schema schema)
Determine whether the specified schema is currently enforced on the document. |
boolean |
propertyExists(FieldDescriptor desc)
Determines whether the property is set by field descriptor. |
boolean |
propertyExists(String name)
Determines whether the property is set. |
boolean |
removeValue(FieldDescriptor desc,
Serializable value)
Removes a property value if present by field descriptor. |
boolean |
removeValue(String name,
Serializable value)
Removes a property value if present. |
void |
setMultiValues(FieldDescriptor desc,
Collection values)
Sets the values of property by field descriptor. |
void |
setMultiValues(String name,
Collection values)
Sets the values of property. |
void |
setName(String name)
Set the canonical name of the document. |
void |
setPropertyValue(FieldDescriptor desc,
Serializable value)
Sets the value of a single-valued property by field descriptor. |
void |
setPropertyValue(String name,
Serializable value)
Set the value of a single-valued property. |
boolean |
unenforceSchema(Schema schema)
Stop enforcing the specified schema on the document. |
| Method Detail |
public String getID()
public Storage getStorage()
public String getName()
public void setName(String name)
throws StorageException
name - Name of document
public void flush()
throws StorageException
StorageException - if the implementation does not support flush or encounters an error on writing
public void delete()
throws StorageException
public Schema[] getEnforcedSchemas()
throws StorageException
public void enforceSchema(Schema schema)
throws StorageException
schema - The schema to enforceStorageException - if the document does not conform to schema
public void enforceSchema(Schema schema,
Map props)
throws StorageException
schema - The schema to enforceprops - Map supplying (property id,value) pairs to satisfy the
requirements of the enforced schema, where id is a String property name
or a FieldDescriptor
name or a FieldDescriptor reference to a property.
public boolean unenforceSchema(Schema schema)
throws StorageException
schema - the schema that is not to be enforced
public boolean isEnforced(Schema schema)
throws StorageException
schema - the schema to check
public boolean conformsTo(Schema schema)
throws StorageException
schema - the schema to check
public void setPropertyValue(String name,
Serializable value)
throws StorageException
name - name of property to setvalue - value to set
public void setPropertyValue(FieldDescriptor desc,
Serializable value)
throws StorageException
desc - field descriptor identifying a propertyvalue - value to set
public Object getPropertyValue(String name)
throws StorageException
name - name of property
public Object getPropertyValue(FieldDescriptor desc)
throws StorageException
desc - field descriptor identifying a property
public void setMultiValues(String name,
Collection values)
throws StorageException
name - the property namevalues - a collection containing the values to set
public void setMultiValues(FieldDescriptor desc,
Collection values)
throws StorageException
desc - field descriptor identifying a propertyvalues - a collection containing the values to set
public void addMultiValue(String name,
Serializable value)
throws StorageException
name - name of propertyvalue - the value to add
public void addMultiValue(FieldDescriptor desc,
Serializable value)
throws StorageException
desc - field descriptor identifying a propertyvalue - the value to add
public Collection getMultiValues(String name)
throws StorageException
name - the name of the property
public Collection getMultiValues(FieldDescriptor desc)
throws StorageException
desc - field descriptor identifying a property
public boolean containsValue(FieldDescriptor desc,
Serializable val)
throws StorageException
desc - field descriptor identifying a propertyval - a value to test
public boolean containsValue(String name,
Serializable val)
throws StorageException
name - name of a propertyval - a value to test
public boolean removeValue(String name,
Serializable value)
throws StorageException
name - the name of the property.
public boolean removeValue(FieldDescriptor desc,
Serializable value)
throws StorageException
desc - field descriptor identifying a property
public boolean clearProperty(String name)
throws StorageException
name - the name of the property
public boolean clearProperty(FieldDescriptor desc)
throws StorageException
desc - field descriptor identifying a property
public boolean propertyExists(String name)
throws StorageException
name - the name of the property
public boolean propertyExists(FieldDescriptor desc)
throws StorageException
desc - field descriptor identifying property
public String[] getPropertyNames()
throws StorageException
public String[] getPropertyNames(String prefix)
throws StorageException
prefix - the prefix
public String[] getUnenforcedPropertyNames(String prefix)
throws StorageException
prefix - prefix to filter with or null
public FieldDescriptor[] getDescriptors(Schema schema)
throws StorageException
schema - the schema to check
public String[] get_all_property_names()
throws StorageException
|
Project Harland | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||