/** * Get key name of this footer. * * @return key name of this footer; that is the text before the ":" on the * line footer's line. The text is decoded according to the commit's * specified (or assumed) character encoding. */ public String getKey() { return RawParseUtils.decode(enc, buffer, keyStart, keyEnd); }
/** * Get value of this footer. * * @return value of this footer; that is the text after the ":" and any * leading whitespace has been skipped. May be the empty string if * the footer has no value (line ended with ":"). The text is * decoded according to the commit's specified (or assumed) * character encoding. */ public String getValue() { return RawParseUtils.decode(enc, buffer, valStart, valEnd); }
String name() { int len = nameLen; if (blockType == LOG_BLOCK_TYPE) { len -= 9; } return RawParseUtils.decode(UTF_8, nameBuf, 0, len); }
static String pathOf(AbstractTreeIterator t) { return RawParseUtils.decode(UTF_8, t.path, 0, t.pathLen); }
static String pathOf(byte[] buf, int pos, int end) { return RawParseUtils.decode(UTF_8, buf, pos, end); }
/** * Decode a buffer under UTF-8, if possible. * * If the byte stream cannot be decoded that way, the platform default is tried * and if that too fails, the fail-safe ISO-8859-1 encoding is tried. * * @param buffer * buffer to pull raw bytes from. * @return a string representation of the range <code>[start,end)</code>, * after decoding the region through the specified character set. */ public static String decode(byte[] buffer) { return decode(buffer, 0, buffer.length); }
/** * Decode a region of the text into a String. * * The default implementation of this method tries to guess the character * set by considering UTF-8, the platform default, and falling back on * ISO-8859-1 if neither of those can correctly decode the region given. * * @param start * first byte of the content to decode. * @param end * one past the last byte of the content to decode. * @return the region {@code [start, end)} decoded as a String. */ protected String decode(int start, int end) { return RawParseUtils.decode(content, start, end); }
/** {@inheritDoc} */ @Override public String toString() { return RawParseUtils.decode(buf.toByteArray()); } }
private String normalize(byte[] raw, int ptr, int end) { String n = RawParseUtils.decode(raw, ptr, end).toLowerCase(Locale.US); return macosx ? Normalizer.normalize(n, Normalizer.Form.NFC) : n; }
@Override public String dequote(byte[] in, int inPtr, int inEnd) { if (2 <= inEnd - inPtr && in[inPtr] == '"' && in[inEnd - 1] == '"') return dq(in, inPtr + 1, inEnd - 1); return RawParseUtils.decode(UTF_8, in, inPtr, inEnd); }
private String readValueString() { int len = readVarint32(); int end = ptr + len; String s = RawParseUtils.decode(UTF_8, buf, ptr, end); ptr = end; return s; }
private String readString(int len) throws IOException { final byte[] raw = new byte[len]; IO.readFully(rawIn, raw, 0, len); return RawParseUtils.decode(UTF_8, raw, 0, len); } }
/** * Get line of the patch script the error appears on. * * @return line of the patch script the error appears on. */ public String getLineText() { final int eol = RawParseUtils.nextLF(buf, offset); return RawParseUtils.decode(UTF_8, buf, offset, eol); }
private static String readFirstLine(File head) { try { final byte[] buf = IO.readFully(head, 4096); int n = buf.length; if (n == 0) return null; if (buf[n - 1] == '\n') n--; return RawParseUtils.decode(buf, 0, n); } catch (IOException e) { return null; } }
@Override public String toString() { final StringBuilder r = new StringBuilder(); r.append("FAST("); //$NON-NLS-1$ boolean first = true; for (byte[] p : fullpaths.toArray()) { if (!first) { r.append(" OR "); //$NON-NLS-1$ } r.append(RawParseUtils.decode(p)); first = false; } r.append(")"); //$NON-NLS-1$ return r.toString(); } }
private 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); }
private static String refName(CanonicalTreeParser p, boolean peel) { byte[] buf = p.getEntryPathBuffer(); int len = p.getEntryPathLength(); if (peel) { len -= 2; } int ptr = 0; if (RawParseUtils.match(buf, ptr, REFS_DOT_DOT) > 0) { ptr = 7; } return RawParseUtils.decode(buf, ptr, len); }
@Nullable private String readCommitMsgFile(String msgFilename) throws IOException { if (isBare() || getDirectory() == null) throw new NoWorkTreeException(); File mergeMsgFile = new File(getDirectory(), msgFilename); try { return RawParseUtils.decode(IO.readFully(mergeMsgFile)); } catch (FileNotFoundException e) { if (mergeMsgFile.exists()) { throw e; } // the file has disappeared in the meantime ignore it return null; } }
private static String readContentAsNormalizedString(DirCacheEntry entry, ObjectReader reader) throws MissingObjectException, IOException { ObjectLoader open = reader.open(entry.getObjectId()); byte[] cachedBytes = open.getCachedBytes(); return FS.detect().normalize(RawParseUtils.decode(cachedBytes)); }
void parseCanonical(RevWalk walk, 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; }