Remote System Explorer DataStore
Release 3.3

org.eclipse.dstore.core.model
Class DataElement

java.lang.Object
  extended by org.eclipse.dstore.core.model.DataElement
All Implemented Interfaces:
IAdaptable, IDataElement, IElement

public final class DataElement
extends Object
implements IDataElement

DataElement is the unit of information for the DataStore. All objects including schema descriptors, commands and instance objects are represented by DataElements. DataElements should not be constructed directly, rather they are requested via the createObject() method in DataStore


Constructor Summary
  DataElement()
          Creates a new DataElement without initializing it.
protected DataElement(DataStore dataStore)
          Creates a new DataElement without initializing it.
 
Method Summary
 void addNestedData(DataElement obj, boolean checkUnique)
          Adds another element as a child to this element.
 void addNestedData(List nestedData, boolean checkUnique)
          Adds a set of elements as children to this element.
 void appendToBuffer(String text)
          Appends to the buffer for this element.
protected  void clear()
          Removes all the attributes of a DataElement.
 boolean contains(DataElement object)
          Tests if this element contains a specified element in the default contents relationship.
 boolean contains(DataElement object, DataElement property)
          Tests if this element contains a specified element in a particular relationship.
 boolean contains(DataElement object, DataElement property, int depth)
          Tests if this element contains a specified element in a particular relationship.
 boolean contains(DataElement object, int depth)
          Tests if this element contains a specified element in the default contents relationship.
 void delete()
          Marks a DataElement as deleted.
 int depth()
          Returns the visibility of this element.
 DataElement dereference()
          Returns the element that this references.
 DataElement doCommandOn(String command, boolean isSynchronized)
          Do the specified command on this element.
 boolean equals(Object arg)
          Tests if this element is the same as another.
protected  void finalize()
           
 DataElement get(int index)
          Returns the child at the specified index.
 Object getAdapter(Class key)
          Gets the adapter specified by key for this element
 List getAssociated(DataElement property)
          Gets the set of elements that are related to this element via a specified relationship.
 List getAssociated(String propertyStr)
          Gets the set of elements that are related to this element via a specified relationship.
 String getAttribute(int attributeIndex)
          Returns an attribute of this element.
 String[] getAttributes()
          Returns the set of attributes for this element.
 StringBuffer getBuffer()
          Returns the buffer for this element.
 DataStore getDataStore()
          Returns the DataStore for this element.
 DataElement getDescriptor()
          Returns the type descriptor for this element.
 Object getElementProperty(Object name)
          Returns the property identified by name.
 String getId()
          Returns the ID attribute for this element.
 String getName()
          Returns the name attribute for this element.
 List getNestedData()
          Returns the children of this element.
 int getNestedSize()
          Returns the number of children this element contains.
 DataElement getParent()
          Returns the parent of this element.
 String getSource()
          Returns the source attribute for this element.
 String getType()
          Returns the type attribute for this element.
 String getValue()
          Returns the value attribute for this element.
 void initializeNestedData(int size)
          Initializes the children set of this element with a specified size.
 boolean isDeleted()
          Indicates whether the DataElement is deleted or not.
 boolean isDescriptor()
           
 boolean isExpanded()
          Indicates whether this element has been queried for it's children.
 boolean isOfType(DataElement type)
          Tests if this element is of the specified type.
 boolean isOfType(DataElement type, boolean isDescriptor)
          Tests if this element is of the specified type.
 boolean isOfType(String typeStr)
          Tests if this element is of the specified type.
 boolean isOfType(String typeStr, boolean isDescriptor)
          Tests if this element is of the specified type.
 boolean isPendingTransfer()
          Indicates whether this element is pending a transfer If the element is queued to be sent, the value will be true.
 boolean isReference()
          Indicates whether this is a reference or not.
 boolean isSpirit()
          Indicates whether this element is a 'spirit' element.
 boolean isUpdated()
          Indicates whether this element has been updated yet.
 void notifyUpdate()
           
 boolean patternMatch(int[] attributes, String[] patterns, int numAttributes, boolean ignoreCase)
          Tests if this element matches the specified patterns.
 void reInit(DataElement parent, DataElement originalObject, DataElement refType)
          Initializes a DataElement to be reference to some other DataElement.
 void reInit(DataElement parent, DataElement originalObject, String refType)
          Initializes a DataElement to be reference to some other DataElement This method should only be called from the DataStore.
 void reInit(DataElement parent, DataElement type, String[] attributes)
          Initializes a DataElement This method should only be called from the DataStore.
 void reInit(DataElement parent, DataElement type, String id, String name, String source)
          Initializes a DataElement This method should only be called from the DataStore.
 void reInit(DataElement parent, DataElement type, String id, String name, String source, boolean isRef)
          Initializes a DataElement This method should only be called from the DataStore.
 void reInit(DataElement parent, String[] attributes)
          Initializes a DataElement This method should only be called from the DataStore.
 void reInit(DataElement parent, String type, String id, String name, String source)
          Initializes a DataElement This method should only be called from the DataStore.
 void reInit(DataElement parent, String type, String id, String name, String source, boolean isRef)
          Initializes a DataElement This method should only be called from the DataStore.
 void reInitAsTransient(String[] attributes)
           
 void removeNestedData()
          Removes all the children from this element.
 void removeNestedData(DataElement object)
          Removes a specified child element from this element.
 void setAttribute(int attributeIndex, String attribute)
          Sets an attribute of the element.
 void setAttributes(String[] attributes)
          Sets all of the attributes of the element.
 void setBuffer(StringBuffer buffer)
          Sets the buffer for this element.
 void setDataStore(DataStore dataStore)
          Sets the DataStore for this element.
 void setDepth(int depth)
          Sets the depth of visibility for this element.
 void setDescriptor(DataElement theDescriptor)
          Explicitly sets the type descriptor for this element.
 void setExpanded(boolean flag)
          Sets the expanded indication for this element.
 void setParent(DataElement parent)
          Sets the parent for this element.
 void setPendingTransfer(boolean flag)
          Sets indication of whether this element is waiting to be transferred.
 void setSpirit(boolean flag)
          Sets indication of whether this element is a 'spirit' element.
 void setUpdated(boolean flag)
          Sets the updated indication for this element.
 String toString()
          Returns a string showing the attributes of this element
 void waitForUpdate(long timeout)
           
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataElement

public DataElement()
Creates a new DataElement without initializing it.


DataElement

protected DataElement(DataStore dataStore)
Creates a new DataElement without initializing it.

Parameters:
dataStore - the owner DataStore for this element
Method Detail

finalize

protected void finalize()
Overrides:
finalize in class Object

reInit

public void reInit(DataElement parent,
                   DataElement originalObject,
                   DataElement refType)
Initializes a DataElement to be reference to some other DataElement. This method should only be called from the DataStore.

Parameters:
parent - the element that contains this reference
originalObject - the element that gets referenced
refType - the type descriptor of the reference

reInit

public void reInit(DataElement parent,
                   DataElement originalObject,
                   String refType)
Initializes a DataElement to be reference to some other DataElement This method should only be called from the DataStore.

Parameters:
parent - the element that contains this reference
originalObject - the element that gets referenced
refType - the a string representing the type of reference

reInit

public void reInit(DataElement parent,
                   DataElement type,
                   String id,
                   String name,
                   String source)
Initializes a DataElement This method should only be called from the DataStore.

Parameters:
parent - the parent of the element
type - the type descriptor of the element
id - the ID of the element
name - the name of the element
source - the source location of the element

reInit

public void reInit(DataElement parent,
                   String type,
                   String id,
                   String name,
                   String source)
Initializes a DataElement This method should only be called from the DataStore.

Parameters:
parent - the parent of the element
type - a string representing the type descriptor of the element
id - the ID of the element
name - the name of the element
source - the source location of the element

reInit

public void reInit(DataElement parent,
                   DataElement type,
                   String id,
                   String name,
                   String source,
                   boolean isRef)
Initializes a DataElement This method should only be called from the DataStore.

Parameters:
parent - the parent of the element
type - the type descriptor of the element
id - the ID of the element
name - the name of the element
source - the source location of the element
isRef - an indication of whether the element is a reference or not

reInit

public void reInit(DataElement parent,
                   String type,
                   String id,
                   String name,
                   String source,
                   boolean isRef)
Initializes a DataElement This method should only be called from the DataStore.

Parameters:
parent - the parent of the element
type - a string representing the type descriptor of the element
id - the ID of the element
name - the name of the element
source - the source location of the element
isRef - an indication of whether the element is a reference or not

reInit

public void reInit(DataElement parent,
                   DataElement type,
                   String[] attributes)
Initializes a DataElement This method should only be called from the DataStore.

Parameters:
parent - the parent of the element
type - the type descriptor of the element
attributes - the attributes for this element (name, source, id, etc.)

reInit

public void reInit(DataElement parent,
                   String[] attributes)
Initializes a DataElement This method should only be called from the DataStore.

Parameters:
parent - the parent of the element
attributes - the attributes for this element (type, name, source, id, etc.)

reInitAsTransient

public void reInitAsTransient(String[] attributes)

isDeleted

public boolean isDeleted()
Indicates whether the DataElement is deleted or not.

Returns:
whehther the element is deleted or not

addNestedData

public void addNestedData(List nestedData,
                          boolean checkUnique)
Adds a set of elements as children to this element.

Parameters:
nestedData - a set of elements to add to this element
checkUnique - whether to prevent duplicates from being added

addNestedData

public void addNestedData(DataElement obj,
                          boolean checkUnique)
Adds another element as a child to this element.

Parameters:
obj - the element to add
checkUnique - whether to prevent duplicates from being added

removeNestedData

public void removeNestedData(DataElement object)
Removes a specified child element from this element.

Parameters:
object - the element to remove

removeNestedData

public void removeNestedData()
Removes all the children from this element.


getAttribute

public String getAttribute(int attributeIndex)
Returns an attribute of this element.

Parameters:
attributeIndex - the index of the element
Returns:
the attribute

getAttributes

public String[] getAttributes()
Returns the set of attributes for this element.

Returns:
the set of attributes

getType

public String getType()
Returns the type attribute for this element.

Specified by:
getType in interface IDataElement
Returns:
the type attribute

getId

public String getId()
Returns the ID attribute for this element.

Specified by:
getId in interface IDataElement
Returns:
the ID attribute

getName

public String getName()
Returns the name attribute for this element.

Specified by:
getName in interface IDataElement
Returns:
the name attribute

getValue

public String getValue()
Returns the value attribute for this element.

Returns:
the value attribute

getSource

public String getSource()
Returns the source attribute for this element.

Returns:
the source attribute

getBuffer

public StringBuffer getBuffer()
Returns the buffer for this element.

Returns:
the buffer

getDataStore

public DataStore getDataStore()
Returns the DataStore for this element.

Returns:
the DataStore

initializeNestedData

public void initializeNestedData(int size)
Initializes the children set of this element with a specified size.

Parameters:
size - the initial size

getNestedData

public List getNestedData()
Returns the children of this element.

Specified by:
getNestedData in interface IDataElement
Returns:
the children of this element

get

public DataElement get(int index)
Returns the child at the specified index.

Parameters:
index - the index of the child to retrieve
Returns:
the child element

getNestedSize

public int getNestedSize()
Returns the number of children this element contains.

Specified by:
getNestedSize in interface IDataElement
Returns:
the number of children

getParent

public DataElement getParent()
Returns the parent of this element.

Returns:
the parent

isDescriptor

public boolean isDescriptor()

setDescriptor

public void setDescriptor(DataElement theDescriptor)
Explicitly sets the type descriptor for this element.

Parameters:
theDescriptor - the type descriptor for this element

getDescriptor

public DataElement getDescriptor()
Returns the type descriptor for this element.

Returns:
the type descriptor for this element

depth

public int depth()
Returns the visibility of this element.

Returns:
the level of visibility for this element

isReference

public boolean isReference()
Indicates whether this is a reference or not.

Returns:
whether this is a reference or not

isExpanded

public boolean isExpanded()
Indicates whether this element has been queried for it's children.

Returns:
whether element has been expanded

isUpdated

public boolean isUpdated()
Indicates whether this element has been updated yet. On a server, an element is updated if it has been transfered the the client. On a client, an element is updated if a notification has been sent out for the ui

Returns:
whether element has been updated yet

isPendingTransfer

public boolean isPendingTransfer()
Indicates whether this element is pending a transfer If the element is queued to be sent, the value will be true.

Returns:
whether element has been updated yet

isSpirit

public boolean isSpirit()
Indicates whether this element is a 'spirit' element. In a client datastore, this means that the element's counterpart on the server is either also a spirit (and will be deleted soon) or has already been deleted. In a server datastore, this means that the element is to be deleted at the next opportunity in order to free memory.


setAttribute

public void setAttribute(int attributeIndex,
                         String attribute)
Sets an attribute of the element.

Parameters:
attributeIndex - the index of the attribute to set
attribute - the new value for the specified attribute

setAttributes

public void setAttributes(String[] attributes)
Sets all of the attributes of the element.

Parameters:
attributes - the new set of attributes for the element

setBuffer

public void setBuffer(StringBuffer buffer)
Sets the buffer for this element. The buffer is used if extra temporary information needs to be stored with this element

Parameters:
buffer - the new buffer for this element

appendToBuffer

public void appendToBuffer(String text)
Appends to the buffer for this element. The buffer is used if extra temporary information needs to be stored with this element

Parameters:
text - text to append to the buffer

setExpanded

public void setExpanded(boolean flag)
Sets the expanded indication for this element.

Parameters:
flag - whether the element is expanded or not

setUpdated

public void setUpdated(boolean flag)
Sets the updated indication for this element.

Parameters:
flag - whether the element is updated or not

setPendingTransfer

public void setPendingTransfer(boolean flag)
Sets indication of whether this element is waiting to be transferred. If so, the updated flag should not be set to true

Parameters:
flag - whether the element is waiting to be transferred

setSpirit

public void setSpirit(boolean flag)
Sets indication of whether this element is a 'spirit' element. In a client datastore, this means that the element's counterpart on the server is either also a spirit (and will be deleted soon) or has already been deleted. In a server datastore, this means that the element is to be deleted at the next opportunity in order to free memory.


setParent

public void setParent(DataElement parent)
Sets the parent for this element.

Parameters:
parent - the new parent

setDataStore

public void setDataStore(DataStore dataStore)
Sets the DataStore for this element.

Parameters:
dataStore - the new dataStore

setDepth

public void setDepth(int depth)
Sets the depth of visibility for this element.

Parameters:
depth - the level of visibility

isOfType

public boolean isOfType(String typeStr)
Tests if this element is of the specified type.

Specified by:
isOfType in interface IDataElement
Parameters:
typeStr - a string representing the type descriptor to compare with
Returns:
whether the element is of the specified type

isOfType

public boolean isOfType(String typeStr,
                        boolean isDescriptor)
Tests if this element is of the specified type.

Parameters:
typeStr - a string representing the type descriptor to compare with
Returns:
whether the element is of the specified type

isOfType

public boolean isOfType(DataElement type)
Tests if this element is of the specified type.

Parameters:
type - the type descriptor to compare with
Returns:
whether the element is of the specified type

isOfType

public boolean isOfType(DataElement type,
                        boolean isDescriptor)
Tests if this element is of the specified type.

Parameters:
type - the type descriptor to compare with
isDescriptor - whehter this element is a descriptor or an instance object
Returns:
whether the element is of the specified type

patternMatch

public boolean patternMatch(int[] attributes,
                            String[] patterns,
                            int numAttributes,
                            boolean ignoreCase)
Tests if this element matches the specified patterns.

Parameters:
attributes - the attribute indexes to compare with
patterns - the values to compare the specified attributes with
numAttributes - the number of attributes to compare
ignoreCase - whether to ignore case or not
Returns:
whether the element matches the patterns

contains

public boolean contains(DataElement object,
                        DataElement property)
Tests if this element contains a specified element in a particular relationship.

Parameters:
object - the object to look for
property - relationship under which to find the object
Returns:
whether the element is found

contains

public boolean contains(DataElement object,
                        DataElement property,
                        int depth)
Tests if this element contains a specified element in a particular relationship.

Parameters:
object - the object to look for
property - relationship under which to find the object
depth - how deep to search for the specified element
Returns:
whether the element is found

contains

public boolean contains(DataElement object)
Tests if this element contains a specified element in the default contents relationship.

Parameters:
object - the object to look for
Returns:
whether the element is found

contains

public boolean contains(DataElement object,
                        int depth)
Tests if this element contains a specified element in the default contents relationship.

Parameters:
object - the object to look for
depth - how deep to search
Returns:
whether the element is found

equals

public boolean equals(Object arg)
Tests if this element is the same as another.

Overrides:
equals in class Object
Parameters:
arg - the object to compare with
Returns:
whether the element is the same

getAssociated

public List getAssociated(String propertyStr)
Gets the set of elements that are related to this element via a specified relationship.

Specified by:
getAssociated in interface IDataElement
Parameters:
propertyStr - a string representing the relationship that is required
Returns:
the set of related elements

getAssociated

public List getAssociated(DataElement property)
Gets the set of elements that are related to this element via a specified relationship.

Parameters:
property - the relationship that is required
Returns:
the set of related elements

dereference

public DataElement dereference()
Returns the element that this references. If the element is not a reference, itself is returned

Returns:
the element that this references

doCommandOn

public DataElement doCommandOn(String command,
                               boolean isSynchronized)
Do the specified command on this element. This element becomes the subject of a command that has a value, command

Parameters:
command - the string representing the command to issue
isSynchronized - an indication of whether this command should be synchronized
Returns:
the status of the command

getAdapter

public Object getAdapter(Class key)
Gets the adapter specified by key for this element

Specified by:
getAdapter in interface IAdaptable
Parameters:
key - the identifier for this adapter
Returns:
the adapter

toString

public String toString()
Returns a string showing the attributes of this element

Overrides:
toString in class Object
Returns:
a printable string

getElementProperty

public Object getElementProperty(Object name)
Returns the property identified by name.

Specified by:
getElementProperty in interface IDataElement
Specified by:
getElementProperty in interface IElement
Parameters:
name - a specifier of which property to return
Returns:
the specified property

clear

protected void clear()
Removes all the attributes of a DataElement. This method should only be called from the UpdateHandlers.


delete

public void delete()
Marks a DataElement as deleted. This method should only be called from the DataStore


notifyUpdate

public void notifyUpdate()

waitForUpdate

public void waitForUpdate(long timeout)

Remote System Explorer DataStore
Release 3.3

Copyright (c) IBM Corporation and others 2000, 2011. All Rights Reserved.