List of usage examples for org.eclipse.jgit.util RawParseUtils parseBase10
public static final int parseBase10(final byte[] b, int ptr, final MutableInteger ptrResult)
From source file:com.google.gerrit.server.notedb.CommentsInNotesUtil.java
License:Apache License
/** * @return a comment range. If the comment range line in the note only has * one number, we return a CommentRange with that one number as the end * line and the other fields as -1. If the comment range line in the note * contains a whole comment range, then we return a CommentRange with all * fields set. If the line is not correctly formatted, return null. */// w w w .ja v a 2 s . c o m private static CommentRange parseCommentRange(byte[] note, MutableInteger ptr) { CommentRange range = new CommentRange(-1, -1, -1, -1); int startLine = RawParseUtils.parseBase10(note, ptr.value, ptr); if (startLine == 0) { range.setEndLine(0); ptr.value += 1; return range; } if (note[ptr.value] == '\n') { range.setEndLine(startLine); ptr.value += 1; return range; } else if (note[ptr.value] == ':') { range.setStartLine(startLine); ptr.value += 1; } else { return null; } int startChar = RawParseUtils.parseBase10(note, ptr.value, ptr); if (startChar == 0) { return null; } if (note[ptr.value] == '-') { range.setStartCharacter(startChar); ptr.value += 1; } else { return null; } int endLine = RawParseUtils.parseBase10(note, ptr.value, ptr); if (endLine == 0) { return null; } if (note[ptr.value] == ':') { range.setEndLine(endLine); ptr.value += 1; } else { return null; } int endChar = RawParseUtils.parseBase10(note, ptr.value, ptr); if (endChar == 0) { return null; } if (note[ptr.value] == '\n') { range.setEndCharacter(endChar); ptr.value += 1; } else { return null; } return range; }
From source file:com.google.gerrit.server.notedb.CommentsInNotesUtil.java
License:Apache License
private static PatchSet.Id parsePsId(byte[] note, MutableInteger curr, Change.Id changeId, Charset enc, String fieldName) throws ConfigInvalidException { checkHeaderLineFormat(note, curr, fieldName, enc, changeId); int startOfPsId = RawParseUtils.endOfFooterLineKey(note, curr.value) + 1; MutableInteger i = new MutableInteger(); int patchSetId = RawParseUtils.parseBase10(note, startOfPsId, i); int endOfLine = RawParseUtils.nextLF(note, curr.value); if (i.value != endOfLine - 1) { throw parseException(changeId, "could not parse %s", fieldName); }/*from ww w . j ava2 s .c om*/ checkResult(patchSetId, "patchset id", changeId); curr.value = endOfLine; return new PatchSet.Id(changeId, patchSetId); }
From source file:com.google.gerrit.server.notedb.CommentsInNotesUtil.java
License:Apache License
private static int parseCommentLength(byte[] note, MutableInteger curr, Change.Id changeId, Charset enc) throws ConfigInvalidException { checkHeaderLineFormat(note, curr, LENGTH, enc, changeId); int startOfLength = RawParseUtils.endOfFooterLineKey(note, curr.value) + 1; MutableInteger i = new MutableInteger(); int commentLength = RawParseUtils.parseBase10(note, startOfLength, i); int endOfLine = RawParseUtils.nextLF(note, curr.value); if (i.value != endOfLine - 1) { throw parseException(changeId, "could not parse %s", PATCH_SET); }//from www. j a v a 2 s . c o m curr.value = endOfLine; return checkResult(commentLength, "comment length", changeId); }