|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--structure.StructCollection
This utility class converts a Structure to a Collection.
Users are advised to make use of the values method
that is part of every Structure that returns a Collection.
This class is necessary because there are certain basic differences in the interfaces of the two classes.
This class works provides a facade: methods of the Collection interface are directly referred to the base Structure, or simple code supports the interface.
Example Usage:
public static void main(String[] argv){
Structure struct = new Vector();
for(int i = 0; i < argv.length; i++) struct.add(argv[i]);
Collection collect = new StructCollection(struct);
}
| Field Summary | |
protected Structure |
base
The subordinate Structure |
| Constructor Summary | |
StructCollection(Structure s)
Constructs a Collection, based on the contents of the subordinate Structure object. |
|
| Method Summary | |
boolean |
add(java.lang.Object o)
Add an object to the subordinate Structure, and return boolean indicating success. |
boolean |
addAll(java.util.Collection c)
Adds all the elements of another collection (c) into this Structure. |
void |
clear()
Remove all elements from the Structure. |
boolean |
contains(java.lang.Object o)
Returns true iff object o is contained within the subordinate structure. |
boolean |
containsAll(java.util.Collection c)
Returns true if all of the elements of c are contained within the subordinate structure. |
boolean |
equals(java.lang.Object o)
Compare one StructCollection with another. |
int |
hashCode()
Return hash code. |
boolean |
isEmpty()
Detect an empty structure. |
java.util.Iterator |
iterator()
Return an iterator to traverse the subordinate structure. |
boolean |
remove(java.lang.Object o)
Removes an instance of object o, if it appears within structure. |
boolean |
removeAll(java.util.Collection c)
Removes all objects found within collection c from this collection. |
boolean |
retainAll(java.util.Collection c)
Retains elements of this Collection that are also in c. |
int |
size()
Determine the number of elements in this collection. |
java.lang.Object[] |
toArray()
Construct an array of values found in the subordinate Structure. |
java.lang.Object[] |
toArray(java.lang.Object[] target)
Copy elements of this structure into target array. |
java.lang.String |
toString()
Construct a string representation of this class. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected Structure base
| Constructor Detail |
public StructCollection(Structure s)
| Method Detail |
public boolean add(java.lang.Object o)
add in interface java.util.Collectionpublic boolean addAll(java.util.Collection c)
addAll in interface java.util.Collectionpublic void clear()
clear in interface java.util.Collectionpublic boolean contains(java.lang.Object o)
contains in interface java.util.Collectionpublic boolean containsAll(java.util.Collection c)
containsAll in interface java.util.Collectionpublic boolean equals(java.lang.Object o)
equals in interface java.util.Collectionequals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.util.CollectionhashCode in class java.lang.Objectpublic boolean isEmpty()
isEmpty in interface java.util.Collectionpublic java.util.Iterator iterator()
iterator in interface java.util.Collectionpublic boolean remove(java.lang.Object o)
remove in interface java.util.Collectionpublic boolean removeAll(java.util.Collection c)
removeAll in interface java.util.Collectionpublic boolean retainAll(java.util.Collection c)
retainAll in interface java.util.Collectionpublic int size()
size in interface java.util.Collectionpublic java.lang.Object[] toArray()
toArray in interface java.util.Collectionpublic java.lang.Object[] toArray(java.lang.Object[] target)
toArray in interface java.util.Collectionpublic java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||