Example usage for org.apache.commons.lang.math NumberUtils INTEGER_MINUS_ONE

List of usage examples for org.apache.commons.lang.math NumberUtils INTEGER_MINUS_ONE

Introduction

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

Prototype

Integer INTEGER_MINUS_ONE

To view the source code for org.apache.commons.lang.math NumberUtils INTEGER_MINUS_ONE.

Click Source Link

Document

Reusable Integer constant for minus one.

Usage

From source file:net.sf.reportengine.core.steps.GroupLevelDetectorStep.java

/**
 * execute method//from  w  w w.j a v  a2s .com
 */
public StepResult<Integer> execute(NewRowEvent newRowEvent, StepInput stepInput) {

    //first time we cannot make any comparison so the return level is zero
    if (getPreviousRowOfGroupValues(stepInput) == null) {
        //handle last row for grouping columns 
        groupLevel = NumberUtils.INTEGER_MINUS_ONE;
    } else {
        groupLevel = checkLevelChangedInGroupingColumns(getGroupColumns(stepInput),
                getPreviousRowOfGroupValues(stepInput), newRowEvent);
        LOGGER.trace("For newRow={} the grouping level found is {}", newRowEvent, groupLevel);
    }

    //set the result in context
    //getAlgoContext().set(ContextKeys.NEW_GROUPING_LEVEL, groupLevel);
    return new StepResult<Integer>(StepIOKeys.NEW_GROUPING_LEVEL, groupLevel);
}

From source file:net.sf.reportengine.core.steps.GroupLevelDetectorStep.java

private Integer checkLevelChangedInGroupingColumns(List<GroupColumn> groupingColumns,
        Object[] lastRowOfGroupingValues, NewRowEvent newRowEvent) {
    boolean newGroupingLevelFound = false;
    int i = 0;// w w w  . java2 s.c o  m

    //TODO: groupings assumed ordered by grouping order: make sure they are ordered
    //iterate through last row for comparison with the new row of data
    GroupColumn currentGroupColumn = null;
    while (!newGroupingLevelFound && i < groupingColumns.size()) {
        currentGroupColumn = groupingColumns.get(i);
        Object valueToBeCompared = currentGroupColumn.getValue(newRowEvent);
        //LOGGER.trace("checking column {} "+currentGroupColumn.getClass()); 
        //LOGGER.trace("       having grouping order {}", currentGroupColumn.getGroupingLevel()); 
        //LOGGER.trace("       and value {} against {}", valueToBeCompared,lastRowOfGroupingValues[i]);
        if (!lastRowOfGroupingValues[i].equals(valueToBeCompared)) {
            //condition to exit from for loop
            newGroupingLevelFound = true;
        } else {
            i++;
        }
    } // end while
    return newGroupingLevelFound ? Integer.valueOf(i) : NumberUtils.INTEGER_MINUS_ONE;
}