Example usage for java.util LinkedHashMap size

List of usage examples for java.util LinkedHashMap size

Introduction

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

Prototype

int size();

Source Link

Document

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

Usage

From source file:com.streamsets.pipeline.stage.origin.jdbc.JdbcSource.java

private Record processRow(ResultSet resultSet, long rowCount) throws SQLException, StageException {
    Source.Context context = getContext();
    ResultSetMetaData md = resultSet.getMetaData();
    int numColumns = md.getColumnCount();

    LinkedHashMap<String, Field> fields = jdbcUtil.resultSetToFields(resultSet, commonSourceConfigBean,
            errorRecordHandler, unknownTypeAction, null);

    if (fields.size() != numColumns) {
        errorRecordHandler.onError(JdbcErrors.JDBC_35, fields.size(), numColumns);
        return null; // Don't output this record.
    }/*  w  w  w.ja va2 s.c  o  m*/

    final String recordContext = StringUtils.substring(query.replaceAll("[\n\r]", ""), 0, 100) + "::rowCount:"
            + rowCount + (StringUtils.isEmpty(offsetColumn) ? "" : ":" + resultSet.getString(offsetColumn));
    Record record = context.createRecord(recordContext);
    if (jdbcRecordType == JdbcRecordType.LIST_MAP) {
        record.set(Field.createListMap(fields));
    } else if (jdbcRecordType == JdbcRecordType.MAP) {
        record.set(Field.create(fields));
    } else {
        // type is LIST
        List<Field> row = new ArrayList<>();
        for (Map.Entry<String, Field> fieldInfo : fields.entrySet()) {
            Map<String, Field> cell = new HashMap<>();
            cell.put("header", Field.create(fieldInfo.getKey()));
            cell.put("value", fieldInfo.getValue());
            row.add(Field.create(cell));
        }
        record.set(Field.create(row));
    }
    if (createJDBCNsHeaders) {
        jdbcUtil.setColumnSpecificHeaders(record, Collections.<String>emptySet(), md, jdbcNsHeaderPrefix);
    }
    // We will add cdc operation type to record header even if createJDBCNsHeaders is false
    // we currently support CDC on only MS SQL.
    if (hikariConfigBean.getConnectionString().startsWith("jdbc:sqlserver")) {
        MSOperationCode.addOperationCodeToRecordHeader(record);
    }

    return record;
}

From source file:au.com.centrumsystems.hudson.plugin.buildpipeline.BuildPipelineView.java

/**
 * From parameterized trigger plugin src/main/java/hudson/plugins/parameterizedtrigger/BuildTriggerConfig.java
 *
 * @param base//from  w w  w . j  av a2s .c om
 *      One of the two parameters to merge.
 * @param overlay
 *      The other parameters to merge
 * @return
 *      Result of the merge.
 */
private static ParametersAction mergeParameters(final ParametersAction base, final ParametersAction overlay) {
    final LinkedHashMap<String, ParameterValue> params = new LinkedHashMap<String, ParameterValue>();
    for (final ParameterValue param : base.getParameters()) {
        params.put(param.getName(), param);
    }
    for (final ParameterValue param : overlay.getParameters()) {
        params.put(param.getName(), param);
    }
    return new ParametersAction(params.values().toArray(new ParameterValue[params.size()]));
}

From source file:com.genentech.chemistry.openEye.apps.SDFStructureTagger.java

/**
 *
 * @return true if at least one match occured.
 *///ww  w  .j  a  v a2 s  . c o  m
private boolean addOccurrenceToOutput(OEMolBase mol) {
    LinkedHashMap<String, Integer> map = structureTagger.countOccurrence(mol);
    Iterator<Entry<String, Integer>> iterator = map.entrySet().iterator();
    while (iterator.hasNext()) {
        Entry<String, Integer> entry = iterator.next();
        oechem.OESetSDData(mol, entry.getKey(), String.valueOf(entry.getValue()));
    }
    return map.size() > 0;
}

From source file:com.impetus.ankush.common.dao.impl.GenericDaoJpa.java

/**
 * Creates the clause list.//www .j  a  v  a 2 s .c  o m
 * 
 * @param queryMap
 *            the query map
 * @param startIndex
 *            the start index
 * @param joiner
 *            the joiner
 * @return the string
 */
private String createClauseList(LinkedHashMap<String, Object> queryMap, int startIndex, String joiner) {
    List<StringBuilder> clauses = new ArrayList<StringBuilder>(queryMap.size());

    for (String property : queryMap.keySet()) {
        clauses.add(new StringBuilder("obj.").append(property).append(" = ?").append(startIndex++));
    }
    return StringUtils.join(clauses, joiner);
}

From source file:org.cytoscape.kddn.internal.KddnMethods.java

/**
 * variable selection based on t-test//from   ww  w.  j  a  v a2s .  com
 * @param var
 * @param d1
 * @param d2
 * @return
 */
public static int[] variableSelection(String[] var, double[][] d1, double[][] d2) {

    LinkedHashMap<String, Integer> selectedVar = new LinkedHashMap<String, Integer>();
    LinkedHashMap<String, Double> varPvalue = new LinkedHashMap<String, Double>();

    TTest aTest = new TTest();

    for (int i = 0; i < var.length; i++) {
        double pval = 0;

        // equal variance
        //pval = aTest.homoscedasticTTest(getColumn(d1,i), getColumn(d2,i));
        // unequal variance
        pval = aTest.tTest(getColumn(d1, i), getColumn(d2, i));

        if (selectedVar.containsKey(var[i])) {
            if (varPvalue.get(var[i]) > pval) {
                selectedVar.put(var[i], i);
                varPvalue.put(var[i], pval);
            }
        } else {
            selectedVar.put(var[i], i);
            varPvalue.put(var[i], pval);
        }
    }

    int[] idx = new int[selectedVar.size()];
    int i = 0;
    for (String s : selectedVar.keySet()) {
        idx[i] = selectedVar.get(s);
        i++;
    }

    return idx;
}

From source file:com.genentech.chemistry.openEye.apps.SDFStructureTagger.java

/**
 *
 * @return true if at least one match occured.
 *//*from  www . jav a2  s . c  o m*/
private boolean addExistsToOutput(OEMolBase mol) {
    LinkedHashMap<String, Boolean> map = structureTagger.checkOccurrence(mol);
    Iterator<Entry<String, Boolean>> iterator = map.entrySet().iterator();
    while (iterator.hasNext()) {
        Entry<String, Boolean> entry = iterator.next();
        oechem.OESetSDData(mol, entry.getKey(), entry.getValue().booleanValue() ? "1" : "0");
    }
    return map.size() > 0;
}

From source file:com.amalto.workbench.dialogs.AddBrowseItemsWizard.java

private TreeObject createNewTreeObject(XSDElementDeclaration decl, String browseItem) {
    WSView view = new WSView();
    view.setIsTransformerActive(new WSBoolean(false));
    view.setTransformerPK("");//$NON-NLS-1$
    view.setName(browseItem);/*from ww  w  .  j  a  v a  2s  . co m*/
    EList<XSDIdentityConstraintDefinition> idtylist = decl.getIdentityConstraintDefinitions();
    List<String> keys = new ArrayList<String>();
    for (XSDIdentityConstraintDefinition idty : idtylist) {
        EList<XSDXPathDefinition> xpathList = idty.getFields();
        for (XSDXPathDefinition path : xpathList) {
            String key = decl.getName();
            // remove
            key = key.replaceFirst("#.*", "");//$NON-NLS-1$//$NON-NLS-2$
            key += "/" + path.getValue();//$NON-NLS-1$
            keys.add(key);
        }

    }
    view.getSearchableBusinessElements().addAll(keys);
    view.getViewableBusinessElements().addAll(keys);

    StringBuffer desc = new StringBuffer();
    LinkedHashMap<String, String> labels = new LinkedHashMap<String, String>();
    if (decl.getAnnotation() != null) {
        labels = new XSDAnnotationsStructure(decl.getAnnotation()).getLabels();
    }
    if (labels.size() == 0) {
        labels.put("EN", decl.getName());//$NON-NLS-1$
    }
    for (String lan : labels.keySet()) {
        desc.append("[" + lan.toUpperCase() + ":" + labels.get(lan) + "]");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
    }
    view.setDescription(desc.toString());

    WSPutView wrap = new WSPutView();
    wrap.setWsView(view);

    WSViewPK viewPk = new WSViewPK();
    viewPk.setPk(browseItem);

    WSDeleteView delView = new WSDeleteView();
    delView.setWsViewPK(viewPk);
    WSGetView getView = new WSGetView();
    getView.setWsViewPK(viewPk);
    service.putView(wrap);
    // add node in the root
    TreeParent root = page.getXObject().getServerRoot();
    TreeObject obj = new TreeObject(browseItem, root, TreeObject.VIEW, viewPk, null // no storage to save
    // space
    );

    return obj;
}

From source file:gov.llnl.lc.smt.command.link.SmtLink.java

private void showLevels() {
    StringBuffer buff = new StringBuffer();
    String formatString = "%9s: %s";
    LinkedHashMap<String, IB_Edge> edgeMap = getEdgeMap();
    if (edgeMap != null) {
        buff.append(String.format(formatString, "total", edgeMap.size() + " links") + SmtConstants.NEW_LINE);

        int maxLevel = getNumLevels(edgeMap);
        for (int l = 0; l < maxLevel; l++) {
            buff.append(String.format(formatString, "level " + l, getNumAtLevel(edgeMap, l) + " links")
                    + SmtConstants.NEW_LINE);
        }/*from  w ww  .  jav  a2 s. com*/
        System.out.println(buff.toString());

    }
}

From source file:com.cburch.logisim.gui.main.SelectionAttributes.java

private void updateList(boolean ignoreIfSelectionSame) {
    Selection sel = selection;//from  w w w  .  ja va 2  s  . c o  m
    Set<Component> oldSel = selected;
    Set<Component> newSel;
    if (sel == null)
        newSel = Collections.emptySet();
    else
        newSel = createSet(sel.getComponents());
    if (haveSameElements(newSel, oldSel)) {
        if (ignoreIfSelectionSame)
            return;
        newSel = oldSel;
    } else {
        for (Component o : oldSel) {
            if (!newSel.contains(o)) {
                o.getAttributeSet().removeAttributeListener(listener);
            }
        }
        for (Component o : newSel) {
            if (!oldSel.contains(o)) {
                o.getAttributeSet().addAttributeListener(listener);
            }
        }
    }

    LinkedHashMap<Attribute<Object>, Object> attrMap = computeAttributes(newSel);
    boolean same = isSame(attrMap, this.attrs, this.values);

    if (same) {
        if (newSel != oldSel)
            this.selected = newSel;
    } else {
        Attribute<?>[] oldAttrs = this.attrs;
        Object[] oldValues = this.values;
        Attribute<?>[] newAttrs = new Attribute[attrMap.size()];
        Object[] newValues = new Object[newAttrs.length];
        boolean[] newReadOnly = new boolean[newAttrs.length];
        int i = -1;
        for (Map.Entry<Attribute<Object>, Object> entry : attrMap.entrySet()) {
            i++;
            newAttrs[i] = entry.getKey();
            newValues[i] = entry.getValue();
            newReadOnly[i] = computeReadOnly(newSel, newAttrs[i]);
        }
        if (newSel != oldSel)
            this.selected = newSel;
        this.attrs = newAttrs;
        this.attrsView = UnmodifiableList.decorate(Arrays.asList(newAttrs));
        this.values = newValues;
        this.readOnly = newReadOnly;

        boolean listSame = oldAttrs != null && oldAttrs.length == newAttrs.length;
        if (listSame) {
            for (i = 0; i < oldAttrs.length; i++) {
                if (!oldAttrs[i].equals(newAttrs[i])) {
                    listSame = false;
                    break;
                }
            }
        }

        if (listSame) {
            for (i = 0; i < oldValues.length; i++) {
                Object oldVal = oldValues[i];
                Object newVal = newValues[i];
                boolean sameVals = oldVal == null ? newVal == null : oldVal.equals(newVal);
                if (!sameVals) {
                    @SuppressWarnings("unchecked")
                    Attribute<Object> attr = (Attribute<Object>) oldAttrs[i];
                    fireAttributeValueChanged(attr, newVal);
                }
            }
        } else {
            fireAttributeListChanged();
        }
    }
}

From source file:com.impetus.ankush.common.dao.impl.GenericDaoJpa.java

/**
 * Creates the disjunction normal query string.
 * /* ww  w. j  a v  a 2s.c o  m*/
 * @param orderedMaps
 *            the ordered maps
 * @return the string builder
 */
private StringBuilder createDisjunctionNormalQueryString(List<LinkedHashMap<String, Object>> orderedMaps) {
    List<String> andClauses = new ArrayList<String>(orderedMaps.size());
    int startIndex = 1;
    for (LinkedHashMap<String, Object> queryMap : orderedMaps) {
        andClauses.add(this.createAndClause(queryMap, startIndex));
        startIndex += queryMap.size();
    }
    String disjunction = new StringBuilder("(").append(StringUtils.join(andClauses, ") or (")).append(") ")
            .toString();

    StringBuilder builder = new StringBuilder(SELECT_OBJ_FROM).append(this.persistentClass.getName())
            .append(" obj where ").append(disjunction);
    return builder;
}