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: import com.versant.core.jdbc.JdbcTypeRegistry;
15: import com.versant.core.jdbc.metadata.JdbcColumn;
16:
17: import java.io.File;
18:
19: /**
20: * This converter converts java.io.File objects to and from SQL. It assumes
21: * that the File is stored in a CHAR column and trims leading and trailing
22: * blanks.
23: * @keep-all
24: */
25: public class FileConverterTrim extends TypeAsTrimStringConverterBase {
26:
27: public static class Factory extends NoArgJdbcConverterFactory {
28:
29: private FileConverterTrim converter;
30:
31: /**
32: * Create a converter for col using args as parameters. Return null if
33: * no converter is required.
34: */
35: public JdbcConverter createJdbcConverter(JdbcColumn col,
36: Object args, JdbcTypeRegistry jdbcTypeRegistry) {
37: if (converter == null)
38: 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 fromString(String s) {
49: return new File(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 getValueType() {
57: return File.class;
58: }
59:
60: }
|