Java Map Remove removeWireAttributes( Map map)

Here you can find the source of removeWireAttributes( Map map)

Description

Remove the wire attributes from the specified map of message attributes (headers).

License

Apache License

Parameter

Parameter Description
map the map containing wire attributes to be removed.

Return

the wire attributes from the input map, with any key prefixes removed.

Declaration

public static Map<String, String> removeWireAttributes(
        Map<String, String> map) 

Method Source Code

//package com.java2s;
/*//from w  w w  .j  a v  a  2s. c  om
 Copyright (c) 2012 LinkedIn Corp.

 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;
import java.util.Iterator;
import java.util.Map;

public class Main {
    private static final String WIRE_ATTR_PREFIX = "X-LI-R2-W-";

    /**
     * Remove the wire attributes from the specified map of message attributes (headers).
     *
     * @param map the map containing wire attributes to be removed.
     * @return the wire attributes from the input map, with any key prefixes removed.
     */
    public static Map<String, String> removeWireAttributes(
            Map<String, String> map) {
        final Map<String, String> wireAttrs = new HashMap<String, String>();

        for (Iterator<Map.Entry<String, String>> it = map.entrySet()
                .iterator(); it.hasNext();) {
            final Map.Entry<String, String> entry = it.next();
            final String key = entry.getKey();
            if (key.startsWith(WIRE_ATTR_PREFIX)) {
                final String value = entry.getValue();
                final String newKey = key.substring(WIRE_ATTR_PREFIX
                        .length());
                wireAttrs.put(newKey, value);
                it.remove();
            }
        }

        return wireAttrs;
    }
}

Related

  1. removeValue(Map subject, String property, Map value, boolean propertyIsArray)
  2. removeValueFromAll(final Map map, final Object value)
  3. removeValueList(final Map> map, final K key, final V value)
  4. removeValuesFromMap(Map map, Collection removed)
  5. removeVersionSelector( Map selector)
  6. splitEachArrayElementAndCreateMap(String[] array, String delimiter, String removeCharacters)