com.infoengine.object.factory
Class Webject

java.lang.Object
  extended by com.infoengine.object.factory.Webject
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Webject

public class Webject
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

See Also:
Serialized Form

Field Summary
static java.lang.String CLASS
           
static java.lang.String DISPLAY
           
static java.lang.String EXTERNAL
           
static java.lang.String GROUP
           
static java.lang.String GROUP_IN
           
static java.lang.String GROUP_OUT
           
static java.lang.String MESSAGE
           
static java.lang.String OBJECT
           
static java.lang.String OUTPUT
           
static java.lang.String TASK
           
static byte[] text
           
static java.lang.String TYPE
           
static java.lang.String UNKNOWN
           
 
Constructor Summary
Webject()
          Constructs an unnamed webject.
Webject(IeNode node)
          Constructs a webject wrapper around an existing set of parameters.
Webject(java.lang.String name)
          Constructs a named webject.
 
Method Summary
 Param addKey(java.lang.String key, java.lang.String value)
          Adds a KEY parameter to this webject.
 void addMessage(java.lang.String message)
          Adds a warning or error message to this webject.
 void addMeta(IeMeta meta)
          Adds a specific meta item to this webject.
 void addMetaValue(java.lang.String name, java.lang.String value)
          Adds a meta item to this webject with a specific name and value.
 void addOutput(java.lang.String message)
          Adds an output message to this webject.
 void addParam(Param param)
          Adds a new parameter to this webject.
 Param addUniqueKey(java.lang.String key, java.lang.String value)
          Adds a KEY parameter to this webject only if the webject does not contain it already.
 Param addUniqueValue(java.lang.String key, java.lang.String value)
          Adds a VALUE parameter to this webject only if the webject does not contain it already.
 Param addValue(java.lang.String keyval)
          Adds a VALUE parameter to this webject.
 Param addValue(java.lang.String key, java.lang.String value)
          Adds a VALUE parameter to this webject.
 void addWebject(Webject webject)
          Adds a new webject as a child of this webject.
 void clearParams()
          Removes all parameters of this webject.
 java.lang.Object clone()
          Returns a shallow copy of this webject.
 Webject deepClone()
          Returns a deep copy of this webject.
 java.lang.String getClassName()
          Returns the class name currently assigned to this webject.
 java.util.Map<java.lang.String,com.infoengine.object.factory.ParameterDef> getDefinition(java.lang.Class w_impl)
          Retrieves a Map of parameter name to parameter definition for a webject implementation class.
 java.lang.String getGroupInName()
          Returns the name of the default input group of this webject.
 java.util.Enumeration getGroupInNames()
          Returns the names of all input groups currently associated with this webject.
 java.lang.String getGroupOutName()
          Returns the name of the default output group of this webject.
 java.util.Enumeration getGroupOutNames()
          Returns the names of all output groups currently associated with this webject.
 Param getKey(java.lang.String name)
          Returns the KEY parameter with the specified name.
 java.util.Enumeration getKeys()
          Returns all of the KEY parameters contained in this webject.
 java.util.Enumeration getMessages()
          Returns any warning or error messages generated by this webject.
 java.lang.String getMetaValue(java.lang.String name)
          Returns a meta value from this webject by name.
 java.lang.String getName()
          Returns the name currently assigned to this webject.
 IeNode getNode()
          Returns the internal IeNode object of this webject.
 java.util.Enumeration getOutput()
          Returns any output messages generated by this webject.
 Param getParam(java.lang.String name)
          Returns a webject parameter by name.
 java.util.Enumeration getParamNames()
          Returns the names of all parameters associated with this webject.
 java.util.Enumeration getParams(java.lang.String name)
          Returns all of the webject parameters with a specified name.
 java.lang.String getPassword()
          Returns the password currently associated with this webject.
 java.lang.String getType()
          Returns the type currently assigned to this webject.
 java.lang.String getUserName()
          Returns the username currently associated with this webject.
 Param getValue(java.lang.String name)
          Returns the VALUE parameter with the specified name.
 java.util.Enumeration getValues()
          Returns all of the VALUE parameters contained in this webject.
 java.util.Enumeration getWebjects()
          Returns any webjects that are children of this webject.
 java.lang.Object objectParamValue(java.lang.String name)
          Retrieves a strongly typed parameter value from this webject.
 java.lang.Object objectParamValue(java.lang.String name, java.lang.Object defaultValue)
           
 java.lang.String paramValue(java.lang.String name)
          Returns the value of a webject parameter by name.
 java.lang.String paramValue(java.lang.String name, java.lang.String defaultValue)
          Returns the value of a webject parameter by name.
 java.util.Enumeration paramValues(java.lang.String name)
          Returns all values of a named parameter of this webject.
 void printTree()
          Prints the internal structure of this webject to System.out.
 void removeAllWebjects()
          Removes all child webjects from this webject.
 void removeParam(Param param)
          Removes a specific parameter from this webject.
 void removeParams(java.lang.String name)
          Removes all parameters with a specified name from this webject.
 void removeWebject(Webject webject)
          Removes a specific child webject from this webject.
 void setClassName(java.lang.String name)
          Sets the class name assigned to this webject.
 void setName(java.lang.String name)
          Sets the name of this webject.
 void setParam(Param param)
          Sets a new parameter for this webject.
 void setPassword(java.lang.String pwd)
          Sets the password associated with this webject.
 void setType(java.lang.String type)
          Sets the type assigned to this webject.
 void setUserName(java.lang.String name)
          Sets the username associated with this webject.
 Param setValue(java.lang.String key, java.lang.String value)
          Sets a VALUE parameter in this webject.
 java.lang.String toString()
          Produces a String representation of this webject.
 void validate(java.lang.Class w_impl, Task t)
          Validates a webject based on its annotation definition (if any).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MESSAGE

public static final java.lang.String MESSAGE
See Also:
Constant Field Values

OUTPUT

public static final java.lang.String OUTPUT
See Also:
Constant Field Values

GROUP_IN

public static final java.lang.String GROUP_IN
See Also:
Constant Field Values

GROUP_OUT

public static final java.lang.String GROUP_OUT
See Also:
Constant Field Values

CLASS

public static final java.lang.String CLASS
See Also:
Constant Field Values

TYPE

public static final java.lang.String TYPE
See Also:
Constant Field Values

UNKNOWN

public static final java.lang.String UNKNOWN
See Also:
Constant Field Values

OBJECT

public static final java.lang.String OBJECT
See Also:
Constant Field Values

EXTERNAL

public static final java.lang.String EXTERNAL
See Also:
Constant Field Values

DISPLAY

public static final java.lang.String DISPLAY
See Also:
Constant Field Values

GROUP

public static final java.lang.String GROUP
See Also:
Constant Field Values

TASK

public static final java.lang.String TASK
See Also:
Constant Field Values

text

public static final byte[] text
Constructor Detail

Webject

public Webject()
Constructs an unnamed webject.


Webject

public Webject(java.lang.String name)
Constructs a named webject.

Parameters:
name - The name of the webject.

Webject

public Webject(IeNode node)
Constructs a webject wrapper around an existing set of parameters.

Method Detail

getName

public java.lang.String getName()
Returns the name currently assigned to this webject.

Returns:
The webject's current name.

setName

public void setName(java.lang.String name)
Sets the name of this webject.

Parameters:
name - The webject's new name.

setPassword

public void setPassword(java.lang.String pwd)
Sets the password associated with this webject.

Parameters:
pwd - The webject's new password.

getPassword

public java.lang.String getPassword()
Returns the password currently associated with this webject.

Returns:
The webject's current password.

setUserName

public void setUserName(java.lang.String name)
Sets the username associated with this webject.

Parameters:
name - The webject's new username.

getUserName

public java.lang.String getUserName()
Returns the username currently associated with this webject.

Returns:
The webject's current username.

getType

public java.lang.String getType()
Returns the type currently assigned to this webject.

Returns:
The webject's current type.

setType

public void setType(java.lang.String type)
Sets the type assigned to this webject.

Parameters:
type - The webject's new type.

getClassName

public java.lang.String getClassName()
Returns the class name currently assigned to this webject.

Returns:
The webject's current class name.

setClassName

public void setClassName(java.lang.String name)
Sets the class name assigned to this webject.

Parameters:
name - The webject's new class name.

getGroupInName

public java.lang.String getGroupInName()
Returns the name of the default input group of this webject.

Returns:
The default input group name.

getGroupInNames

public java.util.Enumeration getGroupInNames()
Returns the names of all input groups currently associated with this webject.

Returns:
The input group names.

getGroupOutName

public java.lang.String getGroupOutName()
Returns the name of the default output group of this webject.

Returns:
The default output group name.

getGroupOutNames

public java.util.Enumeration getGroupOutNames()
Returns the names of all output groups currently associated with this webject.

Returns:
The output group names.

clearParams

public void clearParams()
Removes all parameters of this webject.


addParam

public void addParam(Param param)
Adds a new parameter to this webject.

Parameters:
param - The new parameter to be added.

setParam

public void setParam(Param param)
Sets a new parameter for this webject. If any parameters with the same name were added previously, they are removed.

Parameters:
param - The new parameter to be set.

removeParam

public void removeParam(Param param)
Removes a specific parameter from this webject.

Parameters:
param - The parameter to be removed.

removeParams

public void removeParams(java.lang.String name)
Removes all parameters with a specified name from this webject.

Parameters:
name - The name of the parameter(s) to be removed.

paramValue

public java.lang.String paramValue(java.lang.String name)
Returns the value of a webject parameter by name.

Parameters:
name - The name of the desired parameter.
Returns:
The named parameter's value, or an empty string if the parameter is not found in the webject.

paramValue

public java.lang.String paramValue(java.lang.String name,
                                   java.lang.String defaultValue)
Returns the value of a webject parameter by name. If the parameter is not found in the webject, returns a default value.

Parameters:
name - The name of the desired parameter.
defaultValue - The default value to return if the parameter is not found.
Returns:
The named parameter's value, or the default value if the parameter is not found in the webject.

paramValues

public java.util.Enumeration paramValues(java.lang.String name)
Returns all values of a named parameter of this webject.

Parameters:
name - The name of the desired parameter.
Returns:
The named parameter's values.

getParam

public Param getParam(java.lang.String name)
Returns a webject parameter by name.

Parameters:
name - The name of the desired parameter.
Returns:
The named parameter's value, or null if the parameter is not found in the webject.

getParams

public java.util.Enumeration getParams(java.lang.String name)
Returns all of the webject parameters with a specified name.

Parameters:
name - The name of the desired parameters. A null name causes all parameters, regardless of name, to be returned.
Returns:
The parameters.

getParamNames

public java.util.Enumeration getParamNames()
Returns the names of all parameters associated with this webject.

Returns:
The parameter names.

getMetaValue

public java.lang.String getMetaValue(java.lang.String name)
Returns a meta value from this webject by name.

Parameters:
name - The name of the desired meta value.
Returns:
The value of the named meta, or null if the meta is not found in the webject.

addMetaValue

public void addMetaValue(java.lang.String name,
                         java.lang.String value)
Adds a meta item to this webject with a specific name and value.

Parameters:
name - The name of the new meta item.
value - The value of the meta item.

addMeta

public void addMeta(IeMeta meta)
Adds a specific meta item to this webject.

Parameters:
meta - The IeMeta object to be added.

getKey

public Param getKey(java.lang.String name)
Returns the KEY parameter with the specified name.

Parameters:
name - The name associated with the KEY parameter.
Returns:
The named KEY parameter, or null if the parameter is not found in the webject.

getKeys

public java.util.Enumeration getKeys()
Returns all of the KEY parameters contained in this webject.

Returns:
The KEY parameters.

addKey

public Param addKey(java.lang.String key,
                    java.lang.String value)
Adds a KEY parameter to this webject.

Parameters:
key - The name of the new parameter.
value - The value of the new parameter.
Returns:
The new KEY parameter.

addUniqueKey

public Param addUniqueKey(java.lang.String key,
                          java.lang.String value)
Adds a KEY parameter to this webject only if the webject does not contain it already.

Parameters:
key - The name of the new parameter.
value - The value of the new parameter.
Returns:
The new parameter, or the pre-existing parameter with this value

getValue

public Param getValue(java.lang.String name)
Returns the VALUE parameter with the specified name.

Parameters:
name - The name of the desired VALUE parameter.
Returns:
The named VALUE parameter, or null if the parameter is not found in the webject.

getValues

public java.util.Enumeration getValues()
Returns all of the VALUE parameters contained in this webject.

Returns:
The VALUE parameters.

addValue

public Param addValue(java.lang.String key,
                      java.lang.String value)
Adds a VALUE parameter to this webject.

Parameters:
key - The name of the new parameter.
value - The value of the new parameter.
Returns:
The new parameter.

addUniqueValue

public Param addUniqueValue(java.lang.String key,
                            java.lang.String value)
Adds a VALUE parameter to this webject only if the webject does not contain it already.

Parameters:
key - The name of the new parameter.
value - The value of the new parameter.
Returns:
The new parameter, or the pre-existing parameter with this value

setValue

public Param setValue(java.lang.String key,
                      java.lang.String value)
Sets a VALUE parameter in this webject.

Parameters:
key - The name of the new parameter.
value - The value of the new parameter.
Returns:
The new parameter.

addValue

public Param addValue(java.lang.String keyval)
Adds a VALUE parameter to this webject.

Parameters:
keyval - A key=value string representing a parameter.
Returns:
The new parameter.

getMessages

public java.util.Enumeration getMessages()
Returns any warning or error messages generated by this webject.

Returns:
The warning or error messages.

addMessage

public void addMessage(java.lang.String message)
Adds a warning or error message to this webject.

Parameters:
message - The warning or error message to be added.

getOutput

public java.util.Enumeration getOutput()
Returns any output messages generated by this webject.

Returns:
The output messages.

addOutput

public void addOutput(java.lang.String message)
Adds an output message to this webject.

Parameters:
message - The output message to be added.

clone

public java.lang.Object clone()
Returns a shallow copy of this webject.

Overrides:
clone in class java.lang.Object
Returns:
The shallow copy.

deepClone

public Webject deepClone()
Returns a deep copy of this webject.

Returns:
The deep copy.

getNode

public IeNode getNode()
Returns the internal IeNode object of this webject.

Returns:
This webject's set of parameters and meta.

getWebjects

public java.util.Enumeration getWebjects()
Returns any webjects that are children of this webject.

Returns:
This webject's set of child webjects.

addWebject

public void addWebject(Webject webject)
Adds a new webject as a child of this webject.

Parameters:
webject - The new child webject.

removeWebject

public void removeWebject(Webject webject)
Removes a specific child webject from this webject.

Parameters:
webject - The child webject to be removed.

removeAllWebjects

public void removeAllWebjects()
Removes all child webjects from this webject.


printTree

public void printTree()
Prints the internal structure of this webject to System.out.


toString

public java.lang.String toString()
Produces a String representation of this webject.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of this webject.

getDefinition

public java.util.Map<java.lang.String,com.infoengine.object.factory.ParameterDef> getDefinition(java.lang.Class w_impl)
Retrieves a Map of parameter name to parameter definition for a webject implementation class.

Parameters:
w_impl - The implementation.
Returns:
the Map or null if no annotations defined for the webject (the webject is doing its own validation).

validate

public void validate(java.lang.Class w_impl,
                     Task t)
              throws IEException
Validates a webject based on its annotation definition (if any). This only enforces hard fast rules like; required, interdependant, select and min/max value counts. Following invocation of this method the objectParamValue method can be called to get Strongly typed parameter values.

Parameters:
w_impl - The webject implementation class.
Throws:
IEException - if based on the webject's definition a rule has been broken.

objectParamValue

public java.lang.Object objectParamValue(java.lang.String name)
                                  throws IEException
Retrieves a strongly typed parameter value from this webject. If either; validate has not been called previously OR the webject implementation does not define a webject definition then this method will issue an IllegalStateException. If the parameter name is not part of the webject definition then an IllegalArgumentException will be issued. If the parameter is single valued and not specified then null will be returned. If the parameter is multi-valued then an array will be returned, if the parameter was not specified the array will be empty. Currently supported types include; String, boolean, int, Group and enumerated types.

Parameters:
name - The parameter name.
Returns:
The parameter value(s).
Throws:
IEException - if the incoming parameter is a bad value (not an int, not a boolean, etc.)
java.lang.IllegalArgumentException - if name is not a known parameter for the webject implementation.

objectParamValue

public java.lang.Object objectParamValue(java.lang.String name,
                                         java.lang.Object defaultValue)
                                  throws IEException
Throws:
IEException