Removed unused classes Project: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/commit/8cef8a3b Tree: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/tree/8cef8a3b Diff: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/diff/8cef8a3b
Branch: refs/heads/master Commit: 8cef8a3bb5b90ab972e9f735f76d9e2585b9f9ea Parents: 0cf2a64 Author: myui <[email protected]> Authored: Sat Nov 12 14:53:19 2016 +0900 Committer: myui <[email protected]> Committed: Sat Nov 12 14:53:19 2016 +0900 ---------------------------------------------------------------------- .../hivemall/utils/io/ASCII85InputStream.java | 230 ------------------- .../hivemall/utils/io/ASCII85OutputStream.java | 151 ------------ 2 files changed, 381 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/8cef8a3b/core/src/main/java/hivemall/utils/io/ASCII85InputStream.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/io/ASCII85InputStream.java b/core/src/main/java/hivemall/utils/io/ASCII85InputStream.java deleted file mode 100644 index bc0ca16..0000000 --- a/core/src/main/java/hivemall/utils/io/ASCII85InputStream.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package hivemall.utils.io; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * This class represents an ASCII85 stream. This class is based on the implementation in Apache - * PDFBox. - */ -public final class ASCII85InputStream extends FilterInputStream { - - private static final byte TERMINATOR = '~'; - private static final byte OFFSET = '!'; - private static final byte NEWLINE = '\n'; - private static final byte RETURN = '\r'; - private static final byte SPACE = ' '; - private static final byte PADDING_U = 'u'; - private static final byte Z = 'z'; - - private int index; - private int n; - private boolean eof; - - private final byte[] ascii; - private final byte[] decoded; - - /** - * Constructor. - * - * @param is The input stream to actually read from. - */ - public ASCII85InputStream(InputStream is) { - super(is); - index = 0; - n = 0; - eof = false; - ascii = new byte[5]; - decoded = new byte[4]; - } - - /** - * This will read the next byte from the stream. - * - * @return The next byte read from the stream. - * @throws IOException If there is an error reading from the wrapped stream. - */ - @Override - public int read() throws IOException { - if (index < n) { - return decoded[index++] & 0xFF; - } - if (eof) { - return -1; - } - - index = 0; - int k; - byte z; - do { - int zz = (byte) in.read(); - if (zz == -1) { - eof = true; - return -1; - } - z = (byte) zz; - } while (z == NEWLINE || z == RETURN || z == SPACE); - - if (z == TERMINATOR) { - eof = true; - n = 0; - return -1; - } else if (z == Z) { - decoded[0] = decoded[1] = decoded[2] = decoded[3] = 0; - n = 4; - } else { - ascii[0] = z; // may be EOF here.... - for (k = 1; k < 5; ++k) { - do { - int zz = (byte) in.read(); - if (zz == -1) { - eof = true; - return -1; - } - z = (byte) zz; - } while (z == NEWLINE || z == RETURN || z == SPACE); - ascii[k] = z; - if (z == TERMINATOR) { - // don't include ~ as padding byte - ascii[k] = PADDING_U; - break; - } - } - n = k - 1; - if (n == 0) { - eof = true; - return -1; - } - if (k < 5) { - for (++k; k < 5; ++k) { - ascii[k] = PADDING_U; - } - eof = true; - } - // decode stream - long t = 0; - for (k = 0; k < 5; ++k) { - z = (byte) (ascii[k] - OFFSET); - if (z < 0 || z > 93) { - throw new IOException("Invalid data in Ascii85 stream"); - } - t = (t * 85L) + z; - } - for (k = 3; k >= 0; --k) { - decoded[k] = (byte) (t & 0xFFL); - t >>>= 8; - } - } - return decoded[index++] & 0xFF; - } - - /** - * This will read a chunk of data. - * - * @param data The buffer to write data to. - * @param offset The offset into the data stream. - * @param len The number of byte to attempt to read. - * - * @return The number of bytes actually read. - * - * @throws IOException If there is an error reading data from the underlying stream. - */ - @Override - public int read(final byte[] data, final int offset, final int len) throws IOException { - if (eof && index >= n) { - return -1; - } - for (int i = 0; i < len; i++) { - if (index < n) { - data[i + offset] = decoded[index++]; - } else { - int t = read(); - if (t == -1) { - return i; - } - data[i + offset] = (byte) t; - } - } - return len; - } - - /** - * This will close the underlying stream and release any resources. - * - * @throws IOException If there is an error closing the underlying stream. - */ - @Override - public void close() throws IOException { - eof = true; - super.close(); - } - - /** - * non supported interface methods. - * - * @return False always. - */ - @Override - public boolean markSupported() { - return false; - } - - /** - * Unsupported. - * - * @param nValue ignored. - * - * @return Always zero. - */ - @Override - public long skip(long nValue) { - return 0; - } - - /** - * Unsupported. - * - * @return Always zero. - */ - @Override - public int available() { - return 0; - } - - /** - * Unsupported. - * - * @param readlimit ignored. - */ - @Override - public void mark(int readlimit) {} - - /** - * Unsupported. - * - * @throws IOException telling that this is an unsupported action. - */ - @Override - public void reset() throws IOException { - throw new IOException("Reset is not supported"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/8cef8a3b/core/src/main/java/hivemall/utils/io/ASCII85OutputStream.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/io/ASCII85OutputStream.java b/core/src/main/java/hivemall/utils/io/ASCII85OutputStream.java deleted file mode 100644 index fc7d440..0000000 --- a/core/src/main/java/hivemall/utils/io/ASCII85OutputStream.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package hivemall.utils.io; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * This class represents an ASCII85 output stream. This class is based on the implementation in - * Apache PDFBox. - */ -public final class ASCII85OutputStream extends FilterOutputStream { - - private static final long a85p2 = 85L * 85L; - private static final long a85p3 = 85L * 85L * 85L; - private static final long a85p4 = 85L * 85L * 85L * 85L; - private static final byte TERMINATOR = '~'; - private static final byte OFFSET = '!'; - private static final byte Z = 'z'; - - private final byte[] indata; - private final byte[] encoded; - - private int count; - private boolean flushed; - - /** - * Constructor. - * - * @param out The output stream to write to. - */ - public ASCII85OutputStream(OutputStream out) { - super(out); - indata = new byte[4]; - encoded = new byte[5]; - count = 0; - flushed = true; - } - - /** - * This will transform the next four ascii bytes. - */ - private void transformASCII85() { - long word = ((((indata[0] << 8) | (indata[1] & 0xFF)) << 16) | ((indata[2] & 0xFF) << 8) | (indata[3] & 0xFF)) & 0xFFFFFFFFL; - - if (word == 0) { - encoded[0] = Z; - encoded[1] = 0; - return; - } - - long x = word / a85p4; - encoded[0] = (byte) (x + OFFSET); - word -= x * a85p4; - - x = word / a85p3; - encoded[1] = (byte) (x + OFFSET); - word -= x * a85p3; - - x = word / a85p2; - encoded[2] = (byte) (x + OFFSET); - word -= x * a85p2; - - x = word / 85L; - encoded[3] = (byte) (x + OFFSET); - - encoded[4] = (byte) ((word % 85L) + OFFSET); - } - - /** - * This will write a single byte. - * - * @param b The byte to write. - * - * @throws IOException If there is an error writing to the stream. - */ - @Override - public void write(int b) throws IOException { - flushed = false; - indata[count++] = (byte) b; - if (count < 4) { - return; - } - transformASCII85(); - for (int i = 0; i < 5; i++) { - if (encoded[i] == 0) { - break; - } - out.write(encoded[i]); - } - count = 0; - } - - /** - * This will flush the data to the stream. - * - * @throws IOException If there is an error writing the data to the stream. - */ - @Override - public void flush() throws IOException { - if (flushed) { - return; - } - if (count > 0) { - for (int i = count; i < 4; i++) { - indata[i] = 0; - } - transformASCII85(); - if (encoded[0] == Z) { - for (int i = 0; i < 5; i++) { - encoded[i] = OFFSET;// expand 'z', - } - } - for (int i = 0; i < count + 1; i++) { - out.write(encoded[i]); - } - } - out.write(TERMINATOR); - count = 0; - flushed = true; - super.flush(); - } - - /** - * This will close the stream. - * - * @throws IOException If there is an error closing the wrapped stream. - */ - @Override - public void close() throws IOException { - flush(); - super.close(); - } -}
