org.openptk.structure
Class Structure

java.lang.Object
  extended by org.openptk.structure.Structure
All Implemented Interfaces:
StructureIF
Direct Known Subclasses:
BasicStructure

public abstract class Structure
extends java.lang.Object
implements StructureIF

The abstract base class for a Structure. Provides core method implementations.

Author:
Scott Fehrman, Sun Microsystems, Inc.

Field Summary
 
Fields inherited from interface org.openptk.structure.StructureIF
NAME_ACCESSED, NAME_ACTION, NAME_ACTIONID, NAME_ACTIONS, NAME_ALLOWMULTI, NAME_ANCESTORS, NAME_ANSWERS, NAME_ATTRIBUTE, NAME_ATTRIBUTES, NAME_AUTHENTICATOR, NAME_AUTHENTICATORID, NAME_AUTHENTICATORS, NAME_AVERAGE, NAME_BODY, NAME_CACHE, NAME_CACHEID, NAME_CACHES, NAME_CATEGORY, NAME_CHANGE, NAME_CHILDREN, NAME_CLASS, NAME_CLASSNAME, NAME_CLIENT, NAME_CLIENTID, NAME_CLIENTS, NAME_CONTEXT, NAME_CONTEXTID, NAME_CONTEXTS, NAME_CONVERTER, NAME_CONVERTERID, NAME_CONVERTERS, NAME_COUNT, NAME_CREATED, NAME_CRYPTO, NAME_DATA, NAME_DEBUGLEVEL, NAME_DECIDER, NAME_DECIDERID, NAME_DECIDERS, NAME_DEFAULT, NAME_DEFINITION, NAME_DESCRIPTION, NAME_DIGEST, NAME_DOCUMENT, NAME_EFFECT, NAME_ENCRYPTED, NAME_ENFORCER, NAME_ENFORCERID, NAME_ENFORCERS, NAME_ENGINE, NAME_ENVIRONMENT, NAME_ENVIRONMENTS, NAME_ERROR, NAME_FROM, NAME_ID, NAME_INDEX, NAME_LENGTH, NAME_LEVEL, NAME_LIBRARY, NAME_MAXIMUM, NAME_MEDIA, NAME_META, NAME_MIMETYPE, NAME_MINIMUM, NAME_MODE, NAME_MODEL, NAME_MODELID, NAME_MODELS, NAME_MODIFIED, NAME_NAME, NAME_OFFSET, NAME_OPERATION, NAME_OPERATIONS, NAME_PARAMPATH, NAME_PARAMQUERY, NAME_PASSWORD, NAME_PHASE, NAME_PLUGIN, NAME_PLUGINID, NAME_PLUGINS, NAME_POLICIES, NAME_POLICY, NAME_POLICYID, NAME_PRINCIPAL, NAME_PROPERTIES, NAME_PROPERTY, NAME_QUANTITY, NAME_QUERY, NAME_QUESTIONS, NAME_READONLY, NAME_RELATIONSHIP, NAME_RELATIONSHIPID, NAME_RELATIONSHIPS, NAME_REQUEST, NAME_REQUIRED, NAME_RESOURCE, NAME_RESOURCEID, NAME_RESOURCES, NAME_RESPONSE, NAME_RESULTS, NAME_SEARCH, NAME_SECRET, NAME_SERVICE, NAME_SESSION, NAME_SESSIONID, NAME_SESSIONINFO, NAME_SESSIONS, NAME_SIBLINGS, NAME_SORT, NAME_STAT, NAME_STATE, NAME_STATID, NAME_STATS, NAME_STATUS, NAME_STRUCTURE, NAME_STRUCTURES, NAME_SUBJECT, NAME_SUBJECTID, NAME_SUBJECTS, NAME_TARGET, NAME_TARGETID, NAME_TARGETS, NAME_TEMPLATE, NAME_TO, NAME_TYPE, NAME_TYPES, NAME_UNIQUEID, NAME_UPDATED, NAME_URI, NAME_VALUE, NAME_VALUES, NAME_VERSION, NAME_VIEW, NAME_VIEWID, NAME_VIEWS, NAME_VIRTUAL
 
Constructor Summary
Structure(java.lang.String name)
          Create a new Structure using the provided name.
Structure(java.lang.String name, boolean value)
          Create a new Structure using the provided name and value.
Structure(java.lang.String name, java.lang.Boolean value)
          Create a new Structure using the provided name and value.
Structure(java.lang.String name, java.lang.Boolean[] values)
          Create a new Structure using the provided name and array of values.
Structure(java.lang.String name, int value)
          Create a new Structure using the provided name and value.
Structure(java.lang.String name, java.lang.Integer value)
          Create a new Structure using the provided name and value.
Structure(java.lang.String name, java.lang.Integer[] values)
          Create a new Structure using the provided name and array of values.
Structure(java.lang.String name, java.util.List<java.lang.String> values)
          Create a new Structure using the provided name and List of values.
Structure(java.lang.String name, long value)
          Create a new Structure using the provided name and value.
Structure(java.lang.String name, java.lang.Long value)
          Create a new Structure using the provided name and value.
Structure(java.lang.String name, java.lang.Long[] values)
          Create a new Structure using the provided name and array of values.
Structure(java.lang.String name, java.lang.Object value)
          Create a new Structure using the provided name and value.
Structure(java.lang.String name, java.lang.Object[] values)
          Create a new Structure using the provided name and array of values.
Structure(java.lang.String name, java.lang.String value)
          Create a new Structure using the provided name and value.
Structure(java.lang.String name, java.lang.String[] values)
          Create a new Structure using the provided name and Array of values.
Structure(java.lang.String name, StructureIF struct)
          Create a new Structure using the provide name and child Structure.
 
Method Summary
 void addChild(StructureIF child)
          Adds the provided Structure as a Child.
 void addValue(boolean value)
          Add boolean to the Structure value.
 void addValue(java.lang.Boolean value)
          Add Boolean to the Structure value.
 void addValue(int value)
          Add integer to the Structure value.
 void addValue(java.lang.Integer value)
          Add Integer to the Structure value.
 void addValue(long value)
          Add long to the Structure value.
 void addValue(java.lang.Long value)
          Add Long to the Structure value.
 void addValue(java.lang.Object value)
          Add Object to the Structure value.
 void addValue(java.lang.String value)
          Add String to the Structure value.
 StructureIF getChild(java.lang.String name)
          Returns the specified Child Structure.
 java.util.List<StructureIF> getChildren()
          Returns all Child Structures as a List.
 java.util.List<StructureIF> getChildren(java.lang.String name)
          Returns a List (of Children) that match the provided name.
 StructureIF[] getChildrenAsArray()
          Returns all Child Structures as an Array.
 StructureIF[] getChildrenAsArray(java.lang.String name)
          Returns an Structure array (of Children) that match the provided name.
 java.lang.String[] getChildrenIds()
          Returns a String Array containing the Childrens id (name).
 java.lang.String getName()
          Get the Structure name.
 StructureIF getParent()
          Returns the Structure Parent (if it is a Child).
 State getState()
          Get the Structure's State.
 java.lang.Object getValue()
          Returns the value (if single valued) or the first value (is multi valued) If there is no value, null will be returned.
 java.lang.String getValueAsString()
          Returns a String representation of the (first) value.
 java.util.List<java.lang.Object> getValues()
          Returns the List of values (Object).
 java.lang.Object[] getValuesAsArray()
          Returns an Array of values (Object).
 java.lang.String getValuesAsString()
          Returns a String representation of all (List) the values.
 StructureType getValueType()
          Returns the Structure Type.
 boolean hasChild(java.lang.String name)
          Returns TRUE if a Child exists with the specified name.
 boolean hasChildren()
          Returns TRUE if the Structure contains one or more Children.
 boolean isMultiValued()
          Returns TRUE if the Structure contains more than 1 (one) value.
 void setChild(int index, StructureIF child)
          Sets / Replaces a specific Child with the provided Structure.
 void setName(java.lang.String name)
          Set the Structure's name.
 void setParent(StructureIF struct)
          Set the Structure's parent.
 void setState(State state)
          Set the Structure State.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Structure

public Structure(java.lang.String name)
Create a new Structure using the provided name. The structure will NOT have a type. This can either contain a value OR contain children.

Parameters:
name - Name of the Structure

Structure

public Structure(java.lang.String name,
                 boolean value)
Create a new Structure using the provided name and value. The structure will be of type BOOLEAN and it is single valued. This structure can not have any children.

Parameters:
name - Name of the Structure
value - boolean

Structure

public Structure(java.lang.String name,
                 java.lang.Boolean value)
Create a new Structure using the provided name and value. The structure will be of type BOOLEAN and it is single valued. This structure can not have any children.

Parameters:
name - Name of the Structure
value - Boolean

Structure

public Structure(java.lang.String name,
                 java.lang.Boolean[] values)
Create a new Structure using the provided name and array of values. The structure will be of type BOOLEAN and it is multi valued. This structure can not have any children.

Parameters:
name - Name of the Structure
values - Array of Boolean values

Structure

public Structure(java.lang.String name,
                 int value)
Create a new Structure using the provided name and value. The structure will be of type INTEGER and it is single valued. This structure can not have any children.

Parameters:
name - Name of the Structure
value - Structure integer value

Structure

public Structure(java.lang.String name,
                 java.lang.Integer value)
Create a new Structure using the provided name and value. The structure will be of type INTEGER and it is single valued. This structure can not have any children.

Parameters:
name - Name of the Structure
value - Structure Integer value

Structure

public Structure(java.lang.String name,
                 java.lang.Integer[] values)
Create a new Structure using the provided name and array of values. The structure will be of type INTEGER and it is multi valued. This structure can not have any children.

Parameters:
name - Name of the Structure
values - Array of Integers

Structure

public Structure(java.lang.String name,
                 java.util.List<java.lang.String> values)
Create a new Structure using the provided name and List of values. The structure will be of type STRING and it is multi valued. This structure can not have any children.

Parameters:
name - Name of the Structure
values - List of values

Structure

public Structure(java.lang.String name,
                 long value)
Create a new Structure using the provided name and value. The structure will be of type LONG and it is single valued. This structure can not have any children.

Parameters:
name - Name of the Structure
value - Structure long value

Structure

public Structure(java.lang.String name,
                 java.lang.Long value)
Create a new Structure using the provided name and value. The structure will be of type LONG and it is single valued. This structure can not have any children.

Parameters:
name - Name of the Structure
value - Structure Long value

Structure

public Structure(java.lang.String name,
                 java.lang.Long[] values)
Create a new Structure using the provided name and array of values. The structure will be of type LONG and it is multi valued. This structure can not have any children.

Parameters:
name - Name of the Structure
values - Array of Longs

Structure

public Structure(java.lang.String name,
                 java.lang.Object value)
Create a new Structure using the provided name and value. The structure will be of type OBJECT and it is single valued. This structure can not have any children.

Parameters:
name - Name of the Structure
value - Object

Structure

public Structure(java.lang.String name,
                 java.lang.Object[] values)
Create a new Structure using the provided name and array of values. The structure will be of type OBJECT and it is multi valued. This structure can not have any children.

Parameters:
name - Name of the Structure
values - Array of Object values

Structure

public Structure(java.lang.String name,
                 java.lang.String value)
Create a new Structure using the provided name and value. The structure will be of type STRING and it is single valued. This structure can not have any children.

Parameters:
name - Name of the Structure
value - Structure value

Structure

public Structure(java.lang.String name,
                 java.lang.String[] values)
Create a new Structure using the provided name and Array of values. The structure will be of type STRING and it is multi valued. This structure can not have any children.

Parameters:
name - Name of the Structure
values - Array of values

Structure

public Structure(java.lang.String name,
                 StructureIF struct)
Create a new Structure using the provide name and child Structure. The structure will be of type STRUCTURE. This structure can not contain a value.

Parameters:
name - Name of the Structure
struct - The child Structure
Method Detail

addChild

public final void addChild(StructureIF child)
                    throws StructureException
Adds the provided Structure as a Child. Will throw an StructureException if:

Specified by:
addChild in interface StructureIF
Parameters:
child - Child Structure
Throws:
StructureException

addValue

public final void addValue(boolean value)
                    throws StructureException
Add boolean to the Structure value. Will throw an StructureException if:

Specified by:
addValue in interface StructureIF
Parameters:
value - boolean to add
Throws:
StructureException

addValue

public final void addValue(java.lang.Boolean value)
                    throws StructureException
Add Boolean to the Structure value. Will throw an StructureException if:

Specified by:
addValue in interface StructureIF
Parameters:
value - Boolean to add
Throws:
StructureException

addValue

public final void addValue(int value)
                    throws StructureException
Add integer to the Structure value. Will throw an StructureException if:

Specified by:
addValue in interface StructureIF
Parameters:
value - integer to add
Throws:
StructureException

addValue

public final void addValue(java.lang.Integer value)
                    throws StructureException
Add Integer to the Structure value. Will throw an StructureException if:

Specified by:
addValue in interface StructureIF
Parameters:
value - Integer to add
Throws:
StructureException

addValue

public final void addValue(long value)
                    throws StructureException
Add long to the Structure value. Will throw an StructureException if:

Specified by:
addValue in interface StructureIF
Parameters:
value - long to add
Throws:
StructureException

addValue

public final void addValue(java.lang.Long value)
                    throws StructureException
Add Long to the Structure value. Will throw an StructureException if:

Specified by:
addValue in interface StructureIF
Parameters:
value - Long to add
Throws:
StructureException

addValue

public final void addValue(java.lang.Object value)
                    throws StructureException
Add Object to the Structure value. Will throw an StructureException if:

Specified by:
addValue in interface StructureIF
Parameters:
value - Object to add
Throws:
StructureException

addValue

public final void addValue(java.lang.String value)
                    throws StructureException
Add String to the Structure value. Will throw an StructureException if:

Specified by:
addValue in interface StructureIF
Parameters:
value - String to add
Throws:
StructureException

getChild

public final StructureIF getChild(java.lang.String name)
Returns the specified Child Structure. If the Child does not exist, the returned Structure is null.

Specified by:
getChild in interface StructureIF
Parameters:
name - Child Structure name
Returns:
StructureIF the Child

getChildren

public final java.util.List<StructureIF> getChildren()
Returns all Child Structures as a List. The List is ordered (order of insertion).

Specified by:
getChildren in interface StructureIF
Returns:
List Child Structures.

getChildren

public final java.util.List<StructureIF> getChildren(java.lang.String name)
Returns a List (of Children) that match the provided name. All of the Child Structures are search, those that match the provided name will be returned in a List.

Specified by:
getChildren in interface StructureIF
Parameters:
name - The child name
Returns:
List of matching children

getChildrenAsArray

public final StructureIF[] getChildrenAsArray()
Returns all Child Structures as an Array. The Array is ordered (order of insertion).

Specified by:
getChildrenAsArray in interface StructureIF
Returns:
StructureIF[] Child Structures.

getChildrenAsArray

public final StructureIF[] getChildrenAsArray(java.lang.String name)
Returns an Structure array (of Children) that match the provided name. All of the Child Structures are search, those that match the provided name will be returned in an array.

Specified by:
getChildrenAsArray in interface StructureIF
Parameters:
name - The child name
Returns:
StructureIF[] Array of matching children

getChildrenIds

public final java.lang.String[] getChildrenIds()
Returns a String Array containing the Childrens id (name). The Array is ordered (order of insertion).

Specified by:
getChildrenIds in interface StructureIF
Returns:
String[] Child ids (names)

getName

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

Specified by:
getName in interface StructureIF
Returns:
String The Structure name

getParent

public final StructureIF getParent()
Returns the Structure Parent (if it is a Child). This will be null if it is not a Child.

Specified by:
getParent in interface StructureIF
Returns:
StructureIF Parent Structure

getState

public final State getState()
Get the Structure's State.

Specified by:
getState in interface StructureIF
Returns:
State the current state

getValue

public final java.lang.Object getValue()
Returns the value (if single valued) or the first value (is multi valued) If there is no value, null will be returned.

Specified by:
getValue in interface StructureIF
Returns:
Object the (first) value

getValueAsString

public final java.lang.String getValueAsString()
Returns a String representation of the (first) value.

Specified by:
getValueAsString in interface StructureIF
Returns:
String representation of the (first) value

getValues

public final java.util.List<java.lang.Object> getValues()
Returns the List of values (Object). An ordered list (order of insertion) of values. Use the getValueType() method to determine the value real type. All values will be of the same type.

Specified by:
getValues in interface StructureIF
Returns:
List ordered list of values

getValuesAsArray

public final java.lang.Object[] getValuesAsArray()
Returns an Array of values (Object). An ordered array (order of insertion) of values. Use the getValueType() method to determine the value real type. All values will be of the same type.

Specified by:
getValuesAsArray in interface StructureIF
Returns:
Object[] ordered array of values

getValuesAsString

public final java.lang.String getValuesAsString()
Returns a String representation of all (List) the values.

Specified by:
getValuesAsString in interface StructureIF
Returns:
String representation of all (List) the values.

getValueType

public final StructureType getValueType()
Returns the Structure Type.

Specified by:
getValueType in interface StructureIF
Returns:
StructureType Structure Type

hasChild

public final boolean hasChild(java.lang.String name)
Returns TRUE if a Child exists with the specified name.

Specified by:
hasChild in interface StructureIF
Parameters:
name - Child Structure name
Returns:
boolean TRUE if has children

hasChildren

public final boolean hasChildren()
Returns TRUE if the Structure contains one or more Children.

Specified by:
hasChildren in interface StructureIF
Returns:
boolean contains child(ren)

isMultiValued

public final boolean isMultiValued()
Returns TRUE if the Structure contains more than 1 (one) value.

Specified by:
isMultiValued in interface StructureIF
Returns:
boolean True if more than 1 value

setChild

public final void setChild(int index,
                           StructureIF child)
                    throws StructureException
Sets / Replaces a specific Child with the provided Structure. Will throw an StructureException if:

Specified by:
setChild in interface StructureIF
Parameters:
index - child offset
child - Child Structure
Throws:
StructureException

setName

public final void setName(java.lang.String name)
Set the Structure's name.

Specified by:
setName in interface StructureIF
Parameters:
name - Structure's name

setParent

public final void setParent(StructureIF struct)
Set the Structure's parent.

Note: In most situation this method should not be used / needed. The Child/Parent relationship is maintained by the addChild() and setChild() methods.

Specified by:
setParent in interface StructureIF
Parameters:
struct - Parent Structure

setState

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

Specified by:
setState in interface StructureIF
Parameters:
state - A valid State

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
String representation of a structure


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