1 30 31 32 package org.hsqldb.types; 33 34 import java.io.Serializable ; 35 36 import org.hsqldb.HsqlException; 37 import org.hsqldb.Trace; 38 import org.hsqldb.lib.InOutUtil; 39 40 66 public class JavaObject { 67 68 private byte[] data; 69 70 74 public JavaObject(byte[] data) { 75 this.data = data; 76 } 77 78 84 public JavaObject(Serializable o) throws HsqlException { 85 86 try { 87 data = InOutUtil.serialize(o); 88 } catch (Exception e) { 89 throw Trace.error(Trace.SERIALIZATION_FAILURE, e.getMessage()); 90 } 91 } 92 93 public byte[] getBytes() { 94 return data; 95 } 96 97 public int getBytesLength() { 98 return data.length; 99 } 100 101 107 public Serializable getObject() throws HsqlException { 108 109 try { 110 return InOutUtil.deserialize(data); 111 } catch (Exception e) { 112 throw Trace.error(Trace.SERIALIZATION_FAILURE, e.getMessage()); 113 } 114 } 115 116 121 public String toString() { 122 return super.toString(); 123 } 124 } 125 | Popular Tags |