0N/A/*
2362N/A * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/**/
0N/A
0N/Aimport java.io.*;
0N/A
0N/A
0N/Aclass LineSink implements Runnable {
0N/A
0N/A DataInputStream ui;
0N/A BufferedReader ti;
0N/A int count;
0N/A PrintWriter log;
0N/A
0N/A public LineSink(InputStream us, BufferedReader ts,
0N/A int count, PrintWriter log)
0N/A throws IOException
0N/A {
0N/A this(us, ts, log);
0N/A this.count = count;
0N/A }
0N/A
0N/A public LineSink(InputStream us, BufferedReader ts, PrintWriter log)
0N/A throws IOException
0N/A {
0N/A ui = new DataInputStream(us);
0N/A ti = ts;
0N/A this.count = Integer.MAX_VALUE;
0N/A this.log = log;
0N/A }
0N/A
0N/A private String readUTFLine() throws IOException {
0N/A String s;
0N/A try {
0N/A s = ui.readUTF();
0N/A }
0N/A catch (EOFException x) {
0N/A return null;
0N/A }
0N/A return s;
0N/A }
0N/A
0N/A public void run() {
0N/A try {
0N/A for (int ln = 0; ln < count; ln++) {
0N/A String us = readUTFLine();
0N/A if (us == null) {
0N/A if (count < Integer.MAX_VALUE)
0N/A throw new RuntimeException("Premature EOF on UTF stream");
0N/A log.println("EOF on UTF stream");
0N/A break;
0N/A }
0N/A
0N/A String ts = ti.readLine();
0N/A if (ts == null) {
0N/A if (count < Integer.MAX_VALUE)
0N/A throw new RuntimeException("Premature EOF on char stream");
0N/A log.println("EOF on char stream");
0N/A break;
0N/A }
0N/A
0N/A if (us.length() != ts.length()) {
0N/A log.println("Length mismatch: us = \""
0N/A + us + "\", ts = \""
0N/A + ts + "\"");
0N/A throw new RuntimeException("Line " + ln +
0N/A ": Length mismatch: " +
0N/A us.length() + " " + ts.length());
0N/A }
0N/A
0N/A for (int i = 0; i < us.length(); i++) {
0N/A if (us.charAt(i) != ts.charAt(i))
0N/A throw new RuntimeException("Line " + ln +
0N/A ": Char mismatch: [" + i + "] " +
0N/A Integer.toHexString(us.charAt(i)) +
0N/A " " + Integer.toHexString(ts.charAt(i)));
0N/A }
0N/A log.println(ln + " " + ts.length());
0N/A }
0N/A
0N/A if (readUTFLine() != null)
0N/A throw new RuntimeException("Expected EOF on UTF stream");
0N/A if (ti.readLine() != null)
0N/A throw new RuntimeException("Expected EOF on char stream");
0N/A } catch (IOException x) {
0N/A throw new RuntimeException("Unexpected IOException: " + x);
0N/A }
0N/A }
0N/A
0N/A}