Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / jigsaw / src / org / w3c / tools / resources / upgrade / DoubleAttribute.java
diff --git a/JMCR-Stable/real-world application/jigsaw/src/org/w3c/tools/resources/upgrade/DoubleAttribute.java b/JMCR-Stable/real-world application/jigsaw/src/org/w3c/tools/resources/upgrade/DoubleAttribute.java
new file mode 100644 (file)
index 0000000..a52a826
--- /dev/null
@@ -0,0 +1,80 @@
+// DoubleAttribute.java\r
+// $Id: DoubleAttribute.java,v 1.1 2010/06/15 12:22:52 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.resources.upgrade ;\r
+\r
+import java.io.DataInputStream;\r
+import java.io.DataOutputStream;\r
+import java.io.IOException;\r
+\r
+/**\r
+ * The generic description of an DoubleAttribute.\r
+ */\r
+\r
+public class DoubleAttribute extends Attribute {\r
+\r
+    /**\r
+     * Is the given object a valid DoubleAttribute value ?\r
+     * @param obj The object to test.\r
+     * @return A boolean <strong>true</strong> if okay.\r
+     * @exception IllegalAttributeAccess If the provided value doesn't pass the\r
+     *    test.\r
+     */\r
+\r
+    public boolean checkValue(Object obj) {\r
+       return (obj instanceof Double) ;\r
+    }\r
+\r
+    /**\r
+     * Get the number of bytes required to save that attribute value.\r
+     * @param The value about to be pickled.\r
+     * @return The number of bytes needed to pickle that value.\r
+     */\r
+\r
+    public final int getPickleLength(Object value) {\r
+       return 8;\r
+    }\r
+\r
+    /**\r
+     * Pickle an double to the given output stream.\r
+     * @param out The output stream to pickle to.\r
+     * @param obj The object to pickle.\r
+     * @exception IOException If some IO error occured.\r
+     */\r
+\r
+    public final void pickle(DataOutputStream out, Object d) \r
+       throws IOException\r
+    {\r
+       out.writeDouble(((Double) d).doubleValue()) ;\r
+    }\r
+\r
+    /**\r
+     * Unpickle an integer from the given input stream.\r
+     * @param in The input stream to unpickle from.\r
+     * @return An instance of Double.\r
+     * @exception IOException If some IO error occured.\r
+     */\r
+\r
+    public final Object unpickle (DataInputStream in) \r
+       throws IOException\r
+    {\r
+       return new Double(in.readDouble()) ;\r
+    }\r
+\r
+    /**\r
+     * Create a description for a generic Double attribute.\r
+     * @param name The attribute name.\r
+     * @param def The default value for these attributes.\r
+     * @param flags The associated flags.\r
+     */\r
+\r
+    public DoubleAttribute(String name, Double def, Integer flags) {\r
+       super(name, def, flags) ;\r
+       this.type = "java.lang.Double";\r
+    }\r
+\r
+}\r
+\r
+\r