Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / reportbuilder / java / com / sun / star / report / util / DefaultParameterMap.java
blob0fdda8f21d6173f88d8ca20b0dc5074f9bb478ed
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 package com.sun.star.report.util;
29 import com.sun.star.report.ParameterMap;
31 import java.util.HashMap;
32 import java.util.Map;
35 public class DefaultParameterMap implements ParameterMap
38 private final Map backend;
40 public DefaultParameterMap()
42 backend = new HashMap();
45 public void clear()
47 backend.clear();
50 /**
51 * Retrieves the value stored for a key in this properties collection.
53 * @param key the property key.
54 * @return The stored value, or <code>null</code> if the key does not exist in this
55 * collection.
57 public Object get(final String key)
59 if (key == null)
61 throw new NullPointerException("DefaultParameterMap.get (..): Parameter 'key' must not be null");
63 return backend.get(key);
66 /**
67 * Retrieves the value stored for a key in this properties collection, and returning the
68 * default value if the key was not stored in this properties collection.
70 * @param key the property key.
71 * @param defaultValue the default value to be returned when the key is not stored in
72 * this properties collection.
73 * @return The stored value, or the default value if the key does not exist in this
74 * collection.
76 public Object get(final String key, final Object defaultValue)
78 if (key == null)
80 throw new NullPointerException("DefaultParameterMap.get (..): Parameter 'key' must not be null");
82 final Object o = this.backend.get(key);
83 if (o == null)
85 return defaultValue;
87 return o;
90 public String[] keys()
92 return (String[]) this.backend.keySet().toArray(new String[backend.size()]);
95 /**
96 * Adds a property to this properties collection. If a property with the given name
97 * exist, the property will be replaced with the new value. If the value is null, the
98 * property will be removed.
100 * @param key the property key.
101 * @param value the property value.
103 public void put(final String key, final Object value)
105 if (key == null)
107 throw new NullPointerException("ReportProperties.put (..): Parameter 'key' must not be null");
109 if (value == null)
111 this.backend.remove(key);
113 else
115 this.backend.put(key, value);
119 public int size()
121 return this.backend.size();