Example usage for org.apache.commons.lang.mutable MutableInt intValue

List of usage examples for org.apache.commons.lang.mutable MutableInt intValue

Introduction

In this page you can find the example usage for org.apache.commons.lang.mutable MutableInt intValue.

Prototype

public int intValue() 

Source Link

Document

Returns the value of this MutableInt as a int.

Usage

From source file:de.tudarmstadt.ukp.csniper.webapp.search.tgrep.PennTreeUtils.java

private static PennTreeNode dfs(int aTarget, MutableInt aIndex, PennTreeNode aNode) {
    if (aTarget == aIndex.intValue()) {
        return aNode;
    }/*from   w ww .j a v  a2 s. c o  m*/

    for (PennTreeNode n : aNode.getChildren()) {
        aIndex.increment();
        PennTreeNode r = dfs(aTarget, aIndex, n);
        if (r != null) {
            return r;
        }
    }

    return null;
}

From source file:net.pj.games.eulerproject.elements.StringPermutator.java

private static int getIndexOfMax(String s) {

    final MutableInt maxIndex = new MutableInt(-1);
    s.chars().max().ifPresent(m -> maxIndex.setValue(s.indexOf(m)));
    return maxIndex.intValue();
}

From source file:com.ms.commons.test.classloader.util.VelocityTemplateUtil.java

protected static String evalString(Map<Object, Object> context, String str, MutableInt depth) {
    if (depth.intValue() > 5) {
        System.err.println("eval depth > 5 for `" + StringUtils.substring(str, 0, 50) + "`.");
        return str;
    }/*from www  . j  a v a  2 s  .  co  m*/

    StringBuilder sb = new StringBuilder();
    char[] chars = str.toCharArray();

    boolean in = false;
    StringBuilder tsb = new StringBuilder();
    for (int i = 0; i < chars.length; i++) {
        char c = chars[i];
        char nc = 0;
        if ((i + 1) < chars.length) {
            nc = chars[i + 1];
        }

        if (in) {
            if (c != '}') {
                tsb.append(c);
            } else {
                Object value = context.get(tsb.toString());
                if (value == null) {
                    sb.append("${" + tsb.toString() + "}");
                } else {
                    sb.append(value);
                }
                tsb = new StringBuilder();
                in = false;
            }
        } else {
            if ((c == '$') && (nc == '{')) {
                in = true;
                i++;
            } else {
                sb.append(c);
            }
        }
    }
    if (in) {
        throw new RuntimeException("at last is in");
    }

    String result = sb.toString();

    if (result.contains("${")) {
        depth.add(1);
        return evalString(context, result, depth);
    } else {
        return result;
    }
}

From source file:com.linkedin.pinot.common.utils.request.RequestUtils.java

private static FilterQuery traverseFilterQueryAndPopulateMap(FilterQueryTree tree,
        Map<Integer, FilterQuery> filterQueryMap, MutableInt currentId) {
    int currentNodeId = currentId.intValue();
    currentId.increment();/*  w w w.j a va2s  .c  om*/

    final List<Integer> f = new ArrayList<>();
    if (null != tree.getChildren()) {
        for (final FilterQueryTree c : tree.getChildren()) {
            int childNodeId = currentId.intValue();
            currentId.increment();

            f.add(childNodeId);
            final FilterQuery q = traverseFilterQueryAndPopulateMap(c, filterQueryMap, currentId);
            filterQueryMap.put(childNodeId, q);
        }
    }

    FilterQuery query = new FilterQuery();
    query.setColumn(tree.getColumn());
    query.setId(currentNodeId);
    query.setNestedFilterQueryIds(f);
    query.setOperator(tree.getOperator());
    query.setValue(tree.getValue());
    return query;
}

From source file:com.linkedin.pinot.common.utils.request.RequestUtils.java

private static HavingFilterQuery traverseHavingFilterQueryAndPopulateMap(HavingQueryTree tree,
        Map<Integer, HavingFilterQuery> filterQueryMap, MutableInt currentId) {
    int currentNodeId = currentId.intValue();
    currentId.increment();//from  www  . j  a v a 2s.  c  o m

    final List<Integer> filterIds = new ArrayList<>();
    if (null != tree.getChildren()) {
        for (final HavingQueryTree child : tree.getChildren()) {
            int childNodeId = currentId.intValue();
            currentId.increment();
            filterIds.add(childNodeId);
            final HavingFilterQuery filterQuery = traverseHavingFilterQueryAndPopulateMap(child, filterQueryMap,
                    currentId);
            filterQueryMap.put(childNodeId, filterQuery);
        }
    }

    HavingFilterQuery havingFilterQuery = new HavingFilterQuery();
    havingFilterQuery.setAggregationInfo(tree.getAggregationInfo());
    havingFilterQuery.setId(currentNodeId);
    havingFilterQuery.setNestedFilterQueryIds(filterIds);
    havingFilterQuery.setOperator(tree.getOperator());
    havingFilterQuery.setValue(tree.getValue());
    return havingFilterQuery;
}

From source file:com.datatorrent.lib.testbench.ArrayListTestSink.java

public int getCount(T key) {
    int ret = -1;
    MutableInt val = map.get(key);
    if (val != null) {
        ret = val.intValue();
    }// w  w w.  java  2 s .co m
    return ret;
}

From source file:com.novartis.pcs.ontology.service.parser.obo.SynonymTagHandler.java

private Synonym.Type parseType(String value, MutableInt fromIndex) {
    Synonym.Type type = Synonym.Type.RELATED;

    while (fromIndex.intValue() < value.length()
            && Character.isWhitespace(value.charAt(fromIndex.intValue()))) {
        fromIndex.increment();/*from   www.j a v  a2 s . c  o  m*/
    }

    int start = fromIndex.intValue();

    while (fromIndex.intValue() < value.length() && Character.isLetter(value.charAt(fromIndex.intValue()))) {
        fromIndex.increment();
    }

    if (start < fromIndex.intValue()) {
        String scope = value.substring(start, fromIndex.intValue());
        try {
            type = Synonym.Type.valueOf(scope.toUpperCase());
        } catch (IllegalArgumentException e) {
            type = Synonym.Type.RELATED;
            fromIndex.setValue(start);
        }
    }

    return type;
}

From source file:com.aionemu.gameserver.model.instance.instancereward.DredgionReward.java

public void addPointsByRace(Race race, int points) {
    MutableInt racePoints = getPointsByRace(race);
    racePoints.add(points);//w w  w.  j  a v a 2  s. co  m
    if (racePoints.intValue() < 0) {
        racePoints.setValue(0);
    }
}

From source file:com.novartis.pcs.ontology.service.parser.obo.OBOTagHandler.java

protected String substr(String value, char startChar, char endChar, MutableInt fromIndex) {
    String substr = null;//w ww.  ja  v a  2 s.  c  om
    int start = indexOf(value, startChar, fromIndex.intValue());
    if (start != -1) {
        int end = indexOf(value, endChar, start + 1);

        if (end == -1) {
            throw new InvalidFormatException("Invalid OBO " + tagName.getName() + " format: " + value);
        }
        substr = value.substring(start + 1, end);
        fromIndex.setValue(end + 1);
    }
    return substr;
}

From source file:com.datatorrent.lib.util.AbstractBaseSortOperator.java

/**
 * Emit sorted tuple at end of window//  w w w  . j a  va 2  s  .com
 * Clears internal cache
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void endWindow() {
    if (pqueue.isEmpty()) {
        return;
    }
    ArrayList tuple = new ArrayList();
    HashMap<K, Integer> htuple = new HashMap<K, Integer>(pqueue.size());
    final boolean sok = doEmitList();
    final boolean hok = doEmitHash();

    if (sok) {
        tuple = new ArrayList();
    }

    if (hok) {
        htuple = new HashMap<K, Integer>(pqueue.size());
    }

    K o;
    while ((o = pqueue.poll()) != null) {
        MutableInt count = pmap.get(o);
        if (sok) {
            for (int i = 0; i < count.intValue(); i++) {
                tuple.add(cloneKey(o));
            }
        }

        if (hok) {
            htuple.put(cloneKey(o), count.intValue());
        }
    }
    if (sok) {
        emitToList(tuple);
    }
    if (hok) {
        emitToHash(htuple);
    }
    pmap.clear();
    pqueue.clear();
}