01: // FileField.java
02: // $Id: FileField.java,v 1.4 2000/08/16 21:37:49 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.tools.forms;
07:
08: import java.io.File;
09:
10: public class FileField extends StringField {
11:
12: /**
13: * Get this field's value in its native type.
14: * @return An instance of File, or <strong>null</strong>.
15: */
16:
17: public Object getValue() {
18: return new File(value);
19: }
20:
21: /**
22: * Get this field's value as a File instance.
23: * @return An instance of FIle, or <strong>null</strong>.
24: */
25:
26: public File getFileValue() {
27: return new File(value);
28: }
29:
30: /**
31: * Set this field's value using the native type.
32: * @param value The new File value for the field.
33: * @param update Should we update the editor's view ?
34: * @exception IllegalFieldValueException If the value isn't accepted.
35: */
36:
37: public void setValue(Object object, boolean notify, boolean update)
38: throws IllegalFieldValueException {
39: if (!(object instanceof File))
40: throw new IllegalFieldValueException(object);
41: setValue((File) object, notify, update);
42: }
43:
44: /**
45: * Set this field's value.
46: * @param file The new File value for the field.
47: * @param update Update the editor's view ?
48: * @exception IllegalFieldValueException If the value isn't accepted.
49: */
50:
51: public void setValue(File value, boolean notify, boolean update)
52: throws IllegalFieldValueException {
53: super .setValue(value.getAbsolutePath(), notify, update);
54: }
55:
56: public FileField(FormManager manager, String name, String title,
57: File value) {
58: super (manager, name, title, ((value != null) ? value
59: .getAbsolutePath() : null));
60: }
61:
62: public FileField(FormManager manager, String name, String title) {
63: this(manager, name, title, null);
64: }
65:
66: }
|