1 package org.myoodb; 25 26 public class MyOodbProxy implements MyOodbRemote, java.io.Externalizable 27 { 28 protected transient int m_timeout = -1; 29 protected transient org.myoodb.core.AbstractDatabase m_database = null; 30 31 private org.myoodb.core.Identifier m_objectId = null; 32 33 public MyOodbProxy() 34 { 35 org.myoodb.core.MyOodbManager manager = org.myoodb.core.MyOodbManager.getTheManager(); 36 if (manager != null) 37 { 38 m_database = manager.getDatabase(); 39 } 40 } 41 42 public MyOodbProxy(org.myoodb.core.Identifier id, org.myoodb.core.AbstractDatabase db) 43 { 44 m_objectId = id; 45 m_database = db; 46 } 47 48 public final MyOodbProxy getSelf() 49 { 50 return this; 51 } 52 53 public final org.myoodb.core.AbstractDatabase getDatabase() 54 { 55 return m_database; 56 } 57 58 public final org.myoodb.core.Identifier getDatabaseHandle() 59 { 60 return m_objectId; 61 } 62 63 public final void setTimeout(int timeout) 64 { 65 m_timeout = timeout; 66 } 67 68 public final int getTimeout() 69 { 70 return m_timeout; 71 } 72 73 public final void setBean(MyOodbBean bean) 74 { 75 m_database.setBean(getDatabaseHandle(), bean); 76 } 77 78 public final MyOodbBean getBean() 79 { 80 return m_database.getBean(getDatabaseHandle()); 81 } 82 83 public final void setXML(String xml) 84 { 85 m_database.setXML(getDatabaseHandle(), xml); 86 } 87 88 public final String getXML() 89 { 90 return m_database.getXML(getDatabaseHandle()); 91 } 92 93 public int hashCode() 94 { 95 return getDatabaseHandle().hashCode(); 96 } 97 98 public boolean equals(Object obj) 99 { 100 if (this == obj) 101 { 102 return true; 103 } 104 else if (obj instanceof MyOodbProxy) 105 { 106 return getDatabaseHandle().equals(((MyOodbProxy) obj).getDatabaseHandle()); 107 } 108 else if (obj instanceof org.myoodb.core.Identifier) 109 { 110 return getDatabaseHandle().equals(obj); 111 } 112 else 113 { 114 return false; 115 } 116 } 117 118 public int compareTo(Object obj) 119 { 120 if (obj instanceof MyOodbProxy) 121 { 122 return getDatabaseHandle().compareTo(((MyOodbProxy) obj).getDatabaseHandle()); 123 } 124 else if (obj instanceof org.myoodb.core.Identifier) 125 { 126 return getDatabaseHandle().compareTo(obj); 127 } 128 else 129 { 130 return -1; 131 } 132 } 133 134 public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException 135 { 136 out.writeObject(m_objectId); 137 } 138 139 public void readExternal(java.io.ObjectInput in) throws java.io.IOException , ClassNotFoundException 140 { 141 m_objectId = (org.myoodb.core.Identifier) in.readObject(); 142 143 if (in instanceof org.myoodb.util.FastObjectInputStream) 144 { 145 Object db = ((org.myoodb.util.FastObjectInputStream) in).getUserContext(); 146 147 if (db != null) 148 { 149 m_database = (org.myoodb.core.AbstractDatabase) db; 150 } 151 } 152 } 153 154 public String toString() 155 { 156 return "Proxy Handle: " + getDatabaseHandle(); 157 } 158 } 159 | Popular Tags |