org.xins.common.service
Class GroupDescriptor

java.lang.Object
  extended byorg.xins.common.service.Descriptor
      extended byorg.xins.common.service.GroupDescriptor
All Implemented Interfaces:
Serializable

public final class GroupDescriptor
extends Descriptor

Descriptor for a group of services. Each GroupDescriptor has at least 2 members.

Since:
XINS 1.0.0
Version:
$Revision: 1.25 $ $Date: 2006/10/25 11:20:57 $
Author:
Ernst de Haan
See Also:
Serialized Form

Nested Class Summary
static class GroupDescriptor.Type
          Type of a group.
 
Field Summary
static GroupDescriptor.Type ORDERED_TYPE
          The ordered group type.
static String ORDERED_TYPE_ID
          The identifier of the ordered group type.
static GroupDescriptor.Type RANDOM_TYPE
          The random group type.
static String RANDOM_TYPE_ID
          The identifier of the random group type.
 
Constructor Summary
GroupDescriptor(GroupDescriptor.Type type, Descriptor[] members)
          Constructs a new GroupDescriptor.
 
Method Summary
 Descriptor[] getMembers()
          Returns the members of this group.
 TargetDescriptor getTargetByCRC(int crc)
          Returns the TargetDescriptor that matches the specified CRC-32 checksum.
 int getTargetCount()
          Counts the total number of target descriptors in/under this descriptor.
 GroupDescriptor.Type getType()
          Returns the type of this group.
static GroupDescriptor.Type getType(String identifier)
          Gets a group type by identifier.
 boolean isGroup()
          Checks if this descriptor denotes a group of descriptors.
 Iterator iterateTargets()
          Iterates over all leaves, the target descriptors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RANDOM_TYPE_ID

public static final String RANDOM_TYPE_ID
The identifier of the random group type.

See Also:
Constant Field Values

ORDERED_TYPE_ID

public static final String ORDERED_TYPE_ID
The identifier of the ordered group type.

See Also:
Constant Field Values

RANDOM_TYPE

public static final GroupDescriptor.Type RANDOM_TYPE
The random group type.


ORDERED_TYPE

public static final GroupDescriptor.Type ORDERED_TYPE
The ordered group type.

Constructor Detail

GroupDescriptor

public GroupDescriptor(GroupDescriptor.Type type,
                       Descriptor[] members)
                throws IllegalArgumentException
Constructs a new GroupDescriptor. The members to be included must be passed. The array of members cannot contain any null elements. It may contain duplicates, though.

Since XINS 1.1.0, the array of members cannot be empty, but needs to contain at least 2 descriptors.

Parameters:
type - the type of group, cannot be null.
members - list of members of the group, cannot be null.
Throws:
IllegalArgumentException - if type == null || members == null || members.length < 2 || members[n] == null (where 0 <= n < members.length).
Method Detail

getType

public static GroupDescriptor.Type getType(String identifier)
                                    throws IllegalArgumentException
Gets a group type by identifier.

Parameters:
identifier - the identifier for the group, cannot be null.
Returns:
the type with the specified identifier, or null if there is no matching type.
Throws:
IllegalArgumentException - if identifier == null.

isGroup

public boolean isGroup()
Checks if this descriptor denotes a group of descriptors.

Specified by:
isGroup in class Descriptor
Returns:
true, since this descriptor denotes a group.

iterateTargets

public Iterator iterateTargets()
Iterates over all leaves, the target descriptors.

The returned Iterator will not support Iterator.remove(). The iterator will only return TargetDescriptor instances, no instances of other classes and no null values.

Also, this iterator is guaranteed to return getTargetCount() instances of class TargetDescriptor.

Specified by:
iterateTargets in class Descriptor
Returns:
iterator over the leaves, the target descriptors, in this descriptor, in the correct order, never null.

getTargetCount

public int getTargetCount()
Counts the total number of target descriptors in/under this descriptor.

Specified by:
getTargetCount in class Descriptor
Returns:
the total number of target descriptors, always >= 2.

getType

public GroupDescriptor.Type getType()
Returns the type of this group.

Returns:
the type of this group, not null.

getMembers

public Descriptor[] getMembers()
Returns the members of this group.

Returns:
the members of this group as a new array, not null.

getTargetByCRC

public TargetDescriptor getTargetByCRC(int crc)
Returns the TargetDescriptor that matches the specified CRC-32 checksum.

Specified by:
getTargetByCRC in class Descriptor
Parameters:
crc - the CRC-32 checksum.
Returns:
the TargetDescriptor that matches the specified checksum, or null, if none could be found in this descriptor.


See http://www.xins.org/.