|
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 |
java.lang.Objectorg.hyperic.util.StrongCollection
public class StrongCollection
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 |
---|
protected static final java.lang.String CLASS_NOT_FOUND_MSG
protected final java.util.ArrayList m_aList
Constructor Detail |
---|
protected StrongCollection()
protected StrongCollection(java.lang.Class collection, java.lang.Class object)
collection
- The java.lang.Class type of the subclassed collection.object
- The java.lang.Class type of the object this collection will accept.protected StrongCollection(java.lang.String coll, java.lang.String obj) throws java.lang.ClassNotFoundException
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.
java.lang.ClassNotFoundException
public StrongCollection(java.lang.Class object)
object
- The java.lang.Class type of the object this collection will accept.public StrongCollection(java.lang.String object)
object
- The java.lang.Class type of the object this collection will accept.Method Detail |
---|
public boolean add(java.lang.Object obj)
add
in interface java.util.Collection
obj
- The object to add to the collection.
java.lang.ClassCastException
- If the element is not of the type accepted by the collection.public boolean addAll(java.util.Collection c)
addAll
in interface java.util.Collection
c
- The collection to add to this collection.
java.lang.ClassCastException
- If the specified collection is not the same type as the collection
it's being added to.public void clear()
clear
in interface java.util.Collection
public boolean contains(java.lang.Object obj)
contains
in interface java.util.Collection
obj
- The object to test for in the collection.
java.lang.ClassCastException
- If the element is not of the type accepted by the collectionpublic boolean containsAll(java.util.Collection c)
containsAll
in interface java.util.Collection
obj
- The collection containing the element to check for.
java.lang.ClassCastException
- If the specified collection is not the same type as the collection
it's being added to.public boolean isEmpty()
isEmpty
in interface java.util.Collection
public java.util.Iterator iterator()
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
public boolean remove(java.lang.Object obj)
remove
in interface java.util.Collection
obj
- The object to remove from the collection.
java.lang.ClassCastException
- If the element is not of the type accepted by the collectionpublic boolean removeAll(java.util.Collection c)
removeAll
in interface java.util.Collection
c
- The collection of objects to remove.
java.lang.ClassCastException
- If the specified collection is not the same type as the collection
it's being added to.public boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Collection
c
- The collection of objects to retain.
java.lang.ClassCastException
- If the specified collection is not the same type as the collection
it's being added to.public int size()
size
in interface java.util.Collection
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection
public java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface java.util.Collection
java.lang.ClassCastException
- If the array is is not of the type accepted by the collectionpublic java.lang.String toString()
toString
in class java.lang.Object
public void reverse()
protected void init(java.lang.Class coll, java.lang.Class obj)
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.Collection
protected void init(java.lang.String coll, java.lang.String obj) throws java.lang.ClassNotFoundException
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.
java.lang.ClassNotFoundException
Collection
protected void checkCollection(java.util.Collection collection)
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.ClassCastException
,
Collection
protected void checkObject(java.lang.Object obj)
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.ClassCastException
protected java.lang.Class getCollectionClass()
Class
protected java.lang.Class getObjectClass()
Class
protected boolean isValidCollection(java.util.Collection collection)
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.
Collection
protected boolean isValidObject(java.lang.Object obj)
obj
- The java.lang.Class object of the collection class that will use
the StrongBase.
|
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 |