com.infoengine.object.factory
Class Group

java.lang.Object
  extended bycom.infoengine.object.factory.Group
All Implemented Interfaces:
Cloneable, Serializable

public class Group
extends Object
implements Cloneable, Serializable

See Also:
Serialized Form

Field Summary
private static int counter
           
static int EXCEPTION
           
static String EXCEPTION_OBJECT_KEY
           
private  IeGroup myGroup
           
static int OBJECT
           
static int STATUS
           
static int STREAM
           
static boolean TOP_LEVEL
           
static String[] TYPES
           
static int UNKNOWN
           
 
Constructor Summary
Group()
          Constructs an unnamed Group.
Group(Group grp)
          Constructs a new Group from an existing lightweight connector Group.
Group(IeGroup group)
          Constructs a Group wrapper around an existing IeGroup.
Group(String name)
          Constructs a named Group.
Group(URL locator)
          Contructs a group read from a URL.
 
Method Summary
 void addAttributeValue(int index, String attName, Object attValue)
          add an attribute value
 void addElement(Element element)
          Adds an element to the elements contained in the group.
 void addElement(TypeInstance typeInstance)
          Adds a type instance to the elements contained in the group.
 void addElementByUfid(Element element)
          Adds an element to the elements contained in the group and removes any other elements from the group that have the same UFID (Unique Federation Identifier) as the element being added.
 void addMessage(String message)
          Adds a message to this group.
 Object clone()
          Returns a shallow copy of this group.
private  Att copyConnectorAttribute(Attribute att)
           
private  Element copyConnectorElement(Element elem)
           
private  void copyConnectorMeta(IeObject ieObj, Data data)
           
 Group deepClone()
          Returns a deep copy of this group.
 Enumeration getAllElementsWithMetaValue(String meta, String value)
          Returns an enumeration of all elements of the group that have a meta value with a specified name and value.
 Object getAttributeValue(int index, String name)
          Returns the value of a named attribute within an element at a specific location.
 Object getAttributeValueByMeta(int index, String name, Object value)
          Locates an element by index, then returns the value of the attribute within that element having a specific metadata name/value pair.
 String getClassName()
          Returns this group's class name.
 Element[] getElementArray()
          Returns all of the elements of this group as an array.
 Element getElementAt(int index)
          Returns the element at a specific location.
 Element getElementByUfid(String ufid)
          Returns the element of the group that has a UFID (Unique Federation Identifier) with a specific value.
 Element getElementByUfidWithAttributes(String ufid, AttributeIdentifier[] attrIds)
          Returns the element of the group that has a UFID (Unique Federation Identifier) with a specific value and that also contains a specific set of attributes identified by attribute identifier.
 Element getElementByUfidWithAttributes(String ufid, AttributeTypeIdentifier[] attrTypeIds)
          Returns the element of the group that has a UFID (Unique Federation Identifier) with a specific value and that also contains a specific set of attributes identified by attribute type identifier.
 Element getElementByUfidWithAttributes(String ufid, String[] names)
          Returns the element of the group that has a UFID (Unique Federation Identifier) with a specific value and that also contains a specific set of attributes identified by name.
 int getElementCount()
          Returns the nummber of elements contained in the group.
 Enumeration getElements()
          Returns all of the elements of this group.
 Element getElementWithMetaValue(String meta, String value)
          Returns the element of the group that has a meta value with a specified name and value.
 IeGroup getGroup()
          Returns the group's internal IeGroup object.
 boolean getHasChanged()
          Returns this group's change indicator.
 String getMessage()
          Returns this group's message.
 Enumeration getMessages()
          Returns all of this group's messages.
 String getName()
          Returns this group's name.
 int getStatus()
          Returns this group's current status.
 String getSuccess()
          Returns the current value of this group's SUCCESS meta.
 int getType()
          Returns this group's currently assigned type.
 String getTypeString()
          Returns this group's currently assigned type as a string.
static Group newExceptionGroup(String name, Throwable t)
          Creates an exception group with name and throwable.
static Group newExceptionGroup(String name, Throwable t, boolean storeException)
          Creates an exception group with name and throwable.
static Group newStatusGroup(String name, String message, int status)
          Creates a status group with a specified status and message.
protected static IeGroup newStructure()
          Builds an empty group structure.
private static int nextSeqNo()
           
 void printTree()
          Prints the structure of this group on System.out.
 void removeElement(Element element)
          Removes a specific element from the group.
 void removeElement(String name)
          Removes an element from the group by name.
 void removeElementByUfid(String ufid)
          Removes the element of the group that has a UFID (Unique Federation Identifier) with a specific value.
 void removeElements()
          Removes all Elements from the group
 void setAttributeValue(int index, String attName, Object attValue)
          set an attribute value
 void setClassName(String name)
          Sets this group's class name.
 void setElement(Element element)
          Sets the group such that it contains the specified element only.
 void setElementAt(Element element, int index)
          Sets the element at a specific location.
protected  void setGroup(IeGroup group)
          Sets the group's internal IeGroup object.
 void setHasChanged(boolean hasChanged)
          Sets this group's change indicator.
 void setMessage(String message)
          Sets this group's message.
 void setName(String name)
          Sets this group's name.
 void setStatus(int status)
          Sets this group's status.
 void setSuccess(String value)
          Sets this group's SUCCESS meta to a specified value.
 void setType(int type)
          Sets this group's type.
static String toXML(IeCollection collection)
          Renders a collection of groups to an XML string.
static String toXML(IeCollection collection, boolean includeMeta)
          Renders a collection of groups to an XML string.
static void toXML(IeCollection collection, Writer writer)
          Writes the XML representation of a collection of groups.
static void toXML(IeCollection collection, Writer writer, boolean includeMeta)
          Writes the XML representation of a collection of groups.
 void toXML(PrintWriter output, boolean topLevel)
          Writes the XML representation of this group.
 void toXML(PrintWriter output, boolean topLevel, boolean includeMeta)
          Writes the XML representation of this group.
static int type2Int(String type)
          Converts a string to an integer group type.
private  void updateAttributeValue(int index, String attName, Object attValue, boolean set)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPES

public static String[] TYPES

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

OBJECT

public static final int OBJECT
See Also:
Constant Field Values

STATUS

public static final int STATUS
See Also:
Constant Field Values

STREAM

public static final int STREAM
See Also:
Constant Field Values

EXCEPTION

public static final int EXCEPTION
See Also:
Constant Field Values

EXCEPTION_OBJECT_KEY

public static final String EXCEPTION_OBJECT_KEY
See Also:
Constant Field Values

TOP_LEVEL

public static final boolean TOP_LEVEL
See Also:
Constant Field Values

myGroup

private IeGroup myGroup

counter

private static int counter
Constructor Detail

Group

public Group()
Constructs an unnamed Group.


Group

public Group(String name)
Constructs a named Group.

Parameters:
name - The name to be assigned to the group.

Group

public Group(URL locator)
Contructs a group read from a URL. The URL is assumed to reference a resource containing the XML representation of an Info*Engine group.

Parameters:
locator - The URL of the resource from which to read the group.

Group

public Group(IeGroup group)
Constructs a Group wrapper around an existing IeGroup.

Parameters:
group - The IeGroup object to be wrapped.

Group

public Group(Group grp)
Constructs a new Group from an existing lightweight connector Group.

Parameters:
grp - the connector group oject
Method Detail

copyConnectorElement

private Element copyConnectorElement(Element elem)

copyConnectorAttribute

private Att copyConnectorAttribute(Attribute att)

copyConnectorMeta

private void copyConnectorMeta(IeObject ieObj,
                               Data data)

toXML

public void toXML(PrintWriter output,
                  boolean topLevel)
Writes the XML representation of this group.

Parameters:
output - The PrintWriter on which to write the XML text.
topLevel - true if this group is at the top level of a nested group hierarchy.

toXML

public void toXML(PrintWriter output,
                  boolean topLevel,
                  boolean includeMeta)
Writes the XML representation of this group.

Parameters:
output - The PrintWriter on which to write the XML text.
topLevel - true if this group is at the top level of a nested group hierarchy.
includeMeta - Specify true to include meta-information in the XML representation.

toXML

public static void toXML(IeCollection collection,
                         Writer writer)
Writes the XML representation of a collection of groups.

Parameters:
collection - The IeCollection to render to XML.
writer - The Writer on which to write the XML text.

toXML

public static void toXML(IeCollection collection,
                         Writer writer,
                         boolean includeMeta)
Writes the XML representation of a collection of groups.

Parameters:
collection - The IeCollection to render to XML.
writer - The Writer on which to write the XML text.
includeMeta - Specify true to include meta-information in the XML representation.

toXML

public static String toXML(IeCollection collection)
Renders a collection of groups to an XML string.

Parameters:
collection - The IeCollection to render to XML.
Returns:
The XML string representation of the collection.

toXML

public static String toXML(IeCollection collection,
                           boolean includeMeta)
Renders a collection of groups to an XML string.

Parameters:
collection - The IeCollection to render to XML.
includeMeta - Specify true to include meta-information in the XML representation.
Returns:
The XML string representation of the collection.

clone

public Object clone()
Returns a shallow copy of this group.

Returns:
The shallow copy.

deepClone

public Group deepClone()
Returns a deep copy of this group.

Returns:
The deep copy.

printTree

public void printTree()
Prints the structure of this group on System.out.


getName

public String getName()
Returns this group's name.

Returns:
The group's current name.

setName

public void setName(String name)
Sets this group's name.

Parameters:
name - The group's new name.

setSuccess

public void setSuccess(String value)
Sets this group's SUCCESS meta to a specified value.

Parameters:
value - The value to which to set the SUCCESS meta.

getSuccess

public String getSuccess()
Returns the current value of this group's SUCCESS meta.

Returns:
The current value of the SUCCESS meta.

getClassName

public String getClassName()
Returns this group's class name.

Returns:
The Group's current class name.

setClassName

public void setClassName(String name)
Sets this group's class name.

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

getStatus

public int getStatus()
Returns this group's current status.

Returns:
The group's current status.

setStatus

public void setStatus(int status)
Sets this group's status.

Parameters:
status - The group's new status.

setMessage

public void setMessage(String message)
Sets this group's message.

Parameters:
message - The group's new message.

addMessage

public void addMessage(String message)
Adds a message to this group.

Parameters:
message - The message to add.

getMessage

public String getMessage()
Returns this group's message.

Returns:
The group's first message

getMessages

public Enumeration getMessages()
Returns all of this group's messages.

Returns:
The group's messages.

getType

public int getType()
Returns this group's currently assigned type.

Returns:
The group's current type.

getTypeString

public String getTypeString()
Returns this group's currently assigned type as a string.

Returns:
The group's current type.

type2Int

public static int type2Int(String type)
Converts a string to an integer group type.

Parameters:
type - The group type as a string.
Returns:
The group type as an integer.

setType

public void setType(int type)
Sets this group's type.

Parameters:
type - The group's new type.

getHasChanged

public boolean getHasChanged()
Returns this group's change indicator.

Returns:
true if the group has been updated.

setHasChanged

public void setHasChanged(boolean hasChanged)
Sets this group's change indicator.

Parameters:
hasChanged - The group's new change indicator value.

getElements

public Enumeration getElements()
Returns all of the elements of this group.

Returns:
The group's elements. Each element will be of type com.infoengine.object.factory.Element.

getElementArray

public Element[] getElementArray()
Returns all of the elements of this group as an array.

Returns:
An array containing the group's elements.

getElementWithMetaValue

public Element getElementWithMetaValue(String meta,
                                       String value)
Returns the element of the group that has a meta value with a specified name and value. This method should be called only when it is known that at most one element will have the specified meta value. The method getAllElementsWithMetaValue should be called otherwise. If this method is called when more than one element has the specified meta value, the first such element will be returned.

Parameters:
meta - The name of the meta.
value - The value of the meta.
Returns:
The element containing the specified meta, or null if no element contains the specified meta.

getAllElementsWithMetaValue

public Enumeration getAllElementsWithMetaValue(String meta,
                                               String value)
Returns an enumeration of all elements of the group that have a meta value with a specified name and value.

Parameters:
meta - The name of the meta.
value - The value of the meta.
Returns:
The enumeration of all elements containing the specified meta

getElementAt

public Element getElementAt(int index)
Returns the element at a specific location.

Parameters:
index - The location of the element.
Returns:
The element, or null if the index exceeds the number of elements contained in the group.

setElementAt

public void setElementAt(Element element,
                         int index)
Sets the element at a specific location.

Parameters:
element - The element to set.
index - The location at which to set the element.

getElementByUfid

public Element getElementByUfid(String ufid)
Returns the element of the group that has a UFID (Unique Federation Identifier) with a specific value. If more than one element in the group has a UFID with the specified value, the first one is returned.

Parameters:
ufid - The UFID (Unique Federation Identifier)
Returns:
The element having the specified UFID, or null if no element has the specified UFID.

getElementByUfidWithAttributes

public Element getElementByUfidWithAttributes(String ufid,
                                              String[] names)
Returns the element of the group that has a UFID (Unique Federation Identifier) with a specific value and that also contains a specific set of attributes identified by name.

Parameters:
ufid - The UFID (Unique Federation Identifier)
names - The attribute names
Returns:
The element having the specified UFID and attributes, or null if no element has the specified UFID and attributes.

getElementByUfidWithAttributes

public Element getElementByUfidWithAttributes(String ufid,
                                              AttributeTypeIdentifier[] attrTypeIds)
Returns the element of the group that has a UFID (Unique Federation Identifier) with a specific value and that also contains a specific set of attributes identified by attribute type identifier.

Parameters:
ufid - The UFID (Unique Federation Identifier)
attrTypeIds - The attribute type identifiers
Returns:
The element having the specified UFID and attributes, or null if no element has the specified UFID and attributes.

getElementByUfidWithAttributes

public Element getElementByUfidWithAttributes(String ufid,
                                              AttributeIdentifier[] attrIds)
Returns the element of the group that has a UFID (Unique Federation Identifier) with a specific value and that also contains a specific set of attributes identified by attribute identifier.

Parameters:
ufid - The UFID (Unique Federation Identifier)
attrIds - The attribute identifiers
Returns:
The element having the specified UFID and attributes, or null if no element has the specified UFID and attributes.

removeElementByUfid

public void removeElementByUfid(String ufid)
Removes the element of the group that has a UFID (Unique Federation Identifier) with a specific value. If more than one element in the group has a UFID with the specified value, all are removed.

Parameters:
ufid - The UFID (Unique Federation Identifier)

addElementByUfid

public void addElementByUfid(Element element)
Adds an element to the elements contained in the group and removes any other elements from the group that have the same UFID (Unique Federation Identifier) as the element being added.

Parameters:
element - The element to add to the group.

getElementCount

public int getElementCount()
Returns the nummber of elements contained in the group.

Returns:
The number of elements in the group.

setElement

public void setElement(Element element)
Sets the group such that it contains the specified element only. Any previously set elements are removed from the group.

Parameters:
element - The element to set in the group.

addElement

public void addElement(Element element)
Adds an element to the elements contained in the group.

Parameters:
element - The element to add to the group.

addElement

public void addElement(TypeInstance typeInstance)
Adds a type instance to the elements contained in the group.

Parameters:
typeInstance - The type instance to add to the group.

removeElement

public void removeElement(Element element)
Removes a specific element from the group.

Parameters:
element - The element to be removed.

removeElement

public void removeElement(String name)
Removes an element from the group by name.

Parameters:
name - The name of the element to be removed.

removeElements

public void removeElements()
Removes all Elements from the group


getAttributeValue

public Object getAttributeValue(int index,
                                String name)
Returns the value of a named attribute within an element at a specific location.

Parameters:
index - The location of the element.
name - The name of the attribute
Returns:
The value of the attribute of the element, or null if the element does not contain the specified attribute. If the attribute is multi-valued, the first value is returned.

getAttributeValueByMeta

public Object getAttributeValueByMeta(int index,
                                      String name,
                                      Object value)
Locates an element by index, then returns the value of the attribute within that element having a specific metadata name/value pair.

Parameters:
index - The location of the element.
name - The name of the metadata to match.
value - The value of the metadata to match.
Returns:
The value of the attribute of the element that contains the specified metadata name/value pair, or null if the element does not contain the specified attribute. If the attribute is multi-valued, the first value is returned.

newStatusGroup

public static Group newStatusGroup(String name,
                                   String message,
                                   int status)
Creates a status group with a specified status and message.

Parameters:
name - The name to be assigned to the status group.
message - The message to place in the group.
status - The status assign to the group.
Returns:
The new status group.

newExceptionGroup

public static Group newExceptionGroup(String name,
                                      Throwable t)
Creates an exception group with name and throwable. Will not store the exception object in the group.

Parameters:
name - The name to be assigned to the exception group.
t - The exception.
Returns:
The new exception group.

newExceptionGroup

public static Group newExceptionGroup(String name,
                                      Throwable t,
                                      boolean storeException)
Creates an exception group with name and throwable. Will store the exception object in the group if storeException is true.

Parameters:
name - The name to be assigned to the exception group.
t - The exception.
storeException - specifies whether or not the exception object should be stored as meta-data on the group.
Returns:
The new exception group.

nextSeqNo

private static int nextSeqNo()

newStructure

protected static IeGroup newStructure()
Builds an empty group structure.

Returns:
The empty structure.

getGroup

public IeGroup getGroup()
Returns the group's internal IeGroup object.

Returns:
The internal IeGroup object.

setGroup

protected void setGroup(IeGroup group)
Sets the group's internal IeGroup object.

Parameters:
group - The new internal IeGroup object.

setAttributeValue

public void setAttributeValue(int index,
                              String attName,
                              Object attValue)
set an attribute value

Parameters:
index - - the element index to set the attribute in
attName - - the name of the attribute to set
attValue - - the attribute value

addAttributeValue

public void addAttributeValue(int index,
                              String attName,
                              Object attValue)
add an attribute value

Parameters:
index - - the element index to add the attribute in
attName - - the name of the attribute to set
attValue - - the attribute value

updateAttributeValue

private void updateAttributeValue(int index,
                                  String attName,
                                  Object attValue,
                                  boolean set)