KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdbc > sql > conv > ByteArrayConverter


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdbc.sql.conv;
13
14 import com.versant.core.jdbc.JdbcConverter;
15
16 /**
17  * This converter converts byte[] to and from SQL. It delegates to a nested
18  * converter based on the JDBC type of the column.
19  * @keep-all
20  */

21 public class ByteArrayConverter extends TypeAsBytesConverterBase {
22
23     public static class Factory extends 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 JavaDoc 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 JavaDoc 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 JavaDoc getValueType() {
54         return byte[].class;
55     }
56
57 }
58
59
Popular Tags