Java List Include addToken(String sequence, String delim, int[] markers, boolean includeDelim, List tokens)

Here you can find the source of addToken(String sequence, String delim, int[] markers, boolean includeDelim, List tokens)

Description

add Token

License

Open Source License

Declaration

private static void addToken(String sequence, String delim, int[] markers, boolean includeDelim, List tokens) 

Method Source Code

//package com.java2s;

import java.util.List;

public class Main {
    private static void addToken(String sequence, String delim, int[] markers, boolean includeDelim, List tokens) {
        markers[1] = sequence.indexOf(delim, markers[0]);
        if (markers[1] < 0)
            markers[1] = sequence.length();
        else if (includeDelim)
            markers[1] += delim.length();
        tokens.add(sequence.substring(markers[0], markers[1]));
        if (includeDelim)
            markers[0] = markers[1];/* w  w  w .j  a  v  a 2  s  .c o m*/
        else
            markers[0] = markers[1] + delim.length();
    }

    private static void addToken(String sequence, String start, String end, int[] markers, boolean includeDelim,
            List tokens) {
        markers[1] = sequence.indexOf(start, markers[0]);
        if (markers[1] < 0)
            markers[1] = sequence.length();
        else {
            if (!includeDelim)
                markers[0] = markers[1] + start.length();
            else
                markers[0] = markers[1];
            markers[1] = sequence.indexOf(end, markers[0]);
            if (markers[1] < 0)
                markers[1] = sequence.length();
            else if (includeDelim)
                markers[1] = markers[1] + end.length();
        }
        tokens.add(sequence.substring(markers[0], markers[1]));
        if (includeDelim)
            markers[0] = markers[1];
        else
            markers[0] = markers[1] + end.length();
    }
}

Related

  1. currentPackageIncludedInExcludePatterns(final String fullyQualifiedName, final List excludePatterns)
  2. getPrefixesAndSuffixes(List items, int minSize, int maxSize, T paddingSymbol, boolean includePrefixes, boolean includeSuffixes)
  3. isAcceptedCountry(String country, List countryInclude, List countryExclude)
  4. isIncluded(List list, String src)