org.openptk.api
Class Attribute

java.lang.Object
  extended by org.openptk.api.Attribute
All Implemented Interfaces:
AttributeIF

public class Attribute
extends java.lang.Object
implements AttributeIF

The Attribute is used to store a related name / value and meta-data. An Attribute can be one of the following DataType enumerations, if not specified the default is STRING:

An Attribute has a number of boolean flags, they are all FALSE by default: If the value is an Array (of the type) it is designated as being multi-valued Else the value is designed as not being multi-valued (default) The default State of an Attribute is NEW An Attribute can also have name/value Properties

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openptk.api.AttributeIF
AttributeIF.Access
 
Constructor Summary
Attribute(AttributeIF attribute)
          Creates a new Attribute from an existing Attribute.
Attribute(java.lang.String name)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, boolean value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, java.lang.Boolean value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, boolean[] value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, java.lang.Boolean[] value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, int value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, int[] value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, java.lang.Integer value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, java.lang.Integer[] value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, java.lang.Long value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, java.lang.Long[] value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, java.lang.Object value)
          Creates a new Attribute using the provided name and value.
Attribute(java.lang.String name, java.lang.Object[] value)
          Creates a new Attribute using the provided name and value.
Attribute(java.lang.String name, java.lang.String value)
          Creates a new Attribute using the provided name.
Attribute(java.lang.String name, java.lang.String[] value)
          Creates a new Attribute using the provided name.
 
Method Summary
 boolean allowMultivalue()
          Return TRUE if the Attribute allows multivalues.
 AttributeIF copy()
          Returns a "deep" copy of the Attribute.
 AttributeIF.Access getAccess()
          Get the Attributes Access level.
 java.lang.String getAccessAsString()
          Get the String representation of the Attributes Access level.
 java.lang.String getName()
          Get the Attributes name.
 java.util.Properties getProperties()
          Returns the Properties for the Attribute.
 int getPropertiesSize()
          Returns the quantity of Properties.
 java.lang.String getProperty(java.lang.String key)
          Get the Property value from the Attribute.
 State getState()
          Get the Attributes State.
 DataType getType()
          Get the Attributes type.
 java.lang.String getTypeAsString()
          Get the Attributes type, as a String.
 java.lang.Object getValue()
          Get the Attributes value.
 java.lang.String getValueAsString()
          Get the attributes value as a String, regardless of it's internal type.
 boolean isEncrypted()
          Returns TRUE if the value is encrypted.
 boolean isMultivalued()
          Return TRUE if the actual value is contains muliple values.
 boolean isReadOnly()
          Get the Attributes read only flag.
 boolean isRequired()
          Get the Attributes required flag.
 boolean isVirtual()
          Get the Attributes virtual flag.
 void setAccess(AttributeIF.Access access)
          Set the Attributes Access level.
 void setAccess(java.lang.String access)
          Set the Attribute Access level.
 void setAllowMultivalue(boolean value)
          Set the flag to define if the Attribute allows multivalues.
 void setEncrypted(boolean bEncrypted)
          Set the flag to define if the Attribute value is encrypted.
protected  void setMultiValued(java.lang.Boolean bool)
          Set the flag for a value, is it multivalued.
 void setProperties(java.util.Properties props)
          Sets / Replaces the Attributes Properties.
 void setProperty(java.lang.String key, java.lang.String value)
          Add the key / value as a Property to the Attribute.
 void setReadOnly(boolean value)
          Set the Attributes read only flag.
 void setRequired(boolean bool)
          Set the Attributes required flag.
 void setState(State state)
          Set the Attributes State.
 void setType(DataType type)
          Set the Attributes type (enum).
 void setValue(boolean value)
          Set the Attributes value to a single Boolean.
 void setValue(java.lang.Boolean value)
          Set the Attributes value to a single Boolean.
 void setValue(boolean[] value)
          Set the Attributes value to a Boolean array.
 void setValue(java.lang.Boolean[] value)
          Set the Attributes value to a Boolean array.
 void setValue(int value)
          Set the Attributes value to a single Integer.
 void setValue(int[] value)
          Set the Attributes value to a Integer array.
 void setValue(java.lang.Integer value)
          Set the Attributes value to a single Integer.
 void setValue(java.lang.Integer[] value)
          Set the Attributes value to a Integer array.
 void setValue(java.lang.Long value)
          Set the Attributes value to a single Long.
 void setValue(java.lang.Long[] value)
          Set the Attributes value to a Long array.
 void setValue(java.lang.Object value)
          Set the Attributes value to the single Object.
 void setValue(java.lang.Object[] value)
          Set the Attributes value to the Object array.
 void setValue(java.lang.String value)
          Set the Attributes value to a single String.
 void setValue(java.lang.String[] value)
          Set the Attributes value to a String array.
 void setVirtual(boolean bool)
          Set the Attributes virtual flag.
 java.lang.String toString()
          Get a String that represents the Attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(AttributeIF attribute)
Creates a new Attribute from an existing Attribute. The content of the provided Attribute is copied into the new Attribute The new Attribute is a "deep" copy of the referenced Attribute

Parameters:
attribute - an existing Attribute

Attribute

public Attribute(java.lang.String name)
Creates a new Attribute using the provided name. The DataType will be set to STRING. The value will be NULL.

Parameters:
name - the Attributes name

Attribute

public Attribute(java.lang.String name,
                 boolean value)
Creates a new Attribute using the provided name. The DataType will be set to BOOLEAN. The value will be set using the provided value.

Parameters:
name - the Attributes name
value - the Attributes value [ true | false ]

Attribute

public Attribute(java.lang.String name,
                 java.lang.Boolean value)
Creates a new Attribute using the provided name. The DataType will be set to BOOLEAN. The value will be set using the provided value.

Parameters:
name - the Attributes name
value - the Attributes value, Integer [ true | false ]

Attribute

public Attribute(java.lang.String name,
                 boolean[] value)
Creates a new Attribute using the provided name. The DataType will be set to BOOLEAN, this will be multivalued. The value will be set using the provided value.

Parameters:
name - the Attributes name
value - the Attributes value, Boolean[]

Attribute

public Attribute(java.lang.String name,
                 java.lang.Boolean[] value)
Creates a new Attribute using the provided name. The DataType will be set to BOOLEAN, this will be multivalued The value will be set using the provided value.

Parameters:
name - the Attributes name
value - the Attributes value, Boolean[]

Attribute

public Attribute(java.lang.String name,
                 int value)
Creates a new Attribute using the provided name. The DataType will be set to INTEGER. The value will be set using the provided value.

Parameters:
name - the Attributes name
value - the Attributes value, Integer

Attribute

public Attribute(java.lang.String name,
                 int[] value)
Creates a new Attribute using the provided name. The DataType will be set to INTEGER. The value will be set using the provided value, this will be multivalued

Parameters:
name - the Attributes name
value - the Attributes value, Integer[]

Attribute

public Attribute(java.lang.String name,
                 java.lang.Integer value)
Creates a new Attribute using the provided name. The DataType will be set to INTEGER. The value will be set using the provided value.

Parameters:
name - the Attributes name
value - the Attributes value, Integer

Attribute

public Attribute(java.lang.String name,
                 java.lang.Integer[] value)
Creates a new Attribute using the provided name. The DataType will be set to INTEGER. The value will be set using the provided value, this will be multivalued

Parameters:
name - the Attributes name
value - the Attributes value, Integer[]

Attribute

public Attribute(java.lang.String name,
                 java.lang.Long value)
Creates a new Attribute using the provided name. The DataType will be set to LONG. The value will be set using the provided value.

Parameters:
name - the Attributes name
value - the Attributes value, Long

Attribute

public Attribute(java.lang.String name,
                 java.lang.Long[] value)
Creates a new Attribute using the provided name. The DataType will be set to LONG. The value will be set using the provided value, this will be multivalued

Parameters:
name - the Attributes name
value - the Attributes value, Long[]

Attribute

public Attribute(java.lang.String name,
                 java.lang.Object value)
Creates a new Attribute using the provided name and value. The DataType will be set to OBJECT, this can not be multi-valued.

Parameters:
name - the Attributes name
value - the Attributes value, Java Object

Attribute

public Attribute(java.lang.String name,
                 java.lang.Object[] value)
Creates a new Attribute using the provided name and value. The DataType will be set to OBJECT, this will be multivalued.

Parameters:
name - the Attributes name
value - the Attributes value, Java Object[]

Attribute

public Attribute(java.lang.String name,
                 java.lang.String value)
Creates a new Attribute using the provided name. The DataType will be set to STRING. The value will be set using the provided value.

Parameters:
name - the Attributes name
value - the Attributes value, String

Attribute

public Attribute(java.lang.String name,
                 java.lang.String[] value)
Creates a new Attribute using the provided name. The DataType will be set to STRING. The value will be set using the provided value, this will be multivalued

Parameters:
name - the Attributes name
value - the Attributes value, String[]
Method Detail

allowMultivalue

public final boolean allowMultivalue()
Return TRUE if the Attribute allows multivalues.

Specified by:
allowMultivalue in interface AttributeIF
Returns:
boolean are multivalues allowed

copy

public AttributeIF copy()
Returns a "deep" copy of the Attribute. The new Attribute will have a copy of the name, value, meta-data and Properties from the referenced Attribute.

Specified by:
copy in interface AttributeIF
Returns:
AttributeIF a copy of the Attribute

getAccess

public final AttributeIF.Access getAccess()
Get the Attributes Access level.

Specified by:
getAccess in interface AttributeIF
Returns:
Access the Access level

getAccessAsString

public final java.lang.String getAccessAsString()
Get the String representation of the Attributes Access level.

Specified by:
getAccessAsString in interface AttributeIF
Returns:
val String representation of Access level

getName

public final java.lang.String getName()
Get the Attributes name.

Specified by:
getName in interface AttributeIF
Returns:
String the Attributes name

getProperties

public final java.util.Properties getProperties()
Returns the Properties for the Attribute. Notice: The returned Properties is a "deep copy", not a reference to the internal Properties.

Specified by:
getProperties in interface AttributeIF
Returns:
Properties the current Attribute properties

getPropertiesSize

public final int getPropertiesSize()
Returns the quantity of Properties.

Specified by:
getPropertiesSize in interface AttributeIF
Returns:
int quantity of Properties

getProperty

public final java.lang.String getProperty(java.lang.String key)
Get the Property value from the Attribute. If the property does not exist, a null value is returned. Note: the returned value (String) is a copy of the internal value.

Specified by:
getProperty in interface AttributeIF
Parameters:
key - the name of the Property
Returns:
val the value of the Property

getState

public final State getState()
Get the Attributes State.

Specified by:
getState in interface AttributeIF
Returns:
state State for the Attribute

getType

public final DataType getType()
Get the Attributes type.

Specified by:
getType in interface AttributeIF
Returns:
DataType the Attributes type

getTypeAsString

public final java.lang.String getTypeAsString()
Get the Attributes type, as a String.

Specified by:
getTypeAsString in interface AttributeIF
Returns:
String the String representation of the type

getValue

public final java.lang.Object getValue()
Get the Attributes value.

Specified by:
getValue in interface AttributeIF
Returns:
Object the Attributes value

getValueAsString

public final java.lang.String getValueAsString()
Get the attributes value as a String, regardless of it's internal type. String[] is enclosed with brackets and values are comma delimited Integer and Booleans use their toString() value.

Specified by:
getValueAsString in interface AttributeIF
Returns:
String a String representation of the internal value

isEncrypted

public final boolean isEncrypted()
Returns TRUE if the value is encrypted.

Specified by:
isEncrypted in interface AttributeIF
Returns:
boolean is the value encrypted

isMultivalued

public final boolean isMultivalued()
Return TRUE if the actual value is contains muliple values.

Specified by:
isMultivalued in interface AttributeIF
Returns:
boolean is it multi-valued

isReadOnly

public final boolean isReadOnly()
Get the Attributes read only flag.

Specified by:
isReadOnly in interface AttributeIF
Returns:
boolean the read only flag

isRequired

public final boolean isRequired()
Get the Attributes required flag.

Specified by:
isRequired in interface AttributeIF
Returns:
boolean the required flag

isVirtual

public final boolean isVirtual()
Get the Attributes virtual flag.

Specified by:
isVirtual in interface AttributeIF
Returns:
boolean the virtual flag

setAccess

public final void setAccess(AttributeIF.Access access)
Set the Attributes Access level.

Specified by:
setAccess in interface AttributeIF
Parameters:
access - Access level

setAccess

public final void setAccess(java.lang.String access)
Set the Attribute Access level.

Specified by:
setAccess in interface AttributeIF
Parameters:
access - String representation of the level

setAllowMultivalue

public final void setAllowMultivalue(boolean value)
Set the flag to define if the Attribute allows multivalues.

Specified by:
setAllowMultivalue in interface AttributeIF
Parameters:
value -

setEncrypted

public final void setEncrypted(boolean bEncrypted)
Set the flag to define if the Attribute value is encrypted.

Specified by:
setEncrypted in interface AttributeIF
Parameters:
bEncrypted -

setMultiValued

protected void setMultiValued(java.lang.Boolean bool)
Set the flag for a value, is it multivalued.

Parameters:
bool - boolean is it multivalued.

setProperties

public final void setProperties(java.util.Properties props)
Sets / Replaces the Attributes Properties.

Specified by:
setProperties in interface AttributeIF
Parameters:
props - a Properties object

setProperty

public final void setProperty(java.lang.String key,
                              java.lang.String value)
Add the key / value as a Property to the Attribute.

Specified by:
setProperty in interface AttributeIF
Parameters:
key - the name of the Property
value - the value of the Property

setReadOnly

public final void setReadOnly(boolean value)
Set the Attributes read only flag.

Specified by:
setReadOnly in interface AttributeIF
Parameters:
value - flag to define if the Attribute is read only

setRequired

public final void setRequired(boolean bool)
Set the Attributes required flag.

Specified by:
setRequired in interface AttributeIF
Parameters:
bool - flag to define if the Attribute is required

setState

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

Specified by:
setState in interface AttributeIF
Parameters:
state - State

setType

public final void setType(DataType type)
Set the Attributes type (enum). Notice: The type is automatically set based on the Attributes value. If the type does not match the value, there will be unpredictable behavior.

Specified by:
setType in interface AttributeIF
Parameters:
type - DataType

setValue

public final void setValue(boolean value)
Set the Attributes value to a single Boolean. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - boolean

setValue

public final void setValue(java.lang.Boolean value)
Set the Attributes value to a single Boolean. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - Boolean

setValue

public final void setValue(boolean[] value)
Set the Attributes value to a Boolean array. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - boolean[]

setValue

public final void setValue(java.lang.Boolean[] value)
Set the Attributes value to a Boolean array. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - Boolean[]

setValue

public final void setValue(int value)
Set the Attributes value to a single Integer. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - int

setValue

public final void setValue(int[] value)
Set the Attributes value to a Integer array. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - int[]

setValue

public final void setValue(java.lang.Integer value)
Set the Attributes value to a single Integer. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - Integer

setValue

public final void setValue(java.lang.Integer[] value)
Set the Attributes value to a Integer array. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - Integer[]

setValue

public final void setValue(java.lang.Long value)
Set the Attributes value to a single Long. The Type will be automatically set.

Parameters:
value - Long

setValue

public final void setValue(java.lang.Long[] value)
Set the Attributes value to a Long array. The Type will be automatically set.

Parameters:
value - Long[]

setValue

public final void setValue(java.lang.Object value)
Set the Attributes value to the single Object. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - Object

setValue

public final void setValue(java.lang.Object[] value)
Set the Attributes value to the Object array. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - Object[]

setValue

public final void setValue(java.lang.String value)
Set the Attributes value to a single String. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - String

setValue

public final void setValue(java.lang.String[] value)
Set the Attributes value to a String array. The Type will be automatically set.

Specified by:
setValue in interface AttributeIF
Parameters:
value - String[]

setVirtual

public final void setVirtual(boolean bool)
Set the Attributes virtual flag.

Specified by:
setVirtual in interface AttributeIF
Parameters:
bool - flag to define if the Attribute is virtual

toString

public java.lang.String toString()
Get a String that represents the Attribute. The output will contain the name, type and value information

Overrides:
toString in class java.lang.Object
Returns:
String a string that describes the Attribute.


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