01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.jdbc.sql.conv;
12:
13: import com.versant.core.jdbc.JdbcConverter;
14:
15: /**
16: * This converter converts byte[] to and from SQL. It delegates to a nested
17: * converter based on the JDBC type of the column.
18: * @keep-all
19: */
20: public class ByteArrayConverter extends TypeAsBytesConverterBase {
21:
22: public static class Factory extends
23: TypeAsBytesConverterBase.Factory {
24:
25: protected JdbcConverter createConverter(JdbcConverter nested) {
26: return new ByteArrayConverter(nested);
27: }
28:
29: }
30:
31: public ByteArrayConverter(JdbcConverter nested) {
32: super (nested);
33: }
34:
35: /**
36: * Convert a byte[] into an instance of our value class.
37: */
38: protected Object fromByteArray(byte[] buf) {
39: return buf;
40: }
41:
42: /**
43: * Convert an instance of our value class into a byte[].
44: */
45: protected byte[] toByteArray(Object value) {
46: return (byte[]) value;
47: }
48:
49: /**
50: * Get the type of our expected value objects (e.g. java.util.Locale
51: * for a converter for Locale's).
52: */
53: public Class getValueType() {
54: return byte[].class;
55: }
56:
57: }
|