Example usage for java.util List subList

List of usage examples for java.util List subList

Introduction

In this page you can find the example usage for java.util List subList.

Prototype

List<E> subList(int fromIndex, int toIndex);

Source Link

Document

Returns a view of the portion of this list between the specified fromIndex , inclusive, and toIndex , exclusive.

Usage

From source file:com.trigonic.utils.spring.cmdline.AbstractOperandHandler.java

public boolean addPropertyValue(MutablePropertyValues propertyValues, OptionSet optionSet) {
    boolean result = false;
    List<String> nonOptionArgs = optionSet.nonOptionArguments();
    if (operand.index() < nonOptionArgs.size()) {
        Object propertyValue = nonOptionArgs.get(operand.index());
        if (hasMultipleValues()) {
            propertyValue = nonOptionArgs.subList(operand.index(), nonOptionArgs.size());
        }//from w  ww  .  j  a  v a 2  s.  com
        propertyValues.add(propertyName, propertyValue);
        result = true;
    }
    return result;
}

From source file:edu.cornell.mannlib.vitro.webapp.utils.solr.AutoCompleteWords.java

/**
 * Package-access. Use SolrQueryUtils.parseForAutoComplete() to create an
 * instance./*ww w  . jav a  2s .  c  o m*/
 */
AutoCompleteWords(String searchTerm, String delimiterPattern) {
    this.searchTerm = searchTerm;
    this.delimiterPattern = delimiterPattern;

    List<String> termWords = figureTermWords();
    if (termWords.isEmpty() || this.searchTerm.endsWith(" ")) {
        this.completeWords = termWords;
        this.partialWord = null;
    } else {
        this.completeWords = termWords.subList(0, termWords.size() - 1);
        this.partialWord = termWords.get(termWords.size() - 1);
    }

}

From source file:it.units.malelab.sse.OperationsChromosome.java

private Operation getOperation(int index) {
    List<Integer> bits = getRepresentation().subList(index * BITS_PER_OP, (index + 1) * BITS_PER_OP);
    if (bits.get(0) == 0) {
        return null;
    }//from  w  ww . j a  v a 2s  . co m
    int opCodeIndex = toInt(bits.subList(1, 1 + BITS_PER_OPCODE), OpCode.values().length);
    int index0 = toInt(
            bits.subList(1 + BITS_PER_OPCODE + BITS_PER_INDEX * 0, 1 + BITS_PER_OPCODE + BITS_PER_INDEX * 1),
            MAX_INDEX);
    int index1 = toInt(
            bits.subList(1 + BITS_PER_OPCODE + BITS_PER_INDEX * 1, 1 + BITS_PER_OPCODE + BITS_PER_INDEX * 2),
            MAX_INDEX);
    int index2 = toInt(
            bits.subList(1 + BITS_PER_OPCODE + BITS_PER_INDEX * 2, 1 + BITS_PER_OPCODE + BITS_PER_INDEX * 3),
            MAX_INDEX);
    OpCode opCode = OpCode.values()[opCodeIndex];
    if (opCode.equals(OpCode.JUMP_IF_GT)) {
        index2 = index2 - MAX_INDEX / 2;
    }
    return new Operation(opCode, index0, index1, index2);
}

From source file:de.innovationgate.utils.LineBufferWriter.java

private void appendToList(String str) {

    List lines = WGUtils.deserializeCollection(str, "\n");
    _currentLine.append(str);/*from  ww  w.  j a va2  s  . c o m*/
    if (lines.size() > 1) {
        closeCurrentLine();
        if (lines.size() > 2) {
            List subList = lines.subList(1, lines.size() - 1);
            if (!_countLinesOnly) {
                _buffer.addAll(subList);
            }
            _lineCount += subList.size();
        }
        _currentLine.append(lines.get(lines.size() - 1));
    }

}

From source file:amie.keys.CSAKey.java

private static void mine(Triple<MiningAssistant, Float, String> parsedArgs, List<HashSet<Integer>> nonKeysInt,
        HashMap<String, Integer> property2Id, HashMap<Integer, String> id2Property,
        List<Integer> propertiesList, int start, int end, Set<Rule> output) {
    // First prune non-promising non-keys       
    HashSet<HashSet<Integer>> hs = new HashSet<>(nonKeysInt.subList(start, end));
    CSAKey ckminer = new CSAKey(parsedArgs.first, hs, property2Id, id2Property, propertiesList);
    //System.out.println(hs);
    ckminer.support = parsedArgs.second.floatValue();
    ckminer.discoverConditionalKeys(output);
}

From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java

public static String convertLastEventToJsonString(final Experiment experiment) {
    List<Event> events = experiment.getEvents();
    if (events.isEmpty()) {
        return "[]";
    }/*from  w ww.ja v a2s.  co m*/
    return convertEventsToJsonString(experiment, events.subList(0, 1));
}

From source file:com.sangupta.shire.domain.RenderableResource.java

/**
 * @return the originalContent//ww  w  .  j  a  va 2 s. c om
 * @throws IOException 
 */
public String getOriginalContent() throws IOException {
    if (originalContent == null) {
        List<String> lines = FileUtils.readLines(this.fileHandle);
        this.originalContent = StringUtils.join(lines.subList(this.matterEndingLine, lines.size()), '\n');
    }

    return originalContent;
}

From source file:org.investovator.agentsimulation.multiasset.report.statistics.TopOrdersStatReport.java

protected List<Number> addToList(List<Order> list) {

    List<Number> priceList = new ArrayList<>();
    for (Order order : list) {
        priceList.add(order.getPrice());
    }//  w w w  .j a  v a 2 s  .co m
    Collections.sort(priceList, Collections.reverseOrder());
    return priceList.size() > (size - 1) ? priceList.subList(0, size) : priceList;
}

From source file:org.apache.drill.optiq.DrillJoinRel.java

private int implementInput(DrillImplementor implementor, int i, int offset, RelNode input) {
    final int inputId = implementor.visitChild(this, i, input);
    assert uniqueFieldNames(input.getRowType());
    final List<String> fields = getRowType().getFieldNames();
    final List<String> inputFields = input.getRowType().getFieldNames();
    final List<String> outputFields = fields.subList(offset, offset + inputFields.size());
    if (!outputFields.equals(inputFields)) {
        // Ensure that input field names are the same as output field names.
        // If there are duplicate field names on left and right, fields will get
        // lost./*  www  . ja v  a2 s  .  com*/
        return rename(implementor, inputId, inputFields, outputFields);
    } else {
        return inputId;
    }
}

From source file:com.temenos.useragent.generic.mediatype.JsonEntityHandler.java

@Override
public <T> void setValue(String fqPropertyName, T value) {
    List<String> pathParts = Arrays.asList(flattenPropertyName(fqPropertyName));
    Optional<JSONObject> parent = navigateJsonObjectforPropertyPath(Optional.ofNullable(jsonObject),
            pathParts.subList(0, pathParts.size() - 1), fqPropertyName, true);
    if (parent.isPresent()) {
        parent.get().put(pathParts.get(pathParts.size() - 1), value);
    }// w ww  .  ja v  a 2 s.c  o m
}