1 2 12 package com.versant.core.jdbc.sql.conv; 13 14 import com.versant.core.jdbc.JdbcConverter; 15 16 22 public class BooleanArrayConverter extends TypeAsBytesConverterBase { 23 24 public static class Factory extends TypeAsBytesConverterBase.Factory { 25 26 protected JdbcConverter createConverter(JdbcConverter nested) { 27 return new BooleanArrayConverter(nested); 28 } 29 30 } 31 32 public BooleanArrayConverter(JdbcConverter nested) { 33 super(nested); 34 } 35 36 39 protected Object fromByteArray(byte[] buf) { 40 int n = buf.length; 41 boolean[] a = new boolean[n]; 42 for (int i = 0; i < n; i++) { 43 a[i] = buf[i] != 0; 44 } 45 return a; 46 } 47 48 51 protected byte[] toByteArray(Object value) { 52 if (value == null) return null; 53 boolean[] a = (boolean[])value; 54 int n = a.length; 55 byte[] buf = new byte[n]; 56 for (int i = 0; i < n; i++) { 57 buf[i] = a[i] ? (byte)1 : (byte)0; 58 } 59 return buf; 60 } 61 62 66 public Class getValueType() { 67 return boolean[].class; 68 } 69 70 } 71 72 | Popular Tags |