OSDN Git Service

s2jdbc-genのAntランチャーを移植
[ea2ddl/ea2ddl.git] / ea2ddl-common / src / main / java / org / seasar / extension / jdbc / gen / internal / argtype / FileType.java
1 /*\r
2  * Copyright 2004-2008 the Seasar Foundation and the Others.\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, \r
13  * either express or implied. See the License for the specific language\r
14  * governing permissions and limitations under the License.\r
15  */\r
16 package org.seasar.extension.jdbc.gen.internal.argtype;\r
17 \r
18 import java.io.File;\r
19 \r
20 import org.seasar.extension.jdbc.gen.internal.util.ArgumentUtil;\r
21 import org.seasar.extension.jdbc.gen.internal.util.FileUtil;\r
22 import org.seasar.framework.util.StringUtil;\r
23 \r
24 /**\r
25  * {@link File}を扱う{@link ArgumentType}の実装クラスです。\r
26  * \r
27  * @author taedium\r
28  */\r
29 public class FileType implements ArgumentType<File> {\r
30 \r
31     public File toObject(String value) {\r
32         if (StringUtil.isEmpty(value)) {\r
33             return null;\r
34         }\r
35         String s = ArgumentUtil.decode(value);\r
36         return new File(s);\r
37     }\r
38 \r
39     public String toText(File value) {\r
40         if (value == null) {\r
41             return "";\r
42         }\r
43         String path = FileUtil.getCanonicalPath(value);\r
44         return ArgumentUtil.encode(path);\r
45     }\r
46 \r
47 }\r