Example usage for org.apache.commons.lang.math Range getMinimumInteger

List of usage examples for org.apache.commons.lang.math Range getMinimumInteger

Introduction

In this page you can find the example usage for org.apache.commons.lang.math Range getMinimumInteger.

Prototype

public int getMinimumInteger() 

Source Link

Document

Gets the minimum number in this range as a int.

This implementation uses the #getMinimumNumber() method.

Usage

From source file:au.org.ala.delta.model.impl.DefaultAttributeDataTest.java

private void checkRange(NumericRange range, int extremeMin, int extremeMax, int middle, int min, int max) {
    assertEquals(extremeMin, range.getExtremeLow().intValue());
    assertEquals(extremeMax, range.getExtremeHigh().intValue());
    assertEquals(middle, range.getMiddle().intValue());
    Range normalRange = range.getNormalRange();
    assertEquals(min, normalRange.getMinimumInteger());
    assertEquals(max, normalRange.getMaximumInteger());
}

From source file:au.org.ala.delta.model.impl.DefaultAttributeDataTest.java

private void checkRange(NumericRange range, int min, int max) {
    assertNull(range.getExtremeLow());/*from  www .j  ava 2  s  .  co m*/
    assertNull(range.getExtremeHigh());

    Range normalRange = range.getNormalRange();
    assertEquals(min, normalRange.getMinimumInteger());
    assertEquals(max, normalRange.getMaximumInteger());
}

From source file:edu.cornell.med.icb.goby.reads.TestQualityEncoding.java

/**
 * Validate score conversion for {@link edu.cornell.med.icb.goby.reads.QualityEncoding#SANGER}.
 *//*from  w w w . ja v a 2s. com*/
@Test
public void sanger() {
    final Range qualityRange = new IntRange(0, 40);
    final String qualityChars = encodedQualityCharacters.substring(0, 40);
    final QualityEncoding encoding = QualityEncoding.SANGER;
    for (int i = 0; i < 40; i++) {
        final byte score = (byte) (qualityRange.getMinimumInteger() + i);
        assertEquals("wrong character for score " + score, qualityChars.charAt(i),
                encoding.phredQualityScoreToAsciiEncoding(score));
        assertEquals("wrong score for character " + qualityChars.charAt(i), score,
                encoding.asciiEncodingToPhredQualityScore(qualityChars.charAt(i)));
    }

    final QualityEncoding solexaEncoding = QualityEncoding.ILLUMINA;
    for (byte qPhred = 0; qPhred < 93; qPhred++) {
        final char sanger = solexaEncoding.phredQualityScoreToAsciiEncoding(qPhred);
        final byte roundTrip = solexaEncoding.asciiEncodingToPhredQualityScore(sanger);
        assertEquals(qPhred, roundTrip);

    }
}

From source file:edu.cornell.med.icb.goby.reads.TestQualityEncoding.java

/**
 * Validate score conversion for//from  w  ww .j av a2s.  c  om
 * {@link edu.cornell.med.icb.goby.reads.QualityEncoding#ILLUMINA}.
 */
@Test
public void illumina() {
    final Range qualityRange = new IntRange(0, 40);
    final String qualityChars = encodedQualityCharacters.substring(31, 71);
    final QualityEncoding encoding = QualityEncoding.ILLUMINA;
    for (int i = 0; i < 40; i++) {
        final byte score = (byte) (qualityRange.getMinimumInteger() + i);
        assertEquals("wrong character for score " + score, qualityChars.charAt(i),
                encoding.phredQualityScoreToAsciiEncoding(score));
        assertEquals("wrong score for character " + qualityChars.charAt(i), score,
                encoding.asciiEncodingToPhredQualityScore(qualityChars.charAt(i)));
    }

    final QualityEncoding solexaEncoding = QualityEncoding.ILLUMINA;
    for (byte qPhred = 0; qPhred < 62; qPhred++) {
        final char illumina13 = solexaEncoding.phredQualityScoreToAsciiEncoding(qPhred);
        final byte roundTrip = solexaEncoding.asciiEncodingToPhredQualityScore(illumina13);
        assertEquals(qPhred, roundTrip);

    }
}

From source file:au.org.ala.delta.translation.intkey.IntkeyItemsFileWriter.java

private Pair<IntRange, Boolean> writeIntegerAttributes(int filteredCharacterNumber, Character character) {

    // Returning null here will trigger a change from integer to real
    // character type.
    if (_context.getTreatIntegerCharacterAsReal(character.getCharacterId())) {
        return new Pair<IntRange, Boolean>(new IntRange(0), true);
    }//from  w w  w.  j  ava 2s  .  c o m
    Pair<IntRange, Boolean> result = determineIntegerRange(character);
    IntRange characterRange = result.getFirst();
    if (!result.getSecond()) {

        int unfilteredCharNumber = character.getCharacterId();
        int numStates = characterRange.getMaximumInteger() - characterRange.getMinimumInteger();
        List<BitSet> attributes = new ArrayList<BitSet>();

        Iterator<FilteredItem> items = _dataSet.filteredItems();
        while (items.hasNext()) {
            FilteredItem item = items.next();

            // Turn into bitset.
            BitSet bits = new BitSet();
            IntegerAttribute attribute = (IntegerAttribute) _dataSet
                    .getAttribute(item.getItem().getItemNumber(), unfilteredCharNumber);
            if (isInapplicable(attribute)) {
                bits.set(numStates + 3);
                if (attribute.isInherited()) {
                    attributes.add(bits);
                    continue;
                }
            }
            if (attribute.isUnknown()) {
                attributes.add(bits);
                continue;
            }

            List<NumericRange> ranges = attribute.getNumericValue();

            for (NumericRange range : ranges) {
                Range usedRange;
                if (_context.getUseNormalValues(unfilteredCharNumber)) {
                    usedRange = range.getNormalRange();
                } else {
                    usedRange = range.getFullRange();
                }

                for (int j = usedRange.getMinimumInteger(); j <= usedRange.getMaximumInteger(); j++) {
                    if (j < characterRange.getMinimumInteger()) {
                        bits.set(0);
                    } else if (j <= characterRange.getMaximumInteger()) {
                        bits.set(j - characterRange.getMinimumInteger() + 1);
                    } else {
                        bits.set(numStates + 2);
                    }
                }
            }
            attributes.add(bits);

        }

        _itemsFile.writeAttributeBits(filteredCharacterNumber, attributes, numStates + 4);
    }
    return new Pair<IntRange, Boolean>(characterRange, result.getSecond());
}

From source file:org.mifos.customers.ppi.business.PPILikelihood.java

private void checkRange(Range score) throws ValidationException {
    int maxPoints = GeneralConfig.getMaxPointsPerPPISurvey();
    if (score.getMinimumInteger() < 0 || score.getMaximumInteger() > maxPoints) {
        throw new ValidationException("exception.validation.ppi.PpiLikelihoodArgsInvalidException");
    }/*from  w  w  w.  j  a v  a 2  s  .  c o m*/
}

From source file:org.osframework.contract.date.fincal.holiday.producer.SingleFinancialCalendarProducer.java

public Holiday[] produce(Integer... years) {
    Arrays.sort(years);/* w  w w  . j  a  v a  2 s . co m*/
    Range yearRange = new IntRange(years[0], years[years.length - 1]);
    List<Holiday> holidays = new LinkedList<Holiday>();
    for (int year = yearRange.getMinimumInteger(); yearRange.containsInteger(year); year++) {
        for (HolidayDefinition hd : calendar) {
            HolidayExpression expr = CentralBankDecoratorLocator.decorate(hd, calendar.getCentralBank());
            Date date = expr.evaluate(year);
            holidays.add(new Holiday(calendar, date, hd));
        }
        if (weekendsAsHolidays) {
            this.addWeekends(year, holidays);
        }
    }
    return holidays.toArray(EMPTY_ARRAY);
}