Example usage for java.util List iterator

List of usage examples for java.util List iterator

Introduction

In this page you can find the example usage for java.util List iterator.

Prototype

Iterator<E> iterator();

Source Link

Document

Returns an iterator over the elements in this list in proper sequence.

Usage

From source file:brainleg.app.util.AppWeb.java

/**
 * Copied from ITNProxy//from   w  w  w.j a  v a  2 s . c  o m
 * @param params
 * @return
 * @throws UnsupportedEncodingException
 */
private static byte[] join(List<NameValuePair> params) throws UnsupportedEncodingException {
    StringBuilder builder = new StringBuilder();

    Iterator<NameValuePair> it = params.iterator();

    while (it.hasNext()) {
        NameValuePair param = it.next();

        if (StringUtil.isEmpty(param.getName()))
            throw new IllegalArgumentException(param.toString());

        if (StringUtil.isNotEmpty(param.getValue()))
            builder.append(param.getName()).append("=").append(URLEncoder.encode(param.getValue(), ENCODING));

        if (it.hasNext())
            builder.append(POST_DELIMITER);
    }

    return builder.toString().getBytes();
}

From source file:com.arvato.thoroughly.util.CommonUtils.java

/**
 * @param ins//from  w w w  . ja v  a2  s.co  m
 * @return String
 */
public static String readFile(InputStream ins) {
    List<String> list;
    StringBuffer sb = new StringBuffer();
    try {
        list = IOUtils.readLines(ins, "UTF-8");
        Iterator<String> iter = list.iterator();
        while (iter.hasNext()) {
            sb.append(iter.next());
        }
    } catch (IOException e) {
        LOGGER.error("Exception while reading file " + e.getMessage(), e);
    }
    return sb.toString();
}

From source file:com.aurel.track.persist.TRolePeer.java

private static List<TRoleBean> convertTorqueListToBeanList(List<TRole> torqueList) {
    List<TRoleBean> beanList = new LinkedList<TRoleBean>();
    if (torqueList != null) {
        Iterator<TRole> itrTorqueList = torqueList.iterator();
        while (itrTorqueList.hasNext()) {
            beanList.add(itrTorqueList.next().getBean());
        }//from   w w w . j  ava  2  s .  c om
    }
    return beanList;
}

From source file:com.googlecode.jsfFlex.myFaces.ClassUtils.java

/**
 * @param resource       Name of resource(s) to find in classpath
 * @param defaultObject  The default object to use to determine the class loader (if none associated with current thread.)
 * @return Iterator over URL Objects/*w ww  . j a va2  s .  com*/
 */
public static Iterator getResources(String resource, Object defaultObject) {
    try {
        Enumeration resources = getCurrentLoader(defaultObject).getResources(resource);
        List lst = new ArrayList();
        while (resources.hasMoreElements()) {
            lst.add(resources.nextElement());
        }
        return lst.iterator();
    } catch (IOException e) {
        log.error(e.getMessage(), e);
        throw new FacesException(e);
    }
}

From source file:net.amigocraft.mpt.json.JSONPrettyPrinter.java

public static String listToJsonString(List list) throws IOException {
    StringBuilder sb = new StringBuilder();

    if (list == null) {
        sb.append("null");
        return sb.toString();
    }/*  w  ww.  j av a2s.co m*/

    boolean first = true;
    Iterator iter = list.iterator();

    String newLine = System.getProperty("line.separator");

    sb.append('[');
    while (iter.hasNext()) {
        if (first)
            first = false;
        else
            sb.append(',').append(newLine);
        for (int i = 0; i < column * INDENT + 4; i++)
            sb.append(' ');

        Object value = iter.next();
        if (value == null) {
            sb.append("null");
            continue;
        }

        sb.append(valueToJsonString(value));
    }
    sb.append(newLine);
    for (int i = 0; i < column * INDENT; i++)
        sb.append(' ');
    sb.append(']');
    return sb.toString();
}

From source file:com.lithium.flow.matcher.StringMatchers.java

@Nonnull
private static StringMatcher buildComposite(@Nonnull List<StringMatcher> matchers, boolean lower) {
    matchers = matchers.stream().filter(matcher -> !(matcher instanceof NoStringMatcher)).collect(toList());
    if (matchers.size() == 0) {
        return new NoStringMatcher();
    } else if (matchers.size() == 1) {
        StringMatcher matcher = matchers.iterator().next();
        return lower ? new LowerStringMatcher(matcher) : matcher;
    } else {//ww w  .  java 2 s  .co m
        return new CompositeOrStringMatcher(matchers, lower);
    }
}

From source file:edu.illinois.enforcemop.examples.apache.pool.TestObjectPool.java

static void removeDestroyObjectCall(List calls) {
    Iterator iter = calls.iterator();
    while (iter.hasNext()) {
        MethodCall call = (MethodCall) iter.next();
        if ("destroyObject".equals(call.getName())) {
            iter.remove();//from  w ww.j  ava2s .  c  o m
        }
    }
}

From source file:edu.ksu.cis.indus.tools.slicer.criteria.specification.SliceCriterionSpec.java

/**
 * Extracts the names of the given type.
 *
 * @param parameterTypes is the collection of types whose names should be extracted.
 *
 * @return the names of the type./* ww w  .  j  a v  a2s  .c  o m*/
 *
 * @pre paramterTypes != null
 * @post result != null
 */
public static List<String> getNamesOfTypes(final List<Type> parameterTypes) {
    final List<String> _result = new ArrayList<String>();

    for (final Iterator<Type> _i = parameterTypes.iterator(); _i.hasNext();) {
        _result.add(_i.next().toString().replace(']', ' ').trim());
    }
    return _result;
}

From source file:com.allinfinance.startup.init.MenuInfoUtil.java

/**
 * ???/*www .ja  v a 2 s  . c  o m*/
 * 
 * @param degree
 * @return
 * 2011-9-16?11:17:18
 */
@SuppressWarnings("unchecked")
public static HashSet<String> getAuthSet(String degree) {
    HashSet<String> set = new HashSet<String>();
    ICommQueryDAO commQueryDAO = (ICommQueryDAO) ContextUtil.getBean("CommQueryDAO");
    String sql = "select VALUE_ID FROM TBL_ROLE_FUNC_MAP ,TBL_ROLE_INF WHERE ROLE_ID = KEY_ID and KEY_ID = "
            + degree;
    List<Object> funcMapList = commQueryDAO.findBySQLQuery(sql);

    Iterator<Object> it = funcMapList.iterator();
    while (it.hasNext()) {
        Object obj = it.next();
        if (!StringUtil.isNull(obj)) {
            set.add(obj.toString());
        }
    }
    return set;
}

From source file:de.pixida.logtest.automatondefinitions.SomeTestAutomaton.java

private static void checkEdgesLinkNodesCorrectly(final List<? extends INodeDefinition> nodes,
        final List<? extends IEdgeDefinition> edges) {
    final int firstNode = 0;
    final int secondNode = 1;
    final int thirdNode = 2;
    final int fourthNode = 3;
    final Iterator<? extends IEdgeDefinition> edgesIt = edges.iterator();

    IEdgeDefinition edge = edgesIt.next();
    Assert.assertEquals(nodes.get(firstNode), edge.getSource());
    Assert.assertEquals(nodes.get(secondNode), edge.getDestination());

    edge = edgesIt.next();/*  w  ww .  jav a2 s.co m*/
    Assert.assertEquals(nodes.get(firstNode), edge.getSource());
    Assert.assertEquals(nodes.get(thirdNode), edge.getDestination());

    edge = edgesIt.next();
    Assert.assertEquals(nodes.get(firstNode), edge.getSource());
    Assert.assertEquals(nodes.get(fourthNode), edge.getDestination());

    Assert.assertFalse(edgesIt.hasNext());
}