本文整理汇总了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;
}
示例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;
}
示例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');
}
}
示例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);
}
示例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());
}