KickJava   Java API By Example, From Geeks To Geeks.

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


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 import com.versant.core.jdbc.JdbcTypeRegistry;
16 import com.versant.core.jdbc.metadata.JdbcColumn;
17
18 import java.io.File JavaDoc;
19
20 /**
21  * This converter converts java.io.File objects to and from SQL. It assumes
22  * that the File is stored in a CHAR column and trims leading and trailing
23  * blanks.
24  * @keep-all
25  */

26 public class FileConverterTrim extends TypeAsTrimStringConverterBase {
27
28     public static class Factory extends NoArgJdbcConverterFactory {
29
30         private FileConverterTrim converter;
31
32         /**
33          * Create a converter for col using args as parameters. Return null if
34          * no converter is required.
35          */

36         public JdbcConverter createJdbcConverter(JdbcColumn col, Object JavaDoc args,
37                 JdbcTypeRegistry jdbcTypeRegistry) {
38             if (converter == null) converter = new FileConverterTrim();
39             return converter;
40         }
41
42     }
43
44     /**
45      * Create an instance of our type from a String.
46      * @param s String to use (never null)
47      */

48     protected Object JavaDoc fromString(String JavaDoc s) {
49         return new File JavaDoc(s);
50     }
51
52     /**
53      * Get the type of our expected value objects (e.g. java.util.Locale
54      * for a converter for Locale's).
55      */

56     public Class JavaDoc getValueType() {
57         return File JavaDoc.class;
58     }
59
60 }
61
62
Popular Tags