Example usage for java.lang Integer MIN_VALUE

List of usage examples for java.lang Integer MIN_VALUE

Introduction

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

Prototype

int MIN_VALUE

To view the source code for java.lang Integer MIN_VALUE.

Click Source Link

Document

A constant holding the minimum value an int can have, -231.

Usage

From source file:adams.data.statistics.StatUtils.java

/**
 * Returns the (first occurrence of the) smallest value in the given array.
 * Integer.MIN_VALUE in case of zero-length arrays.
 *
 * @param array   the array to work on//w w w  .j  a va  2  s  .  com
 * @return      the smallest value
 */
public static int min(int[] array) {
    Integer result;

    result = (Integer) min(toNumberArray(array));
    if (result == null)
        return Integer.MIN_VALUE;
    else
        return result;
}

From source file:com.facebook.internal.Utility.java

/**
 * Each array represents a set of closed or open Range, like so:
 * [0,10,50,60] - Ranges are {0-9}, {50-59}
 * [20] - Ranges are {20-}//from www  .  ja  v a 2s  .c  o  m
 * [30,40,100] - Ranges are {30-39}, {100-}
 *
 * All Ranges in the array have a closed lower bound. Only the last Range in each array may be open.
 * It is assumed that the passed in arrays are sorted with ascending order.
 * It is assumed that no two elements in a given are equal (i.e. no 0-length ranges)
 *
 * The method returns an intersect of the two passed in Range-sets
 * @param range1
 * @param range2
 * @return
 */
public static int[] intersectRanges(int[] range1, int[] range2) {
    if (range1 == null) {
        return range2;
    } else if (range2 == null) {
        return range1;
    }

    int[] outputRange = new int[range1.length + range2.length];
    int outputIndex = 0;
    int index1 = 0, lower1, upper1;
    int index2 = 0, lower2, upper2;
    while (index1 < range1.length && index2 < range2.length) {
        int newRangeLower = Integer.MIN_VALUE, newRangeUpper = Integer.MAX_VALUE;
        lower1 = range1[index1];
        upper1 = Integer.MAX_VALUE;

        lower2 = range2[index2];
        upper2 = Integer.MAX_VALUE;

        if (index1 < range1.length - 1) {
            upper1 = range1[index1 + 1];
        }
        if (index2 < range2.length - 1) {
            upper2 = range2[index2 + 1];
        }

        if (lower1 < lower2) {
            if (upper1 > lower2) {
                newRangeLower = lower2;
                if (upper1 > upper2) {
                    newRangeUpper = upper2;
                    index2 += 2;
                } else {
                    newRangeUpper = upper1;
                    index1 += 2;
                }
            } else {
                index1 += 2;
            }
        } else {
            if (upper2 > lower1) {
                newRangeLower = lower1;
                if (upper2 > upper1) {
                    newRangeUpper = upper1;
                    index1 += 2;
                } else {
                    newRangeUpper = upper2;
                    index2 += 2;
                }
            } else {
                index2 += 2;
            }
        }

        if (newRangeLower != Integer.MIN_VALUE) {
            outputRange[outputIndex++] = newRangeLower;
            if (newRangeUpper != Integer.MAX_VALUE) {
                outputRange[outputIndex++] = newRangeUpper;
            } else {
                // If we reach an unbounded/open range, then we know we're done.
                break;
            }
        }
    }

    return Arrays.copyOf(outputRange, outputIndex);
}

From source file:edu.ku.brc.specify.plugins.ipadexporter.VerifyCollectionDlg.java

/**
 * /*ww w  .  ja v a2 s .  c o m*/
 */
private void processResults() {
    //loadAndPushResourceBundle("stats");

    RelationshipType paleoRelType = isCollectionPaleo ? ExportPaleo.discoverPaleRelationshipType()
            : RelationshipType.eTypeError;

    boolean hasCritical = false;

    UIRegistry.setDoShowAllResStrErors(false);
    //logMsg("Verifying the Collection...");

    File tmpFile = ipadExporter.getConfigFile(VERIFY_XML);
    if (tmpFile != null && tmpFile.exists()) {
        Statement stmt0 = null;
        try {
            Element root = XMLHelper.readFileToDOM4J(tmpFile);
            if (root != null) {
                ArrayList<String> okMsgs = new ArrayList<String>();
                ArrayList<String> warnMsgs = new ArrayList<String>();
                ArrayList<String> criticalMsgs = new ArrayList<String>();
                int issueCnt = 0;

                String mainFont = "<font face='verdana' color='black'>";
                String headHTML = "<htmL><head></head><body bgcolor='#EEEEEE'>" + mainFont;
                StringBuilder sb = new StringBuilder(headHTML);
                htmlPane.setText(sb.toString() + "<BR><BR>Verifying collection...</font></body></html>");

                List<?> items = root.selectNodes("eval"); //$NON-NLS-1$

                stmt0 = DBConnection.getInstance().getConnection()
                        .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
                stmt0.setFetchSize(Integer.MIN_VALUE);

                for (Iterator<?> capIter = items.iterator(); capIter.hasNext();) {
                    Element fieldNode = (Element) capIter.next();
                    //String  name      = fieldNode.attributeValue("name"); //$NON-NLS-1$
                    String desc = fieldNode.attributeValue("desc"); //$NON-NLS-1$
                    String sql = fieldNode.getTextTrim();
                    String cond = fieldNode.attributeValue("cond");
                    String vStr = fieldNode.attributeValue("val");
                    String isFmt = fieldNode.attributeValue("fmt");
                    String stop = fieldNode.attributeValue("stop");
                    boolean doStop = stop != null && stop.equals("true");

                    String display = fieldNode.attributeValue("display");
                    boolean doDsp = display == null || display.equals("true");

                    String paleo = fieldNode.attributeValue("isPaleo");
                    boolean isPaleo = paleo != null && paleo.equals("true");
                    if (isPaleo && !isCollectionPaleo)
                        continue;

                    String paleoTypeStr = fieldNode.attributeValue("paleotype"); //$NON-NLS-1$
                    if (isCollectionPaleo && StringUtils.isNotEmpty(paleoTypeStr)) {
                        if (paleoRelType != paleoLookupHash.get(paleoTypeStr)) {
                            continue;
                        }
                    }

                    sql = ipadExporter.adjustSQL(sql);

                    Object rv = BasicSQLUtils.querySingleObj(sql);
                    Integer retVal = cnvToInt(rv);

                    boolean isError = false;
                    if (retVal != null && StringUtils.isNotEmpty(cond) && StringUtils.isNotEmpty(vStr)) {
                        Integer value = cnvToInt(vStr);
                        if (value != null) {
                            if (cond.equals(">")) {
                                isError = retVal.intValue() > value.intValue();
                            } else if (cond.equals("=")) {
                                isError = retVal.intValue() == value.intValue();
                            } else if (cond.equals("<")) {
                                isError = retVal.intValue() < value.intValue();
                            }
                        }
                    }
                    /*
                                            String fontSt = isError ? "<font color='"+(doStop ? "red" : "orange")+"'>" : "";
                                            String fontEn = isError ? "</font>" : "";
                                            if (StringUtils.isNotEmpty(isFmt) && isFmt.equalsIgnoreCase("true"))
                                            {
                                              sb.append(String.format("<LI>%s%s%s</LI>", fontSt, String.format(desc,  retVal), fontEn));
                                              issueCnt++;
                                            } else
                                            {
                                               sb.append(String.format("<LI>%s%s%s</LI>", fontSt, desc, fontEn));
                                               issueCnt++;
                                            }                        
                     */
                    String fullMsg;
                    if (StringUtils.isNotEmpty(isFmt) && isFmt.equalsIgnoreCase("true")) {
                        fullMsg = String.format(desc, retVal);
                    } else {
                        fullMsg = desc;
                    }

                    if (isError) {
                        if (doStop) {
                            criticalMsgs.add(fullMsg);
                            hasCritical = true;
                        } else {
                            warnMsgs.add(fullMsg);
                        }

                    } else if (doDsp) {
                        okMsgs.add(fullMsg);
                    }

                    issueCnt++;
                    //worker.firePropertyChange(PROGRESS, 0, cnt);
                }
                stmt0.close();

                sb = new StringBuilder(headHTML);
                if (issueCnt == 0) {
                    sb.append("<BR><BR>There were no issues to report.");
                } else {
                    listMsgs(sb, "Passed", okMsgs, "green", true);
                    listMsgs(sb, "Warnings", warnMsgs, "yellow", true);
                    listMsgs(sb, "Critical Errors - Cannot proceed.", criticalMsgs, "red", true);
                }
                sb.append(mainFont + "<BR>Verification Complete.<BR><BR></font></body></html>");

                htmlPane.setText(sb.toString());

                // For external report
                sb = new StringBuilder("<htmL><head><title>Collection Verification</title></head><body>");
                listMsgs(sb, "Passed", okMsgs, "green", false);
                listMsgs(sb, "Warnings", warnMsgs, "yellow", false);
                listMsgs(sb, "Critical Errors - Cannot proceed.", criticalMsgs, "red", false);
                sb.append("</body></html>");
                try {
                    TableWriter tblWriter = new TableWriter(reportPath, "Collection Verification Report", true);
                    tblWriter.println(sb.toString());
                    tblWriter.close();

                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }

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

        } finally {
            try {
                if (stmt0 != null)
                    stmt0.close();
            } catch (Exception ex) {
            }
        }
    }
    okBtn.setEnabled(!hasCritical);
}

From source file:com.eho.dynamodb.DynamoDBConnection.java

private static int create_new_version_numbe_old(Item item) throws Exception {
    JSONObject json_resource = new JSONObject(item.toJSONPretty());
    Iterator<String> itr = json_resource.keys();
    int max_version = Integer.MIN_VALUE;
    while (itr.hasNext()) {
        String nextString = itr.next();

        if (nextString.matches("[0-9]+"))//if a ltter does not exist in the key.this means it is a version of the rseource
        {/*w w w.j  a  v  a  2s . c o m*/
            int thisValue = Integer.valueOf(nextString);
            if (thisValue > max_version)
                max_version = thisValue;
        }
    }

    if (max_version == Integer.MIN_VALUE)
        return 0;
    else
        return ++max_version;
}

From source file:com.imobilize.blogposts.fragments.SubscribeFragment.java

private String getRegistrationId(Context context) {
    final SharedPreferences prefs = getGcmPreferences(context);
    String registrationId = prefs.getString(Constants.PROPERTY_REG_ID, "");

    if (registrationId.equals("")) {
        Log.i(Constants.TAG, "Registration not found.");
        return "";
    }//from   ww w  .ja v  a 2  s .  co m

    int registeredVersion = prefs.getInt(Constants.PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion) {
        Log.i(Constants.TAG, "App version changed.");
        return "";
    }
    return registrationId;
}

From source file:hk.hku.cecid.edi.as2.admin.listener.PartnershipPageletAdaptor.java

/**
 * @param request/* ww  w  .  j a  v a2s  . c  o  m*/
 * @throws DAOException
 * @throws IOException
 */
private void updatePartnership(Hashtable ht, HttpServletRequest request, PropertyTree dom)
        throws DAOException, IOException {

    // get the parameters
    String requestAction = (String) ht.get("request_action");
    String partnershipId = (String) ht.get("partnership_id");
    String subject = (String) ht.get("subject");
    String recipientAddress = (String) ht.get("recipient_address");
    boolean isHostnameVerified = new Boolean((String) ht.get("is_hostname_verified")).booleanValue();
    String receiptAddress = (String) ht.get("receipt_address");
    boolean isSyncReply = new Boolean((String) ht.get("is_sync_reply")).booleanValue();
    boolean isReceiptRequested = new Boolean((String) ht.get("is_receipt_requested")).booleanValue();
    boolean isOutboundSignRequired = new Boolean((String) ht.get("is_outbound_sign_required")).booleanValue();
    boolean isOutboundEncryptRequired = new Boolean((String) ht.get("is_outbound_encrypt_required"))
            .booleanValue();
    boolean isOutboundCompressRequired = new Boolean((String) ht.get("is_outbound_compress_required"))
            .booleanValue();
    boolean isReceiptSignRequired = new Boolean((String) ht.get("is_receipt_sign_required")).booleanValue();
    boolean isInboundSignRequired = new Boolean((String) ht.get("is_inbound_sign_required")).booleanValue();
    boolean isInbouhndEncryptRequired = new Boolean((String) ht.get("is_inbound_encrypt_required"))
            .booleanValue();
    String signAlgorithm = (String) ht.get("sign_algorithm");
    String encryptAlgorithm = (String) ht.get("encrypt_algorithm");
    String micAlgorithm = (String) ht.get("mic_algorithm");
    String as2From = (String) ht.get("as2_from");
    String as2To = (String) ht.get("as2_to");
    String retries = (String) ht.get("retries");
    String retryInterval = (String) ht.get("retry_interval");
    boolean isDisabled = new Boolean((String) ht.get("disabled")).booleanValue();
    boolean hasEncryptCert = ht.get("encrypt_cert") != null;
    InputStream encryptCertInputStream = null;
    if (hasEncryptCert) {
        encryptCertInputStream = (InputStream) ht.get("encrypt_cert");
    }
    boolean hasRemoveEncryptCert = false;
    if (ht.get("encrypt_cert_remove") != null) {
        if (((String) ht.get("encrypt_cert_remove")).equalsIgnoreCase("on")) {
            hasRemoveEncryptCert = true;
        }
    }
    boolean hasVerifyCert = ht.get("verify_cert") != null;
    InputStream verifyCertInputStream = null;
    if (hasVerifyCert) {
        verifyCertInputStream = (InputStream) ht.get("verify_cert");
    }
    boolean hasRemoveVerifyCert = false;
    if (ht.get("verify_cert_remove") != null) {
        if (((String) ht.get("verify_cert_remove")).equalsIgnoreCase("on")) {
            hasRemoveVerifyCert = true;
        }
    }

    if ("add".equalsIgnoreCase(requestAction) || "update".equalsIgnoreCase(requestAction)
            || "delete".equalsIgnoreCase(requestAction)) {

        // validate and set to dao
        PartnershipDAO partnershipDAO = (PartnershipDAO) AS2PlusProcessor.getInstance().getDAOFactory()
                .createDAO(PartnershipDAO.class);
        PartnershipDVO partnershipDAOData = (PartnershipDVO) partnershipDAO.createDVO();

        partnershipDAOData.setPartnershipId(partnershipId);
        if ("update".equalsIgnoreCase(requestAction)) {
            partnershipDAO.retrieve(partnershipDAOData);
        }
        partnershipDAOData.setAs2From(as2From);
        partnershipDAOData.setAs2To(as2To);
        partnershipDAOData.setSubject(subject);
        partnershipDAOData.setRecipientAddress(recipientAddress);
        partnershipDAOData.setIsHostnameVerified(isHostnameVerified);
        partnershipDAOData.setReceiptAddress(receiptAddress);
        partnershipDAOData.setIsSyncReply(isSyncReply);
        partnershipDAOData.setIsReceiptRequired(isReceiptRequested);
        partnershipDAOData.setIsOutboundSignRequired(isOutboundSignRequired);
        partnershipDAOData.setIsOutboundEncryptRequired(isOutboundEncryptRequired);
        partnershipDAOData.setIsOutboundCompressRequired(isOutboundCompressRequired);
        partnershipDAOData.setIsReceiptSignRequired(isReceiptSignRequired);
        partnershipDAOData.setIsInboundSignRequired(isInboundSignRequired);
        partnershipDAOData.setIsInboundEncryptRequired(isInbouhndEncryptRequired);
        partnershipDAOData.setSignAlgorithm(signAlgorithm);
        partnershipDAOData.setEncryptAlgorithm(encryptAlgorithm);
        partnershipDAOData.setMicAlgorithm(micAlgorithm);
        partnershipDAOData.setIsDisabled(isDisabled);
        partnershipDAOData.setRetries(StringUtilities.parseInt(retries));
        partnershipDAOData.setRetryInterval(StringUtilities.parseInt(retryInterval));

        if ("add".equalsIgnoreCase(requestAction)) {
            getPartnership(partnershipDAOData, dom, "add_partnership/");
        }

        if (partnershipId.equals("")) {
            request.setAttribute(ATTR_MESSAGE, "Partnership ID cannot be empty");
            return;
        }
        if (as2From.equals("")) {
            request.setAttribute(ATTR_MESSAGE, "AS2 From cannot be empty");
            return;
        }
        if (as2To.equals("")) {
            request.setAttribute(ATTR_MESSAGE, "AS2 To cannot be empty");
            return;
        }
        if (as2From.length() > 100) {
            request.setAttribute(ATTR_MESSAGE, "AS2 From cannot be longer than 100 characters.");
            return;
        }
        if (as2To.length() > 100) {
            request.setAttribute(ATTR_MESSAGE, "AS2 To cannot be longer than 100 characters.");
            return;
        }

        if (partnershipDAOData.getRetries() == Integer.MIN_VALUE) {
            request.setAttribute(ATTR_MESSAGE, "Retries must be integer");
            return;
        }
        if (partnershipDAOData.getRetryInterval() == Integer.MIN_VALUE) {
            request.setAttribute(ATTR_MESSAGE, "Retry Interval must be integer");
            return;
        }

        // encrypt cert
        if (hasRemoveEncryptCert) {
            partnershipDAOData.setEncryptCert(null);
        }
        if (hasEncryptCert) {
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                IOHandler.pipe(encryptCertInputStream, baos);
                CertificateFactory.getInstance("X.509")
                        .generateCertificate(new ByteArrayInputStream(baos.toByteArray()));
                partnershipDAOData.setEncryptCert(baos.toByteArray());
            } catch (Exception e) {
                request.setAttribute(ATTR_MESSAGE, "Uploaded encrypt cert is not an X.509 cert");
                return;
            }
        }
        // verify cert
        if (hasRemoveVerifyCert) {
            partnershipDAOData.setVerifyCert(null);
        }
        if (hasVerifyCert) {
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                IOHandler.pipe(verifyCertInputStream, baos);
                CertificateFactory.getInstance("X.509")
                        .generateCertificate(new ByteArrayInputStream(baos.toByteArray()));
                partnershipDAOData.setVerifyCert(baos.toByteArray());
            } catch (Exception e) {
                request.setAttribute(ATTR_MESSAGE, "Uploaded verify cert is not an X.509 cert");
                return;
            }
        }

        // check partnership conflict
        if (!partnershipDAOData.isDisabled()) {
            Iterator allConflictDAOData = partnershipDAO
                    .findPartnershipsByPartyID(partnershipDAOData.getAS2From(), partnershipDAOData.getAs2To())
                    .iterator();
            while (allConflictDAOData.hasNext()) {
                PartnershipDVO conflictDAOData = (PartnershipDVO) allConflictDAOData.next();
                if (conflictDAOData != null
                        && !conflictDAOData.getPartnershipId().equals(partnershipDAOData.getPartnershipId())
                        && !conflictDAOData.isDisabled()) {
                    request.setAttribute(ATTR_MESSAGE, "Partnership '" + conflictDAOData.getPartnershipId()
                            + "' with same From/To party IDs has already been enabled");
                    return;
                }
            }
        }

        // dao action
        if ("add".equalsIgnoreCase(requestAction)) {

            partnershipDAO.create(partnershipDAOData);
            request.setAttribute(ATTR_MESSAGE, "Partnership added successfully");
            dom.removeProperty("/partnerships/add_partnership");
            dom.setProperty("/partnerships/add_partnership", "");
        }
        if ("update".equalsIgnoreCase(requestAction)) {
            partnershipDAO.persist(partnershipDAOData);
            request.setAttribute(ATTR_MESSAGE, "Partnership updated successfully");
        }
        if ("delete".equalsIgnoreCase(requestAction)) {
            partnershipDAO.remove(partnershipDAOData);
            request.setAttribute(ATTR_MESSAGE, "Partnership deleted successfully");
        }
    }
}

From source file:com.tt.jobtracker.MainActivity.java

private String getRegistrationId(Context context) {
    final SharedPreferences prefs = getGcmPreferences(context);
    String registrationId = prefs.getString(PROPERTY_REG_ID, "");
    if (registrationId.isEmpty()) {
        return "";
    }/*from   w w  w . j  a  va2s  .  c  om*/
    int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion) {
        return "";
    }
    //      sendRegistrationIdToBackend(registrationId, Shared.LoggedInUser.ID);

    return registrationId;
}

From source file:com.nts.alphamale.monitor.EventMonitor.java

private void makeKeyEvent(EventLog evtLog) {

    if (evtLog.getAbsLabel().equals("BTN_TOUCH")) {
        return;/*from w  ww. ja v  a 2 s  .  c  o  m*/
    }
    if (evtLog.getAbsLabel().equals("BTN_TOOL_FINGER")) {
        return;
    }
    if (evtLog.getAbsLabel().equals("MT_TOOL_PEN")) {
        return;
    }

    //TODO   long press  ?  abs_value max(EV_KEY UP ?)  ?  timestamp ? .
    long evtTime = evtLog.getCurTimeStamp();

    if (evtLog.getAbsValue() == Integer.MIN_VALUE) {
        Event event = EventFactory.createEvent(EventType.PRESS_KEY);
        Map<String, Object> value = new HashMap<String, Object>();
        value.put("keyValue", "recent");
        if (evtLog.getAbsLabel().contains("HOME")) {
            value.put("keyValue", "home");
        }
        if (evtLog.getAbsLabel().contains("BACK")) {
            value.put("keyValue", "back");
        }
        if (evtLog.getAbsLabel().contains("VOLUMEUP")) {
            value.put("keyValue", "volume up");
        }
        if (evtLog.getAbsLabel().contains("VOLUMEDOWN")) {
            value.put("keyValue", "volume down");
        }
        if (evtLog.getAbsLabel().contains("POWER")) {
            value.put("keyValue", "power");
        }
        event.setEventStartTime(evtTime);
        event.setEventEndTime(evtTime);
        event.setElapsedTime(0);
        event.setEventMonitoringData(value);
        listener.onCatchEvent(event);
    }
}

From source file:fr.mdk.kisspush.KISSPush.java

/**
 * Gets the current registration ID for application on GCM service, if there
 * is one.// w  w w .j  av  a2 s.  c om
 * <p>
 * If result is empty, the app needs to register.
 *
 * @return registration ID, or empty string if there is no existing
 *         registration ID.
 */
private String getRegistrationId(Context context) {
    final SharedPreferences prefs = getGcmPreferences(context);
    String registrationId = prefs.getString(PROPERTY_REG_ID, "");
    if (registrationId.isEmpty()) {
        Log.i(TAG, "Registration not found.");
        return "";
    }
    // Check if app was updated; if so, it must clear the registration ID
    // since the existing regID is not guaranteed to work with the new
    // app version.
    int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion) {
        Log.i(TAG, "App version changed.");
        return "";
    }

    Log.i(TAG, "Registration ID found in SharedPreferences: " + registrationId);
    return registrationId;
}