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.util.GeneralUtils.java

/**
* Prepares a list of chunks to avoid the IN statement
* limitations in some databases (for ex. Oracle)
* @param objectIDs/*from  w  w  w .ja  v  a 2 s.  c o m*/
* @return
*/
public static List<int[]> getListOfChunks(Set<Integer> objectIDList) {
    if (objectIDList == null || objectIDList.isEmpty()) {
        return new LinkedList<int[]>();
    }
    int[] arrInts = new int[objectIDList.size()];
    int i = 0;
    for (Integer intValue : objectIDList) {
        if (intValue != null) {
            arrInts[i++] = intValue.intValue();
        }
    }
    return getListOfChunks(arrInts);
}

From source file:org.cfr.capsicum.datasource.DataSourceUtils.java

/**
 * Reset the given Connection after a transaction,
 * regarding read-only flag and isolation level.
 * @param con the Connection to reset/*w  ww  .j  a  v a  2 s . co  m*/
 * @param previousIsolationLevel the isolation level to restore, if any
 * @see #prepareConnectionForTransaction
 */
public static void resetConnectionAfterTransaction(Connection con, Integer previousIsolationLevel) {
    Assert.notNull(con, "No Connection specified");
    try {
        // Reset transaction isolation to previous value, if changed for the transaction.
        if (previousIsolationLevel != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("Resetting isolation level of JDBC Connection [" + con + "] to "
                        + previousIsolationLevel);
            }
            con.setTransactionIsolation(previousIsolationLevel.intValue());
        }

        // Reset read-only flag.
        if (con.isReadOnly()) {
            if (logger.isDebugEnabled()) {
                logger.debug("Resetting read-only flag of JDBC Connection [" + con + "]");
            }
            con.setReadOnly(false);
        }
    } catch (Throwable ex) {
        logger.debug("Could not reset JDBC Connection after transaction", ex);
    }
}

From source file:io.fabric8.maven.core.util.KubernetesResourceUtil.java

public static boolean addPort(List<ContainerPort> ports, String portNumberText, String portName, Logger log) {
    if (Strings.isNullOrBlank(portNumberText)) {
        return false;
    }/*from  w  w w.j av  a 2s. c om*/
    int portValue;
    try {
        portValue = Integer.parseInt(portNumberText);
    } catch (NumberFormatException e) {
        log.warn("Could not parse remote debugging port %s as an integer: %s", portNumberText, e);
        return false;
    }
    for (ContainerPort port : ports) {
        String name = port.getName();
        Integer containerPort = port.getContainerPort();
        if (containerPort != null && containerPort.intValue() == portValue) {
            return false;
        }
    }
    ports.add(new ContainerPortBuilder().withName(portName).withContainerPort(portValue).build());
    return true;
}

From source file:org.helm.notation2.tools.HELM2NotationUtils.java

/**
 * @param helm2notation HELM2Notation/*from   w w w . j  av  a2  s  .  com*/
 * @param paddingChar
 * @param basePairChar
 * @return string array of formated nucleotide sequence
 * @throws NotationException
 * @throws RNAUtilsException
 * @throws HELM2HandledException
 * @throws org.helm.notation2.exception.NotationException
 * @throws ChemistryException if the Chemistry Engine can not be initialized
 */
public static String[] getFormatedSirnaSequences(HELM2Notation helm2notation, String paddingChar,
        String basePairChar) throws NotationException, RNAUtilsException, HELM2HandledException,
        org.helm.notation2.exception.NotationException, ChemistryException {
    if (null == paddingChar || paddingChar.length() != 1) {
        throw new NotationException("Padding string must be single character");
    }

    if (null == basePairChar || basePairChar.length() != 1) {
        throw new NotationException("Base pair string must be single character");
    }

    List<PolymerNotation> rnaList = getRNAPolymers(helm2notation.getListOfPolymers());
    int count = rnaList.size();
    if (count == 0) {
        return new String[0];
    } else if (count == 1) {
        return new String[] { RNAUtils.getSequence(rnaList.get(0)) };
    } else if (count == 2) {
        String rna1Seq = null;
        String rna2Seq = null;
        String rna1Annotation = null;
        String rna2Annotation = null;
        PolymerNotation one = null;
        PolymerNotation two = null;

        for (PolymerNotation node : rnaList) {
            if (node.getPolymerID().getId().equals("RNA1")) {
                rna1Seq = RNAUtils.getSequence(node);
                rna1Annotation = node.getAnnotation();
                one = node;
            } else if (node.getPolymerID().getId().equals("RNA2")) {
                rna2Seq = RNAUtils.getSequence(node);
                two = node;
                rna2Annotation = node.getAnnotation();
            }
        }
        String reverseRna2Seq = RNAUtils.getReverseSequence(two);

        List<ConnectionNotation> connections = getAllBasePairConnections(helm2notation.getListOfConnections());
        if (null == connections || connections.size() == 0) {
            return new String[] { rna1Seq, rna2Seq };
        } else {
            Map<Integer, Integer> monomerPositionMap = getSirnaMonomerPositionMap(connections);
            Map<Integer, Integer> seqPositionMap = new HashMap<Integer, Integer>();
            Set<Integer> monomerSet = monomerPositionMap.keySet();
            for (Integer key : monomerSet) {
                Integer value = monomerPositionMap.get(key);
                Integer seqKey = new Integer(key.intValue() / 3 + 1);
                Integer seqValue = new Integer(value.intValue() / 3 + 1);
                seqPositionMap.put(seqKey, seqValue);
            }

            Set<Integer> seqSet = seqPositionMap.keySet();
            List<Integer> seqList = new ArrayList<Integer>();
            for (Integer key : seqSet) {
                seqList.add(key);
            }
            Collections.sort(seqList);

            int rna1First = seqList.get(0).intValue();
            int rna2Last = seqPositionMap.get(seqList.get(0)).intValue();
            int rna1Last = seqList.get(seqList.size() - 1).intValue();
            int rna2First = seqPositionMap.get(seqList.get(seqList.size() - 1)).intValue();

            if ((rna1Last - rna1First) != (rna2Last - rna2First)) {
                throw new NotationException("siRNA matching lengths are different");
            }

            int rna1LeftOverhang = rna1First - 1;
            int rna1RightOverhang = rna1Seq.length() - rna1Last;
            int rna2LeftOverhang = rna2Seq.length() - rna2Last;
            int rna2RightOverhang = rna2First - 1;
            StringBuffer[] sbs = new StringBuffer[3];
            for (int i = 0; i < sbs.length; i++) {
                sbs[i] = new StringBuffer();
            }

            if (rna1LeftOverhang >= rna2LeftOverhang) {
                sbs[0].append(rna1Seq);

                for (int i = 0; i < rna1LeftOverhang; i++) {
                    sbs[1].append(paddingChar);
                }
                for (int i = rna1First; i < (rna1Last + 1); i++) {
                    Integer in = new Integer(i);
                    if (seqPositionMap.containsKey(in)) {
                        sbs[1].append(basePairChar);
                    } else {
                        sbs[1].append(paddingChar);
                    }
                }

                for (int i = 0; i < rna1LeftOverhang - rna2LeftOverhang; i++) {
                    sbs[2].append(paddingChar);
                }
                sbs[2].append(reverseRna2Seq);
            } else {
                for (int i = 0; i < rna2LeftOverhang - rna1LeftOverhang; i++) {
                    sbs[0].append(paddingChar);
                }
                sbs[0].append(rna1Seq);

                for (int i = 0; i < rna2LeftOverhang; i++) {
                    sbs[1].append(paddingChar);
                }
                for (int i = rna1First; i < (rna1Last + 1); i++) {
                    Integer in = new Integer(i);
                    if (seqPositionMap.containsKey(in)) {
                        sbs[1].append(basePairChar);
                    } else {
                        sbs[1].append(paddingChar);
                    }
                }

                sbs[2].append(reverseRna2Seq);
            }

            if (rna1RightOverhang >= rna2RightOverhang) {
                for (int i = 0; i < rna1RightOverhang; i++) {
                    sbs[1].append(paddingChar);
                }

                for (int i = 0; i < rna1RightOverhang - rna2RightOverhang; i++) {
                    sbs[2].append(paddingChar);
                }
            } else {
                for (int i = 0; i < rna2RightOverhang - rna1RightOverhang; i++) {
                    sbs[0].append(paddingChar);
                }

                for (int i = 0; i < rna2RightOverhang - rna1RightOverhang; i++) {
                    sbs[1].append(paddingChar);
                }
            }

            if ((rna1Annotation != null && rna1Annotation.equalsIgnoreCase("AS"))
                    || (rna2Annotation != null && rna2Annotation.equalsIgnoreCase("SS"))) {
                return new String[] { reverseString(sbs[2].toString()), reverseString(sbs[1].toString()),
                        reverseString(sbs[0].toString()) };
            } else {
                return new String[] { sbs[0].toString(), sbs[1].toString(), sbs[2].toString() };
            }
        }

    } else {
        throw new NotationException("Structure contains more than two RNA sequences");
    }

}

From source file:org.metawatch.manager.Monitors.java

public static int getGmailUnreadCount() {
    if (Preferences.logging)
        Log.d(MetaWatch.TAG, "Monitors.getGmailUnreadCount()");
    int totalCount = 0;
    for (String key : gmailUnreadCounts.keySet()) {
        Integer accountCount = gmailUnreadCounts.get(key);
        totalCount += accountCount.intValue();
        if (Preferences.logging)
            Log.d(MetaWatch.TAG, "Monitors.getGmailUnreadCount(): account='" + key + "' accountCount='"
                    + accountCount + "' totalCount='" + totalCount + "'");
    }//w ww .jav  a  2  s .  co  m
    return totalCount;
}

From source file:com.aurel.track.util.GeneralUtils.java

/**
 * Creates an array of ints from an List of Integers
 * @param integerList/*from   w w w . j  a v  a2s. c o m*/
 * @return
 */
public static int[] createIntArrFromIntegerList(List<Integer> integerList) {
    if (integerList == null) {
        return null;
    }
    int[] intArr = new int[integerList.size()];
    Iterator<Integer> iterator = integerList.iterator();
    int i = 0;
    while (iterator.hasNext()) {
        try {
            Integer integer = iterator.next();
            if (integer != null) {
                intArr[i++] = integer.intValue();
            }
        } catch (Exception e) {
            LOGGER.warn("Converting the list value to int failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    return intArr;
}

From source file:com.aurel.track.util.GeneralUtils.java

/**
 * Creates an array of ints from an List of Integers
 * @param integerList//  w ww  .  j  a v a 2  s.  c om
 * @return
 */
public static int[] createIntArrFromIntegerCollection(Collection<Integer> integerList) {
    if (integerList == null) {
        return null;
    }
    int[] intArr = new int[integerList.size()];
    Iterator<Integer> iterator = integerList.iterator();
    int i = 0;
    while (iterator.hasNext()) {
        try {
            Integer integer = iterator.next();
            if (integer != null) {
                intArr[i++] = integer.intValue();
            }
        } catch (Exception e) {
            LOGGER.warn("Converting the list value to int failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    return intArr;
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.publico.teachersBody.ReadProfessorshipsAndResponsibilitiesByDepartmentAndExecutionPeriod.java

protected static List getDetailedProfessorships(List professorships, final List responsibleFors,
        final Integer teacherType) {

    List detailedProfessorshipList = (List) CollectionUtils.collect(professorships, new Transformer() {

        @Override/*from ww  w . j  a  v  a 2s. c o m*/
        public Object transform(Object input) {

            Professorship professorship = (Professorship) input;

            InfoProfessorship infoProfessorShip = InfoProfessorship.newInfoFromDomain(professorship);

            List executionCourseCurricularCoursesList = getInfoCurricularCourses(
                    professorship.getExecutionCourse());

            DetailedProfessorship detailedProfessorship = new DetailedProfessorship();

            Boolean isResponsible = Boolean.valueOf(professorship.getResponsibleFor());

            if ((teacherType.intValue() == 1) && (!isResponsible.booleanValue())) {
                return null;
            }

            detailedProfessorship.setResponsibleFor(isResponsible);

            detailedProfessorship.setInfoProfessorship(infoProfessorShip);
            detailedProfessorship.setExecutionCourseCurricularCoursesList(executionCourseCurricularCoursesList);

            return detailedProfessorship;
        }

        private List getInfoCurricularCourses(ExecutionCourse executionCourse) {

            List infoCurricularCourses = (List) CollectionUtils
                    .collect(executionCourse.getAssociatedCurricularCoursesSet(), new Transformer() {

                        @Override
                        public Object transform(Object input) {

                            CurricularCourse curricularCourse = (CurricularCourse) input;

                            InfoCurricularCourse infoCurricularCourse = InfoCurricularCourse
                                    .newInfoFromDomain(curricularCourse);
                            return infoCurricularCourse;
                        }
                    });
            return infoCurricularCourses;
        }
    });

    return detailedProfessorshipList;
}

From source file:com.aurel.track.report.dashboard.AverageTimeToCloseItem.java

/**
 * Add the time series to the timeSeriesCollection
 * SortedMap at first and second level (year and period)
 * (Sorted because the accumulated should be calculated in the right order)
 * @param timeSeriesCollection//from w w  w .j  a v a 2s. com
 * @param yearToPeriodToOpenedWorkItemCountMap
 * @param selectedTimeInterval
*/
public static SortedMap<Date, Object> transformPeriodsToDates(
        SortedMap/*<Integer, SortedMap<Integer, Object>>*/ yearToPeriodToValuesMap, int selectedTimeInterval) {
    SortedMap<Date, Object> dateToValue = new TreeMap<Date, Object>();
    for (Iterator iterator = yearToPeriodToValuesMap.keySet().iterator(); iterator.hasNext();) {
        Integer year = (Integer) iterator.next();
        SortedMap<Integer, Object> intervalToStatusChangeBeans = (SortedMap<Integer, Object>) yearToPeriodToValuesMap
                .get(year);
        Iterator<Integer> periodIterator = intervalToStatusChangeBeans.keySet().iterator();
        while (periodIterator.hasNext()) {
            Integer period = periodIterator.next();
            Object periodValue = intervalToStatusChangeBeans.get(period);
            if (periodValue != null) {
                dateToValue.put(createDate(period.intValue(), year.intValue(), selectedTimeInterval),
                        periodValue);
            }
        }
    }
    return dateToValue;
}

From source file:io.fabric8.maven.core.util.KubernetesResourceUtil.java

private static void ensureHasPort(Container container, ContainerPort port) {
    List<ContainerPort> ports = container.getPorts();
    if (ports == null) {
        ports = new ArrayList<>();
        container.setPorts(ports);/*  ww w  . j  a v a2 s.  co  m*/
    }
    for (ContainerPort cp : ports) {
        String n1 = cp.getName();
        String n2 = port.getName();
        if (n1 != null && n2 != null && n1.equals(n2)) {
            return;
        }
        Integer p1 = cp.getContainerPort();
        Integer p2 = port.getContainerPort();
        if (p1 != null && p2 != null && p1.intValue() == p2.intValue()) {
            return;
        }
    }
    ports.add(port);
}