1 21 package com.db4o; 22 23 24 final class YChar extends YapJavaClass { 25 26 static final int LENGTH = YapConst.CHAR_BYTES + YapConst.ADDED_LENGTH; 27 28 private static final Character i_primitive = new Character ((char)0); 29 30 public YChar(YapStream stream) { 31 super(stream); 32 } 33 34 public Object defaultValue(){ 35 return i_primitive; 36 } 37 38 public int getID() { 39 return 7; 40 } 41 42 public int linkLength() { 43 return LENGTH; 44 } 45 46 protected Class primitiveJavaClass() { 47 return char.class; 48 } 49 50 Object primitiveNull() { 51 return i_primitive; 52 } 53 54 Object read1(YapReader a_bytes) { 55 if (Deploy.debug) { 56 a_bytes.readBegin(YapConst.YAPCHAR); 57 } 58 byte b1 = a_bytes.readByte(); 59 byte b2 = a_bytes.readByte(); 60 if (Deploy.debug) { 61 a_bytes.readEnd(); 62 } 63 char ret = (char) ((b1 & 0xff) | ((b2 & 0xff) << 8)); 64 return new Character (ret); 65 } 66 67 public void write(Object a_object, YapReader a_bytes) { 68 if (Deploy.debug) { 69 a_bytes.writeBegin(YapConst.YAPCHAR); 70 } 71 char char_ = ((Character ) a_object).charValue(); 72 a_bytes.append((byte) (char_ & 0xff)); 73 a_bytes.append((byte) (char_ >> 8)); 74 if (Deploy.debug) { 75 a_bytes.writeEnd(); 76 } 77 } 78 79 81 private char i_compareTo; 82 83 private char val(Object obj) { 84 return ((Character ) obj).charValue(); 85 } 86 87 void prepareComparison1(Object obj) { 88 i_compareTo = val(obj); 89 } 90 91 public Object current1(){ 92 return new Character (i_compareTo); 93 } 94 95 boolean isEqual1(Object obj) { 96 return obj instanceof Character && val(obj) == i_compareTo; 97 } 98 99 boolean isGreater1(Object obj) { 100 return obj instanceof Character && val(obj) > i_compareTo; 101 } 102 103 boolean isSmaller1(Object obj) { 104 return obj instanceof Character && val(obj) < i_compareTo; 105 } 106 107 } 108 | Popular Tags |