ingo@1022: /*
ingo@1022: * Copyright (c) 2010 by Intevation GmbH
ingo@1022: *
ingo@1022: * This program is free software under the LGPL (>=v2.1)
ingo@1022: * Read the file LGPL.txt coming with the software for details
ingo@1022: * or visit http://www.gnu.org/licenses/ if it does not exist.
ingo@1022: */
ingo@1022:
tim@3: package de.intevation.gnv.propertiesreader;
tim@3:
tim@3: import java.util.Map;
tim@3:
tim@3: import org.apache.log4j.Logger;
tim@3:
tim@3: /**
ingo@690: * A PropertiesReader
storing properties in a Map
.
sascha@699: *
sascha@684: * @author Tim Englich
sascha@681: *
tim@3: */
tim@3: public class MapPropertiesReader implements PropertiesReader {
ingo@690:
tim@3: private static Logger log = Logger.getLogger(MapPropertiesReader.class);
tim@3:
tim@960: /**
tim@960: * The properties which are served by this PropertiesReader
.
tim@960: */
tim@36: private Map properties = null;
tim@36:
tim@3: /**
ingo@690: * Constructs a new MapPropertiesReader with an initial map.
tim@960: *
tim@960: * @param properties the properties which should be served by this
tim@960: * PropertiesReader
.
tim@3: */
tim@3: public MapPropertiesReader(Map properties) {
tim@3: super();
tim@3: this.properties = properties;
tim@3: }
tim@3:
tim@3: public String getPropertieValue(String key, String defaultValue) {
tim@3: String value = this.properties.get(key);
tim@36: if (value == null) {
tim@3: value = defaultValue;
tim@3: }
tim@3: return value;
tim@3: }
tim@3: }
sascha@700: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :