com.bea.content
Class Property

java.lang.Object
  extended by com.bea.content.ContentEntity
      extended by com.bea.content.Property
All Implemented Interfaces
Serializable, Cloneable

public class Property
extends ContentEntity
implements Cloneable

Property is a name value pair, with the name being unique relative to the Node and the value is an Array of Value objects.

The Value object can represent either BinaryValue, Boolean, Calendar, Double, Long, String, or ID (link property -- link to a node) values.

If the property is multivalued it may contain 0..n Values. If it is not multivalued it may contain 0..1.

A Property is part of a Node and its shape is defined by a PropertyDefinition with the same name in it's Node's ObjectClass.

A property may represent both the content and meta-content for a Node.

Link properties have some special restrictions. They can only be created in extended repositories. A node must exist at the specified ID when the link property is created or saved.

See Also
Serialized Form

Field Summary
static int BINARY
          A Constant to define if the Property is a Binary data type.
static int BOOLEAN
          A Constant to define if the Property is a Boolean data type.
static int CALENDAR
          A Constant to define if the Property is a Calendar data type.
static int DOUBLE
          A Constant to define if the Property is a Double data type.
static int LINK
          A Constant to define if the Property is a Link property type (holds an ID which refers to a Node).
static int LONG
          A Constant to define if the Property is a Long data type.
static int NESTED
          A Constant to define if the Property is a nested type.
static String NESTED_DELIMITER
          The delimiter used for nested property names.
static int STRING
          A Constant to define if the Property is a String data type.
static int UNDEFINED
          If a Property's type is not set, it will be set to this by default.
 
Fields inherited from class com.bea.content.ContentEntity
id
 
Constructor Summary
Property(ID id, String name, int type, Value[] values)
          Constructor with all values.
Property(String name)
          Constructor with just the name.
Property(String name, Value value)
          Constructor for a single value without type.
Property(String name, Value[] values)
          Constructor for multiple values without type.
 
Method Summary
 void addValue(Value value)
          Add a value to the current list of values.
 Object clone()
          Clones a property and its values.
 boolean equals(Object obj)
          Indicates whether some other property is "equal to" this one.
 String getIndexedName()
          Returns the indexed name of the Property.
 String getName()
          Returns the name of the Property.
 int getType()
          Gets the type of the Property.
 String getTypeName(int type)
          Gets the String value of the given property type int.
 Value getValue()
          Gets the first Value.
 Value[] getValues()
          Returns an Array of the Property's Values.
 int hashCode()
          Returns a hash code value for this property.
 boolean hasValue()
          Returns true if any Value instance exists AND that instance has a value.
 boolean isDirty()
          Returns true when the value(s) for this property have changed since construction.
 void removeValue(int position)
          Remove a value from the current list of values.
 void removeValue(Value removeValue)
          Remove a value from the current list of values.
 void setIndexedName(String indexedName)
          Sets the indexed name of the property that is unique to the Node.
 void setName(String name)
          Sets the name of the property that is unique to the Node.
 void setType(int type)
          Sets the type of the Property.
 void setValue(Value value)
          Sets a Value for the Property.
 void setValues(Value[] values)
          Sets the properties values.
 String toPrintString()
          Returns the Property name and values as a String in the format name: value1, value2, value3, along with the property id.
 String toString()
          Returns the Property name and values as a String in the format name: value1, value2, value3
 boolean valuesEqual(Value[] otherValues)
          Compares property's values against a value array.
 
Methods inherited from class com.bea.content.ContentEntity
getId, setId
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDEFINED

public static final int UNDEFINED
If a Property's type is not set, it will be set to this by default.

See Also
Constants Summary

BOOLEAN

public static final int BOOLEAN
A Constant to define if the Property is a Boolean data type.

See Also
Constants Summary

LONG

public static final int LONG
A Constant to define if the Property is a Long data type.

See Also
Constants Summary

DOUBLE

public static final int DOUBLE
A Constant to define if the Property is a Double data type.

See Also
Constants Summary

STRING

public static final int STRING
A Constant to define if the Property is a String data type.

See Also
Constants Summary

CALENDAR

public static final int CALENDAR
A Constant to define if the Property is a Calendar data type.

See Also
Constants Summary

BINARY

public static final int BINARY
A Constant to define if the Property is a Binary data type.

See Also
Constants Summary

NESTED

public static final int NESTED
A Constant to define if the Property is a nested type.

If constructing a Property of nested type, the Value should be of a nested type.

For example: Property myProperty = new Property("myNestedProp", myNestedValue); The parameter "myNestedProp" is the name of the nested Property, which nests the properties of the ObjectClass that it represents. The parameter "myNestedValue" is a Value object that contains an array of Property objects. These nested Property objects contain the properties and values from the nested ObjectClass.

Here is a code example using nested properties:

 

// First create the nested and container ObjectClasses ID repId = new ID(repositoryName, null);

// create nested type with a mandatory primary property PropertyDefinition[] pds = new PropertyDefinition[2]; pds[0] = new PropertyDefinition(repId, "stringType", null, Property.STRING, false, false, false, false, false, null); pds[1] = new PropertyDefinition(repId, "primaryType", null, Property.STRING, false, false, true, false, true, null); nestedType = new ObjectClass(repId, "NestedType", pds[1], pds); nestedType = typeManager.addType(context, nestedType);

// create the container ObjectClass pds = new PropertyDefinition[2]; pds[0] = new PropertyDefinition(repId, "longType", null, Property.LONG, false, false, false, false, false, null); pds[1] = new PropertyDefinition(nestedType.getId(), repId, "nestedType", Property.NESTED, false, multiValued, "nested type"); container = new ObjectClass(repId, "container", null, pds); container = typeManager.addType(context, container);

// Now create a Property that nests another Property Property [] nestedTypeProps = new Property[] { new Property("nestedType.stringType", new Value("hello")), new Property("nestedType.primaryType", new Value("primary")) }; Property [] props = new Property[] { new Property("longType", new Value((long)1)), new Property("nestedType", new Value(nestedTypeProps)) };

// Finally, create a node w/ mandatory property in the nested type node = nodeManager.addNode(context, repositoryPath + "node", null, null); node.setObjectClass(container); node.setProperties(props); node = nodeManager.save(context, node);

See Also
Constants Summary

LINK

public static final int LINK
A Constant to define if the Property is a Link property type (holds an ID which refers to a Node).

See Also
Constants Summary

NESTED_DELIMITER

public static final String NESTED_DELIMITER
The delimiter used for nested property names.

See Also
Constants Summary
Constructor Detail

Property

public Property(String name)
Constructor with just the name. This may be used when creating a property whose type is defined by the PropertyDefinition.

Parameters
name - - the unique name (relative to the Node) of this Property.

Property

public Property(String name,
                Value value)
Constructor for a single value without type. After using this constructor a call to getValue will return the value passed in. A call to getValues will return an array of size one with this value at [0]. This may be used when creating a property whose type is defined by the PropertyDefinition.

Parameters
name - - the unique name (relative to the Node) of this Property.
value - - the value for this Property.

Property

public Property(String name,
                Value[] values)
Constructor for multiple values without type. This may be used when creating a property whose type is defined by the PropertyDefinition.

Parameters
name - - the unique name (relative to the Node) of this Property.
values - - the array of values for this Property.

Property

public Property(ID id,
                String name,
                int type,
                Value[] values)
Constructor with all values.

Parameters
id - - the id for this Property.
name - - the unique name (relative to the Node) of this Property.
type - - the type of this Property.
values - - the array of values for this Property.
Method Detail

getName

public String getName()
Returns the name of the Property. This name is unique to the Node.

If this is a nested type, the name will reflect the nested hierarchy with NESTED_DELIMITER between each parent and child property name. The delimiter is not valid for use within the actual name, only to seperate the parent/child names.

Returns
The property name.

setName

public void setName(String name)
Sets the name of the property that is unique to the Node.

If this is a nested type, the name will reflect the nested hierarchy with NESTED_DELIMITER between each parent and child property name. The delimiter is not valid for use within the actual name, only to seperate the parent/child names.

Parameters
name - The property name.

getIndexedName

public String getIndexedName()
Returns the indexed name of the Property. This name is unique to the Node. This name is needed for multivalued nested types, to show the indexed order and be able to uniquely identify each property, ie person.addresses[0].city, where addresses is the multivalued nested type. If the Property is not a multivalued nested type, the indexedName will be the same as the name.

The indexedName will be populated when the Property is retrieved from the DB, which means that it will not exist until after it is persisted for the first time.

Returns
The indexed name.

setIndexedName

public void setIndexedName(String indexedName)
Sets the indexed name of the property that is unique to the Node. This name is necessary for multivalued nested types, to show the indexed order and be able to uniquely identify each property, ie person.addresses[0].city, where addresses is the multivalued nested type. If the Property is not a multivalued nested type, the indexedName will be the same as the name.

Parameters
indexedName - The indexed name.

getType

public int getType()
Gets the type of the Property.

Returns
The property type as defined in the constants in this class.

setType

public void setType(int type)
Sets the type of the Property.

Parameters
type - The property type as defined in the constants in this class.

getTypeName

public String getTypeName(int type)
Gets the String value of the given property type int.

Parameters
type - The property type as defined in the constants in this class.
Returns
The type name as a String.

getValue

public Value getValue()
Gets the first Value. Useful for single value Property.

Returns
The property value.

getValues

public Value[] getValues()
Returns an Array of the Property's Values.

Returns
An array of the property's values.

setValues

public void setValues(Value[] values)
Sets the properties values.

Parameters
values - The properties values.

setValue

public void setValue(Value value)
Sets a Value for the Property.

Parameters
value - The property value.

addValue

public void addValue(Value value)
Add a value to the current list of values.

Parameters
value - The property value to add.

removeValue

public void removeValue(Value removeValue)
                 throws RepositoryException
Remove a value from the current list of values. Removes the first value found which matches the given value. Value equivalence is determined by the rules as described in Value.compareTo(Object)

Parameters
removeValue - The value to remove
Throws
RepositoryException - If the given value isn't found in the properties array.

removeValue

public void removeValue(int position)
                 throws ArrayIndexOutOfBoundsException
Remove a value from the current list of values. Removes the value found at the given position.

Parameters
position - The array position (as found in getValues())
Throws
ArrayIndexOutOfBoundsException - If the position given is not found in the properties array.

hasValue

public boolean hasValue()
Returns true if any Value instance exists AND that instance has a value.

Returns
True if the property has a value.

valuesEqual

public boolean valuesEqual(Value[] otherValues)
Compares property's values against a value array. Returns true if there is a match found for all values in the given array with the values found on this property. Order of values in the property or the given array is not considered. This method will not return the correct value if the property value is binary.

Parameters
otherValues - An array of values to compare against.
Returns
True if all of the values in the given array are equivalent to the values for this Property.

toString

public String toString()
Returns the Property name and values as a String in the format name: value1, value2, value3

Overrides:
toString in class ContentEntity

toPrintString

public String toPrintString()
Returns the Property name and values as a String in the format name: value1, value2, value3, along with the property id.

Returns
The printable version of this object.

isDirty

public boolean isDirty()
Returns true when the value(s) for this property have changed since construction.

Returns
true if dirty.

equals

public boolean equals(Object obj)
Indicates whether some other property is "equal to" this one.

Overrides:
equals in class Object
Parameters
obj - the reference object with which to compare.
Returns
True if the given object is the same as this property.

hashCode

public int hashCode()
Returns a hash code value for this property.

Overrides:
hashCode in class Object
Returns
a hash code value for this property.

clone

public Object clone()
             throws CloneNotSupportedException
Clones a property and its values. Note that binary value streams of property values are not cloned, but merely copied.

Overrides:
clone in class ContentEntity
Returns
A clone of the property.
Throws
CloneNotSupportedException - If the clone fails.


Copyright © 2011, Oracle. All rights reserved.