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


Java RawText.getString方法代码示例

本文整理汇总了Java中org.eclipse.jgit.diff.RawText.getString方法的典型用法代码示例。如果您正苦于以下问题:Java RawText.getString方法的具体用法?Java RawText.getString怎么用?Java RawText.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.diff.RawText的用法示例。


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

示例1: blame

import org.eclipse.jgit.diff.RawText; //导入方法依赖的package包/类
/**
 * Returns the list of lines in the specified source file annotated with the source commit metadata.
 * 
 * @param repository
 * @param blobPath
 * @param objectId
 * @return list of annotated lines
 */
public static List<AnnotatedLine> blame(Repository repository, String blobPath, String objectId) {
	List<AnnotatedLine> lines = new ArrayList<AnnotatedLine>();
	try {
		ObjectId object;
		if (StringUtils.isEmpty(objectId)) {
			object = JGitUtils.getDefaultBranch(repository);
		} else {
			object = repository.resolve(objectId);
		}
		BlameCommand blameCommand = new BlameCommand(repository);
		blameCommand.setFilePath(blobPath);
		blameCommand.setStartCommit(object);
		BlameResult blameResult = blameCommand.call();
		RawText rawText = blameResult.getResultContents();
		int length = rawText.size();
		for (int i = 0; i < length; i++) {
			RevCommit commit = blameResult.getSourceCommit(i);
			AnnotatedLine line = new AnnotatedLine(commit, i + 1, rawText.getString(i));
			lines.add(line);
		}
	} catch (Throwable t) {
		LOGGER.error(MessageFormat.format("failed to generate blame for {0} {1}!", blobPath, objectId), t);
	}
	return lines;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:34,代码来源:DiffUtils.java

示例2: blame

import org.eclipse.jgit.diff.RawText; //导入方法依赖的package包/类
/**
 * Returns the list of lines in the specified source file annotated with the
 * source commit metadata.
 * 
 * @param repository
 * @param blobPath
 * @param objectId
 * @return list of annotated lines
 */
public static List<AnnotatedLine> blame(Repository repository, String blobPath, String objectId) {
	List<AnnotatedLine> lines = new ArrayList<AnnotatedLine>();
	try {
		ObjectId object;
		if (StringUtils.isEmpty(objectId)) {
			object = JGitUtils.getDefaultBranch(repository);
		} else {
			object = repository.resolve(objectId);
		}
		BlameCommand blameCommand = new BlameCommand(repository);
		blameCommand.setFilePath(blobPath);
		blameCommand.setStartCommit(object);
		BlameResult blameResult = blameCommand.call();
		RawText rawText = blameResult.getResultContents();
		int length = rawText.size();
		for (int i = 0; i < length; i++) {
			RevCommit commit = blameResult.getSourceCommit(i);
			AnnotatedLine line = new AnnotatedLine(commit, i + 1, rawText.getString(i));
			lines.add(line);
		}
	} catch (Throwable t) {
		LOGGER.error(MessageFormat.format("failed to generate blame for {0} {1}!", blobPath, objectId), t);
	}
	return lines;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:35,代码来源:DiffUtils.java

示例3: writeLine

import org.eclipse.jgit.diff.RawText; //导入方法依赖的package包/类
@Override
protected void writeLine(final char prefix, final RawText text, final int cur)
		throws IOException {
	switch (prefix) {
	case '+':
		os.write("<span style=\"color:#008000;\">".getBytes());
		break;
	case '-':
		os.write("<span style=\"color:#800000;\">".getBytes());
		break;
	}
	os.write(prefix);
	String line = text.getString(cur);
	line = StringUtils.escapeForHtml(line, false);
	os.write(encode(line));
	switch (prefix) {
	case '+':
	case '-':
		os.write("</span>\n".getBytes());
		break;
	default:
		os.write('\n');
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:25,代码来源:GitWebDiffFormatter.java

示例4: equals

import org.eclipse.jgit.diff.RawText; //导入方法依赖的package包/类
@Override
public boolean equals (RawText a, int ai, RawText b, int bi) {
    String line1 = a.getString(ai);
    String line2 = b.getString(bi);
    line1 = trimTrailingEoL(line1);
    line2 = trimTrailingEoL(line2);

    return line1.equals(line2);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:AutoCRLFComparator.java

示例5: writeLine

import org.eclipse.jgit.diff.RawText; //导入方法依赖的package包/类
@Override
protected void writeLine(final char prefix, final RawText text, final int cur)
		throws IOException {
	os.write("<tr>".getBytes());
	switch (prefix) {
	case '+':
		os.write(("<th></th><th>" + (right++) + "</th>").getBytes());
		os.write("<td><div class=\"diff add2\">".getBytes());
		break;
	case '-':
		os.write(("<th>" + (left++) + "</th><th></th>").getBytes());
		os.write("<td><div class=\"diff remove2\">".getBytes());
		break;
	default:
		os.write(("<th>" + (left++) + "</th><th>" + (right++) + "</th>").getBytes());
		os.write("<td>".getBytes());
		break;
	}
	os.write(prefix);
	String line = text.getString(cur);
	line = StringUtils.escapeForHtml(line, false);
	os.write(encode(line));
	switch (prefix) {
	case '+':
	case '-':
		os.write("</div>".getBytes());
		break;
	default:
		os.write("</td>".getBytes());
	}
	os.write("</tr>\n".getBytes());
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:33,代码来源:GitBlitDiffFormatter.java


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