Removed deprecated package 'configuration'.
authorMarco Zanon <info@marcozanon.com>
Sun, 26 Aug 2012 10:30:23 +0000 (10:30 +0000)
committerMarco Zanon <info@marcozanon.com>
Sun, 26 Aug 2012 10:30:23 +0000 (10:30 +0000)
src/java/com/marcozanon/macaco/configuration/MConfiguration.java [deleted file]
src/java/com/marcozanon/macaco/configuration/MConfigurationException.java [deleted file]
src/java/com/marcozanon/macaco/configuration/MFileParsingConfigurationException.java [deleted file]
src/java/com/marcozanon/macaco/configuration/MValueNotFoundConfigurationException.java [deleted file]

diff --git a/src/java/com/marcozanon/macaco/configuration/MConfiguration.java b/src/java/com/marcozanon/macaco/configuration/MConfiguration.java
deleted file mode 100644 (file)
index f012ea7..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Macaco
- * Copyright (c) 2009-2012 Marco Zanon <info@marcozanon.com>.
- * Released under MIT license (see LICENSE for details).
- */
-
-package com.marcozanon.macaco.configuration;
-
-import com.marcozanon.macaco.MInformation;
-import com.marcozanon.macaco.MObject;
-import com.marcozanon.macaco.text.MText;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.io.LineNumberReader;
-import java.io.UnsupportedEncodingException;
-import java.util.LinkedHashMap;
-
-public class MConfiguration extends MObject {
-
-    protected LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
-
-    /* */
-
-    public MConfiguration(String file) throws MFileParsingConfigurationException {
-        super();
-        //
-        this.parseFile(file);
-    }
-
-    /* Parameters */
-
-    protected LinkedHashMap<String, String> getParametersReference() {
-        return this.parameters;
-    }
-
-    /* Strings management */
-
-    public void parseFile(String file) throws MFileParsingConfigurationException {
-        if (MText.isBlank(file)) {
-            throw new IllegalArgumentException("Invalid 'file': null or empty.");
-        }
-        //
-        LineNumberReader buffer = null;
-        try {
-            buffer = new LineNumberReader(new InputStreamReader(new FileInputStream(file), MInformation.TEXT_ENCODING));
-        }
-        catch (FileNotFoundException exception) {
-            throw new MFileParsingConfigurationException("Could not open file.", exception);
-        }
-        catch (UnsupportedEncodingException exception) { // cannot happen
-        }
-        String line = null;
-        synchronized (this.getParametersReference()) {
-            while (true) {
-                try {
-                    line = buffer.readLine();
-                }
-                catch (IOException exception) {
-                    throw new MFileParsingConfigurationException("Could not read file.", exception);
-                }
-                if (null == line) {
-                    break;
-                }
-                line = line.trim();
-                if ((line.startsWith("#")) || (line.startsWith(";")) || (MText.isEmpty(line))) {
-                    continue;
-                }
-                else {
-                    int a = line.indexOf("=");
-                    if (-1 == a) {
-                        throw new MFileParsingConfigurationException(String.format("Invalid line: %s: string malformed.", buffer.getLineNumber()));
-                    }
-                    String key = line.substring(0, a).trim();
-                    String value = line.substring(a + 1).trim();
-                    if (this.getParametersReference().containsKey(key)) {
-                        throw new MFileParsingConfigurationException(String.format("Invalid line: %s: duplicated key: %s.", buffer.getLineNumber(), key));
-                    }
-                    this.getParametersReference().put(key, value);
-                }
-            }
-        }
-        try {
-            buffer.close();
-        }
-        catch (IOException exception) {
-            throw new MFileParsingConfigurationException("Could not close file.", exception);
-        }
-    }
-
-    public void clear() {
-        synchronized (this.getParametersReference()) {
-            this.getParametersReference().clear();
-        }
-    }
-
-    public String getValue(String key) throws MValueNotFoundConfigurationException {
-        if (MText.isBlank(key)) {
-            throw new IllegalArgumentException("Invalid 'key': null or empty.");
-        }
-        //
-        if (!this.getParametersReference().containsKey(key)) {
-            throw new MValueNotFoundConfigurationException(String.format("Invalid 'key': %s: not available.", key));
-        }
-        return this.getParametersReference().get(key);
-    }
-
-}
diff --git a/src/java/com/marcozanon/macaco/configuration/MConfigurationException.java b/src/java/com/marcozanon/macaco/configuration/MConfigurationException.java
deleted file mode 100644 (file)
index 2335d50..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Macaco
- * Copyright (c) 2009-2012 Marco Zanon <info@marcozanon.com>.
- * Released under MIT license (see LICENSE for details).
- */
-
-package com.marcozanon.macaco.configuration;
-
-import com.marcozanon.macaco.MException;
-
-public abstract class MConfigurationException extends MException {
-
-    /* */
-
-    public MConfigurationException() {
-        super();
-    }
-
-    public MConfigurationException(String message) {
-        super(message);
-    }
-
-    public MConfigurationException(Throwable error) {
-        super(error);
-    }
-
-    public MConfigurationException(String message, Throwable error) {
-        super(message, error);
-    }
-
-}
diff --git a/src/java/com/marcozanon/macaco/configuration/MFileParsingConfigurationException.java b/src/java/com/marcozanon/macaco/configuration/MFileParsingConfigurationException.java
deleted file mode 100644 (file)
index b464314..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Macaco
- * Copyright (c) 2009-2012 Marco Zanon <info@marcozanon.com>.
- * Released under MIT license (see LICENSE for details).
- */
-
-package com.marcozanon.macaco.configuration;
-
-@SuppressWarnings("serial")
-public class MFileParsingConfigurationException extends MConfigurationException {
-
-    /* */
-
-    public MFileParsingConfigurationException() {
-        super();
-    }
-
-    public MFileParsingConfigurationException(String message) {
-        super(message);
-    }
-
-    public MFileParsingConfigurationException(Throwable error) {
-        super(error);
-    }
-
-    public MFileParsingConfigurationException(String message, Throwable error) {
-        super(message, error);
-    }
-
-}
diff --git a/src/java/com/marcozanon/macaco/configuration/MValueNotFoundConfigurationException.java b/src/java/com/marcozanon/macaco/configuration/MValueNotFoundConfigurationException.java
deleted file mode 100644 (file)
index 05a13cd..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Macaco
- * Copyright (c) 2009-2012 Marco Zanon <info@marcozanon.com>.
- * Released under MIT license (see LICENSE for details).
- */
-
-package com.marcozanon.macaco.configuration;
-
-@SuppressWarnings("serial")
-public class MValueNotFoundConfigurationException extends MConfigurationException {
-
-    /* */
-
-    public MValueNotFoundConfigurationException() {
-        super();
-    }
-
-    public MValueNotFoundConfigurationException(String message) {
-        super(message);
-    }
-
-    public MValueNotFoundConfigurationException(Throwable error) {
-        super(error);
-    }
-
-    public MValueNotFoundConfigurationException(String message, Throwable error) {
-        super(message, error);
-    }
-
-}