|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Dictionary<K,V>
java.util.Hashtable
info.aduna.gee.publication.util.Result
public class Result
Class Result is a utility class for returning multiple values from a method, where no modelling is available or required (i.e. a sort of anonymous object). It has advantages over using one of the default Java containers (where excessive casting is required, esp. with basic types), or encoding the information into a String (which will have to be parsed). Example: public Result findChapterAndPage(Book b, String textToFind) { Result result = new Result(); Chapter chapter = getChapter(...); int page = getPage(...); result.put("chapter", chapter); result.put("page", page); return result; } ... Result chapterAndPage = findChapterAndPage(book, "mytext"); Chapter chapter = (Chapter)result.get("chapter"); int page = result.getInt("page");
| Constructor Summary | |
|---|---|
Result()
|
|
Result(int initialCapacity)
|
|
Result(int initialCapacity,
float loadFactor)
|
|
| Method Summary | |
|---|---|
boolean |
getBoolean(Object key)
return the boolean value corresponding to the specified key Note: returns Boolean.FALSE if the key was not found or the value is not a Boolean |
char |
getChar(Object key)
return the char value corresponding to the specified key Note: returns Char.MIN_VALUE if the key was not found or the value is not a Character |
double |
getDouble(Object key)
return the double value corresponding to the specified key Note: returns Double.MIN_VALUE if the key was not found or the value is not a Double |
float |
getFloat(Object key)
return the float value corresponding to the specified key Note: returns Float.MIN_VALUE if the key was not found or the value is not a Float |
int |
getInt(Object key)
return the int value corresponding to the specified key Note: returns Integer.MIN_VALUE if the key was not found or the value is not an Integer |
long |
getLong(Object key)
return the long value corresponding to the specified key Note: returns Long.MIN_VALUE if the key was not found or the value is not a Long |
String |
getString(Object key)
return the String value corresponding to the specified key Note: returns null if the key was not found or the value is not a String |
void |
put(Object key,
boolean booleanValue)
Wrap a boolean in a Boolean and put it in the Result. |
void |
put(Object key,
char charValue)
Wrap a char in a Character and put it in the Result. |
void |
put(Object key,
double doubleValue)
Wrap a double in a Double and put it in the Result. |
void |
put(Object key,
float floatValue)
Wrap a float in a Float and put it in the Result. |
void |
put(Object key,
int intValue)
Wrap a int in an Integer and put it in the Result. |
void |
put(Object key,
long longValue)
Wrap a long in a Long and put it in the Result. |
| Methods inherited from class java.util.Hashtable |
|---|
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Result()
public Result(int initialCapacity)
public Result(int initialCapacity,
float loadFactor)
| Method Detail |
|---|
public boolean getBoolean(Object key)
public char getChar(Object key)
public double getDouble(Object key)
public float getFloat(Object key)
public int getInt(Object key)
public long getLong(Object key)
public String getString(Object key)
public void put(Object key,
boolean booleanValue)
Map.put(Object key, Object value)
public void put(Object key,
char charValue)
Map.put(Object key, Object value)
public void put(Object key,
double doubleValue)
Map.put(Object key, Object value)
public void put(Object key,
float floatValue)
Map.put(Object key, Object value)
public void put(Object key,
int intValue)
Map.put(Object key, Object value)
public void put(Object key,
long longValue)
Map.put(Object key, Object value)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||