/** * Construct a data entry. * * @param name A name used for diagnostics. * @param data The data for this entry. * @param charset The character encoding for this entry. */ public DataEntry(String name, byte[] data, String charset) { this.name = name; this.data = data.clone(); this.charset = charset; // The key always ends with \n, typically \r\n this.keyEnd = SwordUtil.findByte(this.data, SEPARATOR); }
/** * Get the position of the second \n in the data. This represents the end of the link and the * start of the rest of the data. * * @return the end of the link or -1 if not found. */ private int getLinkEnd() { if (linkEnd == 0) { linkEnd = SwordUtil.findByte(data, keyEnd + 1, SEPARATOR); if (linkEnd == -1) { linkEnd = data.length - 1; } } return linkEnd; }