Example usage for java.util Map keySet

List of usage examples for java.util Map keySet

Introduction

In this page you can find the example usage for java.util Map keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:com.ning.billing.recurly.model.RecurlyObject.java

public static DateTime dateTimeOrNull(@Nullable final Object object) {
    if (isNull(object)) {
        return null;
    }/*from  w  w w  . j a  v  a  2  s . c  o m*/

    // DateTimes are represented as objects (e.g. <created_at type="datetime">2011-04-19T07:00:00Z</created_at>), which Jackson
    // will interpret as an Object (Map), not DateTimes.
    if (object instanceof Map) {
        final Map map = (Map) object;
        if (map.keySet().size() == 2 && "datetime".equals(map.get("type"))) {
            return new DateTime(map.get(""));
        }
    }

    return new DateTime(object.toString());
}

From source file:com.aurel.track.admin.customize.category.filter.execute.ReportQueryBL.java

public static String encodeMapAsUrl(Map<String, String> map) {
    StringBuffer sb = new StringBuffer();
    Iterator<String> it = map.keySet().iterator();
    while (it.hasNext()) {
        String key = it.next();/* www .  j a  v a 2  s.c o m*/
        sb.append(key).append("=").append(map.get(key)).append("&");
    }
    return sb.toString();
}

From source file:com.asual.lesscss.ResourcePackage.java

public static <K, V> K getKeyFromValue(Map<K, V> m, V value) {
    for (K o : m.keySet()) {
        if (m.get(o).equals(value)) {
            return o;
        }/*from w  w w .java2s .  c o m*/
    }
    return null;
}

From source file:com.ning.billing.recurly.model.RecurlyObject.java

public static boolean isNull(@Nullable final Object object) {
    if (object == null) {
        return true;
    }/*from   w w w  .j av  a  2s . co  m*/

    // Hack to work around Recurly output for nil values: the response will contain
    // an element with a nil attribute (e.g. <city nil="nil"></city> or <username nil="true"></username>) which Jackson will
    // interpret as an Object (Map), not a String.
    if (object instanceof Map) {
        final Map map = (Map) object;
        if (map.keySet().size() >= 1 && map.get(NIL_STR) != null
                && NIL_VAL.contains(map.get(NIL_STR).toString())) {
            return true;
        }
    }

    return false;
}

From source file:eu.dasish.annotation.backend.Helpers.java

public static String replace(String text, Map<String, ?> pairs) {
    StringBuilder result = new StringBuilder(text);
    for (String old : pairs.keySet()) {
        if (old != null) {
            if (!old.equals("")) {
                replaceString(result, old, pairs.get(old));
            }//from   w w  w .j a v a2 s .c  o m
        }
    }
    return result.toString();
}

From source file:Main.java

/**
 * Merge lists//from w w w  .  ja v a  2  s .  co m
 * @param first - List
 * @param second - List
 * @param <T> - Object class
 * @return - List
 */
public static <T> List<T> mergeLists(List<T> first, List<T> second) {
    Map<T, T> dataMap = listToMap(first);

    for (T object : second) {
        dataMap.put(object, object);
    }

    List<T> resultObject = new LinkedList<T>();
    for (T object : dataMap.keySet()) {
        resultObject.add(object);
    }
    return resultObject;
}

From source file:com.microsoft.azure.shortcuts.resources.samples.NetworksSample.java

private static void testProvisionMinimal(Subscription subscription) throws Exception {
    String suffix = String.valueOf(System.currentTimeMillis());
    String newNetworkName = "net" + suffix;

    Network network = subscription.networks().define(newNetworkName).withRegion(Region.US_WEST)
            .withNewResourceGroup().withAddressSpace("10.0.0.0/28").create();

    // Get info about a specific network using its id
    network = subscription.networks(network.id());
    printNetwork(network);/*from   w  w  w  .j a v a 2  s .  com*/

    // Listing all networks
    Map<String, Network> networks = subscription.networks().asMap();
    System.out.println(String.format("Network ids: \n\t%s", StringUtils.join(networks.keySet(), ",\n\t")));

    // Clean up
    String groupName = network.resourceGroup();
    subscription.networks().delete(network.id());
    subscription.resourceGroups().delete(groupName);
}

From source file:Main.java

private static List<String> filterParamNames(Map<String, Object> paramValueMap,
        List<String> ignoreParamNameList) {
    List<String> filteredParamNames = new ArrayList<>(paramValueMap.size());
    filteredParamNames.addAll(paramValueMap.keySet());
    if (ignoreParamNameList != null && ignoreParamNameList.size() > 0) {
        for (String ignoreParamName : ignoreParamNameList) {
            filteredParamNames.remove(ignoreParamName);
        }//from   w  w  w  .ja  v a 2 s .c  o  m
    }
    return filteredParamNames;
}

From source file:Main.java

public static String encodeUrl(String url) {
    Uri uri = Uri.parse(url);//  w ww.  ja v a 2s .c om

    try {
        Map<String, List<String>> splitQuery = splitQuery(uri);
        StringBuilder encodedQuery = new StringBuilder();
        for (String key : splitQuery.keySet()) {
            for (String value : splitQuery.get(key)) {
                if (encodedQuery.length() > 0) {
                    encodedQuery.append("&");
                }
                encodedQuery.append(key + "=" + URLEncoder.encode(value, "UTF-8"));
            }
        }
        String queryString = encodedQuery != null && encodedQuery.length() > 0 ? "?" + encodedQuery : "";

        URI baseUri = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), null, uri.getFragment());
        return baseUri + queryString;
    } catch (UnsupportedEncodingException ignore) {
    } catch (URISyntaxException ignore) {
    }

    return uri.toString();
}

From source file:com.android.volley.toolbox.HttpClientStack.java

private static void addHeaders(HttpUriRequest httpRequest, Map<String, String> headers) {
    for (String key : headers.keySet()) {
        httpRequest.setHeader(key, headers.get(key));
    }/*from w ww.  j a  v a2s . co  m*/
}