Example usage for java.util SortedMap size

List of usage examples for java.util SortedMap size

Introduction

In this page you can find the example usage for java.util SortedMap size.

Prototype

int size();

Source Link

Document

Returns the number of key-value mappings in this map.

Usage

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientExtensionsConfTable.java

public CFAstExtensionsConfBuff[] readAllDerived(CFAstAuthorization Authorization) {
    final String S_ProcName = "readAllDerived";
    String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAstXMsgExtensionsConfMessageFormatter.formatExtensionsConfRqstReadAll("\n\t\t\t") + "\n"
            + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/*from w ww  .j  a  va 2 s  . c o m*/
    CFAstXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAstConfigurationFilePKey, ICFAstConfigurationFileObj> sortedMap = (SortedMap<CFAstConfigurationFilePKey, ICFAstConfigurationFileObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAstExtensionsConfBuff arr[] = new CFAstExtensionsConfBuff[sz];
    Iterator<ICFAstConfigurationFileObj> iter = sortedMap.values().iterator();
    ICFAstExtensionsConfObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAstExtensionsConfObj) iter.next();
        arr[idx] = cur.getExtensionsConfBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientSecGroupMemberTable.java

public CFAstSecGroupMemberBuff[] readAllDerived(CFAstAuthorization Authorization) {
    final String S_ProcName = "readAllDerived";
    String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAstXMsgSecGroupMemberMessageFormatter.formatSecGroupMemberRqstReadAll("\n\t\t\t") + "\n"
            + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }//  w ww  .  ja v  a2 s  . c  o  m
    CFAstXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAstSecGroupMemberPKey, ICFAstSecGroupMemberObj> sortedMap = (SortedMap<CFAstSecGroupMemberPKey, ICFAstSecGroupMemberObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAstSecGroupMemberBuff arr[] = new CFAstSecGroupMemberBuff[sz];
    Iterator<ICFAstSecGroupMemberObj> iter = sortedMap.values().iterator();
    ICFAstSecGroupMemberObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAstSecGroupMemberObj) iter.next();
        arr[idx] = cur.getSecGroupMemberBuff();
    }
    return (arr);
}

From source file:com.streamsets.pipeline.lib.jdbc.JdbcMultiRowRecordWriter.java

@SuppressWarnings("unchecked")
private void processPartition(Connection connection, Multimap<Long, Record> partitions, Long partitionKey,
        List<OnRecordErrorException> errorRecords) throws SQLException, OnRecordErrorException {
    Collection<Record> partition = partitions.get(partitionKey);
    // Fetch the base insert query for this partition.
    SortedMap<String, String> columnsToParameters = getFilteredColumnsToParameters(getColumnsToParameters(),
            partition.iterator().next());

    // put all the records in a queue for consumption
    LinkedList<Record> queue = new LinkedList<>(partition);

    // compute number of rows per batch
    if (columnsToParameters.isEmpty()) {
        throw new OnRecordErrorException(Errors.JDBCDEST_22);
    }//from ww w .  j a v  a  2s  .co m
    int maxRowsPerBatch = maxPrepStmtParameters / columnsToParameters.size();

    PreparedStatement statement = null;

    // parameters are indexed starting with 1
    int paramIdx = 1;
    int rowCount = 0;
    while (!queue.isEmpty()) {
        // we're at the start of a batch.
        if (statement == null) {
            // instantiate the new statement
            statement = generatePreparedStatement(columnsToParameters,
                    // the next batch will have either the max number of records, or however many are left.
                    Math.min(maxRowsPerBatch, queue.size()), getTableName(), connection);
        }

        // process the next record into the current statement
        Record record = queue.removeFirst();
        for (String column : columnsToParameters.keySet()) {
            Field field = record.get(getColumnsToFields().get(column));
            Field.Type fieldType = field.getType();
            Object value = field.getValue();

            try {
                switch (fieldType) {
                case LIST:
                    List<Object> unpackedList = unpackList((List<Field>) value);
                    Array array = connection.createArrayOf(getSQLTypeName(fieldType), unpackedList.toArray());
                    statement.setArray(paramIdx, array);
                    break;
                case DATE:
                case DATETIME:
                    // Java Date types are not accepted by JDBC drivers, so we need to convert to java.sql.Date
                    java.util.Date date = field.getValueAsDatetime();
                    statement.setObject(paramIdx, new java.sql.Date(date.getTime()));
                    break;
                default:
                    statement.setObject(paramIdx, value, getColumnType(column));
                    break;
                }
            } catch (SQLException e) {
                LOG.error(Errors.JDBCDEST_23.getMessage(), column, fieldType.toString(), e);
                throw new OnRecordErrorException(record, Errors.JDBCDEST_23, column, fieldType.toString());
            }
            ++paramIdx;
        }

        rowCount++;

        // check if we've filled up the current batch
        if (rowCount == maxRowsPerBatch) {
            // time to execute the current batch
            statement.addBatch();
            statement.executeBatch();
            statement.close();
            statement = null;

            // reset our counters
            rowCount = 0;
            paramIdx = 1;
        }
    }

    // check if there are any records left. this should occur whenever there isn't *exactly* maxRowsPerBatch records in
    // this partition.
    if (statement != null) {
        statement.addBatch();
        statement.executeBatch();
        statement.close();
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientSecGroupMemberTable.java

public CFAccSecGroupMemberBuff[] readDerivedByClusterIdx(CFAccAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "readDerivedByClusterIdx";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAccXMsgSecGroupMemberMessageFormatter.formatSecGroupMemberRqstReadByClusterIdx("\n\t\t\t",
                    argClusterId)/*from  ww w  .j  av a  2 s  .c o  m*/
            + "\n" + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccSecGroupMemberPKey, ICFAccSecGroupMemberObj> sortedMap = (SortedMap<CFAccSecGroupMemberPKey, ICFAccSecGroupMemberObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccSecGroupMemberBuff arr[] = new CFAccSecGroupMemberBuff[sz];
    Iterator<ICFAccSecGroupMemberObj> iter = sortedMap.values().iterator();
    ICFAccSecGroupMemberObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccSecGroupMemberObj) iter.next();
        arr[idx] = cur.getSecGroupMemberBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientSecGroupMemberTable.java

public CFAccSecGroupMemberBuff[] readDerivedByUserIdx(CFAccAuthorization Authorization, UUID argSecUserId) {
    final String S_ProcName = "readDerivedByUserIdx";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAccXMsgSecGroupMemberMessageFormatter.formatSecGroupMemberRqstReadByUserIdx("\n\t\t\t",
                    argSecUserId)/*from   w w  w .  j ava  2  s .  com*/
            + "\n" + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccSecGroupMemberPKey, ICFAccSecGroupMemberObj> sortedMap = (SortedMap<CFAccSecGroupMemberPKey, ICFAccSecGroupMemberObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccSecGroupMemberBuff arr[] = new CFAccSecGroupMemberBuff[sz];
    Iterator<ICFAccSecGroupMemberObj> iter = sortedMap.values().iterator();
    ICFAccSecGroupMemberObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccSecGroupMemberObj) iter.next();
        arr[idx] = cur.getSecGroupMemberBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientExtensionsConfTable.java

public CFAstExtensionsConfBuff[] readDerivedByClusterIdx(CFAstAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "readDerivedByClusterIdx";
    String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAstXMsgExtensionsConfMessageFormatter.formatExtensionsConfRqstReadByClusterIdx("\n\t\t\t",
                    argClusterId)/*from w  ww.j a v a  2s  . c om*/
            + "\n" + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }
    CFAstXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAstConfigurationFilePKey, ICFAstConfigurationFileObj> sortedMap = (SortedMap<CFAstConfigurationFilePKey, ICFAstConfigurationFileObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAstExtensionsConfBuff arr[] = new CFAstExtensionsConfBuff[sz];
    Iterator<ICFAstConfigurationFileObj> iter = sortedMap.values().iterator();
    ICFAstExtensionsConfObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAstExtensionsConfObj) iter.next();
        arr[idx] = cur.getExtensionsConfBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientSecGroupMemberTable.java

public CFAstSecGroupMemberBuff[] readDerivedByClusterIdx(CFAstAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "readDerivedByClusterIdx";
    String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAstXMsgSecGroupMemberMessageFormatter.formatSecGroupMemberRqstReadByClusterIdx("\n\t\t\t",
                    argClusterId)/*w w w.  j a  v a 2  s.c o  m*/
            + "\n" + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }
    CFAstXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAstSecGroupMemberPKey, ICFAstSecGroupMemberObj> sortedMap = (SortedMap<CFAstSecGroupMemberPKey, ICFAstSecGroupMemberObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAstSecGroupMemberBuff arr[] = new CFAstSecGroupMemberBuff[sz];
    Iterator<ICFAstSecGroupMemberObj> iter = sortedMap.values().iterator();
    ICFAstSecGroupMemberObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAstSecGroupMemberObj) iter.next();
        arr[idx] = cur.getSecGroupMemberBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientSecGroupMemberTable.java

public CFAstSecGroupMemberBuff[] readDerivedByUserIdx(CFAstAuthorization Authorization, UUID argSecUserId) {
    final String S_ProcName = "readDerivedByUserIdx";
    String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAstXMsgSecGroupMemberMessageFormatter.formatSecGroupMemberRqstReadByUserIdx("\n\t\t\t",
                    argSecUserId)//  w w w.j  a va2  s  . c  om
            + "\n" + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }
    CFAstXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAstSecGroupMemberPKey, ICFAstSecGroupMemberObj> sortedMap = (SortedMap<CFAstSecGroupMemberPKey, ICFAstSecGroupMemberObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAstSecGroupMemberBuff arr[] = new CFAstSecGroupMemberBuff[sz];
    Iterator<ICFAstSecGroupMemberObj> iter = sortedMap.values().iterator();
    ICFAstSecGroupMemberObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAstSecGroupMemberObj) iter.next();
        arr[idx] = cur.getSecGroupMemberBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientSecGroupMemberTable.java

public CFAccSecGroupMemberBuff[] readDerivedByGroupIdx(CFAccAuthorization Authorization, long argClusterId,
        int argSecGroupId) {
    final String S_ProcName = "readDerivedByGroupIdx";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAccXMsgSecGroupMemberMessageFormatter.formatSecGroupMemberRqstReadByGroupIdx("\n\t\t\t",
                    argClusterId, argSecGroupId)
            + "\n" + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }//from  w w  w . j  a  v  a 2  s  . c  o m
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccSecGroupMemberPKey, ICFAccSecGroupMemberObj> sortedMap = (SortedMap<CFAccSecGroupMemberPKey, ICFAccSecGroupMemberObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccSecGroupMemberBuff arr[] = new CFAccSecGroupMemberBuff[sz];
    Iterator<ICFAccSecGroupMemberObj> iter = sortedMap.values().iterator();
    ICFAccSecGroupMemberObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccSecGroupMemberObj) iter.next();
        arr[idx] = cur.getSecGroupMemberBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientExtensionsConfTable.java

public CFAstExtensionsConfBuff[] readDerivedByHostIdx(CFAstAuthorization Authorization, long argClusterId,
        long argHostNodeId) {
    final String S_ProcName = "readDerivedByHostIdx";
    String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAstXMsgExtensionsConfMessageFormatter.formatExtensionsConfRqstReadByHostIdx("\n\t\t\t",
                    argClusterId, argHostNodeId)
            + "\n" + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/*w ww  . j a  v  a2  s .  co  m*/
    CFAstXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAstConfigurationFilePKey, ICFAstConfigurationFileObj> sortedMap = (SortedMap<CFAstConfigurationFilePKey, ICFAstConfigurationFileObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAstExtensionsConfBuff arr[] = new CFAstExtensionsConfBuff[sz];
    Iterator<ICFAstConfigurationFileObj> iter = sortedMap.values().iterator();
    ICFAstExtensionsConfObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAstExtensionsConfObj) iter.next();
        arr[idx] = cur.getExtensionsConfBuff();
    }
    return (arr);
}