本文整理汇总了Java中org.eclipse.jgit.util.RawParseUtils.decode方法的典型用法代码示例。如果您正苦于以下问题:Java RawParseUtils.decode方法的具体用法?Java RawParseUtils.decode怎么用?Java RawParseUtils.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.util.RawParseUtils
的用法示例。
在下文中一共展示了RawParseUtils.decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: 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);
}
示例4: 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();
}
示例5: 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. "<[email protected]>"), 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);
}
示例6: readFile
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
public static String readFile(File directory, String fileName)
throws IOException {
byte[] content = IO.readFully(new File(directory, fileName));
// strip off the last LF
int end = RawParseUtils.prevLF(content, content.length);
return RawParseUtils.decode(content, 0, end + 1);
}
示例7: decode
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
@Override
protected String decode(int s, int e) {
if (charset == null) {
charset = charset(content, null);
}
return RawParseUtils.decode(charset, content, s, e);
}
示例8: parseStringField
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
private static String parseStringField(
byte[] note, MutableInteger curr, Change.Id changeId, String fieldName)
throws ConfigInvalidException {
int endOfLine = RawParseUtils.nextLF(note, curr.value);
checkHeaderLineFormat(note, curr, fieldName, changeId);
int startOfField = RawParseUtils.endOfFooterLineKey(note, curr.value) + 2;
curr.value = endOfLine;
return RawParseUtils.decode(UTF_8, note, startOfField, endOfLine - 1);
}
示例9: parseTimestamp
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
private static Timestamp parseTimestamp(byte[] note, MutableInteger curr, Change.Id changeId)
throws ConfigInvalidException {
int endOfLine = RawParseUtils.nextLF(note, curr.value);
Timestamp commentTime;
String dateString = RawParseUtils.decode(UTF_8, note, curr.value, endOfLine - 1);
try {
commentTime = new Timestamp(GitDateParser.parse(dateString, null, Locale.US).getTime());
} catch (ParseException e) {
throw new ConfigInvalidException("could not parse comment timestamp", e);
}
curr.value = endOfLine;
return checkResult(commentTime, "comment timestamp", changeId);
}
示例10: getPath
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
public synchronized String getPath() {
if (path == null) {
path = RawParseUtils.decode(Constants.CHARSET, rawPath);
rawPath = null; // release memory
}
return path;
}
示例11: TextBlobView
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
TextBlobView(ObjectLoader objectLoader) throws IOException {
byte[] cachedBytes = objectLoader.getCachedBytes();
Log.d(TAG, "Got " + cachedBytes.length + " of data");
String decode = RawParseUtils.decode(cachedBytes);
blobHTML = dressFileContentForWebView(decode);
}
示例12: extractTitleFromMarkdown
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
public String extractTitleFromMarkdown(byte[] data, String charEnc) {
String md = RawParseUtils.decode(Charset.forName(charEnc), data);
return findTitle(parseMarkdown(md));
}
示例13: readUTF8
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
protected String readUTF8(String fileName) throws IOException {
byte[] raw = readFile(fileName);
return raw.length != 0 ? RawParseUtils.decode(raw) : "";
}
示例14: parseChangeMessage
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
private void parseChangeMessage(
PatchSet.Id psId,
Account.Id accountId,
Account.Id realAccountId,
ChangeNotesCommit commit,
Timestamp ts) {
byte[] raw = commit.getRawBuffer();
int size = raw.length;
Charset enc = RawParseUtils.parseEncoding(raw);
int subjectStart = RawParseUtils.commitMessage(raw, 0);
if (subjectStart < 0 || subjectStart >= size) {
return;
}
int subjectEnd = RawParseUtils.endOfParagraph(raw, subjectStart);
if (subjectEnd == size) {
return;
}
int changeMessageStart;
if (raw[subjectEnd] == '\n') {
changeMessageStart = subjectEnd + 2; // \n\n ends paragraph
} else if (raw[subjectEnd] == '\r') {
changeMessageStart = subjectEnd + 4; // \r\n\r\n ends paragraph
} else {
return;
}
int ptr = size - 1;
int changeMessageEnd = -1;
while (ptr > changeMessageStart) {
ptr = RawParseUtils.prevLF(raw, ptr, '\r');
if (ptr == -1) {
break;
}
if (raw[ptr] == '\n') {
changeMessageEnd = ptr - 1;
break;
} else if (raw[ptr] == '\r') {
changeMessageEnd = ptr - 3;
break;
}
}
if (ptr <= changeMessageStart) {
return;
}
String changeMsgString =
RawParseUtils.decode(enc, raw, changeMessageStart, changeMessageEnd + 1);
ChangeMessage changeMessage =
new ChangeMessage(
new ChangeMessage.Key(psId.getParentKey(), commit.name()), accountId, ts, psId);
changeMessage.setMessage(changeMsgString);
changeMessage.setTag(tag);
changeMessage.setRealAuthor(realAccountId);
changeMessagesByPatchSet.put(psId, changeMessage);
allChangeMessages.add(changeMessage);
}
示例15: text
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
private String text(RevCommit rev, String path) throws Exception {
RevObject blob = util.get(rev.getTree(), path);
byte[] data = db.open(blob).getCachedBytes(Integer.MAX_VALUE);
return RawParseUtils.decode(data);
}