01: /*
02: * @(#) FileConverter.java
03: *
04: * Copyright 2002 - 2003 JIDE Software. All rights reserved.
05: */
06: package com.jidesoft.converter;
07:
08: import java.io.File;
09:
10: /**
11: * Converter which converts File to String and converts it back.
12: */
13: public class FileConverter implements ObjectConverter {
14: public String toString(Object object, ConverterContext context) {
15: if (object == null || !(object instanceof File)) {
16: return null;
17: } else {
18: return ((File) object).getAbsolutePath();
19: }
20: }
21:
22: public boolean supportToString(Object object,
23: ConverterContext context) {
24: return true;
25: }
26:
27: public Object fromString(String string, ConverterContext context) {
28: return new File(string);
29: }
30:
31: public boolean supportFromString(String string,
32: ConverterContext context) {
33: return true;
34: }
35: }
|