Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / iapi / util / DoubleProperties.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/iapi/util/DoubleProperties.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/iapi/util/DoubleProperties.java
new file mode 100644 (file)
index 0000000..5e4e3a4
--- /dev/null
@@ -0,0 +1,82 @@
+/*\r
+\r
+   Derby - Class com.ihost.cs.DoubleProperties\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to you under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.iapi.util;\r
+\r
+import java.util.Properties;\r
+import java.util.Enumeration;\r
+\r
+/**\r
+       A properties object that links two independent\r
+       properties together. The read property set is always\r
+       searched first, with the write property set being\r
+       second. But any put() calls are always made directly to\r
+       the write object.\r
+\r
+    Only the put(), keys() and getProperty() methods are supported\r
+       by this class.\r
+*/\r
+\r
+public final class DoubleProperties extends Properties {\r
+\r
+       private final Properties read;\r
+       private final Properties write;\r
+\r
+       public DoubleProperties(Properties read, Properties write) {\r
+               this.read = read;\r
+               this.write = write;\r
+       }\r
+\r
+       public Object put(Object key, Object value) {\r
+               return write.put(key, value);\r
+       }\r
+\r
+       public String getProperty(String key) {\r
+\r
+               return read.getProperty(key, write.getProperty(key));\r
+       }\r
+\r
+       public String getProperty(String key, String defaultValue) {\r
+               return read.getProperty(key, write.getProperty(key, defaultValue));\r
+\r
+       }\r
+\r
+       public Enumeration propertyNames() {\r
+\r
+               Properties p = new Properties();\r
+\r
+               if (write != null) {\r
+\r
+                       for (Enumeration e = write.propertyNames(); e.hasMoreElements(); ) {\r
+                               String key = (String) e.nextElement();\r
+                               p.put(key, write.getProperty(key));\r
+                       }\r
+               }\r
+\r
+               if (read != null) {\r
+                       for (Enumeration e = read.propertyNames(); e.hasMoreElements(); ) {\r
+                               String key = (String) e.nextElement();\r
+                               p.put(key, read.getProperty(key));\r
+                       }\r
+               }\r
+               return p.keys();\r
+       }\r
+}\r