Example usage for java.util Map values

List of usage examples for java.util Map values

Introduction

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

Prototype

Collection<V> values();

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:com.evanmclean.evlib.commons.fileupload.FileUploadUtils.java

/**
 * Call FileItem.delete for all items that have been stored on disk.
 * //from w ww  .  j av  a2s .  com
 * @param file_items
 */
public static void delete(final Map<String, FileItem[]> file_items) {
    for (FileItem[] fis : file_items.values())
        for (FileItem fi : fis)
            if (!fi.isInMemory())
                fi.delete();
}

From source file:Main.java

public static <T> T getMapOnlyValue(Map<? extends Object, T> map) {
    if (map.size() != 1) {
        throw new IllegalArgumentException("Can't get map only value, it has " + map.size() + " elements");
    }/*  w w  w .  ja v  a2s .c o  m*/
    return map.values().iterator().next();
}

From source file:com.google.gdt.eclipse.designer.util.ui.ImageSelectionDialog.java

/**
 * Disposes given {@link Image}'s map.//from  w w w  . j  a  v  a2 s. c  om
 */
private static void disposeImagesMap(Map<?, Image> fileToImage) {
    for (Image image : fileToImage.values()) {
        image.dispose();
    }
}

From source file:com.github.fge.jackson.SampleNodeProvider.java

public static Iterator<Object[]> getSamples(final EnumSet<NodeType> types) {
    final Map<NodeType, JsonNode> map = Maps.newEnumMap(SAMPLE_DATA);
    map.keySet().retainAll(types);/*from  w ww .  j  a v a  2  s. c o m*/

    return FluentIterable.from(map.values()).transform(new Function<JsonNode, Object[]>() {
        @Override
        public Object[] apply(final JsonNode input) {
            return new Object[] { input };
        }
    }).iterator();
}

From source file:Main.java

private static List<Activity> getAllActivitiesHack() throws ClassNotFoundException, NoSuchMethodException,
        NoSuchFieldException, IllegalAccessException, InvocationTargetException {
    Class activityThreadClass = Class.forName("android.app.ActivityThread");
    Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
    Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
    activitiesField.setAccessible(true);
    Map activities = (Map) activitiesField.get(activityThread);
    List<Activity> activitiesList = new ArrayList<Activity>(activities.size());

    for (Object activityRecord : activities.values()) {
        Class activityRecordClass = activityRecord.getClass();
        Field activityField = activityRecordClass.getDeclaredField("activity");
        activityField.setAccessible(true);
        Activity activity = (Activity) activityField.get(activityRecord);
        activitiesList.add(activity);//w w w .j  a  v a 2 s .  c om
    }

    return activitiesList;
}

From source file:Main.java

/** Find all values of a named field in a nested Map containing fields, Maps, and Collections of Maps (Lists, etc) */
public static void findAllFieldsNestedMap(String key, Map theMap, Set<Object> valueSet) {
    Object localValue = theMap.get(key);
    if (localValue != null)
        valueSet.add(localValue);//ww w.j  ava  2 s .  c  o m
    for (Object value : theMap.values()) {
        if (value instanceof Map) {
            findAllFieldsNestedMap(key, (Map) value, valueSet);
        } else if (value instanceof Collection) {
            // only look in Collections of Maps
            for (Object colValue : (Collection) value) {
                if (colValue instanceof Map)
                    findAllFieldsNestedMap(key, (Map) colValue, valueSet);
            }
        }
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualJsonWrapper.java

public static Collection<String> getMostSpecificTypes(Individual individual, WebappDaoFactory wdf) {
    ObjectPropertyStatementDao opsDao = wdf.getObjectPropertyStatementDao();
    Map<String, String> mostSpecificTypes = opsDao
            .getMostSpecificTypesInClassgroupsForIndividual(individual.getURI());
    return mostSpecificTypes.values();
}

From source file:com.wrmsr.wava.basic.BasicSet.java

public static BasicSet build(Map<Name, Basic> basics) {
    return build(basics.values().stream());
}

From source file:Main.java

@SuppressLint("NewApi")
@SuppressWarnings("all")
private static boolean setProxyKK(WebView webView, String host, int port, String applicationClassName) {
    Context appContext = webView.getContext().getApplicationContext();
    if (null == host) {
        System.clearProperty("http.proxyHost");
        System.clearProperty("http.proxyPort");
        System.clearProperty("https.proxyHost");
        System.clearProperty("https.proxyPort");
    } else {// www .  j ava  2s.  co m
        System.setProperty("http.proxyHost", host);
        System.setProperty("http.proxyPort", port + "");
        System.setProperty("https.proxyHost", host);
        System.setProperty("https.proxyPort", port + "");
    }
    try {
        Class applictionCls = Class.forName(applicationClassName);
        Field loadedApkField = applictionCls.getField("mLoadedApk");
        loadedApkField.setAccessible(true);
        Object loadedApk = loadedApkField.get(appContext);
        Class loadedApkCls = Class.forName("android.app.LoadedApk");
        Field receiversField = loadedApkCls.getDeclaredField("mReceivers");
        receiversField.setAccessible(true);
        Map receivers = (Map) receiversField.get(loadedApk);
        for (Object receiverMap : receivers.values()) {
            for (Object rec : ((Map) receiverMap).keySet()) {
                Class clazz = rec.getClass();
                if (clazz.getName().contains("ProxyChangeListener")) {
                    Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
                    Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);

                    /*********** optional, may be need in future *************/
                    final String CLASS_NAME = "android.net.ProxyProperties";
                    Class cls = Class.forName(CLASS_NAME);
                    Constructor constructor = cls.getConstructor(String.class, Integer.TYPE, String.class);
                    constructor.setAccessible(true);
                    Object proxyProperties = constructor.newInstance(host, port, null);
                    intent.putExtra("proxy", (Parcelable) proxyProperties);
                    /*********** optional, may be need in future *************/

                    onReceiveMethod.invoke(rec, appContext, intent);
                }
            }
        }
        Log.d(LOG_TAG, "Setting proxy with >= 4.4 API successful!");
        return true;
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:playground.app.Application.java

public static HttpHandler createHttpHandler() throws IOException {
    Properties prop = new Properties();
    prop.load(Application.class.getClassLoader().getResourceAsStream("application.properties"));
    String profiles = prop.getProperty("profiles");
    if (profiles != null) {
        System.setProperty("spring.profiles.active", profiles);
    }//  ww  w  .  j  av  a2 s .c om

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("playground");

    DispatcherHandler dispatcherHandler = new DispatcherHandler();
    dispatcherHandler.setApplicationContext(context);

    Map<String, WebFilter> beanNameToFilters = context.getBeansOfType(WebFilter.class);
    WebFilter[] filters = beanNameToFilters.values().toArray(new WebFilter[0]);
    Arrays.sort(filters, AnnotationAwareOrderComparator.INSTANCE);

    return WebHttpHandlerBuilder.webHandler(dispatcherHandler)
            .exceptionHandlers(new ResponseStatusExceptionHandler()).filters(filters).build();
}