]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/java/org/opensrf/util/OSRFObject.java
added a lot of documentation
[OpenSRF.git] / src / java / org / opensrf / util / OSRFObject.java
1 package org.opensrf.util;
2
3 import java.util.Map;
4 import java.util.HashMap;
5
6
7 /**
8  * Generic OpenSRF network-serializable object.  This allows
9  * access to object fields.  
10  */
11 public class OSRFObject extends HashMap<String, Object> implements OSRFSerializable {
12     
13     /** This objects registry */
14     private OSRFRegistry registry;
15
16     public OSRFObject() {
17     }
18
19     /**
20      * Creates a new object with the provided registry
21      */
22     public OSRFObject(OSRFRegistry reg) {
23         this();
24         registry = reg;
25     }
26
27     /**
28      * @return This object's registry
29      */
30     public OSRFRegistry getRegistry() {
31         return registry;
32     }
33
34     /**
35      * Implement get() to fulfill our contract with OSRFSerializable
36      */
37     public Object get(String field) {
38         return super.get(field);
39     }
40
41     /** Returns the string value found at the given field */
42     public String getString(String field) {
43         return (String) get(field);
44     }
45
46     /** Returns the int value found at the given field */
47     public int getInt(String field) {
48         Object o = get(field);
49         if(o instanceof String)
50             return Integer.parseInt((String) o);
51         return ((Integer) get(field)).intValue();
52     }
53 }