You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by mi...@apache.org on 2006/03/02 16:14:23 UTC

svn commit: r382405 - in /lenya/trunk/tools/configure/src/org/apache/lenya/config: Configuration.java FileConfiguration.java Parameter.java PropertiesConfiguration.java

Author: michi
Date: Thu Mar  2 07:14:20 2006
New Revision: 382405

URL: http://svn.apache.org/viewcvs?rev=382405&view=rev
Log:
utility classes added

Added:
    lenya/trunk/tools/configure/src/org/apache/lenya/config/Configuration.java
    lenya/trunk/tools/configure/src/org/apache/lenya/config/FileConfiguration.java
    lenya/trunk/tools/configure/src/org/apache/lenya/config/Parameter.java
    lenya/trunk/tools/configure/src/org/apache/lenya/config/PropertiesConfiguration.java

Added: lenya/trunk/tools/configure/src/org/apache/lenya/config/Configuration.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/tools/configure/src/org/apache/lenya/config/Configuration.java?rev=382405&view=auto
==============================================================================
--- lenya/trunk/tools/configure/src/org/apache/lenya/config/Configuration.java (added)
+++ lenya/trunk/tools/configure/src/org/apache/lenya/config/Configuration.java Thu Mar  2 07:14:20 2006
@@ -0,0 +1,39 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.lenya.config;
+
+/**
+ * Configuration
+ */
+public interface Configuration {
+
+    /**
+     *
+     */
+    public Parameter[] getParameters();
+
+    /**
+     *
+     */
+    public void read();
+
+    /**
+     *
+     */
+    public void write();
+}

Added: lenya/trunk/tools/configure/src/org/apache/lenya/config/FileConfiguration.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/tools/configure/src/org/apache/lenya/config/FileConfiguration.java?rev=382405&view=auto
==============================================================================
--- lenya/trunk/tools/configure/src/org/apache/lenya/config/FileConfiguration.java (added)
+++ lenya/trunk/tools/configure/src/org/apache/lenya/config/FileConfiguration.java Thu Mar  2 07:14:20 2006
@@ -0,0 +1,57 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.lenya.config;
+
+import java.io.File;
+
+/**
+ * File Configuration
+ */
+abstract public class FileConfiguration implements Configuration {
+
+    private File filenameDefault;
+    private File filenameLocal;
+
+    /**
+     *
+     */
+    public File getFilenameDefault() {
+        return filenameDefault;
+    }
+
+    /**
+     *
+     */
+    public File getFilenameLocal() {
+        return filenameLocal;
+    }
+
+    /**
+     *
+     */
+    public void setFilenameDefault(String filename) {
+        this.filenameDefault = new File(filename);
+    }
+
+    /**
+     * @param String Filename
+     */
+    public void setFilenameLocal(String filename) {
+        this.filenameLocal = new File(filename);
+    }
+}

Added: lenya/trunk/tools/configure/src/org/apache/lenya/config/Parameter.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/tools/configure/src/org/apache/lenya/config/Parameter.java?rev=382405&view=auto
==============================================================================
--- lenya/trunk/tools/configure/src/org/apache/lenya/config/Parameter.java (added)
+++ lenya/trunk/tools/configure/src/org/apache/lenya/config/Parameter.java Thu Mar  2 07:14:20 2006
@@ -0,0 +1,56 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.lenya.config;
+
+/**
+ * Parameter
+ */
+public class Parameter {
+
+    private String name;
+    private String defaultValue;
+    private String localValue;
+
+    /**
+     *
+     */
+    public void setName(String name) { 
+        this.name = name;
+    }
+
+    /**
+     *
+     */
+    public void setDefaultValue(String value) { 
+        this.defaultValue = value;
+    }
+
+    /**
+     *
+     */
+    public void setLocalValue(String value) { 
+        this.localValue = value;
+    }
+
+    /**
+     *
+     */
+    public String toString() { 
+        return name + " " + defaultValue;
+    }
+}

Added: lenya/trunk/tools/configure/src/org/apache/lenya/config/PropertiesConfiguration.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/tools/configure/src/org/apache/lenya/config/PropertiesConfiguration.java?rev=382405&view=auto
==============================================================================
--- lenya/trunk/tools/configure/src/org/apache/lenya/config/PropertiesConfiguration.java (added)
+++ lenya/trunk/tools/configure/src/org/apache/lenya/config/PropertiesConfiguration.java Thu Mar  2 07:14:20 2006
@@ -0,0 +1,70 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.lenya.config;
+
+import java.io.FileInputStream;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.Vector;
+
+/**
+ * Properties Configuration
+ */
+public class PropertiesConfiguration extends FileConfiguration {
+
+    private Properties defaultProps;
+
+    /**
+     *
+     */
+    public void read() {
+        try {
+        defaultProps = new Properties();
+        defaultProps.load(new FileInputStream(getFilenameDefault()));
+        } catch (Exception e) {
+            System.err.println(e.getMessage());
+        }
+    }
+
+    /**
+     *
+     */
+    public void write() {
+        System.out.println(getFilenameLocal());
+    }
+
+    /**
+     *
+     */
+    public Parameter[] getParameters() {
+        Vector params = new Vector();
+        Enumeration names = defaultProps.propertyNames();
+        while (names.hasMoreElements()) {
+            String name = (String) names.nextElement();
+            Parameter param = new Parameter();
+            param.setName(name);
+            param.setDefaultValue(defaultProps.getProperty(name));
+            params.addElement(param);
+        }
+        Parameter[] p = new Parameter[params.size()];
+        for (int i = 0; i < p.length; i++) {
+            p[i] = (Parameter) params.elementAt(i);
+        }
+        return p;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org