Search in sources :

Example 46 with Iterator

use of java.util.Iterator in project groovy-core by groovy.

the class StatementWriter method writeSwitch.

public void writeSwitch(SwitchStatement statement) {
    controller.getAcg().onLineNumber(statement, "visitSwitch");
    writeStatementLabel(statement);
    statement.getExpression().visit(controller.getAcg());
    // switch does not have a continue label. use its parent's for continue
    Label breakLabel = controller.getCompileStack().pushSwitch();
    int switchVariableIndex = controller.getCompileStack().defineTemporaryVariable("switch", true);
    List caseStatements = statement.getCaseStatements();
    int caseCount = caseStatements.size();
    Label[] labels = new Label[caseCount + 1];
    for (int i = 0; i < caseCount; i++) {
        labels[i] = new Label();
    }
    int i = 0;
    for (Iterator iter = caseStatements.iterator(); iter.hasNext(); i++) {
        CaseStatement caseStatement = (CaseStatement) iter.next();
        writeCaseStatement(caseStatement, switchVariableIndex, labels[i], labels[i + 1]);
    }
    statement.getDefaultStatement().visit(controller.getAcg());
    controller.getMethodVisitor().visitLabel(breakLabel);
    controller.getCompileStack().pop();
}
Also used : CaseStatement(org.codehaus.groovy.ast.stmt.CaseStatement) Label(org.objectweb.asm.Label) Iterator(java.util.Iterator) List(java.util.List)

Example 47 with Iterator

use of java.util.Iterator in project groovy-core by groovy.

the class Janitor method cleanup.

public void cleanup() {
    Iterator iterator = pending.iterator();
    while (iterator.hasNext()) {
        HasCleanup object = (HasCleanup) iterator.next();
        try {
            object.cleanup();
        } catch (Exception e) {
        // Ignore
        }
    }
    pending.clear();
}
Also used : Iterator(java.util.Iterator)

Example 48 with Iterator

use of java.util.Iterator in project groovy-core by groovy.

the class CharacterRangeTest method testIterate.

/**
     * Tests iterating through the range.
     */
public void testIterate() {
    Iterator iter = range.iterator();
    assertEquals(FROM, iter.next());
    for (char expected = (char) (FROM.charValue() + 1); expected <= TO.charValue(); expected++) {
        assertEquals(expected, ((Character) iter.next()).charValue());
    }
}
Also used : Iterator(java.util.Iterator)

Example 49 with Iterator

use of java.util.Iterator in project grails-core by grails.

the class LazyMetaPropertyMap method putAll.

public void putAll(Map map) {
    for (Iterator i = map.keySet().iterator(); i.hasNext(); ) {
        Object key = i.next();
        put(key, map.get(key));
    }
}
Also used : Iterator(java.util.Iterator)

Example 50 with Iterator

use of java.util.Iterator in project grails-core by grails.

the class DefaultUrlCreator method appendRequestParams.

/*
     * Appends all the request parameters to the URI buffer
     */
private void appendRequestParams(FastStringWriter actualUriBuf, Map<Object, Object> params, String encoding) {
    boolean querySeparator = false;
    for (Map.Entry<Object, Object> entry : params.entrySet()) {
        Object name = entry.getKey();
        if (name.equals(GrailsControllerClass.CONTROLLER) || name.equals(GrailsControllerClass.ACTION) || name.equals(ARGUMENT_ID)) {
            continue;
        }
        if (!querySeparator) {
            actualUriBuf.append('?');
            querySeparator = true;
        } else {
            actualUriBuf.append(ENTITY_AMPERSAND);
        }
        Object value = entry.getValue();
        if (value instanceof Collection) {
            Collection values = (Collection) value;
            Iterator valueIterator = values.iterator();
            while (valueIterator.hasNext()) {
                Object currentValue = valueIterator.next();
                appendRequestParam(actualUriBuf, name, currentValue, encoding);
                if (valueIterator.hasNext()) {
                    actualUriBuf.append(ENTITY_AMPERSAND);
                }
            }
        } else if (value != null && value.getClass().isArray()) {
            Object[] array = (Object[]) value;
            for (int j = 0; j < array.length; j++) {
                Object currentValue = array[j];
                appendRequestParam(actualUriBuf, name, currentValue, encoding);
                if (j < (array.length - 1)) {
                    actualUriBuf.append(ENTITY_AMPERSAND);
                }
            }
        } else {
            appendRequestParam(actualUriBuf, name, value, encoding);
        }
    }
}
Also used : Iterator(java.util.Iterator) Collection(java.util.Collection) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Iterator (java.util.Iterator)8930 ArrayList (java.util.ArrayList)2267 Set (java.util.Set)1895 HashMap (java.util.HashMap)1828 Map (java.util.Map)1714 List (java.util.List)1622 HashSet (java.util.HashSet)1602 Test (org.junit.Test)624 IOException (java.io.IOException)524 Collection (java.util.Collection)377 Region (org.apache.geode.cache.Region)240 SSOException (com.iplanet.sso.SSOException)227 File (java.io.File)216 LinkedList (java.util.LinkedList)213 TreeSet (java.util.TreeSet)191 LinkedHashMap (java.util.LinkedHashMap)181 Entry (java.util.Map.Entry)174 SMSException (com.sun.identity.sm.SMSException)169 ListIterator (java.util.ListIterator)146 TreeMap (java.util.TreeMap)145