e.g. Calendar Search Help
You must enter a value before pressing Search
spring

Class: org.springframework.beans.propertyeditors.FileEditor   ©

 OK to copy?
01 /*
02  * Copyright 2002-2004 the original author or authors.
03  *
04  * Licensed under the Apache License, Version 2.0 (the "License");
05  * you may not use this file except in compliance with the License.
06  * You may obtain a copy of the License at
07  *
08  *      http://www.apache.org/licenses/LICENSE-2.0
09  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package org.springframework.beans.propertyeditors;
18 
19 import java.beans.PropertyEditorSupport;
20 import java.io.File;
21 
22 import org.springframework.util.StringUtils;
23 
24 /**
25  * Editor for java.io.File, to directly feed a File property
26  * instead of using a String file name property.
27  * @author Juergen Hoeller
28  * @since 09.12.2003
29  * @see java.io.File
30  */
31 public class FileEditor extends PropertyEditorSupport {
32 
33     public void setAsText(String text) throws IllegalArgumentException {
34         if (StringUtils.hasText(text)) {
35             setValue(new File(text));
36         }
37         else {
38             setValue(null);
39         }
40     }
41 
42     public String getAsText() {
43         if (getValue() != null) {
Rate44             return ((File) getValue()).getAbsolutePath();
45         }
46         else {
47             return "";
48         }
49     }
50 
51 }

            
All Examples in File:
Example
Line
Rating (found
useful by...)
44 0% of 0