|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.avian.tuple.BasicTupleTree
public class BasicTupleTree
A basic implementation of a tuplespace using ArrayListMultimap from Google Collections. The TupleTree implements the put method and a variety of get methods, such as readFirstMatching and readAllMatching.
Constructor Summary | |
---|---|
BasicTupleTree()
Default constructor for the BasicTupleTree. |
Method Summary | |
---|---|
java.lang.String |
getFileName()
Returns the filename to use when saving the contents of the BasicTupleTree. |
void |
put(java.lang.String key,
java.lang.Object value)
Puts an Object into the ArrayListMultimap (BasicTupleTree). |
void |
put(java.lang.String key,
java.lang.String value)
Puts a String value into the ArrayListMultimap (BasicTupleTree). |
void |
putSingleton(java.lang.String key,
java.lang.Object value)
Puts an Object into the ArrayListMultiMap and verifies that there is no other Object in the tree with that same key. |
java.util.List<java.lang.Object> |
readAllMatching(java.lang.String key)
Performs a (modified) get from the ArrayListMultimap and receives a list of Objects but doesn't remove them. |
java.util.List<java.lang.Object> |
readAndRemoveAllMatching(java.lang.String key)
Performs a get from the ArrayListMultimap and receives a java.util.List |
java.lang.Object |
readAndRemoveOne(java.lang.String key)
Performs a get from the ArrayListMultimap using the parameter key String, removes the object, and returns the removed object or null if no matching object found. |
java.lang.Object |
readFirstMatching(java.lang.String key)
Performs a (modified) get from the ArrayListMultimap and receives an Object that is associated with the key parameter but doesn't remove it. |
java.lang.Object |
readSingleton(java.lang.String key)
Reads an object from the ArrayListMultimap and verifies that it is the only value in the TupleTree with that key. |
void |
save(java.lang.String outputFileName)
Writes the contents of the BasicTupleTree to the file that is specified in the output file name that is passed as a parameter. |
void |
setFileName(java.lang.String fileName)
Saves the file name parameter that is passed into this method as the name of the file to use when saving the contents of the BasicTupleTree. |
java.lang.String |
show()
Provides a formatted output that represents the contents of the BasicTupleTree. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BasicTupleTree()
Method Detail |
---|
public void put(java.lang.String key, java.lang.String value)
key
- String identifier that is used to store and retrieve the value in
the BasicTupleTree. The key is normally the name of the food that a bird will
eat or store.value
- String that is associated with the key.public void put(java.lang.String key, java.lang.Object value)
key
- String identifier that is used to store and retrieve the value in
the BasicTupleTree. The key is normally the name of the food that a bird will
eat or store.value
- Java Object that holds the contents of the "work packet" that the
various birds will work upon.public void putSingleton(java.lang.String key, java.lang.Object value)
key
- String identifier that is used to store and retrieve the value in
the BasicTupleTree. The key is normally the name of the food that a bird will
eat or store.value
- Object that holds the contents of the "work packet" that the
requesting bird will work upon.public java.util.List<java.lang.Object> readAllMatching(java.lang.String key)
key
- String identifier that is used as the key to retrieve a list of all values in
the BasicTupleTree which have this key.
public java.lang.Object readFirstMatching(java.lang.String key)
Internally, a get is performed that returns a list of all values (Objects) that are associated with the parameter (key). Since the ArrayListMultimap doesn't specify or expect to provide any order or sequence in the Objects in the list, all Objects are assumed to be equivalent, so the first item in the list is returned.
key
- String identifier that is used as the key to retrieve a value from
the BasicTupleTree.
public java.lang.Object readAndRemoveOne(java.lang.String key)
Internally, a get is performed that returns a list of all values (Objects) that are associated with the parameter (key). Since the ArrayListMultimap doesn't specify or expect to provide any order or sequence in the Objects in the list, all Objects are assumed to be equivalent, so the first item in the list is returned.
key
- String identifier that is used as the key to retrieve a value from
the BasicTupleTree.
public java.lang.Object readSingleton(java.lang.String key)
key
- String identifier that is used as the key to retrieve a list of all values in
the BasicTupleTree which have this key.
public java.util.List<java.lang.Object> readAndRemoveAllMatching(java.lang.String key)
public java.lang.String getFileName()
public void setFileName(java.lang.String fileName)
fileName
- String to use when saving the contents of the BasicTupleTree.public java.lang.String show()
public void save(java.lang.String outputFileName)
outputFileName
- String that specifies the file that should have the
contents of the BasicTupleTree written to it.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |