Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hyperic.util
Class StrongCollection

    java.lang.Object
      org.hyperic.util.StrongCollection

All Implemented Interfaces:
  java.lang.Iterable, java.util.Collection

Direct Known Subclasses:
  StringCollection, StrongList

    public class StrongCollection

extends java.lang.Object
implements java.util.Collection

StrongCollection is a collection class that will only accept objects into the collection of a type specified when constructing the collection. StrongCollection's are subclassed to to create a type specific collection (e.g., FooCollection extends StrongCollection). In this example, FooCollection would only accept objects of type Foo. StrongCollection enforces the Collection checks at runtime. Subclassing the StrongCollection class and providing stub implementions of methods like add(Foo element) adds compile time checks. StrongCollection implements all of the methods of the java.util.Collection interface.

Nested Class Summary
`protected class` | `StrongCollection.Itr`

Field Summary
`protected static java.lang.String` | `CLASS_NOT_FOUND_MSG`
`protected java.util.ArrayList` | `m_aList`

Constructor Summary
`protected` | `StrongCollection()` Constructs a StrongCollection class.
`` | `StrongCollection(java.lang.Class object)` Constructs a StrongCollection class.
`protected` | `StrongCollection(java.lang.Class collection, java.lang.Class object)` Constructs a StrongCollection class.
`` | `StrongCollection(java.lang.String object)` Constructs a StrongCollection class.
`protected` | `StrongCollection(java.lang.String coll, java.lang.String obj)` Constructs a StrongCollection class.

Method Summary
`boolean` | `add(java.lang.Object obj)` Adds an element to the collection.
`boolean` | `addAll(java.util.Collection c)` Adds the elements of the specified collection to this collection.
`protected void` | `checkCollection(java.util.Collection collection)` Checks whether a Collection object is of the type specified when constructing the StrongBase class and throws a ClassCastException if it is not.
`protected void` | `checkObject(java.lang.Object obj)` Checks whether a object is of the type that the collection accepts and throws a ClassCastException if it is not.
`void` | `clear()` Removes all of the elements from the collection.
`boolean` | `contains(java.lang.Object obj)` Determines whether the collection contains the specified element.
`boolean` | `containsAll(java.util.Collection c)` Determines whether the collection contains all of the elements in the specified collection.
`protected java.lang.Class` | `getCollectionClass()` Returns the collection Class.
`protected java.lang.Class` | `getObjectClass()` Returns the object Class of the objects accepted by a Collection.
`protected void` | `init(java.lang.Class coll, java.lang.Class obj)` Initializes a StrongBase class.
`protected void` | `init(java.lang.String coll, java.lang.String obj)` Initializes a StrongBase class.
`boolean` | `isEmpty()` Determines whether the collection contains any elements.
`protected boolean` | `isValidCollection(java.util.Collection collection)` Returns whether a Collection object is of the type specified when constructing the StrongBase class.
`protected boolean` | `isValidObject(java.lang.Object obj)` Returns whether an object is of the type that the collection accepts.
`java.util.Iterator` | `iterator()` Returns an Iterator of the elements in the collection.
`boolean` | `remove(java.lang.Object obj)` Removes the specified element from the collection.
`boolean` | `removeAll(java.util.Collection c)` Removes all of the elements in the specified collection from this collection.
`boolean` | `retainAll(java.util.Collection c)` Removes all of the elements in the collection except those in the specified collection.
`void` | `reverse()` reverses the element order
`int` | `size()` The number of elements in the collection.
`java.lang.Object[]` | `toArray()` Returns an array containing all of the elements in the collection.
`java.lang.Object[]` | `toArray(java.lang.Object[] a)` Returns an array containing all of the elements in the collection whose runtime type is that of the specified array.
`java.lang.String` | `toString()` Returns a string of all of the elements in the collection.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Collection
`equals, hashCode`

Field Detail

### CLASS_NOT_FOUND_MSG

    protected static final java.lang.String CLASS_NOT_FOUND_MSG

See Also:
  Constant Field Values

### m_aList

    protected final java.util.ArrayList m_aList

Constructor Detail

### StrongCollection

    protected StrongCollection()

  Constructs a StrongCollection class. This constructor is provided so that subclasses can use the init() method, which makes it easier to catch exceptions in their constructors. If this constructor is called the next method call must be to init().

### StrongCollection

    protected StrongCollection(java.lang.Class collection,
                               java.lang.Class object)

  Constructs a StrongCollection class. This constructor is used by subclasses that are strongly typed at compile time and runtime. Because this constructor is protected a subclass should provide the public constructor and subclass the methods in this class that accept types.

  Parameters:
    `collection` - The java.lang.Class type of the subclassed collection.
    `object` - The java.lang.Class type of the object this collection will accept.

### StrongCollection

    protected StrongCollection(java.lang.String coll,
                               java.lang.String obj)
                        throws java.lang.ClassNotFoundException

  Constructs a StrongCollection class. This constructor is used by subclasses that are strongly typed at compile time and runtime. Because this constructor is protected a subclass should provide the public constructor and subclass the methods in this class that accept types.

  Parameters:
    `collection` - The java.lang.String type that specifies the fully qualified class name of the subclassed collection.
    `object` - The java.lang.String type that specifies the fully qualified class name of the class this collection will accept.
  Throws:
    `java.lang.ClassNotFoundException`

### StrongCollection

    public StrongCollection(java.lang.Class object)

  Constructs a StrongCollection class. This constructor allows you to use a strongly typed collection that is only type checked at runtime.

  Parameters:
    `object` - The java.lang.Class type of the object this collection will accept.

### StrongCollection

    public StrongCollection(java.lang.String object)

  Constructs a StrongCollection class. This constructor allows you to use a strongly typed collection that is only type checked at runtime.

  Parameters:
    `object` - The java.lang.Class type of the object this collection will accept.

Method Detail

### add

    public boolean add(java.lang.Object obj)

  Adds an element to the collection.

  Specified by:
    `add` in interface `java.util.Collection`
  Parameters:
    `obj` - The object to add to the collection.
  Returns:
    true of object was successfully added to the collection.
  Throws:
    `java.lang.ClassCastException` - If the element is not of the type accepted by the collection.

### addAll

    public boolean addAll(java.util.Collection c)

  Adds the elements of the specified collection to this collection.

  Specified by:
    `addAll` in interface `java.util.Collection`
  Parameters:
    `c` - The collection to add to this collection.
  Returns:
    true if the objects was successfully added to the collection.
  Throws:
    `java.lang.ClassCastException` - If the specified collection is not the same type as the collection it's being added to.

### clear

    public void clear()

  Removes all of the elements from the collection.

  Specified by:
    `clear` in interface `java.util.Collection`

### contains

    public boolean contains(java.lang.Object obj)

  Determines whether the collection contains the specified element.

  Specified by:
    `contains` in interface `java.util.Collection`
  Parameters:
    `obj` - The object to test for in the collection.
  Returns:
    true if the collection contains the specified element.
  Throws:
    `java.lang.ClassCastException` - If the element is not of the type accepted by the collection

### containsAll

    public boolean containsAll(java.util.Collection c)

  Determines whether the collection contains all of the elements in the specified collection.

  Specified by:
    `containsAll` in interface `java.util.Collection`
  Parameters:
    `obj` - The collection containing the element to check for.
  Returns:
    true if the collection contains the specified objects.
  Throws:
    `java.lang.ClassCastException` - If the specified collection is not the same type as the collection it's being added to.

### isEmpty

    public boolean isEmpty()

  Determines whether the collection contains any elements.

  Specified by:
    `isEmpty` in interface `java.util.Collection`
  Returns:
    true if the collection contains no elements.

### iterator

    public java.util.Iterator iterator()

  Returns an Iterator of the elements in the collection.

  Specified by:
    `iterator` in interface `java.lang.Iterable`
  Specified by:
    `iterator` in interface `java.util.Collection`
  Returns:
    A java.util.Iterator object.

### remove

    public boolean remove(java.lang.Object obj)

  Removes the specified element from the collection.

  Specified by:
    `remove` in interface `java.util.Collection`
  Parameters:
    `obj` - The object to remove from the collection.
  Returns:
    true if object was successfully removed from the collection.
  Throws:
    `java.lang.ClassCastException` - If the element is not of the type accepted by the collection

### removeAll

    public boolean removeAll(java.util.Collection c)

  Removes all of the elements in the specified collection from this collection.

  Specified by:
    `removeAll` in interface `java.util.Collection`
  Parameters:
    `c` - The collection of objects to remove.
  Returns:
    true if the elements were successfully removed from the collection.
  Throws:
    `java.lang.ClassCastException` - If the specified collection is not the same type as the collection it's being added to.

### retainAll

    public boolean retainAll(java.util.Collection c)

  Removes all of the elements in the collection except those in the specified collection.

  Specified by:
    `retainAll` in interface `java.util.Collection`
  Parameters:
    `c` - The collection of objects to retain.
  Returns:
    true if the elements were succesfully retained.
  Throws:
    `java.lang.ClassCastException` - If the specified collection is not the same type as the collection it's being added to.

### size

    public int size()

  The number of elements in the collection.

  Specified by:
    `size` in interface `java.util.Collection`
  Returns:
    The number of elements in the collection.

### toArray

    public java.lang.Object[] toArray()

  Returns an array containing all of the elements in the collection.

  Specified by:
    `toArray` in interface `java.util.Collection`
  Returns:
    An array that contains all of the elements in the collection.

### toArray

    public java.lang.Object[] toArray(java.lang.Object[] a)

  Returns an array containing all of the elements in the collection whose runtime type is that of the specified array. The specied array must be of the type specified when the StrongCollection class was instantiated.

  Specified by:
    `toArray` in interface `java.util.Collection`
  Returns:
    An array that contains all of the elements in the collection.
  Throws:
    `java.lang.ClassCastException` - If the array is is not of the type accepted by the collection

### toString

    public java.lang.String toString()

  Returns a string of all of the elements in the collection.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    A string with all of the elements in the collection.

### reverse

    public void reverse()

  reverses the element order

### init

    protected void init(java.lang.Class coll,
                        java.lang.Class obj)

  Initializes a StrongBase class.

  Parameters:
    `c` - The java.lang.Class object of the collection class that will use the StrongBase. The collection class must implement the java.util.Collection interface or a sublcass of this interface.
    `obj` - The java.lang.Class object of the class that the collection will contain. The obj Class can be any type that can be implemented in the Java language.
  See Also:
    `Collection`

### init

    protected void init(java.lang.String coll,
                        java.lang.String obj)
                 throws java.lang.ClassNotFoundException

  Initializes a StrongBase class.

  Parameters:
    `c` - The java.lang.Class object of the collection class that will use the StrongBase. The collection class must implement the java.util.Collection interface or a sublcass of this interface.
    `obj` - The java.lang.Class object of the class that the collection will contain. The obj Class can be any type that can be implemented in the Java language.
  Throws:
    `java.lang.ClassNotFoundException`
  See Also:
    `Collection`

### checkCollection

    protected void checkCollection(java.util.Collection collection)

  Checks whether a Collection object is of the type specified when constructing the StrongBase class and throws a ClassCastException if it is not.

  Parameters:
    `collection` - The java.lang.Class object of the collection class that will use the StrongBase. This methods throws a ClassCastException if the paramater is not valid.
  See Also:
    `ClassCastException`, `Collection`

### checkObject

    protected void checkObject(java.lang.Object obj)

  Checks whether a object is of the type that the collection accepts and throws a ClassCastException if it is not.

  Parameters:
    `obj` - The java.lang.Class object of the collection class that will use the StrongBase. This methods throws a ClassCastException if the paramater is not valid.
  See Also:
    `ClassCastException`

### getCollectionClass

    protected java.lang.Class getCollectionClass()

  Returns the collection Class.

  Returns:
    The java.lang.Class object of the Collection class.
  See Also:
    `Class`

### getObjectClass

    protected java.lang.Class getObjectClass()

  Returns the object Class of the objects accepted by a Collection.

  Returns:
    The java.lang.Class object of the objects allowed in the collection.
  See Also:
    `Class`

### isValidCollection

    protected boolean isValidCollection(java.util.Collection collection)

  Returns whether a Collection object is of the type specified when constructing the StrongBase class.

  Parameters:
    `collection` - The java.lang.Class object of the collection class that will use the StrongBase. This methods throws a ClassCastException if the paramater is not valid.
  Returns:
    true if the collection class is valid. false otherwise.
  See Also:
    `Collection`

### isValidObject

    protected boolean isValidObject(java.lang.Object obj)

  Returns whether an object is of the type that the collection accepts.

  Parameters:
    `obj` - The java.lang.Class object of the collection class that will use the StrongBase.
  Returns:
    true if the object is allowed in the collection. false otherwise.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.