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

/**
 * Fold up a collection into a string.//from   w w  w  . ja va  2 s  .  c  o  m
 */
public static String join(Collection a_collection, String a_sDelimiter)
/*
---------------------------------------------------------------
d1      17-Oct-2006      Adam Bones      Created 
-----------------------------------------------------------------
 */
{
    StringBuffer buffer = new StringBuffer();
    Iterator it = a_collection.iterator();
    while (it.hasNext()) {
        buffer.append(it.next());
        if (it.hasNext()) {
            buffer.append(a_sDelimiter);
        }
    }
    return buffer.toString();
}

From source file:Main.java

public static String implode(Iterator it) {
    StringBuilder sb = new StringBuilder();
    while (it.hasNext()) {
        sb.append(it.next());
        sb.append(", ");
    }//from  w w w  .j  a  v  a  2 s.c om

    return sb.toString().replaceAll(", +$", "");
}

From source file:Main.java

protected static void checkExcludedEmail(Set excluded, String email) throws CertPathValidatorException {
    if (excluded.isEmpty()) {
        return;/*from  w  w w.j  a va 2s.c o  m*/
    }

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

    while (it.hasNext()) {
        String str = (String) it.next();
        if (sub.endsWith(str)) {
            throw new CertPathValidatorException("Subject email address is from an excluded subtree");
        }
    }
}

From source file:Main.java

public static String toString(Iterable<Object> pathItrb) {
    LinkedList<Object> list = new LinkedList<Object>();
    Iterator itr = pathItrb.iterator();
    while (itr.hasNext()) {
        list.addFirst(itr.next());
    }//from w  w  w .  j  av  a2 s . c  o  m
    //
    StringBuilder sb = new StringBuilder();
    boolean isFirst = true;
    for (Object obj : list) {
        if (isFirst) {
            isFirst = false;
        } else {
            sb.append("/"); // NOI18N
        }
        sb.append(obj.toString());
    }
    //
    return sb.toString();
}

From source file:Main.java

public static String toPathString(Iterable<File> files, String separator) {
    final StringBuilder builder = new StringBuilder();
    final Iterator<File> fileIt = files.iterator();
    while (fileIt.hasNext()) {
        builder.append(fileIt.next().getAbsolutePath());
        if (fileIt.hasNext()) {
            builder.append(separator);/*from w  w  w. ja  v a  2s .c  om*/
        }
    }
    return builder.toString();
}

From source file:Main.java

/**
 * Joins a collection of strings to a single string, all parts are merged with a delimiter string.
 *
 * @param aContainer//from w  ww.  j  a v a 2s.  c  o m
 * @param aDelimiter
 * @return
 */
public static String join(final Iterable<String> aContainer, final String aDelimiter) {
    StringBuilder builder = new StringBuilder();
    Iterator<String> it = aContainer.iterator();
    while (it.hasNext()) {
        builder.append(it.next());
        if (it.hasNext())
            builder.append(aDelimiter);
    }
    return builder.toString();
}

From source file:Main.java

public static String join(Collection<?> s, String delimiter) {
    StringBuilder builder = new StringBuilder();
    Iterator<?> iter = s.iterator();
    while (iter.hasNext()) {
        builder.append(iter.next());
        if (iter.hasNext()) {
            builder.append(delimiter);/* www.  j  a  v  a2 s .  c  om*/
        }
    }
    return builder.toString();
}

From source file:Main.java

public static Map<String, String> parse(JSONObject json, Map<String, String> out) throws JSONException {
    Iterator<String> keys = json.keys();
    while (keys.hasNext()) {
        String key = keys.next();
        String val = null;
        try {// w  ww .  ja v  a 2  s .  c  om
            JSONObject value = json.getJSONObject(key);
            parse(value, out);
        } catch (Exception e) {
            val = json.getString(key);
        }

        if (val != null) {
            out.put(key, val);
        }
    }
    return out;
}

From source file:Main.java

public static boolean containsInstance(Collection collection, Object element) {
    if (collection != null) {
        Iterator it = collection.iterator();

        while (it.hasNext()) {
            Object candidate = it.next();
            if (candidate == element) {
                return true;
            }/*w  ww  . ja  v  a2 s  .c  o  m*/
        }
    }

    return false;
}

From source file:Main.java

public static boolean containsInstance(Collection collection, Object element) {
    if (collection != null) {
        Iterator i$ = collection.iterator();

        while (i$.hasNext()) {
            Object candidate = i$.next();
            if (candidate == element) {
                return true;
            }//from  w  w  w  . jav  a  2 s . co  m
        }
    }

    return false;
}