001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.resource;
018
019import org.apache.wicket.util.value.ValueMap;
020
021/**
022 * Kind of like java.util.Properties but based on Wicket's ValueMap and thus benefiting from all its
023 * nice build-in type converters and without parent properties.
024 * 
025 * @author Juergen Donnerstag
026 */
027public final class Properties
028{
029        /** Empty Properties */
030        public static final Properties EMPTY_PROPERTIES = new Properties("NULL", ValueMap.EMPTY_MAP);
031
032        /** A unique key for this specific group of properties. */
033        private final String key;
034
035        /** Property values */
036        private final ValueMap strings;
037
038        /**
039         * Construct
040         * 
041         * @param key
042         *            The key
043         * @param strings
044         *            Properties values
045         */
046        public Properties(final String key, final ValueMap strings)
047        {
048                this.key = key;
049                this.strings = strings;
050        }
051
052        /**
053         * Get direct access to all values from the properties file.
054         * 
055         * @return map
056         */
057        public final ValueMap getAll()
058        {
059                return strings;
060        }
061
062        /**
063         * Get the property value identified by its 'key'.
064         * 
065         * @param key
066         * @return property message
067         */
068        public final String getString(final String key)
069        {
070                return strings.getString(key);
071        }
072
073        /**
074         * @see java.lang.Object#toString()
075         */
076        @Override
077        public final String toString()
078        {
079                return "unique key:" + key;
080        }
081}