Example usage for org.eclipse.jgit.util IntList size

List of usage examples for org.eclipse.jgit.util IntList size

Introduction

In this page you can find the example usage for org.eclipse.jgit.util IntList size.

Prototype

public int size() 

Source Link

Document

Get number of entries in this list.

Usage

From source file:com.google.gerrit.server.patch.PatchListEntry.java

License:Apache License

public List<String> getHeaderLines() {
    final IntList m = RawParseUtils.lineMap(header, 0, header.length);
    final List<String> headerLines = new ArrayList<>(m.size() - 1);
    for (int i = 1; i < m.size() - 1; i++) {
        final int b = m.get(i);
        int e = m.get(i + 1);
        if (header[e - 1] == '\n') {
            e--;// w  ww.jav a 2  s.com
        }
        headerLines.add(RawParseUtils.decode(Constants.CHARSET, header, b, e));
    }
    return headerLines;
}

From source file:org.eclipse.egit.ui.internal.dialogs.SpellcheckableMessageArea.java

License:Open Source License

/**
 * Calculates wrap offsets for the given line, so that resulting lines are
 * no longer than <code>maxLineLength</code> if possible.
 *
 * @param line/*from  w w w.j  a  va  2s  .c o m*/
 *            the line to wrap (can contain '\n', but no other line delimiters)
 * @param maxLineLength
 *            the maximum line length
 * @return an array of offsets where hard-wraps should be inserted, or
 *         <code>null</code> if the line does not need to be wrapped
 */
public static int[] calculateWrapOffsets(final String line, final int maxLineLength) {
    if (line.length() == 0)
        return null;

    IntList wrapOffsets = new IntList();
    int wordStart = 0;
    int lineStart = 0;
    boolean lastWasSpace = true;
    boolean onlySpaces = true;
    for (int i = 0; i < line.length(); i++) {
        char ch = line.charAt(i);
        if (ch == ' ') {
            lastWasSpace = true;
        } else if (ch == '\n') {
            lineStart = i + 1;
            wordStart = i + 1;
            lastWasSpace = true;
            onlySpaces = true;
        } else { // a word character
            if (lastWasSpace) {
                lastWasSpace = false;
                if (!onlySpaces) { // don't break line with <spaces><veryLongWord>
                    wordStart = i;
                }
            } else {
                onlySpaces = false;
            }
            if (i >= lineStart + maxLineLength) {
                if (wordStart != lineStart) { // don't break before a single long word
                    wrapOffsets.add(wordStart);
                    lineStart = wordStart;
                    onlySpaces = true;
                }
            }
        }
    }

    int size = wrapOffsets.size();
    if (size == 0) {
        return null;
    } else {
        int[] result = new int[size];
        for (int i = 0; i < size; i++) {
            result[i] = wrapOffsets.get(i);
        }
        return result;
    }
}

From source file:svnserver.repository.git.GitRepository.java

License:GNU General Public License

@Override
public int getLastChange(@NotNull String nodePath, int beforeRevision) {
    if (nodePath.isEmpty())
        return beforeRevision;
    final IntList revs = this.lastUpdates.get(nodePath);
    if (revs != null) {
        int prev = 0;
        for (int i = revs.size() - 1; i >= 0; --i) {
            final int rev = revs.get(i);
            if ((rev >= 0) && (rev <= beforeRevision)) {
                if (prev == MARK_NO_FILE) {
                    return MARK_NO_FILE;
                }// www. ja  va2 s  .c o  m
                return rev;
            }
            prev = rev;
        }
    }
    return MARK_NO_FILE;
}