Example usage for java.lang Integer equals

List of usage examples for java.lang Integer equals

Introduction

In this page you can find the example usage for java.lang Integer equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:edu.ku.brc.specify.rstools.SpAnalysis.java

public void checkCollectors(final TableWriter tblWriter) {
    Statement stmt = null;//from w w w  .jav a 2s  . c  o  m
    try {
        tblWriter.append("<H3>Collectors</H3>");
        tblWriter.startTable();
        tblWriter.append(
                "<TR><TH>AddressID</TH><TH>Address</TH><TH>Address2</TH><TH>City</TH><TH>State</TH><TH>PostalCode</TH><TH>Ids</TH></TR>");

        String sql = "SELECT c.CollectingEventID, a.AgentID FROM collector c INNER JOIN agent a ON c.AgentID = a.AgentID ORDER BY c.CollectingEventID ASC, c.OrderNumber ASC";

        Hashtable<String, Triple<Integer, Integer, ArrayList<Integer>>> hash = new Hashtable<String, Triple<Integer, Integer, ArrayList<Integer>>>();
        StringBuilder sb = new StringBuilder();

        Integer ceId = null;
        Connection conn = DBConnection.getInstance().getConnection();
        stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sql + "  ORDER BY AddressID");
        while (rs.next()) {
            int id = rs.getInt(1);
            int agentId = rs.getInt(2);

            if (ceId == null || !ceId.equals(id)) {
                if (ceId != null) {
                    Pair<Integer, Integer> count = hash.get(sb.toString());
                    if (count == null) {
                        //hash.put(sb.toString(), new Pair<Integer, Integer>(ceId, 1));
                    } else {
                        count.second++;
                    }
                }
                sb.setLength(0);
                sb.append(agentId);
                sb.append(',');
                ceId = id;
            }
        }
        rs.close();

    } catch (Exception ex) {
        ex.printStackTrace();

    } finally {
        try {
            if (stmt != null) {
                stmt.close();
            }
        } catch (Exception ex) {
        }
    }

    tblWriter.endTable();
}

From source file:io.github.msdk.features.ransacaligner.RansacAlignerMethod.java

private Hashtable<FeatureTableRow, FeatureTableRow> getAlignmentMap(FeatureTable featureTable) {

    // Create a table of mappings for best scores
    Hashtable<FeatureTableRow, FeatureTableRow> alignmentMapping = new Hashtable<FeatureTableRow, FeatureTableRow>();

    // Create a sorted set of scores matching
    TreeSet<RowVsRowScore> scoreSet = new TreeSet<RowVsRowScore>();

    // RANSAC algorithm
    List<AlignStructMol> list = ransacPeakLists(result, featureTable);
    PolynomialFunction function = this.getPolynomialFunction(list);

    List<FeatureTableRow> allRows = featureTable.getRows();

    for (FeatureTableRow row : allRows) {
        // Calculate limits for a row with which the row can be aligned
        Range<Double> mzRange = mzTolerance.getToleranceRange(row.getMz());

        double rt;
        try {/*from  w  w  w  . j a  v  a  2  s . c  om*/
            rt = function.value(row.getChromatographyInfo().getRetentionTime());
        } catch (NullPointerException e) {
            rt = row.getChromatographyInfo().getRetentionTime();
        }
        if (Double.isNaN(rt) || rt == -1) {
            rt = row.getChromatographyInfo().getRetentionTime();
        }

        Range<Double> rtRange = rtToleranceAfterCorrection.getToleranceRange(rt);

        // Get all rows of the aligned feature table within the m/z and
        // RT limits
        List<FeatureTableRow> candidateRows = result.getRowsInsideRange(rtRange, mzRange);

        for (FeatureTableRow candidateRow : candidateRows) {
            RowVsRowScore score;
            if (requireSameCharge) {
                FeatureTableColumn<Integer> chargeColumn1 = featureTable.getColumn(ColumnName.CHARGE, null);
                FeatureTableColumn<Integer> chargeColumn2 = result.getColumn(ColumnName.CHARGE, null);
                Integer charge1 = row.getData(chargeColumn1);
                Integer charge2 = candidateRow.getData(chargeColumn2);
                if (!charge1.equals(charge2))
                    continue;
            }

            // Check ion annotation
            if (requireSameAnnotation) {
                FeatureTableColumn<List<IonAnnotation>> ionAnnotationColumn1 = featureTable
                        .getColumn(ColumnName.IONANNOTATION, null);
                FeatureTableColumn<List<IonAnnotation>> ionAnnotationColumn2 = result
                        .getColumn(ColumnName.IONANNOTATION, null);
                List<IonAnnotation> ionAnnotations1 = row.getData(ionAnnotationColumn1);
                List<IonAnnotation> ionAnnotations2 = candidateRow.getData(ionAnnotationColumn2);

                // Check that all ion annotations in first row are in
                // the candidate row
                boolean equalIons = false;
                if (ionAnnotations1 != null && ionAnnotations2 != null) {
                    for (IonAnnotation ionAnnotation : ionAnnotations1) {
                        for (IonAnnotation targetIonAnnotation : ionAnnotations2) {
                            if (targetIonAnnotation.compareTo(ionAnnotation) == 0)
                                equalIons = true;
                        }
                    }
                }
                if (!equalIons)
                    continue;

            }

            try {
                double mzLength = mzRange.upperEndpoint() - mzRange.lowerEndpoint();
                double rtLength = rtRange.upperEndpoint() - rtRange.lowerEndpoint();
                score = new RowVsRowScore(row, candidateRow, mzLength, rtLength, new Float(rt));

                scoreSet.add(score);

            } catch (Exception e) {
                return null;
            }
        }
    }

    // Iterate scores by descending order
    Iterator<RowVsRowScore> scoreIterator = scoreSet.iterator();
    while (scoreIterator.hasNext()) {

        RowVsRowScore score = scoreIterator.next();

        // Check if the row is already mapped
        if (alignmentMapping.containsKey(score.getFeatureTableRow())) {
            continue;
        }

        // Check if the aligned row is already filled
        if (alignmentMapping.containsValue(score.getAlignedRow())) {
            continue;
        }

        alignmentMapping.put(score.getFeatureTableRow(), score.getAlignedRow());

    }

    return alignmentMapping;
}

From source file:com.aurel.track.item.history.HistoryLoaderBL.java

public static int getType(Set<Integer> fieldIDs) {
    if (fieldIDs == null) {
        return HistoryBean.HISTORY_TYPE.COMMON_HISTORYVALUES;
    }//from w w w .  ja  va2 s. c o  m
    if (fieldIDs.contains(SystemFields.INTEGER_STATE)) {
        return HistoryBean.HISTORY_TYPE.STATE_CHANGE;
    }
    if (fieldIDs.contains(SystemFields.INTEGER_STARTDATE) || fieldIDs.contains(SystemFields.INTEGER_ENDDATE)) {
        return HistoryBean.HISTORY_TYPE.BASELINE_CHANGE;
    }
    if (fieldIDs.contains(SystemFields.ATTACHMENT_ADD_HISTORY_FIELD)
            || fieldIDs.contains(SystemFields.ATTACHMENT_MODIFY_HISTORY_FIELD)
            || fieldIDs.contains(SystemFields.ATTACHMENT_DELETE_HISTORY_FIELD)) {
        return HistoryBean.HISTORY_TYPE.ATTACHMENT;
    }
    Iterator<Integer> iterator = fieldIDs.iterator();
    while (iterator.hasNext()) {
        Integer fieldID = iterator.next();
        //not common and not comment but probably explicit history field
        if (!fieldID.equals(TFieldChangeBean.COMPOUND_HISTORY_FIELD)
                && !fieldID.equals(SystemFields.INTEGER_COMMENT)
                && !fieldIDs.contains(SystemFields.COMMENT_MODIFY_HISTORY_FIELD)
                && !fieldIDs.contains(SystemFields.COMMENT_DELETE_HISTORY_FIELD)) {
            return HistoryBean.HISTORY_TYPE.OTHER_EXPLICIT_HISTORY;
        }
    }
    if (fieldIDs.contains(SystemFields.INTEGER_COMMENT)
            || fieldIDs.contains(SystemFields.COMMENT_MODIFY_HISTORY_FIELD)
            || fieldIDs.contains(SystemFields.COMMENT_DELETE_HISTORY_FIELD)) {
        //comment
        return HistoryBean.HISTORY_TYPE.COMMENT;
    }
    //common
    return HistoryBean.HISTORY_TYPE.COMMON_HISTORYVALUES;
}

From source file:ch.puzzle.itc.mobiliar.business.property.entity.ResourceEditProperty.java

@Override
public int compareTo(ResourceEditProperty o) {

    Integer cardinality = o.getCardinalityProperty();
    if (cardinality == null) {
        cardinality = Integer.MAX_VALUE;
    }//from   ww  w.j av  a2 s  . com
    Integer myCardinality = getCardinalityProperty();
    if (myCardinality == null) {
        myCardinality = Integer.MAX_VALUE;
    }

    if (!myCardinality.equals(cardinality)) {
        return myCardinality - cardinality;
    }

    // compare displayed name such that the displayed list is sorted
    if (o.getPropertyDisplayName() != null && getPropertyDisplayName() != null) {
        return getPropertyDisplayName().compareToIgnoreCase(o.getPropertyDisplayName());
    }

    return 0;
}

From source file:com.tasktop.c2c.server.internal.wiki.server.WikiServiceController.java

@Section("Attachments")
@Title("Modify Page Attachment")
@Documentation("Modify the content of a page attachment. The name and mime type of an attachment cannot be changed.")
@RequestMapping(value = "/page/{pageId}/attachment/{attId}", method = RequestMethod.POST)
public AttachmentHandle updateAttachment(@PathVariable(value = "pageId") Integer pageId,
        @PathVariable(value = "attId") Integer attachmentId, @RequestBody Attachment attachment)
        throws EntityNotFoundException, ValidationException {
    if (attachmentId == null || !attachmentId.equals(attachment.getId())) {
        throw new EntityNotFoundException();
    }/*from  w  w w . j a v a  2s  .c om*/
    return updateAttachment(attachment);
}

From source file:com.tasktop.c2c.server.internal.wiki.server.WikiServiceController.java

@Section(value = "Wiki Pages", order = 0)
@Title("Modify Page")
@Documentation("Modify a page. The provided page must have an id.\n"
        + "It is possible to change the page content and its path.")
@RequestMapping(value = "/page/{pageId}", method = RequestMethod.POST)
public Page updatePage(@PathVariable(value = "pageId") Integer pageId, @RequestBody Page wikiPage)
        throws ValidationException, EntityNotFoundException, ConcurrentUpdateException {
    if (pageId == null || !pageId.equals(wikiPage.getId())) {
        throw new EntityNotFoundException();
    }//from   w  ww  .  j  av a 2 s.c  om
    return updatePage(wikiPage);
}

From source file:com.almende.eve.agent.google.GoogleTaskAgent.java

/**
 * Get a single task by id.//  w w  w  .  ja  v  a 2 s.  co  m
 * 
 * @param taskId
 *            Id of the task
 * @param taskListId
 *            the task list id
 * @return the task
 * @throws Exception
 *             the exception
 */
@Override
public ObjectNode getTask(@Name("taskId") final String taskId, @Optional @Name("taskListId") String taskListId)
        throws Exception {
    if (taskListId == null) {
        taskListId = getDefaultTaskList();
    }

    // built url
    final String url = CALENDAR_URI + "lists/" + taskListId + "/tasks/" + taskId;

    // perform GET request
    final Map<String, String> headers = getAuthorizationHeaders();
    final String resp = HttpUtil.get(url, headers);
    final ObjectMapper mapper = JOM.getInstance();
    final ObjectNode task = mapper.readValue(resp, ObjectNode.class);

    LOG.info("getTask task=" + (task != null ? JOM.getInstance().writeValueAsString(task) : null));

    // check for errors
    if (task.has("error")) {
        final ObjectNode error = (ObjectNode) task.get("error");
        final Integer code = error.has("code") ? error.get("code").asInt() : null;
        if (code != null && code.equals(404)) {
            throw new JSONRPCException(CODE.NOT_FOUND);
        }

        throw new JSONRPCException(error);
    }

    // check if canceled. If so, return null
    // TODO: be able to retrieve canceled events?
    if (task.has("status") && task.get("status").asText().equals("cancelled")) {
        throw new JSONRPCException(CODE.NOT_FOUND);
    }

    return task;
}

From source file:com.aurel.track.item.link.ItemLinkBL.java

/**
 * Load all linked workItems for a list of workItemIDs
 * @param workItemIDs base set of workItemIDs
 * @param linkTypes/*from  w ww  .  ja v  a2 s  .  c o  m*/
 * @param direction the link direction
 * @param isBidirectional whether linkType is bidirectional
 * @return
 */
public static Map<Integer, SortedSet<Integer>> loadByWorkItemsAndLinkType(List<Integer> workItemIDs,
        List<Integer> linkTypes, Integer direction, boolean isBidirectional, Integer archived,
        Integer deleted) {
    Map<Integer, SortedSet<Integer>> workItemLinksMap = new HashMap<Integer, SortedSet<Integer>>();
    if (workItemIDs == null || workItemIDs.isEmpty()) {
        return workItemLinksMap;
    }
    Integer reverseDirection = null;
    if (isBidirectional && direction != null) {
        reverseDirection = LinkTypeBL.getReverseDirection(direction);
        if (direction.equals(reverseDirection)) {
            reverseDirection = null;
        }
    }
    List<int[]> workItemIDChunksList = GeneralUtils.getListOfChunks(workItemIDs);
    if (workItemIDChunksList == null) {
        return workItemLinksMap;
    }
    Set<Integer> checkedWorkItems = new HashSet<Integer>();
    int i = 0;
    int originalSize = workItemIDChunksList.size();
    while (i < originalSize) {
        int[] workItemIDChunk = workItemIDChunksList.get(i);
        List<Integer> toLoad = new ArrayList<Integer>();
        for (Integer workItemID : workItemIDChunk) {
            if (!checkedWorkItems.contains(workItemID)) {
                checkedWorkItems.add(workItemID);
                toLoad.add(workItemID);
            }
        }
        if (toLoad.size() > 0) {
            int[] toLoadArray = GeneralUtils.createIntArrFromIntegerCollection(toLoad);
            if (isBidirectional) {
                Map<Integer, SortedSet<Integer>> succWorkItemLinksMap = getSuccOrPredLinkedWorkItemIDMaps(
                        workItemLinkDAO.getWorkItemsOfDirection(toLoadArray, linkTypes, true, direction,
                                archived, deleted),
                        true);
                addChuck(workItemLinksMap, succWorkItemLinksMap);
                Set<Integer> newItemsToLoad = new HashSet<Integer>();
                for (Integer key : succWorkItemLinksMap.keySet()) {
                    newItemsToLoad.addAll(succWorkItemLinksMap.get(key));
                }
                if (reverseDirection != null) {
                    Map<Integer, SortedSet<Integer>> predWorkItemLinksMap = getSuccOrPredLinkedWorkItemIDMaps(
                            workItemLinkDAO.getWorkItemsOfDirection(toLoadArray, linkTypes, false,
                                    reverseDirection, archived, deleted),
                            false);
                    addChuck(workItemLinksMap, predWorkItemLinksMap);
                    for (Integer key : predWorkItemLinksMap.keySet()) {
                        newItemsToLoad.addAll(predWorkItemLinksMap.get(key));
                    }
                }
                if (newItemsToLoad.size() > 0) {
                    List<int[]> chunkList = GeneralUtils.getListOfChunks(newItemsToLoad);
                    workItemIDChunksList.addAll(chunkList);// GeneralUtils.createIntArrFromIntegerCollection(newItemsToLoad));
                    originalSize += chunkList.size();
                }
            } else {
                Map<Integer, SortedSet<Integer>> predWorkItemLinksMap = getSuccOrPredLinkedWorkItemIDMaps(
                        workItemLinkDAO.getWorkItemsOfDirection(toLoadArray, linkTypes, false, direction,
                                archived, deleted),
                        false);
                addChuck(workItemLinksMap, predWorkItemLinksMap);
                Set<Integer> newItemsToLoad = new HashSet<Integer>();
                for (Integer key : predWorkItemLinksMap.keySet()) {
                    newItemsToLoad.addAll(predWorkItemLinksMap.get(key));
                }
                if (newItemsToLoad.size() > 0) {
                    List<int[]> chunkList = GeneralUtils.getListOfChunks(newItemsToLoad);
                    workItemIDChunksList.addAll(chunkList);//GeneralUtils.createIntArrFromIntegerCollection(newItemsToLoad)
                    originalSize += chunkList.size();
                }
            }
        }
        i++;
    }
    return workItemLinksMap;
}

From source file:eionet.gdem.web.struts.config.PurgeAction.java

@Override
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm,
        HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {

    ActionMessages errors = new ActionMessages();
    ActionMessages messages = new ActionMessages();

    DynaValidatorForm form = (DynaValidatorForm) actionForm;

    Integer nofDays = (Integer) form.get("nofDays");
    String user = (String) httpServletRequest.getSession().getAttribute("user");
    int deleted = 0;

    try {/*from w w w  . ja  va  2  s.c o m*/

        if (!SecurityUtil.hasPerm(user, "/" + Names.ACL_QUERIES_PATH, "u")) {
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("label.autorization.config.purge"));
            httpServletRequest.getSession().setAttribute("dcm.errors", errors);
            return actionMapping.findForward("success");
        }
        if (nofDays == null || nofDays.equals("") || nofDays <= 0) {
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("label.config.purge.validation"));
            httpServletRequest.getSession().setAttribute("dcm.errors", errors);
            return actionMapping.findForward("success");
        }
        BackupManager bm = new BackupManager();
        deleted = bm.purgeBackup(nofDays);

    } catch (DCMException e) {
        e.printStackTrace();
        LOGGER.error("SystemAction error", e);
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getErrorCode()));
        saveErrors(httpServletRequest, errors);
        httpServletRequest.getSession().setAttribute("dcm.errors", errors);
        return actionMapping.findForward("success");
    } catch (Exception e) {
        e.printStackTrace();
        LOGGER.error("SystemAction error", e);
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("label.exception.unknown"));
        saveErrors(httpServletRequest, errors);
        httpServletRequest.getSession().setAttribute("dcm.errors", errors);
        return actionMapping.findForward("success");
    }
    String[] numbers = { String.valueOf(nofDays.intValue()), String.valueOf(deleted) };
    messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("label.config.purge.successful", numbers));

    httpServletRequest.getSession().setAttribute("dcm.errors", errors);
    httpServletRequest.getSession().setAttribute("dcm.messages", messages);
    return actionMapping.findForward("success");
}

From source file:lockstep.LockstepServer.java

private void forwardFrameInputs(Map<Integer, FrameInput> nextFrameInputs) {
    //For each command
    for (Entry<Integer, FrameInput> frameEntry : nextFrameInputs.entrySet()) {
        Integer senderID = frameEntry.getKey();
        FrameInput input = frameEntry.getValue();

        //For each client, take its tree of transmission queues
        for (Entry<Integer, Map<Integer, TransmissionQueue>> transmissionFrameQueueMapEntry : this.transmissionFrameQueueTree
                .entrySet()) {/*from www. j a  va  2 s.  c o  m*/
            Integer recipientID = transmissionFrameQueueMapEntry.getKey();

            //If the frameInput doesn't come from that client, forward the frameInput though the correct transmission queue
            if (!recipientID.equals(senderID)) {
                Map<Integer, TransmissionQueue> recipientTransmissionQueueMap = transmissionFrameQueueMapEntry
                        .getValue();
                TransmissionQueue transmissionFrameQueueFromSender = recipientTransmissionQueueMap
                        .get(senderID);
                transmissionFrameQueueFromSender.push(input);

                if (input.getCommand() instanceof DisconnectionSignal) {
                    if (receivingQueues.containsKey(senderID))
                        disconnectReceivingQueues(senderID);
                }
            }
        }
    }
}