Package org.eclipse.jgit.util

Examples of org.eclipse.jgit.util.IntList


  public int getDeletions() {
    return deletions;
  }

  public List<String> getHeaderLines() {
    final IntList m = RawParseUtils.lineMap(header, 0, header.length);
    final List<String> headerLines = new ArrayList<String>(m.size() - 1);
    for (int i = 1; i < m.size() - 1; i++) {
      final int b = m.get(i);
      final int e = m.get(i + 1);
      headerLines.add(RawParseUtils.decode(Constants.CHARSET, header, b, e));
    }
    return headerLines;
  }
View Full Code Here


      return true;
    return content[end - 1] != '\n';
  }

  private IntList computeHashes() {
    final IntList r = new IntList(lines.size());
    r.add(0);
    for (int lno = 1; lno < lines.size() - 1; lno++) {
      final int ptr = lines.get(lno);
      final int end = lines.get(lno + 1);
      r.add(hashLine(content, ptr, end));
    }
    r.add(0);
    return r;
  }
View Full Code Here

   */
  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;
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.util.IntList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.