/** * Split two texts into a list of strings. Reduce the texts to a string of * hashes where each Unicode character represents one line. * * @param text1 First string. * @param text2 Second string. * @return An object containing the encoded text1, the encoded text2 and * the List of unique strings. The zeroth element of the List of * unique strings is intentionally blank. */ protected LinesToCharsResult diffLinesToChars(String text1, String text2) { List<String> lineArray = new ArrayList<String>(); Map<String, Integer> lineHash = new HashMap<String, Integer>(); // e.g. linearray[4] == "Hello\n" // e.g. linehash.get("Hello\n") == 4 // "\x00" is a valid character, but various debuggers don't like it. // So we'll insert a junk entry to avoid generating a null character. lineArray.add(""); String chars1 = diffLinesToCharsMunge(text1, lineArray, lineHash); String chars2 = diffLinesToCharsMunge(text2, lineArray, lineHash); return new LinesToCharsResult(chars1, chars2, lineArray); }