Example usage for java.util HashMap isEmpty

List of usage examples for java.util HashMap isEmpty

Introduction

In this page you can find the example usage for java.util HashMap isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this map contains no key-value mappings.

Usage

From source file:com.brightcove.com.zartan.verifier.video.CustomFieldVerifier.java

@Override
public boolean isApplicable(UploadData pData) {
    HashMap<String, String> customEnums = pData.getmIngestFile().getMetaData().getCustomEnumFields();
    HashMap<String, String> customStrings = pData.getmIngestFile().getMetaData().getCustomStringFields();
    //is JSON populated
    if (pData.getUploadMethod() != UploadData.UploadType.MGR && //check to see if this verification should be skipped, due to upload type.
            pData.getHttpResponseJson() != null && ((customEnums != null && !customEnums.isEmpty())
                    || (customStrings != null && !customStrings.isEmpty()))) {
        return true;
    }//from   www.ja va2s.  c  o m
    mLog.info(this.getClass().getName() + " is not applicable for this test.");
    return false;
}

From source file:org.kuali.ole.module.purap.document.web.struts.BulkReceivingAction.java

protected ActionForward isDuplicateDocumentEntry(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response, BulkReceivingDocument bulkReceivingDocument)
        throws Exception {
    ActionForward forward = null;/*from  ww  w  .ja va 2s .co  m*/
    HashMap<String, String> duplicateMessages = SpringContext.getBean(BulkReceivingService.class)
            .bulkReceivingDuplicateMessages(bulkReceivingDocument);

    if (duplicateMessages != null && !duplicateMessages.isEmpty()) {
        Object question = request.getParameter(OLEConstants.QUESTION_INST_ATTRIBUTE_NAME);
        if (question == null) {

            return this.performQuestionWithoutInput(mapping, form, request, response,
                    PurapConstants.BulkReceivingDocumentStrings.DUPLICATE_BULK_RECEIVING_DOCUMENT_QUESTION,
                    duplicateMessages.get(
                            PurapConstants.BulkReceivingDocumentStrings.DUPLICATE_BULK_RECEIVING_DOCUMENT_QUESTION),
                    OLEConstants.CONFIRMATION_QUESTION, OLEConstants.ROUTE_METHOD, "");
        }

        Object buttonClicked = request.getParameter(OLEConstants.QUESTION_CLICKED_BUTTON);
        if ((PurapConstants.BulkReceivingDocumentStrings.DUPLICATE_BULK_RECEIVING_DOCUMENT_QUESTION
                .equals(question)) && ConfirmationQuestion.NO.equals(buttonClicked)) {
            forward = mapping.findForward(OLEConstants.MAPPING_BASIC);
        }
    }

    return forward;
}

From source file:gda.device.detector.countertimer.BufferedScaler.java

@Override
public int getNumberFrames() throws DeviceException {
    if (!continuousMode)
        return 0;
    String[] cmds = new String[] { "status show-armed", "progress", "status", "full", "lap", "frame" };
    HashMap<String, String> currentVals = new HashMap<String, String>();
    for (String cmd : cmds) {
        currentVals.put(cmd, daserver.sendCommand("tfg read " + cmd).toString());
        //         logger.info("tfg read "+ cmd + ": " + currentVals.get(cmd));
    }/* w w w .j  a  v  a2 s  .c o  m*/
    if (currentVals.isEmpty())
        return 0;

    // else either scan not started (return -1) or has finished (return continuousParameters.getNumberDataPoints())

    // if started but nothing collected yet
    if (currentVals.get("status show-armed")
            .equals("EXT-ARMED") /*&& currentVals.get("status").equals("IDLE")*/ ) {
        return 0;
    }

    // if frame is non-0 then work out the current frame
    if (!currentVals.get("frame").equals("0")) {
        String numFrames = currentVals.get("frame");
        try {
            return extractCurrentFrame(Integer.parseInt(numFrames));
        } catch (NumberFormatException e) {
            throw new DeviceException(numFrames);
        }
    }

    return parameters.getNumberDataPoints();
}

From source file:org.alfresco.mobile.android.application.operations.sync.SynchroManager.java

public static String serializeProperties(Node node) {
    HashMap<String, Serializable> persistentProperties = new HashMap<String, Serializable>();
    Map<String, Property> props = node.getProperties();
    for (Entry<String, Property> entry : props.entrySet()) {
        if (entry.getValue().getValue() instanceof GregorianCalendar) {
            persistentProperties.put(entry.getKey(),
                    ((GregorianCalendar) entry.getValue().getValue()).getTimeInMillis());
        } else {/* www.j a v a  2s. c  o  m*/
            persistentProperties.put(entry.getKey(), (Serializable) entry.getValue().getValue());
        }
    }
    if (!persistentProperties.isEmpty()) {
        return MapUtil.mapToString(persistentProperties);
    } else {
        return "";
    }

}

From source file:org.kuali.kfs.module.purap.document.web.struts.BulkReceivingAction.java

protected ActionForward isDuplicateDocumentEntry(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response, BulkReceivingDocument bulkReceivingDocument)
        throws Exception {
    ActionForward forward = null;/*w w w. ja v a 2  s . c  om*/
    HashMap<String, String> duplicateMessages = SpringContext.getBean(BulkReceivingService.class)
            .bulkReceivingDuplicateMessages(bulkReceivingDocument);

    if (duplicateMessages != null && !duplicateMessages.isEmpty()) {
        Object question = request.getParameter(KFSConstants.QUESTION_INST_ATTRIBUTE_NAME);
        if (question == null) {

            return this.performQuestionWithoutInput(mapping, form, request, response,
                    PurapConstants.BulkReceivingDocumentStrings.DUPLICATE_BULK_RECEIVING_DOCUMENT_QUESTION,
                    duplicateMessages.get(
                            PurapConstants.BulkReceivingDocumentStrings.DUPLICATE_BULK_RECEIVING_DOCUMENT_QUESTION),
                    KFSConstants.CONFIRMATION_QUESTION, KFSConstants.ROUTE_METHOD, "");
        }

        Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
        if ((PurapConstants.BulkReceivingDocumentStrings.DUPLICATE_BULK_RECEIVING_DOCUMENT_QUESTION
                .equals(question)) && ConfirmationQuestion.NO.equals(buttonClicked)) {
            forward = mapping.findForward(KFSConstants.MAPPING_BASIC);
        }
    }

    return forward;
}

From source file:gda.device.detector.countertimer.TFGTriggeredScaler.java

public int getNumberFrames() throws DeviceException {
    String[] cmds = new String[] { "status show-armed", "progress", "status", "full", "lap", "frame" };
    HashMap<String, String> currentVals = new HashMap<String, String>();
    for (String cmd : cmds) {
        currentVals.put(cmd, daserver.sendCommand("tfg read " + cmd).toString());
    }// ww  w.ja  v a2 s. com

    if (currentVals.isEmpty())
        return 0;

    // if started but nothing collected yet
    if (currentVals.get("status show-armed")
            .equals("EXT-ARMED") /* && currentVals.get("status").equals("IDLE") */)
        return 0;

    // if frame is non-0 then work out the current frame
    if (!currentVals.get("frame").equals("0")) {
        String numFrames = currentVals.get("frame");
        try {
            return extractCurrentFrame(Integer.parseInt(numFrames));
        } catch (NumberFormatException e) {
            throw new DeviceException(numFrames);
        }
    }
    return triggerProvider.getNumberTriggers();
}

From source file:edu.umass.cs.gigapaxos.PaxosPacketBatcher.java

private boolean enqueueImpl(BatchedCommit commit) {
    if (!this.commits.containsKey(commit.getPaxosID()))
        this.commits.put(commit.getPaxosID(), new HashMap<Ballot, BatchedCommit>());
    HashMap<Ballot, BatchedCommit> cMap = this.commits.get(commit.getPaxosID());
    boolean added = false;
    if (cMap.isEmpty())
        added = (cMap.put(commit.ballot, (commit)) != null);
    else if (cMap.containsKey(commit.ballot))
        added = cMap.get(commit.ballot).addBatchedCommit(commit);
    else// w  ww  .ja  v a2 s . com
        added = (cMap.put(commit.ballot, (commit)) != null);

    return added;
}

From source file:edu.umass.cs.gigapaxos.PaxosPacketBatcher.java

private boolean enqueueImpl(BatchedAccept bAccept) {
    assert (bAccept.getPaxosID() != null);
    if (!this.accepts.containsKey(bAccept.getPaxosID()))
        this.accepts.put(bAccept.getPaxosID(), new HashMap<Ballot, BatchedAccept>());
    HashMap<Ballot, BatchedAccept> aMap = this.accepts.get(bAccept.getPaxosID());
    boolean added = false;
    if (aMap.isEmpty())
        added = (aMap.put(bAccept.ballot, (bAccept)) != null);
    else if (aMap.containsKey(bAccept.ballot))
        added = aMap.get(bAccept.ballot).addBatchedAccept(bAccept);
    else/*from w w  w. j a v a2s.c o  m*/
        added = (aMap.put(bAccept.ballot, (bAccept)) != null);

    return added;

}

From source file:org.apache.hadoop.hive.ql.parse.TezCompiler.java

@Override
protected void setInputFormat(Task<? extends Serializable> task) {
    if (task instanceof TezTask) {
        TezWork work = ((TezTask) task).getWork();
        List<BaseWork> all = work.getAllWork();
        for (BaseWork w : all) {
            if (w instanceof MapWork) {
                MapWork mapWork = (MapWork) w;
                HashMap<String, Operator<? extends OperatorDesc>> opMap = mapWork.getAliasToWork();
                if (!opMap.isEmpty()) {
                    for (Operator<? extends OperatorDesc> op : opMap.values()) {
                        setInputFormat(mapWork, op);
                    }// w  ww  .  jav a 2s  .co m
                }
            }
        }
    } else if (task instanceof ConditionalTask) {
        List<Task<? extends Serializable>> listTasks = ((ConditionalTask) task).getListTasks();
        for (Task<? extends Serializable> tsk : listTasks) {
            setInputFormat(tsk);
        }
    }

    if (task.getChildTasks() != null) {
        for (Task<? extends Serializable> childTask : task.getChildTasks()) {
            setInputFormat(childTask);
        }
    }
}

From source file:edu.umass.cs.gigapaxos.PaxosPacketBatcher.java

private boolean enqueueImpl(AcceptReplyPacket acceptReply) {
    if (!this.acceptReplies.containsKey(acceptReply.getPaxosID()))
        this.acceptReplies.put(acceptReply.getPaxosID(), new HashMap<Ballot, BatchedAcceptReply>());

    HashMap<Ballot, BatchedAcceptReply> arMap = this.acceptReplies.get(acceptReply.getPaxosID());
    boolean added = false;
    if (arMap.isEmpty())
        added = (arMap.put(acceptReply.ballot, new BatchedAcceptReply(acceptReply)) != null);
    else if (arMap.containsKey(acceptReply.ballot)) {
        added = arMap.get(acceptReply.ballot).addAcceptReply(acceptReply);
    } else {/*from  www .  ja  v  a 2s.c om*/
        arMap.put(acceptReply.ballot, new BatchedAcceptReply(acceptReply));
    }

    return added;
}