001/* 
002    Licensed to the Apache Software Foundation (ASF) under one
003    or more contributor license agreements.  See the NOTICE file
004    distributed with this work for additional information
005    regarding copyright ownership.  The ASF licenses this file
006    to you under the Apache License, Version 2.0 (the
007    "License"); you may not use this file except in compliance
008    with the License.  You may obtain a copy of the License at
009
010       http://www.apache.org/licenses/LICENSE-2.0
011
012    Unless required by applicable law or agreed to in writing,
013    software distributed under the License is distributed on an
014    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015    KIND, either express or implied.  See the License for the
016    specific language governing permissions and limitations
017    under the License.  
018 */
019package org.apache.wiki.htmltowiki;
020
021import java.util.Collection;
022import java.util.Map;
023import java.util.Properties;
024import java.util.Set;
025
026/**
027 * Adds the load / save - functionality known from the Properties - class to any
028 * Map implementation.
029 * 
030 */
031public class PersistentMapDecorator extends Properties
032{
033    private static final long serialVersionUID = 0L;
034    
035    private Map m_delegate;
036
037    /**
038     *  Creates a new decorator for a given map.
039     *  
040     *  @param delegate The map to create a decorator for.
041     */
042    public PersistentMapDecorator( Map delegate )
043    {
044        m_delegate = delegate;
045    }
046
047    /**
048     *  {@inheritDoc}
049     */
050    @Override
051    public void clear()
052    {
053        m_delegate.clear();
054    }
055
056    /**
057     *  {@inheritDoc}
058     */
059    @Override
060    public boolean containsKey( Object key )
061    {
062        return m_delegate.containsKey( key );
063    }
064
065    /**
066     *  {@inheritDoc}
067     */
068    @Override
069    public boolean containsValue( Object value )
070    {
071        return m_delegate.containsValue( value );
072    }
073
074    /**
075     *  {@inheritDoc}
076     */
077    @SuppressWarnings("unchecked")
078    @Override
079    public Set entrySet()
080    {
081        return m_delegate.entrySet();
082    }
083
084    /**
085     *  {@inheritDoc}
086     */
087    @Override
088    public boolean equals( Object obj )
089    {
090        return m_delegate.equals( obj );
091    }
092
093    /**
094     *  {@inheritDoc}
095     */
096    @Override
097    public Object get( Object key )
098    {
099        return m_delegate.get( key );
100    }
101
102    /**
103     *  {@inheritDoc}
104     */
105    @Override
106    public int hashCode()
107    {
108        return m_delegate.hashCode();
109    }
110
111    /**
112     *  {@inheritDoc}
113     */
114    @Override
115    public boolean isEmpty()
116    {
117        return m_delegate.isEmpty();
118    }
119
120    /**
121     *  {@inheritDoc}
122     */
123    @SuppressWarnings("unchecked")
124    @Override
125    public Set keySet()
126    {
127        return m_delegate.keySet();
128    }
129
130    /**
131     *  {@inheritDoc}
132     */
133    @SuppressWarnings("unchecked")
134    @Override
135    public Object put( Object arg0, Object arg1 )
136    {
137        return m_delegate.put( arg0, arg1 );
138    }
139
140    /**
141     *  {@inheritDoc}
142     */
143    @SuppressWarnings("unchecked")
144    @Override
145    public void putAll( Map arg0 )
146    {
147        m_delegate.putAll( arg0 );
148    }
149
150    /**
151     *  {@inheritDoc}
152     */
153    @Override
154    public Object remove( Object key )
155    {
156        return m_delegate.remove( key );
157    }
158
159    /**
160     *  {@inheritDoc}
161     */
162    @Override
163    public int size()
164    {
165        return m_delegate.size();
166    }
167
168    /**
169     *  {@inheritDoc}
170     */
171    @Override
172    public String toString()
173    {
174        return m_delegate.toString();
175    }
176
177    /**
178     *  {@inheritDoc}
179     */
180    @SuppressWarnings("unchecked")
181    @Override
182    public Collection values()
183    {
184        return m_delegate.values();
185    }
186}