com.bea.content
Class Value

java.lang.Object
  extended by com.bea.content.Value
All Implemented Interfaces
Serializable, Cloneable, Comparable

public class Value
extends Object
implements Serializable, Cloneable, Comparable

The value for a Property. The typed value can be null. If you call a getter method for a different data type, such as getLongValue() where the type of the property which contains the value is Property.DOUBLE, the long value should be null. Likewise if you set a value of an incorrect data type the underlying repository will ignore that value. It is specific to the repository and SPI implementor whether or not this is an error condition.

See Also
Serialized Form

Constructor Summary
Value()
          Constructs an empty Value.
Value(BinaryValue binaryValue)
          Constructs a BinaryValue Value.
Value(Boolean booleanValue)
          Constructs a Boolean value.
Value(Calendar calendarValue)
          Constructs a Calendar value.
Value(Double doubleValue)
          Constructs a Double value.
Value(ID linkedNodeIdValue)
          Constructs a Link value, which refers to a node.
Value(Long longValue)
          Constructs a Long value.
Value(Property[] nestedValue)
          Constructs a nested value.
Value(String stringValue)
          Constructs a String value.
 
Method Summary
 Object clone()
          Clones a value.
 int compareTo(Object obj)
          Compares this Value to the given object.
 boolean equals(Object obj)
          Indicates whether some other value is "equal to" this one.
 BinaryValue getBinaryValue()
          The value as a BinaryValue.
 Boolean getBooleanValue()
          The value as a Boolean.
 Calendar getCalendarValue()
          The value as a Calendar.
 Double getDoubleValue()
          The value as a Double.
 ID getLinkValue()
          The value as a Link node ID.
 Long getLongValue()
          The value as a Long.
 Property[] getNestedValue()
          The value as an array of Property objects, a nested type.
 int getOrderedPosition()
          If multivalued property, the position dictates the order
 String getStringValue()
          The value as a String.
 Object getValue()
          Gets the Value as an Object.
 Object getValueByType(int type)
          Return the correct value based on the type.
 int hashCode()
          Returns a hash code value for this value.
 void setOrderedPosition(int position)
          Set the position dictating the order, if the Value is part of a Value[] on a Property.
 String toString()
          Returns the Value as a String, except if the value is Binary, in which case mimeType, name and size is returned.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Value

public Value()
Constructs an empty Value.


Value

public Value(BinaryValue binaryValue)
Constructs a BinaryValue Value.

Parameters
binaryValue - The binary value.

Value

public Value(Boolean booleanValue)
Constructs a Boolean value.

Parameters
booleanValue - The boolean value.

Value

public Value(Calendar calendarValue)
Constructs a Calendar value.

Parameters
calendarValue - The calendar value.

Value

public Value(Double doubleValue)
Constructs a Double value.

Parameters
doubleValue - The double value.

Value

public Value(ID linkedNodeIdValue)
Constructs a Link value, which refers to a node.

Parameters
linkedNodeIdValue - The linked node id value.

Value

public Value(Long longValue)
Constructs a Long value.

Parameters
longValue - The long value.

Value

public Value(String stringValue)
Constructs a String value.

Parameters
stringValue - The string value.

Value

public Value(Property[] nestedValue)
Constructs a nested value.

Parameters
nestedValue - The nested value.
Method Detail

getBinaryValue

public BinaryValue getBinaryValue()
The value as a BinaryValue.

Returns
The binary value.

getOrderedPosition

public int getOrderedPosition()
If multivalued property, the position dictates the order

Note: If this Value is set on more than one property, this position cannot be different for each Property. It is best to avoid setting the position if this Value is going to be added to multiple properties.

Returns
The ordered position.

setOrderedPosition

public void setOrderedPosition(int position)
Set the position dictating the order, if the Value is part of a Value[] on a Property.

Note: If this Value is set on more than one property, this position cannot be different for each Property. It is best to avoid setting the position if this Value is going to be added to multiple properties.

Parameters
position - The position of this Value in the array of multivalued values, if applicable

getBooleanValue

public Boolean getBooleanValue()
The value as a Boolean.

Returns
The boolean value.

getCalendarValue

public Calendar getCalendarValue()
The value as a Calendar.

Returns
The calendar value.

getDoubleValue

public Double getDoubleValue()
The value as a Double.

Returns
The double value.

getLinkValue

public ID getLinkValue()
The value as a Link node ID.

Returns
The link value.

getLongValue

public Long getLongValue()
The value as a Long.

Returns
The long value.

getStringValue

public String getStringValue()
The value as a String.

Returns
The string value.

getNestedValue

public Property[] getNestedValue()
The value as an array of Property objects, a nested type.

Returns
The nested value array.

getValueByType

public Object getValueByType(int type)
Return the correct value based on the type. The user will then cast it to the appropriate object.

Parameters
type - The data type of the value as found in the constants in the Property class.
Returns
The value.

getValue

public Object getValue()
Gets the Value as an Object.

Returns
The value.

compareTo

public int compareTo(Object obj)
Compares this Value to the given object. This performs a native compare on all types, with the exception that Calendar values are compared based on the time in milliseconds and BinaryValue is compared by name.

Specified by:
compareTo in interface Comparable
Parameters
obj - the Object to be compared.
Returns
the int value 0 if the Value being compared is equal to the argument Object; a value less than 0 if the Value being compared is somehow (this varies depending on the specific type of value) less than the argument Object; and a value greater than 0 if the Value being compared is somehow greater than the argument Object (signed comparison).

toString

public String toString()
Returns the Value as a String, except if the value is Binary, in which case mimeType, name and size is returned.

Note: Calendar values will be printed with the default Locale.
If there's a need to print the date in some specific format, call getCalendarValue() and use a DateFormatter to format the returned Calendar as desired.

Overrides:
toString in class Object

clone

public Object clone()
             throws CloneNotSupportedException
Clones a value. Note that binary value stream values are not cloned, but merely copied.

Overrides:
clone in class Object
Returns
A clone of the value.
Throws
CloneNotSupportedException - If the clone fails.

equals

public boolean equals(Object obj)
Indicates whether some other value 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 value.

hashCode

public int hashCode()
Returns a hash code value for this value. This should match the hash of the actual value represented by this object.

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


Copyright © 2011, Oracle. All rights reserved.