Search in sources :

Example 41 with Iterator

use of java.util.Iterator in project nutz by nutzam.

the class Collection2Array method cast.

@Override
public Object cast(Collection src, Class<?> toType, String... args) throws FailToCastObjectException {
    Class<?> compType = toType.getComponentType();
    Object ary = Array.newInstance(compType, src.size());
    int index = 0;
    for (Iterator it = src.iterator(); it.hasNext(); ) {
        Array.set(ary, index++, Castors.me().castTo(it.next(), compType));
    }
    return ary;
}
Also used : Iterator(java.util.Iterator)

Example 42 with Iterator

use of java.util.Iterator in project otter by alibaba.

the class IbatisDataColumnPairDAO method insertBatch.

public void insertBatch(List<DataColumnPairDO> dataColumnPairDos) {
    try {
        getSqlMapClientTemplate().getSqlMapClient().startBatch();
        Iterator it = dataColumnPairDos.iterator();
        while (it.hasNext()) {
            DataColumnPairDO dataColumnPairDo = (DataColumnPairDO) it.next();
            getSqlMapClientTemplate().getSqlMapClient().insert("insertDataColumnPair", dataColumnPairDo);
        }
        getSqlMapClientTemplate().getSqlMapClient().executeBatch();
    } catch (SQLException ex1) {
        ex1.printStackTrace();
    }
}
Also used : SQLException(java.sql.SQLException) Iterator(java.util.Iterator) DataColumnPairDO(com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.DataColumnPairDO)

Example 43 with Iterator

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

the class ClosureWriter method getClosureSharedVariables.

protected Parameter[] getClosureSharedVariables(ClosureExpression ce) {
    VariableScope scope = ce.getVariableScope();
    Parameter[] ret = new Parameter[scope.getReferencedLocalVariablesCount()];
    int index = 0;
    for (Iterator iter = scope.getReferencedLocalVariablesIterator(); iter.hasNext(); ) {
        Variable element = (org.codehaus.groovy.ast.Variable) iter.next();
        Parameter p = new Parameter(element.getType(), element.getName());
        p.setOriginType(element.getOriginType());
        p.setClosureSharedVariable(element.isClosureSharedVariable());
        ret[index] = p;
        index++;
    }
    return ret;
}
Also used : Variable(org.codehaus.groovy.ast.Variable) Iterator(java.util.Iterator) Parameter(org.codehaus.groovy.ast.Parameter) VariableScope(org.codehaus.groovy.ast.VariableScope)

Example 44 with Iterator

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

the class AsmClassGenerator method visitArrayExpression.

public void visitArrayExpression(ArrayExpression expression) {
    MethodVisitor mv = controller.getMethodVisitor();
    ClassNode elementType = expression.getElementType();
    String arrayTypeName = BytecodeHelper.getClassInternalName(elementType);
    List sizeExpression = expression.getSizeExpression();
    int size = 0;
    int dimensions = 0;
    if (sizeExpression != null) {
        for (Iterator iter = sizeExpression.iterator(); iter.hasNext(); ) {
            Expression element = (Expression) iter.next();
            if (element == ConstantExpression.EMPTY_EXPRESSION)
                break;
            dimensions++;
            // let's convert to an int
            element.visit(this);
            controller.getOperandStack().doGroovyCast(ClassHelper.int_TYPE);
        }
        controller.getOperandStack().remove(dimensions);
    } else {
        size = expression.getExpressions().size();
        BytecodeHelper.pushConstant(mv, size);
    }
    int storeIns = AASTORE;
    if (sizeExpression != null) {
        arrayTypeName = BytecodeHelper.getTypeDescription(expression.getType());
        mv.visitMultiANewArrayInsn(arrayTypeName, dimensions);
    } else if (ClassHelper.isPrimitiveType(elementType)) {
        int primType = 0;
        if (elementType == ClassHelper.boolean_TYPE) {
            primType = T_BOOLEAN;
            storeIns = BASTORE;
        } else if (elementType == ClassHelper.char_TYPE) {
            primType = T_CHAR;
            storeIns = CASTORE;
        } else if (elementType == ClassHelper.float_TYPE) {
            primType = T_FLOAT;
            storeIns = FASTORE;
        } else if (elementType == ClassHelper.double_TYPE) {
            primType = T_DOUBLE;
            storeIns = DASTORE;
        } else if (elementType == ClassHelper.byte_TYPE) {
            primType = T_BYTE;
            storeIns = BASTORE;
        } else if (elementType == ClassHelper.short_TYPE) {
            primType = T_SHORT;
            storeIns = SASTORE;
        } else if (elementType == ClassHelper.int_TYPE) {
            primType = T_INT;
            storeIns = IASTORE;
        } else if (elementType == ClassHelper.long_TYPE) {
            primType = T_LONG;
            storeIns = LASTORE;
        }
        mv.visitIntInsn(NEWARRAY, primType);
    } else {
        mv.visitTypeInsn(ANEWARRAY, arrayTypeName);
    }
    for (int i = 0; i < size; i++) {
        mv.visitInsn(DUP);
        BytecodeHelper.pushConstant(mv, i);
        Expression elementExpression = expression.getExpression(i);
        if (elementExpression == null) {
            ConstantExpression.NULL.visit(this);
        } else {
            elementExpression.visit(this);
            controller.getOperandStack().doGroovyCast(elementType);
        }
        mv.visitInsn(storeIns);
        controller.getOperandStack().remove(1);
    }
    controller.getOperandStack().push(expression.getType());
}
Also used : InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) InterfaceHelperClassNode(org.codehaus.groovy.ast.InterfaceHelperClassNode) ClassNode(org.codehaus.groovy.ast.ClassNode) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) MethodVisitor(org.objectweb.asm.MethodVisitor)

Example 45 with Iterator

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

the class Grails5535Factory method replaceProperties.

/**
     * Replaces any properties that appear in the supplied string
     * with their actual values
     *
     * @param str the string to replace the properties in
     * @return the same string but with any properties expanded out to their
     * actual values
     */
private String replaceProperties(String str) {
    Set props = configProps.entrySet();
    for (Iterator it = props.iterator(); it.hasNext(); ) {
        Map.Entry entry = (Map.Entry) it.next();
        String key = (String) entry.getKey();
        int idx;
        while ((idx = str.indexOf(key)) >= 0) {
            StringBuilder buf = new StringBuilder(100);
            buf.append(str.substring(0, idx));
            buf.append(entry.getValue());
            buf.append(str.substring(idx + key.length()));
            str = buf.toString();
        }
    }
    return str;
}
Also used : Set(java.util.Set) Iterator(java.util.Iterator) 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