Package org.eclipse.birt.report.model.api

# Class SimpleValueHandle

java.lang.Object
org.eclipse.birt.report.model.api.ElementDetailHandle
org.eclipse.birt.report.model.api.ValueHandle
org.eclipse.birt.report.model.api.SimpleValueHandle

Direct Known Subclasses:
  `MemberHandle`, `PropertyHandleImpl`

public abstract class SimpleValueHandle extends ValueHandle
Abstract base class that represents a handle for the value to either a property or a structure member.

## Field Summary

### Fields inherited from class org.eclipse.birt.report.model.api.ElementDetailHandle

`elementHandle`

## Constructor Summary

Constructors
Constructor
Description
`SimpleValueHandle(DesignElementHandle element)`
Constructs a handle with the given handle to an design element.

## Method Summary

Modifier and Type
Method
Description
`abstract void`
`addItem(Object item)`
Adds an item to the end of a list property.
`StructureHandle`
`addItem(IStructure item)`
Adds an item to the end of a list property or member.
`void`
`clearValue()`
Clears the value of the property or member.
`Object`
`get(int n)`
Returns the the nth entry in a list property or member.
`StructureHandle`
`getAt(int n)`
Returns the the nth entry in a list property or member.
`IChoice[]`
`getChoices()`
Returns the array of choices that are defined for this property or member.
`String`
`getDefaultUnit()`
Gets the default unit of the property.
`abstract IPropertyDefn`
`getDefn()`
Gets the generic property definition.
`String`
`getDisplayValue()`
gets the localized value of the property.
`double`
`getFloatValue()`
Gets the value as a double.
`int`
`getIntValue()`
Gets the value as an integer.
`List`
`getItems()`
Gets the items of the list property.
`ArrayList`
`getListValue()`
Gets the value as a list.
`BigDecimal`
`getNumberValue()`
Gets the value as a number (BigDecimal).
`protected abstract Object`
`getRawValue()`
Gets the value stored in the memory directly.
`String`
`getStringValue()`
Gets the value as a string.
`int`
`getTypeCode()`
Returns the numeric code for the type of this property or member.
`final Object`
`getValue()`
Gets the value of the property as a generic object.
`int`
`indexOf(Object o)`
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
`StructureHandle`
`insertItem(IStructure item, int posn)`
Inserts a new item into a list property or member at the given position.
`protected boolean`
`isList()`
Indicate if this handle is working on a list property.
`abstract boolean`
`isReadOnly()`
Checks whether a value is read-only in the property sheet.
`abstract boolean`
`isVisible()`
Checks whether a value is visible in the property sheet.
`Iterator`
`iterator()`
Returns an iterator over the values in a list property, or `null` if the property is not a list property.
`void`
`moveItem(int from, int to)`
Moves an item within a list property or member.
`abstract void`
`removeItem(int posn)`
Removes an item from a list property or member.
`final void`
`removeItem(Object item)`
Removes an item from a list property or member.
`void`
`removeItems(List items)`
Removes all the items in the list from a list property or member.
`void`
`replaceItem(IStructure oldItem, IStructure newItem)`
Replaces an old structure with a new one for the this property or member.
`void`
`setFloatValue(double value)`
Sets the value of the property or member to the given double.
`void`
`setIntValue(int value)`
Sets the value of the property or member to the given integer.
`void`
`setNumberValue(BigDecimal value)`
Sets the value of the property or member to the given number.
`void`
`setStringValue(String value)`
Sets the value of the property or member to the given integer.
`abstract void`
`setValue(Object value)`
Sets the value of a property or member to the object given.

### Methods inherited from class org.eclipse.birt.report.model.api.ValueHandle

`getContext, getPropertyDefn, getReference`

### Methods inherited from class org.eclipse.birt.report.model.api.ElementDetailHandle

`getDesign, getElement, getElementHandle, getModule`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SimpleValueHandle

public SimpleValueHandle(DesignElementHandle element)
Constructs a handle with the given handle to an design element.

Parameters:
  `element` - a handle to a report element

## Method Details

### getDefn

public abstract IPropertyDefn getDefn()
Gets the generic property definition. Its a property definition for an element or a member definition for a structure.

Returns:
  the value definition.

### getRawValue

protected abstract Object getRawValue()
Gets the value stored in the memory directly. The returned value won't be done any conversion.

Returns:
  the value stored in the memory

### getValue

public final Object getValue()
Gets the value of the property as a generic object. Use the specialized methods to get the value as a particular type.

Returns:
  The value of the property as a generic object.
See Also:
  - `getStringValue()`
  - `getIntValue()`
  - `getFloatValue()`
  - `getNumberValue()`

### getIntValue

public int getIntValue()
Gets the value as an integer.

Returns:
  The value as an integer. Returns 0 if the value cannot be converted to an integer.

### getStringValue

public String getStringValue()
Gets the value as a string.

Returns:
  The value as a string.

### getFloatValue

public double getFloatValue()
Gets the value as a double.

Returns:
  The value as a double. Returns 0 if the value cannot be converted to a double.

### getNumberValue

public BigDecimal getNumberValue()
Gets the value as a number (BigDecimal).

Returns:
  The value as a number. Returns null if the value cannot be converted to a number.

### getListValue

public ArrayList getListValue()
Gets the value as a list.

Returns:
  The value as a list. Returns null if the value cannot be converted to a list.

### getDisplayValue

public String getDisplayValue()
gets the localized value of the property.

Returns:
  the localized value

### getAt

public StructureHandle getAt(int n)
Returns the the nth entry in a list property or member. Use this method for properties that contain a list of structures. The index must be valid for the list.

Parameters:
  `n` - The list index.
Returns:
  A handle to the structure at the given index.

### get

public Object get(int n)
Returns the the nth entry in a list property or member. Use this method for properties that contain a list of items. The index must be valid for the list. In the following cases, this method will return a meaningful value:

If this property or member is a structure list type, then return `StructureHandle`.
If this property or member is a list of element reference, return `DesignElementHandle` if resolved, otherwise return the qualified name of the referred element.
If this property or member is a list of simeple value(int, float, decimal, date-time, string), then return the atomice Java Object(Integer, Float, Double, BigDecimal, Date, String).
If this property or member is not a list value or the index is out of range, then return `null`.

Parameters:
  `n` - The list index.
Returns:
  A handle to the structure, a handle to the referred element, or some simple value(int, float, decimal, data-time, string) at the given index.

- ### indexOf

  public int indexOf(Object o)
  Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the lowest index `i` such that `(o==null ? get(i)==null : o.equals(get(i)))`, or -1 if there is no such index.
  Parameters:
    `o` - element to search for.
  Returns:
    the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.

- ### getTypeCode

  public int getTypeCode()
  Returns the numeric code for the type of this property or member. The types are defined in the `PropertyType` class.
  Returns:
    The property type code.
  See Also:
    - `PropertyType`

- ### iterator

  public Iterator iterator()
  Returns an iterator over the values in a list property, or `null` if the property is not a list property. The iterator returns a `StructureHandle` for each entry in the list. For highlight rules, the iterator returns a list of `HighlightRuleHandle`s.
  Returns:
    An iterator over the values in a list property.
  See Also:
    - `StructureHandle`
    - `StructureIterator`

- ### setIntValue

  public void setIntValue(int value) throws SemanticException
  Sets the value of the property or member to the given integer. It can also be used to set dimensions but dimensions are better set using a double.
  Parameters:
    `value` - The value to set.
  Throws:
    `SemanticException` - If the property value cannot be converted from an integer, or if the value of a choice is incorrect.

- ### setStringValue

  public void setStringValue(String value) throws SemanticException
  Sets the value of the property or member to the given integer. Use this for properties such as expressions, labels, HTML, or XML. Also use it to set the value of a choice using the internal string name of the choice. Use it to set the value of a dimension when using specified units, such as "10pt".
  Parameters:
    `value` - The value to set.
  Throws:
    `SemanticException` - If the value of a choice or other property is incorrect.

- ### setFloatValue

  public void setFloatValue(double value) throws SemanticException
  Sets the value of the property or member to the given double. Used primarily for dimension properties. The units of the dimension are assumed to be application units.
  Parameters:
    `value` - The value to set.
  Throws:
    `SemanticException` - If the property value cannot be converted from a double.

- ### setNumberValue

  public void setNumberValue(BigDecimal value) throws SemanticException
  Sets the value of the property or member to the given number.
  Parameters:
    `value` - The value to set.
  Throws:
    `SemanticException` - If the property value cannot be converted from a number.

- ### clearValue

  public void clearValue() throws SemanticException
  Clears the value of the property or member.
  Throws:
    `SemanticException` - If the value cannot be cleared.

- ### setValue

  public abstract void setValue(Object value) throws SemanticException
  Sets the value of a property or member to the object given. If the object is `null`, then the value is cleared.
  Parameters:
    `value` - The new value.
  Throws:
    `SemanticException` - If the value is not valid for the property or member.
  See Also:
    - `setIntValue(int)`
    - `setStringValue(java.lang.String)`
    - `setFloatValue(double)`
    - `setNumberValue(java.math.BigDecimal)`
    - `clearValue()`

- ### removeItem

  public abstract void removeItem(int posn) throws PropertyValueException
  Removes an item from a list property or member. The handle must be working on a list property or member.
  Parameters:
    `posn` - The position of the item to remove.
  Throws:
    `PropertyValueException` - If the property is not a list property.
    `IndexOutOfBoundsException` - if the given `posn` is out of range `(index < 0 || index >= list.size())`.

- ### removeItem

  public final void removeItem(Object item) throws PropertyValueException
  Removes an item from a list property or member. The handle must be working on a list property or member.The item should be a meaningfule value in the following cases:

- If this property or member is a structure list type, the item should be a `StructureHandle` or `Structure`.
- If this property or member is a list of element reference, the item should be `DesignElementHandle` or `IDesignElement` .
- If this property or member is a list of simeple value(int, float, decimal, date-time, string), then return the atomice Java Object(Integer, Float, Double, BigDecimal, Date, String).

Parameters:
  `item` - the item to remove
Throws:
  `PropertyValueException` - If the property is not a list property, or if the given item is not contained in the list.

- ### removeItems

  public void removeItems(List items) throws PropertyValueException
  Removes all the items in the list from a list property or member. The handle must be working on a list property or member. Each one in the list is instance of `StructureHandle`
  Parameters:
    `items` - the item list to remove
  Throws:
    `PropertyValueException` - If the property or the member is not a list type, or if any item in the list is not found

- ### replaceItem

  public void replaceItem(IStructure oldItem, IStructure newItem) throws SemanticException
  Replaces an old structure with a new one for the this property or member. The handle must be working on a list property or member.
  Parameters:
    `oldItem` - the old item to be replaced.
    `newItem` - the new item.
  Throws:
    `SemanticException` - if the property/member does not contain the list value or the new structure is invalid or the old structure is not contained in the list.

- ### addItem

  public StructureHandle addItem(IStructure item) throws SemanticException
  Adds an item to the end of a list property or member. The handle must be working on a list property or member.
  Parameters:
    `item` - The new item to add.
  Returns:
    a handle to the newly added structure; return null if the item is null.
  Throws:
    `SemanticException` - If the property is not a list property, or if the the value of the item is incorrect.

- ### addItem

  public abstract void addItem(Object item) throws SemanticException
  Adds an item to the end of a list property. The handle must be working on a list property.
  Parameters:
    `item` - The new item to add.
  Throws:
    `SemanticException` - If the property is not a list property, or if the the value of the item is incorrect.

- ### insertItem

  public StructureHandle insertItem(IStructure item, int posn) throws SemanticException
  Inserts a new item into a list property or member at the given position. The handle must be working on a list property or member.
  Parameters:
    `item` - The new item to insert.
    `posn` - The insert position.
  Returns:
    a handle to the newly inserted structure, return null if the item is null.
  Throws:
    `SemanticException` - If the property is not a list property, or if the the value of the item is incorrect.
    `IndexOutOfBoundsException` - if the given `posn` is out of range `(index < 0 || index > list.size())`.

- ### moveItem

  public void moveItem(int from, int to) throws PropertyValueException
  Moves an item within a list property or member. The handle must be working on a list property or member.
  Parameters:
    `from` - The current position of the item to move
    `to` - The new position of the item to move.
  Throws:
    `PropertyValueException` - If the property is not a list property.
    `IndexOutOfBoundsException` - if the given from or to index is out of range `(index < 0 || index >= list.size())`.

- ### getChoices

  public IChoice[] getChoices()
  Returns the array of choices that are defined for this property or member.
  Returns:
    an array containing choices of this property. Return `null`, if this property has no choice.
  See Also:
    - `Choice`

- ### isList

  protected boolean isList()
  Indicate if this handle is working on a list property.
  Returns:
    `true` if the handle is working on a list property, otherwise return `false`

- ### getDefaultUnit

  public String getDefaultUnit()
  Gets the default unit of the property.
  Returns:
    the default unit if the property is dimension type, otherwise empty string

- ### isVisible

  public abstract boolean isVisible()
  Checks whether a value is visible in the property sheet.
  Returns:
    `true` if it is visible. Otherwise `false`.

- ### isReadOnly

  public abstract boolean isReadOnly()
  Checks whether a value is read-only in the property sheet.
  Returns:
    `true` if it is read-only. Otherwise `false`.

- ### getItems

  public List getItems()
  Gets the items of the list property. The handle must be working on a list property or member.
  Returns:
    the list of items, or null if the property is not a list property.