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
;
35 public class DefaultParameterMap
implements ParameterMap
38 private final Map backend
;
40 public DefaultParameterMap()
42 backend
= new HashMap();
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
57 public Object
get(final String key
)
61 throw new NullPointerException("DefaultParameterMap.get (..): Parameter 'key' must not be null");
63 return backend
.get(key
);
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
76 public Object
get(final String key
, final Object defaultValue
)
80 throw new NullPointerException("DefaultParameterMap.get (..): Parameter 'key' must not be null");
82 final Object o
= this.backend
.get(key
);
90 public String
[] keys()
92 return (String
[]) this.backend
.keySet().toArray(new String
[backend
.size()]);
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
)
107 throw new NullPointerException("ReportProperties.put (..): Parameter 'key' must not be null");
111 this.backend
.remove(key
);
115 this.backend
.put(key
, value
);
121 return this.backend
.size();