1 21 package com.db4o; 22 23 import com.db4o.foundation.*; 24 import com.db4o.reflect.*; 25 26 27 final class YByte extends YapJavaClass 28 { 29 30 static final int LENGTH = 1 + YapConst.ADDED_LENGTH; 31 32 private static final Byte i_primitive = new Byte ((byte)0); 33 34 public YByte(YapStream stream) { 35 super(stream); 36 } 37 38 public Object coerce(ReflectClass claxx, Object obj) { 39 return Coercion4.toSByte(obj); 40 } 41 42 public int getID(){ 43 return 6; 44 } 45 46 public Object defaultValue(){ 47 return i_primitive; 48 } 49 50 public int linkLength(){ 51 return LENGTH; 52 } 53 54 protected Class primitiveJavaClass(){ 55 return byte.class; 56 } 57 58 Object primitiveNull(){ 59 return i_primitive; 60 } 61 62 Object read1(YapReader a_bytes){ 63 if (Deploy.debug){ 64 a_bytes.readBegin(YapConst.YAPBYTE); 65 } 66 byte ret = a_bytes.readByte(); 67 if (Deploy.debug){ 68 a_bytes.readEnd(); 69 } 70 return new Byte (ret); 71 } 72 73 public void write(Object a_object, YapReader a_bytes){ 74 if(Deploy.debug){ 75 a_bytes.writeBegin(YapConst.YAPBYTE); 76 } 77 a_bytes.append(((Byte )a_object).byteValue()); 78 if(Deploy.debug){ 79 a_bytes.writeEnd(); 80 } 81 } 82 83 public boolean readArray(Object array, YapReader reader) { 84 if(array instanceof byte[]){ 85 reader.readBytes((byte[])array); 86 return true; 87 } 88 89 return false; 90 } 91 92 public boolean writeArray(Object array, YapReader writer) { 93 if(array instanceof byte[]){ 94 writer.append((byte[])array); 95 return true; 96 } 97 return false; 98 } 99 100 101 102 104 private byte i_compareTo; 105 106 private byte val(Object obj){ 107 return ((Byte )obj).byteValue(); 108 } 109 110 void prepareComparison1(Object obj){ 111 i_compareTo = val(obj); 112 } 113 114 public Object current1(){ 115 return new Byte (i_compareTo); 116 } 117 118 boolean isEqual1(Object obj){ 119 return obj instanceof Byte && val(obj) == i_compareTo; 120 } 121 122 boolean isGreater1(Object obj){ 123 return obj instanceof Byte && val(obj) > i_compareTo; 124 } 125 126 boolean isSmaller1(Object obj){ 127 return obj instanceof Byte && val(obj) < i_compareTo; 128 } 129 } 130 | Popular Tags |