Example usage for java.util Iterator next

List of usage examples for java.util Iterator next

Introduction

In this page you can find the example usage for java.util Iterator next.

Prototype

E next();

Source Link

Document

Returns the next element in the iteration.

Usage

From source file:Main.java

public static boolean hasValue(Map<?, ?> map, String key, String val) {
    if (map == null) {
        return false;
    }// ww w.jav  a2  s.co m
    Collection<?> col = (Collection<?>) map.get(key);
    if (col == null) {
        return false;
    }
    Iterator<?> itr = col.iterator();
    while (itr.hasNext()) {
        String str = (String) itr.next();
        if (str.equalsIgnoreCase(val)) {
            return true;
        }
        if (str.toLowerCase().startsWith(val)) {
            return true;
        }
    }
    return false;
}

From source file:Main.java

public static void removeNullValues(List<?> list) {

    Iterator<?> iterator = list.iterator();

    while (iterator.hasNext()) {

        Object value = iterator.next();

        if (value == null) {

            iterator.remove();/*from   w  w w.  j a v a2  s  .  co  m*/
        }
    }
}

From source file:Main.java

public static void writeToWriter(Iterator it, Writer out) throws IOException {
    while (it.hasNext()) {
        out.write(it.next().toString());
        out.write(newLine);/*from   ww w .  j  a  v a 2 s  . c  o  m*/
    }
    out.flush();
}

From source file:Main.java

public static void dumpIntent(Intent i) {

    Bundle bundle = i.getExtras();//  ww  w  .j av a  2 s  . c o m
    if (bundle != null) {
        Set<String> keys = bundle.keySet();
        Iterator<String> it = keys.iterator();
        while (it.hasNext()) {
            String key = it.next();
        }
    }
}

From source file:Main.java

public static ArrayList<Integer> filterPoint(ArrayList<Integer> timePoints) {
    int lastPeriod = -1;
    logInConsole(timePoints);//from ww  w.j a  v  a  2s.  c o m
    Iterator<Integer> it = timePoints.iterator();
    while (it.hasNext()) {
        int tmp = it.next();
        if (lastPeriod != -1 && tmp - lastPeriod < MIN_PERIOD) {
            it.remove();
        } else {
            lastPeriod = tmp;
        }
    }
    logInConsole(timePoints);
    return timePoints;
}

From source file:Main.java

public static <T> List<T> ToList2(Collection<T> values) {
    List<T> alllist = new ArrayList<T>();
    Iterator<T> iterator = values.iterator();
    T obj = null;/*from w w w  . j ava 2 s . c  om*/
    while (iterator.hasNext()) {
        obj = iterator.next();
        alllist.add(obj);
    }
    return alllist;
}

From source file:Main.java

public static Map<Object, Object> copySafelyToObjectToObjectMap(Map<?, ?> map) {
    Map<Object, Object> castedCopy = new LinkedHashMap<Object, Object>();

    if (map == null) {
        return castedCopy;
    }//from  ww w. j a v  a 2 s .c  o  m

    Iterator<?> it = map.keySet().iterator();
    while (it.hasNext()) {
        Object nextKey = it.next();
        castedCopy.put(nextKey, map.get(nextKey));
    }
    return castedCopy;
}

From source file:Main.java

public static void putAllInHashMapByGivenAttribute(HashMap map, Collection col, String attribName) {

    Iterator iter = col.iterator();
    while (iter.hasNext())
        putInHashMapByGivenAttribute(map, iter.next(), attribName);
}

From source file:Main.java

public static String join(Collection<?> items, String delimiter) {
    if (items == null || items.isEmpty()) {
        return "";
    }/*from w  ww . j  av  a 2  s  .c o m*/

    final Iterator<?> iter = items.iterator();
    final StringBuilder buffer = new StringBuilder(iter.next().toString());

    while (iter.hasNext()) {
        buffer.append(delimiter).append(iter.next());
    }

    return buffer.toString();
}

From source file:Main.java

protected static void checkPermittedEmail(Set permitted, String email) throws CertPathValidatorException {
    if (permitted.isEmpty()) {
        return;//from w ww. j  ava  2 s  .c o  m
    }

    String sub = email.substring(email.indexOf('@') + 1);
    Iterator it = permitted.iterator();

    while (it.hasNext()) {
        String str = (String) it.next();

        if (sub.endsWith(str)) {
            return;
        }
    }

    throw new CertPathValidatorException("Subject email address is not from a permitted subtree");
}