org.openptk.api
Class Element

java.lang.Object
  extended by org.openptk.api.Element
All Implemented Interfaces:
ElementIF
Direct Known Subclasses:
Connection, Input, Output

public class Element
extends java.lang.Object
implements ElementIF

An Element is a foundation class that holds Properties and Attributes. It has a unique id, a Description, State and Status

Author:
Scott Fehrman, Sun Microsystems, Inc.
contributor: Derrick Harcey, Sun Microsystems, Inc.

Constructor Summary
Element()
          Creates an empty element, The state is set to NEW.
Element(ElementIF elem)
          Create an Element using the provided element.
 
Method Summary
 void addAttribute(AttributeIF attr)
          Add an Attribute, copying an existing Attribute.
 void addAttribute(java.lang.String name)
          Add an Attribute, name only, with no value.
 void addAttribute(java.lang.String name, boolean value)
          Add an Attribute with the give name and boolean value.
 void addAttribute(java.lang.String name, java.lang.Boolean value)
          Add an Attribute with the give name and Boolean value.
 void addAttribute(java.lang.String name, java.lang.Boolean[] value)
          Add an Attribute with the give name and Boolean value.
 void addAttribute(java.lang.String name, int value)
          Add an Attribute with the give name and integer value.
 void addAttribute(java.lang.String name, java.lang.Integer value)
          Add an Attribute with the give name and Integer value.
 void addAttribute(java.lang.String name, java.lang.Integer[] value)
          Add an Attribute with the give name and Integer[] value.
 void addAttribute(java.lang.String name, long value)
          Add an Attribute with the give name and Long value.
 void addAttribute(java.lang.String name, java.lang.Long value)
          Add an Attribute with the give name and Long value.
 void addAttribute(java.lang.String name, java.lang.Long[] value)
          Add an Attribute with the give name and Long[] value.
 void addAttribute(java.lang.String name, java.lang.Object value)
          Add an Attribute with the give name and Object value.
 void addAttribute(java.lang.String name, java.lang.String value)
          Add an Attribute with the give name and a single String value.
 void addAttribute(java.lang.String name, java.lang.String[] values)
          Add an Attribute with the give name and multiple String values.
 void addAttributes(java.util.List<java.lang.String> names)
          Add multiple Attributes, with no value, one for each String.
 ElementIF copy()
          Creates a "deep" copy of the Element.
 AttributeIF getAttribute(java.lang.String name)
          Get the named Attribute.
 java.lang.String[] getAttributeNames()
          Gets all the Attribute names.
 java.util.Map<java.lang.String,AttributeIF> getAttributes()
          Get all of the Attributes as a Properties object.
 int getAttributesSize()
          Get the number of Attributes.
 java.lang.String getDescription()
          Get the Description a generic value that can be defined by the application.
 java.lang.String getKey()
          Gets the name of the attribute which is defined as the unique primary key.
 java.util.Properties getProperties()
          Get all of the Properties.
 int getPropertiesSize()
          Get the number Property key/value pairs.
 java.lang.String getProperty(java.lang.String key)
          Get a property value.
 State getState()
          Returns the Element's State.
 java.lang.String getStateAsString()
          Get the String representation for the current state.
 java.lang.String getStatus()
          Get the status
a general purpose piece of information that can store arbitrary information, typically used to store application status information.
 java.lang.Object getUniqueId()
          Get the Unique ID, a generic identifier.
 DataType getUniqueIdType()
          Get the Unique ID data type
 boolean isError()
          Flag to determine if there was an Error.
 void removeAttribute(java.lang.String name)
          Remove the named Attribute.
 void removeProperty(java.lang.String key)
          Remove the named Property
 void setAttributes(java.util.Map<java.lang.String,AttributeIF> map)
          Set / Replace all Attributes with the new Collection.
 void setDescription(java.lang.String str)
          Set the Description, a generic value that can be defined.
 void setError(boolean error)
          Flag to set if there is an Error.
 void setKey(java.lang.String key)
          Sets the name of the attribute which is defined as the unique primary key.
 void setProperties(java.util.Properties props)
          Set/Replace the properties with the new Properties.
 void setProperty(java.lang.String key, java.lang.String value)
          Set a property using the key and value.
 void setState(State state)
          Set the State.
 void setStatus(java.lang.String str)
          Set the status
a general purpose piece of information that can be used to store arbitrary information, typically used to store application level status information.
 void setUniqueId(ElementIF elem)
           
 void setUniqueId(java.lang.Integer value)
          Set the Unique ID to the Integer
 void setUniqueId(java.lang.Long value)
          Set the Unique ID to the Long
 void setUniqueId(java.lang.String value)
          Set the Unique ID to the String
 java.lang.String toString()
          Information about the Element, summarize data into a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Element

public Element()
Creates an empty element, The state is set to NEW.


Element

public Element(ElementIF elem)
Create an Element using the provided element. All of the information is copied into the new Element

Parameters:
elem - an existing ElementIF object
Method Detail

addAttribute

public final void addAttribute(AttributeIF attr)
Add an Attribute, copying an existing Attribute.

Specified by:
addAttribute in interface ElementIF
Parameters:
attr - an existing AttributeIF

addAttribute

public final void addAttribute(java.lang.String name)
Add an Attribute, name only, with no value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute

addAttribute

public final void addAttribute(java.lang.String name,
                               boolean value)
Add an Attribute with the give name and boolean value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - TRUE/FALSE

addAttribute

public final void addAttribute(java.lang.String name,
                               java.lang.Boolean value)
Add an Attribute with the give name and Boolean value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - TRUE/FALSE

addAttribute

public final void addAttribute(java.lang.String name,
                               java.lang.Boolean[] value)
Add an Attribute with the give name and Boolean value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - TRUE/FALSE

addAttribute

public final void addAttribute(java.lang.String name,
                               int value)
Add an Attribute with the give name and integer value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - integer

addAttribute

public final void addAttribute(java.lang.String name,
                               java.lang.Integer value)
Add an Attribute with the give name and Integer value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - Integer

addAttribute

public final void addAttribute(java.lang.String name,
                               java.lang.Integer[] value)
Add an Attribute with the give name and Integer[] value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - Integer[]

addAttribute

public final void addAttribute(java.lang.String name,
                               long value)
Add an Attribute with the give name and Long value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - Long

addAttribute

public final void addAttribute(java.lang.String name,
                               java.lang.Long value)
Add an Attribute with the give name and Long value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - Long

addAttribute

public final void addAttribute(java.lang.String name,
                               java.lang.Long[] value)
Add an Attribute with the give name and Long[] value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - Long[]

addAttribute

public final void addAttribute(java.lang.String name,
                               java.lang.Object value)
Add an Attribute with the give name and Object value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - Object

addAttribute

public final void addAttribute(java.lang.String name,
                               java.lang.String value)
Add an Attribute with the give name and a single String value.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
value - of the Attribute

addAttribute

public final void addAttribute(java.lang.String name,
                               java.lang.String[] values)
Add an Attribute with the give name and multiple String values.

Specified by:
addAttribute in interface ElementIF
Parameters:
name - of the Attribute
values - String[] with multiple values

addAttributes

public final void addAttributes(java.util.List<java.lang.String> names)
Add multiple Attributes, with no value, one for each String.

Specified by:
addAttributes in interface ElementIF
Parameters:
names - List of Attributes to add

copy

public ElementIF copy()
Creates a "deep" copy of the Element.

Specified by:
copy in interface ElementIF
Returns:
Element the new Element (a copy)

getAttribute

public final AttributeIF getAttribute(java.lang.String name)
Get the named Attribute.

Specified by:
getAttribute in interface ElementIF
Parameters:
name - the Attributes name
Returns:
AttributeIF object

getAttributeNames

public final java.lang.String[] getAttributeNames()
Gets all the Attribute names.

Specified by:
getAttributeNames in interface ElementIF
Returns:
String[] String Array of Attribute names

getAttributes

public final java.util.Map<java.lang.String,AttributeIF> getAttributes()
Get all of the Attributes as a Properties object.
If an attribute has multiple values, only the first one is used

Specified by:
getAttributes in interface ElementIF
Returns:
Map a map all of the attributes.

getAttributesSize

public final int getAttributesSize()
Get the number of Attributes.

Specified by:
getAttributesSize in interface ElementIF
Returns:
int the number of attributes

getDescription

public final java.lang.String getDescription()
Get the Description a generic value that can be defined by the application.

Specified by:
getDescription in interface ElementIF
Returns:
String the description of the Element

getKey

public final java.lang.String getKey()
Gets the name of the attribute which is defined as the unique primary key.

Specified by:
getKey in interface ElementIF
Returns:
String the name of the primary unique key attribute

getProperties

public final java.util.Properties getProperties()
Get all of the Properties.

Specified by:
getProperties in interface ElementIF
Returns:
Properties all of the properties

getPropertiesSize

public final int getPropertiesSize()
Get the number Property key/value pairs.

Specified by:
getPropertiesSize in interface ElementIF
Returns:
int number of properties

getProperty

public final java.lang.String getProperty(java.lang.String key)
Get a property value. Note: this is a "copy" of the value

Specified by:
getProperty in interface ElementIF
Parameters:
key - for the property
Returns:
String value of the property

getState

public final State getState()
Returns the Element's State.

Specified by:
getState in interface ElementIF
Returns:
State State enumeration

getStateAsString

public final java.lang.String getStateAsString()
Get the String representation for the current state.

Specified by:
getStateAsString in interface ElementIF
Returns:
String the current state

getStatus

public final java.lang.String getStatus()
Get the status
a general purpose piece of information that can store arbitrary information, typically used to store application status information.

Specified by:
getStatus in interface ElementIF
Returns:
String the Elements status

getUniqueId

public final java.lang.Object getUniqueId()
Get the Unique ID, a generic identifier.

Specified by:
getUniqueId in interface ElementIF
Returns:
String the unique id of the ElementIF

getUniqueIdType

public final DataType getUniqueIdType()
Get the Unique ID data type

Specified by:
getUniqueIdType in interface ElementIF
Returns:
DataType uniqueid type

isError

public final boolean isError()
Flag to determine if there was an Error.

Specified by:
isError in interface ElementIF
Returns:
boolean error TRUE/FALSE

removeAttribute

public final void removeAttribute(java.lang.String name)
Remove the named Attribute.

Specified by:
removeAttribute in interface ElementIF
Parameters:
name - the Attributes name

removeProperty

public final void removeProperty(java.lang.String key)
Remove the named Property

Specified by:
removeProperty in interface ElementIF
Parameters:
key - name of the property

setAttributes

public final void setAttributes(java.util.Map<java.lang.String,AttributeIF> map)
Set / Replace all Attributes with the new Collection.

Specified by:
setAttributes in interface ElementIF
Parameters:
map - Collection of new AttributeIF items

setDescription

public final void setDescription(java.lang.String str)
Set the Description, a generic value that can be defined.

Specified by:
setDescription in interface ElementIF
Parameters:
str - the description for the Element

setError

public final void setError(boolean error)
Flag to set if there is an Error.

Specified by:
setError in interface ElementIF
Parameters:
error - set the error flag

setKey

public final void setKey(java.lang.String key)
Sets the name of the attribute which is defined as the unique primary key.

Specified by:
setKey in interface ElementIF
Parameters:
key - the name of the attribute which defines the primary key

setProperties

public final void setProperties(java.util.Properties props)
Set/Replace the properties with the new Properties.

Specified by:
setProperties in interface ElementIF
Parameters:
props - new properties object

setProperty

public final void setProperty(java.lang.String key,
                              java.lang.String value)
Set a property using the key and value.

Specified by:
setProperty in interface ElementIF
Parameters:
key - for the property
value - for the property

setState

public final void setState(State state)
Set the State.

Specified by:
setState in interface ElementIF
Parameters:
state - enumeration value

setStatus

public final void setStatus(java.lang.String str)
Set the status
a general purpose piece of information that can be used to store arbitrary information, typically used to store application level status information.

Specified by:
setStatus in interface ElementIF
Parameters:
str - the Elements status

setUniqueId

public final void setUniqueId(ElementIF elem)
Specified by:
setUniqueId in interface ElementIF

setUniqueId

public final void setUniqueId(java.lang.Integer value)
Set the Unique ID to the Integer

Specified by:
setUniqueId in interface ElementIF
Parameters:
value - the Element's unique id

setUniqueId

public final void setUniqueId(java.lang.Long value)
Set the Unique ID to the Long

Specified by:
setUniqueId in interface ElementIF
Parameters:
value - the Element's unique id

setUniqueId

public final void setUniqueId(java.lang.String value)
Set the Unique ID to the String

Specified by:
setUniqueId in interface ElementIF
Parameters:
value - the Element's unique id

toString

public java.lang.String toString()
Information about the Element, summarize data into a String.

Overrides:
toString in class java.lang.Object
Returns:
String element information


View/submit a bug or feature

For further API reference and developer documentation, see www.openptk.org. That documentation contains more detailed, developer-targeted descriptions, definitions of terms, workarounds, and working code examples.

Copyright (C) 2008-2012, Project OpenPTK. All Rights Reserved