diff options
Diffstat (limited to 'src/java/org/apache/poi/hssf/util/CellRangeAddress8Bit.java')
-rw-r--r-- | src/java/org/apache/poi/hssf/util/CellRangeAddress8Bit.java | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/java/org/apache/poi/hssf/util/CellRangeAddress8Bit.java b/src/java/org/apache/poi/hssf/util/CellRangeAddress8Bit.java index 3b0c83fe98..ac5f540412 100644 --- a/src/java/org/apache/poi/hssf/util/CellRangeAddress8Bit.java +++ b/src/java/org/apache/poi/hssf/util/CellRangeAddress8Bit.java @@ -16,9 +16,10 @@ package org.apache.poi.hssf.util;
-import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.ss.util.CellRangeAddressBase;
-import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.LittleEndianByteArrayOutputStream;
+import org.apache.poi.util.LittleEndianInput;
+import org.apache.poi.util.LittleEndianOutput;
/**
* See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'<p/>
@@ -35,25 +36,31 @@ public final class CellRangeAddress8Bit extends CellRangeAddressBase { super(firstRow, lastRow, firstCol, lastCol);
}
- public CellRangeAddress8Bit(RecordInputStream in) {
+ public CellRangeAddress8Bit(LittleEndianInput in) {
super(readUShortAndCheck(in), in.readUShort(), in.readUByte(), in.readUByte());
}
- private static int readUShortAndCheck(RecordInputStream in) {
- if (in.remaining() < ENCODED_SIZE) {
+ private static int readUShortAndCheck(LittleEndianInput in) {
+ if (in.available() < ENCODED_SIZE) {
// Ran out of data
throw new RuntimeException("Ran out of data reading CellRangeAddress");
}
return in.readUShort();
}
+ /**
+ * @deprecated use {@link #serialize(LittleEndianOutput)}
+ */
public int serialize(int offset, byte[] data) {
- LittleEndian.putUShort(data, offset + 0, getFirstRow());
- LittleEndian.putUShort(data, offset + 2, getLastRow());
- LittleEndian.putByte(data, offset + 4, getFirstColumn());
- LittleEndian.putByte(data, offset + 5, getLastColumn());
+ serialize(new LittleEndianByteArrayOutputStream(data, offset, ENCODED_SIZE));
return ENCODED_SIZE;
}
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(getFirstRow());
+ out.writeShort(getLastRow());
+ out.writeByte(getFirstColumn());
+ out.writeByte(getLastColumn());
+ }
public CellRangeAddress8Bit copy() {
return new CellRangeAddress8Bit(getFirstRow(), getLastRow(), getFirstColumn(), getLastColumn());
|