Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
1 /*
2 * ====================================================================
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 * ====================================================================
20 *
21 * This software consists of voluntary contributions made by many
22 * individuals on behalf of the Apache Software Foundation. For more
23 * information on the Apache Software Foundation, please see
24 * <http://www.apache.org/>.
25 *
26 */
28 package ch.boye.httpclientandroidlib.params;
30 import ch.boye.httpclientandroidlib.params.HttpParams;
32 /**
33 * Abstract base class for parameter collections.
34 * Type specific setters and getters are mapped to the abstract,
35 * generic getters and setters.
36 *
37 * @since 4.0
38 */
39 public abstract class AbstractHttpParams implements HttpParams {
41 /**
42 * Instantiates parameters.
43 */
44 protected AbstractHttpParams() {
45 super();
46 }
48 public long getLongParameter(final String name, long defaultValue) {
49 Object param = getParameter(name);
50 if (param == null) {
51 return defaultValue;
52 }
53 return ((Long)param).longValue();
54 }
56 public HttpParams setLongParameter(final String name, long value) {
57 setParameter(name, new Long(value));
58 return this;
59 }
61 public int getIntParameter(final String name, int defaultValue) {
62 Object param = getParameter(name);
63 if (param == null) {
64 return defaultValue;
65 }
66 return ((Integer)param).intValue();
67 }
69 public HttpParams setIntParameter(final String name, int value) {
70 setParameter(name, new Integer(value));
71 return this;
72 }
74 public double getDoubleParameter(final String name, double defaultValue) {
75 Object param = getParameter(name);
76 if (param == null) {
77 return defaultValue;
78 }
79 return ((Double)param).doubleValue();
80 }
82 public HttpParams setDoubleParameter(final String name, double value) {
83 setParameter(name, new Double(value));
84 return this;
85 }
87 public boolean getBooleanParameter(final String name, boolean defaultValue) {
88 Object param = getParameter(name);
89 if (param == null) {
90 return defaultValue;
91 }
92 return ((Boolean)param).booleanValue();
93 }
95 public HttpParams setBooleanParameter(final String name, boolean value) {
96 setParameter(name, value ? Boolean.TRUE : Boolean.FALSE);
97 return this;
98 }
100 public boolean isParameterTrue(final String name) {
101 return getBooleanParameter(name, false);
102 }
104 public boolean isParameterFalse(final String name) {
105 return !getBooleanParameter(name, false);
106 }
108 } // class AbstractHttpParams