mobile/android/thirdparty/ch/boye/httpclientandroidlib/message/BasicNameValuePair.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

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.message;
    30 import java.io.Serializable;
    32 import ch.boye.httpclientandroidlib.NameValuePair;
    33 import ch.boye.httpclientandroidlib.util.CharArrayBuffer;
    34 import ch.boye.httpclientandroidlib.util.LangUtils;
    36 /**
    37  * Basic implementation of {@link NameValuePair}.
    38  *
    39  * @since 4.0
    40  */
    41 public class BasicNameValuePair implements NameValuePair, Cloneable, Serializable {
    43     private static final long serialVersionUID = -6437800749411518984L;
    45     private final String name;
    46     private final String value;
    48     /**
    49      * Default Constructor taking a name and a value. The value may be null.
    50      *
    51      * @param name The name.
    52      * @param value The value.
    53      */
    54     public BasicNameValuePair(final String name, final String value) {
    55         super();
    56         if (name == null) {
    57             throw new IllegalArgumentException("Name may not be null");
    58         }
    59         this.name = name;
    60         this.value = value;
    61     }
    63     public String getName() {
    64         return this.name;
    65     }
    67     public String getValue() {
    68         return this.value;
    69     }
    71     public String toString() {
    72         // don't call complex default formatting for a simple toString
    74         if (this.value == null) {
    75             return name;
    76         } else {
    77             int len = this.name.length() + 1 + this.value.length();
    78             CharArrayBuffer buffer = new CharArrayBuffer(len);
    79             buffer.append(this.name);
    80             buffer.append("=");
    81             buffer.append(this.value);
    82             return buffer.toString();
    83         }
    84     }
    86     public boolean equals(final Object object) {
    87         if (this == object) return true;
    88         if (object instanceof NameValuePair) {
    89             BasicNameValuePair that = (BasicNameValuePair) object;
    90             return this.name.equals(that.name)
    91                   && LangUtils.equals(this.value, that.value);
    92         } else {
    93             return false;
    94         }
    95     }
    97     public int hashCode() {
    98         int hash = LangUtils.HASH_SEED;
    99         hash = LangUtils.hashCode(hash, this.name);
   100         hash = LangUtils.hashCode(hash, this.value);
   101         return hash;
   102     }
   104     public Object clone() throws CloneNotSupportedException {
   105         return super.clone();
   106     }
   108 }

mercurial