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:Main.java

public static void main(String[] args) {
    Map<String, Charset> charsets = Charset.availableCharsets();
    Iterator<Charset> iterator = charsets.values().iterator();
    while (iterator.hasNext()) {
        Charset cs = (Charset) iterator.next();
        System.out.println(cs.displayName());
        if (cs.isRegistered()) {
            System.out.print(" (registered): ");
        } else {/*from w  w w .  ja v  a 2s  .  c  om*/
            System.out.print(" (unregistered): ");
        }
    }
}

From source file:Main.java

public static void main(String[] a) {
    Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");

    Collection set = map.values();
    Iterator iter = set.iterator();

    while (iter.hasNext()) {
        System.out.println(iter.next());
    }/*  www.  j  a v  a  2  s  .c  o m*/
}

From source file:at.ac.tuwien.infosys.logger.ProvisioningLogger.java

public static void main(String[] args) {
    Map<String, Log> deviceLogs = Collections.synchronizedMap(new HashMap<String, Log>());

    System.out.println(deviceLogs.values().contains(null));

    deviceLogs.put("id1", null);

    System.out.println(deviceLogs.values().contains(null));
}

From source file:com.khartec.waltz.jobs.DatabaseHarness.java

public static void main(String[] args) throws ParseException {

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);

    DatabaseInformationDao databaseDao = ctx.getBean(DatabaseInformationDao.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);

    List<DatabaseInformation> dbs = databaseDao.findByApplicationId(801L);
    System.out.println(dbs.size());

    SelectConditionStep<Record1<Long>> idSelector = dsl.select(APPLICATION.ID).from(APPLICATION)
            .where(APPLICATION.ID.in(801L, 802L, 803L));

    Map<Long, List<DatabaseInformation>> moreDbs = databaseDao.findByAppSelector(idSelector);
    System.out.println(moreDbs.size());
    System.out.println(moreDbs.values().size());

}

From source file:com.stratio.streaming.StreamingEngine.java

public static void main(String[] args) {
    try (AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(
            BaseConfiguration.class)) {

        annotationConfigApplicationContext.registerShutdownHook();

        Map<String, JavaStreamingContext> contexts = annotationConfigApplicationContext
                .getBeansOfType(JavaStreamingContext.class);

        for (JavaStreamingContext context : contexts.values()) {
            context.start();/*from   www.j a va 2 s.co m*/
            log.info("Started context {}", context.sparkContext().appName());
        }
        contexts.get("actionContext").awaitTermination();
    } catch (Exception e) {
        log.error("Fatal error", e);
    }
}

From source file:Main.java

public static void main(String[] argv) {
    List collection = new ArrayList();

    // For a set or list
    for (Iterator it = collection.iterator(); it.hasNext();) {
        Object element = it.next();
    }/*www .j  ava  2 s.c o  m*/
    Map map = new HashMap();
    // For keys of a map
    for (Iterator it = map.keySet().iterator(); it.hasNext();) {
        Object key = it.next();
    }

    // For values of a map
    for (Iterator it = map.values().iterator(); it.hasNext();) {
        Object value = it.next();
    }

    // For both the keys and values of a map
    for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
        Map.Entry entry = (Map.Entry) it.next();
        Object key = entry.getKey();
        Object value = entry.getValue();
    }
}

From source file:Main.java

public static void main(String[] args) {
    Map<String, Student> map = new HashMap<>();
    map.put("s1", new Student(5, "A"));
    map.put("s2", new Student(4, "B"));
    map.put("s3", new Student(10, "C"));
    map.put("s4", new Student(2, "D"));
    Collection<Student> students = map.values();
    List<Student> list = new ArrayList<>(students);
    Collections.sort(list, new MyComparator());

    for (Iterator<Student> it = list.iterator(); it.hasNext();) {
        Student stdn = (Student) it.next();
        System.out.println("Student id : " + stdn.id);
        System.out.println("Student Name : " + stdn.name);
    }/*from ww  w.j  a  va2s .co m*/
}

From source file:CollectionAll.java

public static void main(String[] args) {
    List list1 = new LinkedList();
    list1.add("list");
    list1.add("dup");
    list1.add("x");
    list1.add("dup");
    traverse(list1);/*  w  w  w .  jav a  2s . co m*/
    List list2 = new ArrayList();
    list2.add("list");
    list2.add("dup");
    list2.add("x");
    list2.add("dup");
    traverse(list2);
    Set set1 = new HashSet();
    set1.add("set");
    set1.add("dup");
    set1.add("x");
    set1.add("dup");
    traverse(set1);
    SortedSet set2 = new TreeSet();
    set2.add("set");
    set2.add("dup");
    set2.add("x");
    set2.add("dup");
    traverse(set2);
    LinkedHashSet set3 = new LinkedHashSet();
    set3.add("set");
    set3.add("dup");
    set3.add("x");
    set3.add("dup");
    traverse(set3);
    Map m1 = new HashMap();
    m1.put("map", "Java2s");
    m1.put("dup", "Kava2s");
    m1.put("x", "Mava2s");
    m1.put("dup", "Lava2s");
    traverse(m1.keySet());
    traverse(m1.values());
    SortedMap m2 = new TreeMap();
    m2.put("map", "Java2s");
    m2.put("dup", "Kava2s");
    m2.put("x", "Mava2s");
    m2.put("dup", "Lava2s");
    traverse(m2.keySet());
    traverse(m2.values());
    LinkedHashMap /* from String to String */ m3 = new LinkedHashMap();
    m3.put("map", "Java2s");
    m3.put("dup", "Kava2s");
    m3.put("x", "Mava2s");
    m3.put("dup", "Lava2s");
    traverse(m3.keySet());
    traverse(m3.values());
}

From source file:Main.java

public static void main(String[] a) {
    Map<String, String> yourMap = new HashMap<String, String>();
    yourMap.put("1", "one");
    yourMap.put("2", "two");
    yourMap.put("3", "three");

    Map<String, Object> map = new LinkedHashMap<String, Object>();

    List<String> keyList = new ArrayList<String>(yourMap.keySet());
    List<String> valueList = new ArrayList<String>(yourMap.values());
    Set<String> sortedSet = new TreeSet<String>(valueList);

    Object[] sortedArray = sortedSet.toArray();
    int size = sortedArray.length;

    for (int i = 0; i < size; i++) {
        map.put(keyList.get(valueList.indexOf(sortedArray[i])), sortedArray[i]);
    }//w  ww  .ja v a 2s .c  o m

    Set ref = map.keySet();
    Iterator it = ref.iterator();

    while (it.hasNext()) {
        String i = (String) it.next();
        System.out.println(i);
    }
}

From source file:org.onebusaway.nyc.vehicle_tracking.utility.SensorModelVerificationMain.java

public static void main(String[] args)
        throws ParseException, ClassNotFoundException, CsvEntityIOException, IOException {

    Options options = new Options();
    options.addOption(ARG_RULE, true, "sensor model rule class");
    GnuParser parser = new GnuParser();
    CommandLine cli = parser.parse(options, args);

    args = cli.getArgs();/* w  ww  .j  a  va 2 s. c  om*/

    if (args.length != 2) {
        System.err.println("usage: data-sources.xml tracesPath");
        System.exit(-1);
    }

    ConfigurableApplicationContext context = ContainerLibrary.createContext(
            "classpath:org/onebusaway/nyc/vehicle_tracking/application-context.xml",
            "classpath:org/onebusaway/transit_data_federation/application-context.xml", args[0]);

    SensorModelVerificationMain m = new SensorModelVerificationMain();
    context.getAutowireCapableBeanFactory().autowireBean(m);

    Collection<SensorModelRule> rules = Collections.emptyList();

    if (cli.hasOption(ARG_RULE)) {
        Class<?> ruleClass = Class.forName(cli.getOptionValue(ARG_RULE));
        rules = Arrays.asList((SensorModelRule) context.getBean(ruleClass));
    } else {
        Map<String, SensorModelRule> rulesByName = context.getBeansOfType(SensorModelRule.class);
        rules = rulesByName.values();
    }

    m.setRules(rules);

    File tracePath = new File(args[1]);
    List<File> traces = new ArrayList<File>();
    getAllTraces(tracePath, traces);
    m.setTraces(traces);

    try {
        m.run();
    } catch (Throwable ex) {
        ex.printStackTrace();
        System.exit(-1);
    }

    System.exit(0);
}