Example usage for java.lang Integer intValue

List of usage examples for java.lang Integer intValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public int intValue() 

Source Link

Document

Returns the value of this Integer as an int .

Usage

From source file:com.aurel.track.item.ItemActionJSON.java

public static String encodeFieldDisplayValues(Set<Integer> presentFields, WorkItemContext workItemContext,
        boolean useProjectSpecificID, boolean isMobileApplication) {
    StringBuilder sb = new StringBuilder();
    sb.append("{");

    for (Iterator<Integer> iterator = presentFields.iterator(); iterator.hasNext();) {
        Integer fieldID = iterator.next();
        IFieldTypeRT fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID);

        Object value = workItemContext.getWorkItemBean().getAttribute(fieldID);
        String displayValue = null;

        if (useProjectSpecificID && fieldID.intValue() == SystemFields.ISSUENO) {
            displayValue = ItemBL.getSpecificProjectID(workItemContext);
        } else {/*from   www .j a v  a2  s  .  com*/
            if (fieldTypeRT != null) {
                displayValue = fieldTypeRT.getShowValue(value, workItemContext, fieldID);
            }
        }
        if (fieldID == SystemFields.DESCRIPTION) {
            displayValue = ItemDetailBL.formatDescription(displayValue, workItemContext.getLocale());
        }
        if (isMobileApplication) {
            try {
                if (fieldTypeRT.getValueType() == ValueType.LONGTEXT) {
                    displayValue = Html2Text.getNewInstance().convert(displayValue);
                    displayValue = displayValue.replaceAll("[\n\r]", "");
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                LOGGER.error(ExceptionUtils.getStackTrace(e));
            }
        }
        //append "," after each value. we need to remove the last one
        JSONUtility.appendStringValue(sb, "f" + fieldID, displayValue);
    }
    if (sb.length() > 1) {
        //remove last ","
        sb.deleteCharAt(sb.length() - 1);
    }
    sb.append("}");
    return sb.toString();
}

From source file:com.aurel.track.persist.TDashboardFieldPeer.java

/**
 * Gets the last used sort order/*from   w  w w . ja v  a 2  s.  c  o m*/
 * @param objectID
 * @return
 */
public static Integer getNextSortOrder(Integer objectID) {
    Integer sortOrder = null;
    Criteria crit = new Criteria();
    crit.add(PARENT, objectID);
    try {
        sortOrder = ((Record) doSelectVillageRecords(crit).get(0)).getValue(1).asIntegerObj();
    } catch (Exception e) {
    }
    if (sortOrder != null) {
        sortOrder = new Integer(sortOrder.intValue() + 1);
    } else {
        sortOrder = new Integer(1);
    }
    return sortOrder;
}

From source file:com.aurel.track.item.SendItemEmailBL.java

public static String getFieldDisplayValue(Integer fieldID, WorkItemContext workItemContext,
        boolean useProjectSpecificID) {
    Object value = workItemContext.getWorkItemBean().getAttribute(fieldID);
    String displayValue = null;/*from  w w w .  ja v  a2 s.co m*/
    if (useProjectSpecificID && fieldID.intValue() == SystemFields.ISSUENO) {
        displayValue = ItemBL.getSpecificProjectID(workItemContext);
    } else {
        IFieldTypeRT fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID);
        if (fieldTypeRT != null) {
            displayValue = fieldTypeRT.getShowValue(value, workItemContext, fieldID);
        }
    }
    if (fieldID == SystemFields.DESCRIPTION) {
        displayValue = ItemDetailBL.formatDescription(displayValue, workItemContext.getLocale());
    }
    return displayValue;
}

From source file:com.borqs.sync.server.contact.MergeUtils.java

/**
 *
 *///from w  w w  . j  av  a2s  .  co m
public static MergeResult compareIntegers(Integer integerA, Integer integerB) {

    MergeResult result = null;

    if (integerA == null && integerB == null) {
        return new MergeResult(false, false);
    }

    if (integerA != null && integerB == null) {
        result = new MergeResult();
        result.addPropertyB("Integer", integerA.intValue() + ", null");
        return result;
    }

    if (integerA == null && integerB != null) {
        result = new MergeResult();
        result.addPropertyA("Integer", "null, " + integerB.intValue());
        return result;
    }

    if (integerA.compareTo(integerB) != 0) {
        //
        // The values are different so
        // an update on integerB is required
        //
        result = new MergeResult();
        result.addPropertyB("Integer", integerA.intValue() + ", " + integerB.intValue());
        return result;
    }

    return new MergeResult(false, false);
}

From source file:com.aurel.track.fieldType.runtime.bl.AttributeValueBL.java

/**
 * Prepares a map of maps with attributeValueBeans:
 *    -   key:   workItemKey//from w  w  w . ja va 2  s .co  m
 *    -   value:   map
 *          -   key:   fieldID_parameterCode
 *          -   value:   attributeValueBean or list of attributeValueBeans 
 *                   (custom and system selects because they might be multiple)
 * attributeValueBeanList contains attributeValueBeans for the more workItems
 * @param attributeValueBeanList list of attributeValueBeans
 * @param customOptionIDs output parameter for gathering the optionIDs
 * @return
 */
public static Map<Integer, Map<String, Object>> prepareAttributeValueMapForWorkItems(
        List<TAttributeValueBean> attributeValueBeanList, Set<Integer> customOptionIDs,
        Map<Integer, Set<Integer>> externalOptionsMap) {
    Map<Integer, Map<String, Object>> workItemsAttributesMap = new HashMap<Integer, Map<String, Object>>();
    //load the custom attributes to workItemBeans
    if (attributeValueBeanList != null) {
        for (TAttributeValueBean attributeValueBean : attributeValueBeanList) {
            Integer workItemKey = attributeValueBean.getWorkItem();
            Integer fieldID = attributeValueBean.getField();
            Integer customOptionID = attributeValueBean.getCustomOptionID();
            //gather the custom options
            if (customOptionIDs != null && customOptionID != null) {
                customOptionIDs.add(customOptionID);
            }
            //gather the external options
            if (externalOptionsMap != null) {
                Integer integerValue = attributeValueBean.getIntegerValue();
                if (integerValue != null) {
                    IFieldTypeRT fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID);
                    if (fieldTypeRT != null && fieldTypeRT.getValueType() == ValueType.EXTERNALID) {
                        Set<Integer> externalOptionIDs = externalOptionsMap.get(fieldID);
                        if (externalOptionIDs == null) {
                            externalOptionIDs = new HashSet<Integer>();
                            externalOptionsMap.put(fieldID, externalOptionIDs);
                        }
                        externalOptionIDs.add(integerValue);
                    }
                }
            }
            String mergeKey = MergeUtil.mergeKey(fieldID, attributeValueBean.getParameterCode());
            Map<String, Object> attributeValueBeanMap = workItemsAttributesMap.get(workItemKey);
            if (attributeValueBeanMap == null) {
                attributeValueBeanMap = new HashMap<String, Object>();
                workItemsAttributesMap.put(workItemKey, attributeValueBeanMap);
            }
            Integer valueType = attributeValueBean.getValidValue();
            if (valueType == null || (valueType.intValue() != ValueType.CUSTOMOPTION
                    && valueType.intValue() != ValueType.SYSTEMOPTION
                    && !SystemFields.INTEGER_COMMENT.equals(attributeValueBean.getField()))) {
                //direct value (not a select)
                attributeValueBeanMap.put(mergeKey, attributeValueBean);
            } else {
                //select value (custom or system): there might be more entries for the same mergeKey (when multiple=true).
                //Each fieldType should know whether it should get the value from 
                //the map as attributeValueBean or as list of attributeValueBeans 
                List<TAttributeValueBean> selectAttributeList = (List<TAttributeValueBean>) attributeValueBeanMap
                        .get(mergeKey);
                if (selectAttributeList == null) {
                    selectAttributeList = new LinkedList<TAttributeValueBean>();
                    attributeValueBeanMap.put(mergeKey, selectAttributeList);
                }
                selectAttributeList.add(attributeValueBean);
            }
        }
    }
    return workItemsAttributesMap;
}

From source file:com.adito.policyframework.ResourceUtil.java

/**
 * Gets a list of {@link Resource} granted for use for the specified
 * session.//from   ww w  . ja v  a  2s.  com
 * 
 * @param session session
 * @param resourceType resource type
 * @return list of resources
 * @throws Exception
 */
public static List getGrantedResource(SessionInfo session, ResourceType resourceType) throws Exception {
    List l = new ArrayList();
    List granted = PolicyDatabaseFactory.getInstance().getGrantedResourcesOfType(session.getUser(),
            resourceType);
    for (Iterator i = granted.iterator(); i.hasNext();) {
        Integer r = (Integer) i.next();
        Resource resource = resourceType.getResourceById(r.intValue());
        if (resource == null) {
            log.warn("Could not locate resource with ID of " + r.intValue() + " for type "
                    + resourceType.getResourceTypeId());
        } else {
            if (isPolicyResourceTypeEnforceable(resourceType) && Property
                    .getPropertyBoolean(new SystemConfigKey("security.enforce.policy.resource.access"))) {
                for (Iterator iter = PolicyDatabaseFactory.getInstance()
                        .getPoliciesAttachedToResource(resource, session.getUser().getRealm()).iterator(); iter
                                .hasNext();) {
                    Policy element = (Policy) iter.next();
                    List authSchemePolicies = (List) session.getHttpSession()
                            .getAttribute("auth.scheme.policies");
                    if (authSchemePolicies != null && (authSchemePolicies).contains(element)) {
                        l.add(resource);
                    }
                }
            } else {
                l.add(resource);
            }
        }
    }
    return l;
}

From source file:com.aurel.track.exchange.excel.ExcelFieldMatchBL.java

/**
 * Returns the first row of a sheet where there is the fields name
 * @return  Map<ColumnNumber, FieldLabelName>
 *//*from   w  w  w .  ja va  2s .c om*/
static SortedMap<Integer, String> getFirstRowNumericToLetter(Workbook hSSFWorkbook, Integer sheetID) {
    SortedMap<Integer, String> firstRowMap = new TreeMap<Integer, String>();
    if (hSSFWorkbook == null || sheetID == null) {
        return firstRowMap;
    }
    Sheet sheet = hSSFWorkbook.getSheetAt(sheetID.intValue());
    Row firstRow = sheet.getRow(0);
    if (firstRow != null) {
        for (Cell cell : firstRow) {
            firstRowMap.put(Integer.valueOf(cell.getColumnIndex()), colNumericToLetter(cell.getColumnIndex()));
        }
    }
    return firstRowMap;
}

From source file:gridool.sqlet.catalog.MapReduceConf.java

private static int[] toFieldIndexes(@Nullable Map<String, Integer> map) {
    if (map == null) {
        return new int[] { 0, 1, 2, 3, 4, 5, 6 };
    } else {/*from w w  w .ja v  a2s .co m*/
        Integer c0 = map.get("ID");
        Integer c1 = map.get("NODE");
        Integer c2 = map.get("DBURL");
        Integer c3 = map.get("USER");
        Integer c4 = map.get("PASSWORD");
        Integer c5 = map.get("XFER_PORT");
        Integer c6 = map.get("SHUFFLE_DATASINK");

        Preconditions.checkNotNull(c0, c1, c2, c3, c4, c5, c6);

        final int[] indexes = new int[7];
        indexes[0] = c0.intValue();
        indexes[1] = c1.intValue();
        indexes[2] = c2.intValue();
        indexes[3] = c3.intValue();
        indexes[4] = c4.intValue();
        indexes[5] = c5.intValue();
        indexes[6] = c6.intValue();
        return indexes;
    }
}

From source file:cn.edu.zju.acm.onlinejudge.util.ProblemManager.java

private static ProblemPackage parse(Map<String, byte[]> files, ActionMessages messages) {
    Map<String, ProblemEntry> entryMap = new TreeMap<String, ProblemEntry>();
    byte[] csv = files.get(ProblemManager.PROBLEM_CSV_FILE);

    BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(csv)));
    int index = 0;
    try {/*from   w  w w  .ja v a2s  .  c  om*/
        for (;;) {
            index++;
            String messageKey = "Line " + index;
            String line = reader.readLine();
            if (line == null) {
                break;
            }
            if (line.trim().length() == 0) {
                continue;
            }
            // CSV format code,title,checker,tl,ml,ol,sl,author,source,contest
            String[] values = ProblemManager.split(line);
            Problem problem = new Problem();
            if (values.length < 2) {
                messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.invalidline"));
                continue;
            }
            if (values[0].length() > 8 || values[0].length() == 0) {
                messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.invalidcode"));
            }

            problem.setCode(values[0]);

            if (values[1].length() > 128 || values[1].length() == 0) {
                messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.invalidtitle"));
            }
            problem.setTitle(values[1]);

            if (values.length > 2 && Boolean.valueOf(values[2]).booleanValue()) {
                problem.setChecker(true);
            }

            Limit limit = new Limit();

            Integer tl = ProblemManager.retrieveInt(values, 3);
            if (tl != null) {
                if (tl.intValue() < 0) {
                    messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.invalidtl"));
                } else {
                    limit.setTimeLimit(tl.intValue());
                }
            }
            Integer ml = ProblemManager.retrieveInt(values, 4);
            if (ml != null) {
                if (ml.intValue() < 0) {
                    messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.invalidml"));
                } else {
                    limit.setMemoryLimit(ml.intValue());
                }
            }
            Integer ol = ProblemManager.retrieveInt(values, 5);
            if (ol != null) {
                if (ol.intValue() < 0) {
                    messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.invalidol"));
                } else {
                    limit.setOutputLimit(ol.intValue());
                }
            }
            Integer sl = ProblemManager.retrieveInt(values, 6);
            if (sl != null) {
                if (sl.intValue() < 0) {
                    messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.invalidsl"));
                } else {
                    limit.setSubmissionLimit(sl.intValue());
                }
            }
            if (tl != null || ml != null || ol != null || sl != null) {
                if (tl != null && ml != null && ol != null && sl != null) {
                    problem.setLimit(limit);
                } else {
                    messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.missinglimit"));
                }
            }

            if (values.length > 7 && values[7].length() > 0) {
                if (values[7].length() > 32) {
                    messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.invalidauthor"));
                } else {
                    problem.setAuthor(values[7]);
                }
            }

            if (values.length > 8 && values[8].length() > 0) {
                if (values[8].length() > 128) {
                    messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.invalidsource"));
                } else {
                    problem.setSource(values[8]);
                }
            }

            if (values.length > 9 && values[9].length() > 0) {
                if (values[9].length() > 128) {
                    messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.invalidcontest"));
                } else {
                    problem.setContest(values[9]);
                }
            }
            ProblemEntry entry = new ProblemEntry();
            entry.setProblem(problem);
            if (entryMap.containsKey(problem.getCode())) {
                messages.add(messageKey, new ActionMessage("onlinejudge.importProblem.reduplicatecode"));
            }
            entryMap.put(problem.getCode(), entry);
        }
    } catch (IOException e) {
        messages.add("error", new ActionMessage("onlinejudge.importProblem.invalidproblemscsv"));
    }
    if (messages.size() > 0) {
        return null;
    }
    if (entryMap.size() == 0) {
        messages.add("error", new ActionMessage("onlinejudge.importProblem.emptyproblemscsv"));
    }

    ProblemPackage problemPackage = new ProblemPackage();
    problemPackage.setProblemEntries(new ProblemEntry[entryMap.size()]);

    // retrieve checker, input, output
    index = 0;
    for (String string : entryMap.keySet()) {
        ProblemEntry entry = entryMap.get(string);
        String code = entry.getProblem().getCode();
        byte[] checker = files.get(code + "/" + ProblemManager.CHECKER_FILE);
        byte[] input = files.get(code + "/" + ProblemManager.INPUT_FILE);
        byte[] output = files.get(code + "/" + ProblemManager.OUTPUT_FILE);
        byte[] text = files.get(code + "/" + ProblemManager.PROBLEM_TEXT_FILE);
        byte[] solution = null;
        byte[] checkerSource = null;
        String checkerSourceType = ProblemManager.getFileType(code, ProblemManager.CHECKER_SOURCE_FILE, files);
        if (checkerSourceType != null) {
            checkerSource = files
                    .get(code + "/" + ProblemManager.CHECKER_SOURCE_FILE + "." + checkerSourceType);
        }

        String solutionType = ProblemManager.getFileType(code, ProblemManager.JUDGE_SOLUTION_FILE, files);
        if (solutionType != null) {
            solution = files.get(code + "/" + ProblemManager.JUDGE_SOLUTION_FILE + "." + solutionType);
        }
        if ("cpp".equals(checkerSourceType)) {
            checkerSourceType = "cc";
        }
        if ("cpp".equals(solutionType)) {
            solutionType = "cc";
        }

        entry.setChecker(checker);
        entry.setInput(input);
        entry.setOutput(output);
        entry.setText(text);
        entry.setSolution(solution);
        entry.setSolutionType(solutionType);
        entry.setCheckerSource(checkerSource);
        entry.setCheckerSourceType(checkerSourceType);

        problemPackage.getProblemEntries()[index] = entry;
        index++;
    }
    // retrieve images
    Map<String, byte[]> imageMap = new HashMap<String, byte[]>();
    Map<String, String> usedImages = new HashMap<String, String>();
    Map<String, String> duplicateImages = new HashMap<String, String>();
    for (String string : files.keySet()) {
        String path = string;
        if (ProblemManager.isImageFile(path)) {
            String imageName = new File(path).getName();

            if (imageMap.containsKey(imageName)) {
                String s = duplicateImages.get(imageName);
                s = (s == null ? "" : s) + " " + path;
                duplicateImages.put(imageName, s);
            }
            if (ProblemManager.isUsed(imageName)) {
                String s = usedImages.get(imageName);
                s = (s == null ? "" : s) + " " + path;
                usedImages.put(imageName, s);
            }
            imageMap.put(imageName, files.get(path));

        }
    }
    problemPackage.setImages(imageMap);
    problemPackage.setUsedImages(usedImages);
    problemPackage.setDuplicateImages(duplicateImages);
    return problemPackage;
}

From source file:Main.java

/**
 * Access the Hashtable s_exportBatches to see what the current page count
 * of this export batch is. This call decrements the value in the table.
 *///w w w  . j a  va2  s . co  m
private static boolean isExportFileComplete(String p_fileId, int p_pageCount) {
    // Default is to write out the file.
    boolean result = true;
    int curPageCnt = -1;

    synchronized (s_exportBatches) {
        Integer oldPageCount = (Integer) s_exportBatches.get(p_fileId);
        if (oldPageCount == null) {
            // First page of this exportBatch.
            curPageCnt = p_pageCount - 1;
            if (curPageCnt == 0) {
                // The batch is complete, no need to put anything
                // in the hashtable.
                result = true;
            } else {
                result = false;
                s_exportBatches.put(p_fileId, new Integer(curPageCnt));
            }
        } else {
            curPageCnt = oldPageCount.intValue() - 1;
            if (curPageCnt == 0) {
                // The batch is complete, remove the value from the
                // hashtable.
                result = true;
                s_exportBatches.remove(p_fileId);
            } else {
                result = false;
                s_exportBatches.put(p_fileId, new Integer(curPageCnt));
            }
        }
    }

    return result;
}