Java HashMap Copy copyDirective(HashMap directives, StringBuilder sb, String directive)

Here you can find the source of copyDirective(HashMap directives, StringBuilder sb, String directive)

Description

Copy the directive to the StringBuilder if not null.

License

Open Source License

Parameter

Parameter Description
directives the directives map
sb the output buffer
directive the directive name to look for

Declaration

public static void copyDirective(HashMap<String, String> directives,
        StringBuilder sb, String directive) 

Method Source Code

//package com.java2s;
/**/*from  w  w  w .j  a v  a2 s.  c o  m*/
 * Copyright 2007-2016, Kaazing Corporation. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.HashMap;

public class Main {
    /**
     * Copy the directive to the {@link StringBuilder} if not null.
     * (A directive is a parameter of the digest authentication process.)
     * 
     * @param directives the directives map
     * @param sb the output buffer
     * @param directive the directive name to look for
     */
    public static void copyDirective(HashMap<String, String> directives,
            StringBuilder sb, String directive) {
        String directiveValue = directives.get(directive);
        if (directiveValue != null) {
            sb.append(directive).append(" = \"").append(directiveValue)
                    .append("\", ");
        }
    }

    /**
     * Copy the directive from the source map to the destination map, if it's
     * value isn't null.
     * (A directive is a parameter of the digest authentication process.)
     * 
     * @param src the source map
     * @param dst the destination map
     * @param directive the directive name
     * @return the value of the copied directive
     */
    public static String copyDirective(HashMap<String, String> src,
            HashMap<String, String> dst, String directive) {
        String directiveValue = src.get(directive);
        if (directiveValue != null) {
            dst.put(directive, directiveValue);
        }

        return directiveValue;
    }
}

Related

  1. copy(HashMap oldHashMap)
  2. copyHashMap(final HashMap map)
  3. copyHashWords(HashMap> ohwords, HashMap> nhwords, int start, int end, int nstart)
  4. copyItem(HashMap to, HashMap from, String key)
  5. copyMap(HashMap map)