diff options
author | Josh Micich <josh@apache.org> | 2009-05-19 16:29:51 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2009-05-19 16:29:51 +0000 |
commit | 6a7fc37e734c70cc7bbc3a8c30657700cdc88a3b (patch) | |
tree | fb36bc8922694f4c42e61dfbf4fda72d57542fa0 /src/java/org/apache/poi/util | |
parent | 25b954d792dfd4795f6ae6147eb6f1f3520eb436 (diff) | |
download | poi-6a7fc37e734c70cc7bbc3a8c30657700cdc88a3b.tar.gz poi-6a7fc37e734c70cc7bbc3a8c30657700cdc88a3b.zip |
Changed CRLF to LF in .java base src files. Minor reformatting fixes.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@776377 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/util')
5 files changed, 334 insertions, 334 deletions
diff --git a/src/java/org/apache/poi/util/DelayableLittleEndianOutput.java b/src/java/org/apache/poi/util/DelayableLittleEndianOutput.java index d8e4395e64..13282ac378 100644 --- a/src/java/org/apache/poi/util/DelayableLittleEndianOutput.java +++ b/src/java/org/apache/poi/util/DelayableLittleEndianOutput.java @@ -1,34 +1,34 @@ -/* ====================================================================
- 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 org.apache.poi.util;
-/**
- * Implementors of this interface allow client code to 'delay' writing to a certain section of a
- * data output stream.<br/>
- * A typical application is for writing BIFF records when the size is not known until well after
- * the header has been written. The client code can call {@link #createDelayedOutput(int)}
- * to reserve two bytes of the output for the 'ushort size' header field. The delayed output can
- * be written at any stage.
- *
- * @author Josh Micich
- */
-public interface DelayableLittleEndianOutput extends LittleEndianOutput {
- /**
- * Creates an output stream intended for outputting a sequence of <tt>size</tt> bytes.
- */
- LittleEndianOutput createDelayedOutput(int size);
-}
+/* ==================================================================== + 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 org.apache.poi.util; +/** + * Implementors of this interface allow client code to 'delay' writing to a certain section of a + * data output stream.<br/> + * A typical application is for writing BIFF records when the size is not known until well after + * the header has been written. The client code can call {@link #createDelayedOutput(int)} + * to reserve two bytes of the output for the 'ushort size' header field. The delayed output can + * be written at any stage. + * + * @author Josh Micich + */ +public interface DelayableLittleEndianOutput extends LittleEndianOutput { + /** + * Creates an output stream intended for outputting a sequence of <tt>size</tt> bytes. + */ + LittleEndianOutput createDelayedOutput(int size); +} diff --git a/src/java/org/apache/poi/util/LittleEndianInput.java b/src/java/org/apache/poi/util/LittleEndianInput.java index dafa7eadac..d8db24797f 100644 --- a/src/java/org/apache/poi/util/LittleEndianInput.java +++ b/src/java/org/apache/poi/util/LittleEndianInput.java @@ -1,34 +1,34 @@ -/* ====================================================================
- 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 org.apache.poi.util;
-/**
- *
- * @author Josh Micich
- */
-public interface LittleEndianInput {
- int available();
- byte readByte();
- int readUByte();
- short readShort();
- int readUShort();
- int readInt();
- long readLong();
- double readDouble();
- void readFully(byte[] buf);
- void readFully(byte[] buf, int off, int len);
-}
+/* ==================================================================== + 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 org.apache.poi.util; +/** + * + * @author Josh Micich + */ +public interface LittleEndianInput { + int available(); + byte readByte(); + int readUByte(); + short readShort(); + int readUShort(); + int readInt(); + long readLong(); + double readDouble(); + void readFully(byte[] buf); + void readFully(byte[] buf, int off, int len); +} diff --git a/src/java/org/apache/poi/util/LittleEndianInputStream.java b/src/java/org/apache/poi/util/LittleEndianInputStream.java index 622ee23cd4..1a37964a8f 100644 --- a/src/java/org/apache/poi/util/LittleEndianInputStream.java +++ b/src/java/org/apache/poi/util/LittleEndianInputStream.java @@ -1,144 +1,144 @@ -/* ====================================================================
- 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 org.apache.poi.util;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Wraps an {@link InputStream} providing {@link LittleEndianInput}<p/>
- *
- * This class does not buffer any input, so the stream read position maintained
- * by this class is consistent with that of the inner stream.
- *
- * @author Josh Micich
- */
-public class LittleEndianInputStream extends FilterInputStream implements LittleEndianInput {
- public LittleEndianInputStream(InputStream is) {
- super(is);
- }
- public int available() {
- try {
- return super.available();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- public byte readByte() {
- return (byte)readUByte();
- }
- public int readUByte() {
- int ch;
- try {
- ch = in.read();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- checkEOF(ch);
- return ch;
- }
- public double readDouble() {
- return Double.longBitsToDouble(readLong());
- }
- public int readInt() {
- int ch1;
- int ch2;
- int ch3;
- int ch4;
- try {
- ch1 = in.read();
- ch2 = in.read();
- ch3 = in.read();
- ch4 = in.read();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- checkEOF(ch1 | ch2 | ch3 | ch4);
- return (ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0);
- }
- public long readLong() {
- int b0;
- int b1;
- int b2;
- int b3;
- int b4;
- int b5;
- int b6;
- int b7;
- try {
- b0 = in.read();
- b1 = in.read();
- b2 = in.read();
- b3 = in.read();
- b4 = in.read();
- b5 = in.read();
- b6 = in.read();
- b7 = in.read();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- checkEOF(b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7);
- return (((long)b7 << 56) +
- ((long)b6 << 48) +
- ((long)b5 << 40) +
- ((long)b4 << 32) +
- ((long)b3 << 24) +
- (b2 << 16) +
- (b1 << 8) +
- (b0 << 0));
- }
- public short readShort() {
- return (short)readUShort();
- }
- public int readUShort() {
- int ch1;
- int ch2;
- try {
- ch1 = in.read();
- ch2 = in.read();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- checkEOF(ch1 | ch2);
- return (ch2 << 8) + (ch1 << 0);
- }
- private static void checkEOF(int value) {
- if (value <0) {
- throw new RuntimeException("Unexpected end-of-file");
- }
- }
-
- public void readFully(byte[] buf) {
- readFully(buf, 0, buf.length);
- }
-
- public void readFully(byte[] buf, int off, int len) {
- int max = off+len;
- for(int i=off; i<max; i++) {
- int ch;
- try {
- ch = in.read();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- checkEOF(ch);
- buf[i] = (byte) ch;
- }
- }
-}
+/* ==================================================================== + 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 org.apache.poi.util; + +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * Wraps an {@link InputStream} providing {@link LittleEndianInput}<p/> + * + * This class does not buffer any input, so the stream read position maintained + * by this class is consistent with that of the inner stream. + * + * @author Josh Micich + */ +public class LittleEndianInputStream extends FilterInputStream implements LittleEndianInput { + public LittleEndianInputStream(InputStream is) { + super(is); + } + public int available() { + try { + return super.available(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + public byte readByte() { + return (byte)readUByte(); + } + public int readUByte() { + int ch; + try { + ch = in.read(); + } catch (IOException e) { + throw new RuntimeException(e); + } + checkEOF(ch); + return ch; + } + public double readDouble() { + return Double.longBitsToDouble(readLong()); + } + public int readInt() { + int ch1; + int ch2; + int ch3; + int ch4; + try { + ch1 = in.read(); + ch2 = in.read(); + ch3 = in.read(); + ch4 = in.read(); + } catch (IOException e) { + throw new RuntimeException(e); + } + checkEOF(ch1 | ch2 | ch3 | ch4); + return (ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0); + } + public long readLong() { + int b0; + int b1; + int b2; + int b3; + int b4; + int b5; + int b6; + int b7; + try { + b0 = in.read(); + b1 = in.read(); + b2 = in.read(); + b3 = in.read(); + b4 = in.read(); + b5 = in.read(); + b6 = in.read(); + b7 = in.read(); + } catch (IOException e) { + throw new RuntimeException(e); + } + checkEOF(b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7); + return (((long)b7 << 56) + + ((long)b6 << 48) + + ((long)b5 << 40) + + ((long)b4 << 32) + + ((long)b3 << 24) + + (b2 << 16) + + (b1 << 8) + + (b0 << 0)); + } + public short readShort() { + return (short)readUShort(); + } + public int readUShort() { + int ch1; + int ch2; + try { + ch1 = in.read(); + ch2 = in.read(); + } catch (IOException e) { + throw new RuntimeException(e); + } + checkEOF(ch1 | ch2); + return (ch2 << 8) + (ch1 << 0); + } + private static void checkEOF(int value) { + if (value <0) { + throw new RuntimeException("Unexpected end-of-file"); + } + } + + public void readFully(byte[] buf) { + readFully(buf, 0, buf.length); + } + + public void readFully(byte[] buf, int off, int len) { + int max = off+len; + for(int i=off; i<max; i++) { + int ch; + try { + ch = in.read(); + } catch (IOException e) { + throw new RuntimeException(e); + } + checkEOF(ch); + buf[i] = (byte) ch; + } + } +} diff --git a/src/java/org/apache/poi/util/LittleEndianOutput.java b/src/java/org/apache/poi/util/LittleEndianOutput.java index 450b337bdb..708d97bf4a 100644 --- a/src/java/org/apache/poi/util/LittleEndianOutput.java +++ b/src/java/org/apache/poi/util/LittleEndianOutput.java @@ -1,31 +1,31 @@ -/* ====================================================================
- 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 org.apache.poi.util;
-/**
- *
- * @author Josh Micich
- */
-public interface LittleEndianOutput {
- void writeByte(int v);
- void writeShort(int v);
- void writeInt(int v);
- void writeLong(long v);
- void writeDouble(double v);
- void write(byte[] b);
- void write(byte[] b, int offset, int len);
-}
+/* ==================================================================== + 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 org.apache.poi.util; +/** + * + * @author Josh Micich + */ +public interface LittleEndianOutput { + void writeByte(int v); + void writeShort(int v); + void writeInt(int v); + void writeLong(long v); + void writeDouble(double v); + void write(byte[] b); + void write(byte[] b, int offset, int len); +} diff --git a/src/java/org/apache/poi/util/LittleEndianOutputStream.java b/src/java/org/apache/poi/util/LittleEndianOutputStream.java index 249211d049..c8bb9d4b78 100644 --- a/src/java/org/apache/poi/util/LittleEndianOutputStream.java +++ b/src/java/org/apache/poi/util/LittleEndianOutputStream.java @@ -1,91 +1,91 @@ -/* ====================================================================
- 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 org.apache.poi.util;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- *
- * @author Josh Micich
- */
-public final class LittleEndianOutputStream extends FilterOutputStream implements LittleEndianOutput {
- public LittleEndianOutputStream(OutputStream out) {
- super(out);
- }
-
- public void writeByte(int v) {
- try {
- out.write(v);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public void writeDouble(double v) {
- writeLong(Double.doubleToLongBits(v));
- }
-
- public void writeInt(int v) {
- int b3 = (v >>> 24) & 0xFF;
- int b2 = (v >>> 16) & 0xFF;
- int b1 = (v >>> 8) & 0xFF;
- int b0 = (v >>> 0) & 0xFF;
- try {
- out.write(b0);
- out.write(b1);
- out.write(b2);
- out.write(b3);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public void writeLong(long v) {
- writeInt((int)(v >> 0));
- writeInt((int)(v >> 32));
- }
-
- public void writeShort(int v) {
- int b1 = (v >>> 8) & 0xFF;
- int b0 = (v >>> 0) & 0xFF;
- try {
- out.write(b0);
- out.write(b1);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- public void write(byte[] b) {
- // suppress IOException for interface method
- try {
- super.write(b);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- public void write(byte[] b, int off, int len) {
- // suppress IOException for interface method
- try {
- super.write(b, off, len);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-}
+/* ==================================================================== + 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 org.apache.poi.util; + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * @author Josh Micich + */ +public final class LittleEndianOutputStream extends FilterOutputStream implements LittleEndianOutput { + public LittleEndianOutputStream(OutputStream out) { + super(out); + } + + public void writeByte(int v) { + try { + out.write(v); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public void writeDouble(double v) { + writeLong(Double.doubleToLongBits(v)); + } + + public void writeInt(int v) { + int b3 = (v >>> 24) & 0xFF; + int b2 = (v >>> 16) & 0xFF; + int b1 = (v >>> 8) & 0xFF; + int b0 = (v >>> 0) & 0xFF; + try { + out.write(b0); + out.write(b1); + out.write(b2); + out.write(b3); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public void writeLong(long v) { + writeInt((int)(v >> 0)); + writeInt((int)(v >> 32)); + } + + public void writeShort(int v) { + int b1 = (v >>> 8) & 0xFF; + int b0 = (v >>> 0) & 0xFF; + try { + out.write(b0); + out.write(b1); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + public void write(byte[] b) { + // suppress IOException for interface method + try { + super.write(b); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + public void write(byte[] b, int off, int len) { + // suppress IOException for interface method + try { + super.write(b, off, len); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} |