当前位置: 首页>>代码示例>>Java>>正文


Java RawParseUtils类代码示例

本文整理汇总了Java中org.eclipse.jgit.util.RawParseUtils的典型用法代码示例。如果您正苦于以下问题:Java RawParseUtils类的具体用法?Java RawParseUtils怎么用?Java RawParseUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RawParseUtils类属于org.eclipse.jgit.util包,在下文中一共展示了RawParseUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAddMissingSymlink

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
public void testAddMissingSymlink () throws Exception {
    if (isWindows()) {
        return;
    }
    String path = "folder/file";
    File f = new File(workDir, path);
    
    // try with commandline client
    File link = new File(workDir, "link");
    Files.createSymbolicLink(Paths.get(link.getAbsolutePath()), Paths.get(path));
    getClient(workDir).add(new File[] { link }, NULL_PROGRESS_MONITOR);
    DirCacheEntry e = repository.readDirCache().getEntry(link.getName());
    assertEquals(FileMode.SYMLINK, e.getFileMode());
    assertEquals(0, e.getLength());
    ObjectReader reader = repository.getObjectDatabase().newReader();
    assertTrue(reader.has(e.getObjectId()));
    byte[] bytes = reader.open(e.getObjectId()).getBytes();
    assertEquals(path, RawParseUtils.decode(bytes));
    reader.release();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AddTest.java

示例2: parseCanonical

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
void parseCanonical(final RevWalk walk, final byte[] rawTag)
		throws CorruptObjectException {
	final MutableInteger pos = new MutableInteger();
	final int oType;

	pos.value = 53; // "object $sha1\ntype "
	oType = Constants.decodeTypeString(this, rawTag, (byte) '\n', pos);
	walk.idBuffer.fromString(rawTag, 7);
	object = walk.lookupAny(walk.idBuffer, oType);

	int p = pos.value += 4; // "tag "
	final int nameEnd = RawParseUtils.nextLF(rawTag, p) - 1;
	tagName = RawParseUtils.decode(UTF_8, rawTag, p, nameEnd);

	if (walk.isRetainBody())
		buffer = rawTag;
	flags |= PARSED;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:19,代码来源:RevTag.java

示例3: run

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
@Override
protected final void run() throws UnloggedFailure {
  try {
    RevisionResource revision =
        revisions.parse(
            changes.parse(TopLevelResource.INSTANCE, IdString.fromUrl(changeId)),
            IdString.fromUrl("current"));
    if (useStdin) {
      ByteBuffer buf = IO.readWholeStream(in, 4096);
      input.rule = RawParseUtils.decode(buf.array(), buf.arrayOffset(), buf.limit());
    }
    Object result = createView().apply(revision, input);
    OutputFormat.JSON.newGson().toJson(result, stdout);
    stdout.print('\n');
  } catch (Exception e) {
    throw die("Processing of prolog script failed: " + e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:BaseTestPrologCommand.java

示例4: display

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
public void display(String rule, HttpServletResponse res) throws IOException {
  res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
  res.setContentType("text/html");
  res.setCharacterEncoding(UTF_8.name());
  CacheHeaders.setNotCacheable(res);

  Escaper html = HtmlEscapers.htmlEscaper();
  try (PrintWriter w = res.getWriter()) {
    w.write("<html><title>BUILD FAILED</title><body>");
    w.format("<h1>%s FAILED</h1>", html.escape(rule));
    w.write("<pre>");
    w.write(html.escape(RawParseUtils.decode(why)));
    w.write("</pre>");
    w.write("</body></html>");
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:BazelBuild.java

示例5: sendMarkdownAsHtml

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
private void sendMarkdownAsHtml(
    PluginContentScanner scanner,
    PluginEntry entry,
    String pluginName,
    PluginResourceKey key,
    HttpServletResponse res)
    throws IOException {
  byte[] rawmd = readWholeEntry(scanner, entry);
  String encoding = null;
  Map<Object, String> atts = entry.getAttrs();
  if (atts != null) {
    encoding = Strings.emptyToNull(atts.get(ATTR_CHARACTER_ENCODING));
  }

  String txtmd =
      RawParseUtils.decode(Charset.forName(encoding != null ? encoding : UTF_8.name()), rawmd);
  long time = entry.getTime();
  if (0 < time) {
    res.setDateHeader("Last-Modified", time);
  }
  sendMarkdownAsHtml(txtmd, pluginName, key, res, time);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:HttpPluginServlet.java

示例6: parseAssignee

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
private void parseAssignee(ChangeNotesCommit commit) throws ConfigInvalidException {
  if (pastAssignees == null) {
    pastAssignees = Lists.newArrayList();
  }
  String assigneeValue = parseOneFooter(commit, FOOTER_ASSIGNEE);
  if (assigneeValue != null) {
    Optional<Account.Id> parsedAssignee;
    if (assigneeValue.equals("")) {
      // Empty footer found, assignee deleted
      parsedAssignee = Optional.empty();
    } else {
      PersonIdent ident = RawParseUtils.parsePersonIdent(assigneeValue);
      parsedAssignee = Optional.ofNullable(noteUtil.parseIdent(ident, id));
    }
    if (assignee == null) {
      assignee = parsedAssignee;
    }
    if (parsedAssignee.isPresent()) {
      pastAssignees.add(parsedAssignee.get());
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:ChangeNotesParser.java

示例7: parseCommentLength

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
private static int parseCommentLength(byte[] note, MutableInteger curr, Change.Id changeId)
    throws ConfigInvalidException {
  checkHeaderLineFormat(note, curr, LENGTH, changeId);
  int startOfLength = RawParseUtils.endOfFooterLineKey(note, curr.value) + 1;
  MutableInteger i = new MutableInteger();
  i.value = startOfLength;
  int commentLength = RawParseUtils.parseBase10(note, startOfLength, i);
  if (i.value == startOfLength) {
    throw parseException(changeId, "could not parse %s", LENGTH);
  }
  int endOfLine = RawParseUtils.nextLF(note, curr.value);
  if (i.value != endOfLine - 1) {
    throw parseException(changeId, "could not parse %s", LENGTH);
  }
  curr.value = endOfLine;
  return checkResult(commentLength, "comment length", changeId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:ChangeNoteUtil.java

示例8: getBytes

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
/** @return a copy of the file's contents. */
public byte[] getBytes() {
  byte[] data = read(getPath());

  if (isScript(data)) {
    // Embed Gerrit's version number into the top of the script.
    //
    final String version = Version.getVersion();
    final int lf = RawParseUtils.nextLF(data, 0);
    if (version != null && lf < data.length) {
      byte[] versionHeader = Constants.encode("# From Gerrit Code Review " + version + "\n");

      ByteArrayOutputStream buf = new ByteArrayOutputStream();
      buf.write(data, 0, lf);
      buf.write(versionHeader, 0, versionHeader.length);
      buf.write(data, lf, data.length - lf);
      data = buf.toByteArray();
    }
  }

  return data;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:ToolsCatalog.java

示例9: format

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
@Override
public void format(FileHeader hdr, RawText a, RawText b)
    throws IOException {
  int start = hdr.getStartOffset();
  int end = hdr.getEndOffset();
  if (!hdr.getHunks().isEmpty()) {
    end = hdr.getHunks().get(0).getStartOffset();
  }
  renderHeader(RawParseUtils.decode(hdr.getBuffer(), start, end));

  if (hdr.getPatchType() == PatchType.UNIFIED) {
    getOutputStream().write(DIFF_BEGIN);
    format(hdr.toEditList(), a, b);
    getOutputStream().write(DIFF_END);
  }
}
 
开发者ID:afrojer,项目名称:gitiles,代码行数:17,代码来源:HtmlDiffFormatter.java

示例10: getHtml

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
/**
 * Workaround function for complex private methods in DiffFormatter. This
 * sets the html for the diff headers.
 * 
 * @return
 */
public String getHtml() {
	ByteArrayOutputStream bos = (ByteArrayOutputStream) os;
	String html = RawParseUtils.decode(bos.toByteArray());
	String[] lines = html.split("\n");
	StringBuilder sb = new StringBuilder();
	sb.append("<div class=\"diff\">");
	for (String line : lines) {
		if (line.startsWith("diff")) {
			sb.append("<div class=\"diff header\">").append(StringUtils.convertOctal(line)).append("</div>");
		} else if (line.startsWith("---")) {
			sb.append("<span style=\"color:#800000;\">").append(StringUtils.convertOctal(line)).append("</span><br/>");
		} else if (line.startsWith("+++")) {
			sb.append("<span style=\"color:#008000;\">").append(StringUtils.convertOctal(line)).append("</span><br/>");
		} else {
			sb.append(line).append('\n');
		}
	}
	sb.append("</div>\n");
	return sb.toString();
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:27,代码来源:GitWebDiffFormatter.java

示例11: guessEncoding

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
private Charset guessEncoding() {
	try {
		return RawParseUtils.parseEncoding(buffer);
	} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
		return UTF_8;
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:8,代码来源:RevTag.java

示例12: getEmailAddress

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
/**
 * Extract the email address (if present) from the footer.
 * <p>
 * If there is an email address looking string inside of angle brackets
 * (e.g. "&lt;[email protected]&gt;"), the return value is the part extracted from inside the
 * brackets. If no brackets are found, then {@link #getValue()} is returned
 * if the value contains an '@' sign. Otherwise, null.
 *
 * @return email address appearing in the value of this footer, or null.
 */
public String getEmailAddress() {
	final int lt = RawParseUtils.nextLF(buffer, valStart, '<');
	if (valEnd <= lt) {
		final int at = RawParseUtils.nextLF(buffer, valStart, '@');
		if (valStart < at && at < valEnd)
			return getValue();
		return null;
	}
	final int gt = RawParseUtils.nextLF(buffer, lt, '>');
	if (valEnd < gt)
		return null;
	return RawParseUtils.decode(enc, buffer, lt, gt - 1);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:24,代码来源:FooterLine.java

示例13: getFooterLines

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
/**
 * Parse the footer lines (e.g. "Signed-off-by") for machine processing.
 * <p>
 * This method splits all of the footer lines out of the last paragraph of
 * the commit message, providing each line as a key-value pair, ordered by
 * the order of the line's appearance in the commit message itself.
 * <p>
 * A footer line's key must match the pattern {@code ^[A-Za-z0-9-]+:}, while
 * the value is free-form, but must not contain an LF. Very common keys seen
 * in the wild are:
 * <ul>
 * <li>{@code Signed-off-by} (agrees to Developer Certificate of Origin)
 * <li>{@code Acked-by} (thinks change looks sane in context)
 * <li>{@code Reported-by} (originally found the issue this change fixes)
 * <li>{@code Tested-by} (validated change fixes the issue for them)
 * <li>{@code CC}, {@code Cc} (copy on all email related to this change)
 * <li>{@code Bug} (link to project's bug tracking system)
 * </ul>
 *
 * @return ordered list of footer lines; empty list if no footers found.
 */
public final List<FooterLine> getFooterLines() {
	final byte[] raw = buffer;
	int ptr = raw.length - 1;
	while (raw[ptr] == '\n') // trim any trailing LFs, not interesting
		ptr--;

	final int msgB = RawParseUtils.commitMessage(raw, 0);
	final ArrayList<FooterLine> r = new ArrayList<>(4);
	final Charset enc = guessEncoding();
	for (;;) {
		ptr = RawParseUtils.prevLF(raw, ptr);
		if (ptr <= msgB)
			break; // Don't parse commit headers as footer lines.

		final int keyStart = ptr + 2;
		if (raw[keyStart] == '\n')
			break; // Stop at first paragraph break, no footers above it.

		final int keyEnd = RawParseUtils.endOfFooterLineKey(raw, keyStart);
		if (keyEnd < 0)
			continue; // Not a well formed footer line, skip it.

		// Skip over the ': *' at the end of the key before the value.
		//
		int valStart = keyEnd + 1;
		while (valStart < raw.length && raw[valStart] == ' ')
			valStart++;

		// Value ends at the LF, and does not include it.
		//
		int valEnd = RawParseUtils.nextLF(raw, valStart);
		if (raw[valEnd - 1] == '\n')
			valEnd--;

		r.add(new FooterLine(raw, enc, keyStart, keyEnd, valStart, valEnd));
	}
	Collections.reverse(r);
	return r;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:61,代码来源:RevCommit.java

示例14: textFor

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
static RawCharSequence textFor(final RevCommit cmit) {
	final byte[] raw = cmit.getRawBuffer();
	final int b = RawParseUtils.commitMessage(raw, 0);
	if (b < 0)
		return RawCharSequence.EMPTY;
	return new RawCharSequence(raw, b, raw.length);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:8,代码来源:MessageRevFilter.java

示例15: textFor

import org.eclipse.jgit.util.RawParseUtils; //导入依赖的package包/类
static RawCharSequence textFor(final RevCommit cmit) {
	final byte[] raw = cmit.getRawBuffer();
	final int b = RawParseUtils.committer(raw, 0);
	if (b < 0)
		return RawCharSequence.EMPTY;
	final int e = RawParseUtils.nextLF(raw, b, '>');
	return new RawCharSequence(raw, b, e);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:9,代码来源:CommitterRevFilter.java


注:本文中的org.eclipse.jgit.util.RawParseUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。