1 package org.opensrf.util;
4 import java.util.HashMap;
8 * Generic OpenSRF network-serializable object. This allows
9 * access to object fields.
11 public class OSRFObject extends HashMap<String, Object> implements OSRFSerializable {
13 /** This objects registry */
14 private OSRFRegistry registry;
21 * Creates a new object with the provided registry
23 public OSRFObject(OSRFRegistry reg) {
30 * Creates a new OpenSRF object based on the net class string
32 public OSRFObject(String netClass) {
33 this(OSRFRegistry.getRegistry(netClass));
38 * @return This object's registry
40 public OSRFRegistry getRegistry() {
45 * Implement get() to fulfill our contract with OSRFSerializable
47 public Object get(String field) {
48 return super.get(field);
51 /** Returns the string value found at the given field */
52 public String getString(String field) {
53 return (String) get(field);
56 /** Returns the int value found at the given field */
57 public int getInt(String field) {
58 Object o = get(field);
59 if(o instanceof String)
60 return Integer.parseInt((String) o);
61 return ((Integer) get(field)).intValue();