Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / jigsaw / src / org / w3c / tools / forms / FileField.java
diff --git a/JMCR-Stable/real-world application/jigsaw/src/org/w3c/tools/forms/FileField.java b/JMCR-Stable/real-world application/jigsaw/src/org/w3c/tools/forms/FileField.java
new file mode 100644 (file)
index 0000000..8b9ecd9
--- /dev/null
@@ -0,0 +1,70 @@
+// FileField.java\r
+// $Id: FileField.java,v 1.1 2010/06/15 12:27:21 smhuang Exp $\r
+// (c) COPYRIGHT MIT and INRIA, 1996.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.tools.forms ;\r
+\r
+import java.io.File;\r
+\r
+public class FileField extends StringField {\r
+\r
+    /**\r
+     * Get this field's value in its native type.\r
+     * @return An instance of File, or <strong>null</strong>.\r
+     */\r
+\r
+    public Object getValue() {\r
+       return new File(value) ;\r
+    }\r
+\r
+    /**\r
+     * Get this field's value as a File instance.\r
+     * @return An instance of FIle, or <strong>null</strong>.\r
+     */\r
+\r
+    public File getFileValue() {\r
+       return new File(value) ;\r
+    }\r
+\r
+    /**\r
+     * Set this field's value using the native type.\r
+     * @param value The new File value for the field.\r
+     * @param update Should we update the editor's view ?\r
+     * @exception IllegalFieldValueException If the value isn't accepted.\r
+     */\r
+\r
+    public void setValue(Object object, boolean notify, boolean update) \r
+       throws IllegalFieldValueException\r
+    {\r
+       if ( ! (object instanceof File) )\r
+           throw new IllegalFieldValueException (object) ;\r
+       setValue((File) object, notify, update) ;\r
+    }\r
+\r
+    /**\r
+     * Set this field's value.\r
+     * @param file The new File value for the field.\r
+     * @param update Update the editor's view ?\r
+     * @exception IllegalFieldValueException If the value isn't accepted.\r
+     */\r
+\r
+    public void setValue(File value, boolean notify, boolean update) \r
+       throws IllegalFieldValueException\r
+    {\r
+       super.setValue(value.getAbsolutePath(), notify, update) ;\r
+    }\r
+       \r
+    public FileField(FormManager manager\r
+                    , String name, String title\r
+                    , File value) {\r
+       super(manager, name, title, ((value != null) \r
+                                    ? value.getAbsolutePath()\r
+                                    : null)) ;\r
+    }\r
+\r
+    public FileField(FormManager manager, String name, String title) {\r
+       this(manager, name, title, null) ;\r
+    }\r
+                    \r
+}\r