KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > converters > extended > FileConverter


1 package com.thoughtworks.xstream.converters.extended;
2
3 import com.thoughtworks.xstream.converters.basic.AbstractBasicConverter;
4
5 import java.io.File JavaDoc;
6
7 /**
8  * This converter will take care of storing and retrieving File with either
9  * an absolute path OR a relative path depending on how they were created.
10  *
11  * @author Joe Walnes
12  */

13 public class FileConverter extends AbstractBasicConverter {
14
15     public boolean canConvert(Class JavaDoc type) {
16         return type.equals(File JavaDoc.class);
17     }
18
19     protected Object JavaDoc fromString(String JavaDoc str) {
20         return new File JavaDoc(str);
21     }
22
23     protected String JavaDoc toString(Object JavaDoc obj) {
24         return ((File JavaDoc) obj).getPath();
25     }
26
27 }
Popular Tags