#62355 - unsplit packages - 4 - open HPSF

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1832361 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2018-05-27 22:15:59 +00:00
parent e2ec4ebe95
commit 09fa9890a6
15 changed files with 63 additions and 81 deletions

View File

@ -20,7 +20,7 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
@Internal
class Array
public class Array
{
static class ArrayDimension {
private long _size;
@ -74,9 +74,7 @@ class Array
private final ArrayHeader _header = new ArrayHeader();
private TypedPropertyValue[] _values;
Array() {}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
_header.read(lei);
long numberOfScalarsLong = _header.getNumberOfScalarValues();
@ -99,8 +97,8 @@ class Array
}
}
}
TypedPropertyValue[] getValues(){
public TypedPropertyValue[] getValues(){
return _values;
}
}

View File

@ -21,16 +21,14 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianInput;
@Internal
class Blob {
public class Blob {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 1_000_000;
private byte[] _value;
Blob() {}
void read( LittleEndianInput lei ) {
public void read( LittleEndianInput lei ) {
int size = lei.readInt();
_value = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
if ( size > 0 ) {

View File

@ -25,7 +25,7 @@ import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@Internal
class ClipboardData {
public class ClipboardData {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000_000;
@ -33,10 +33,8 @@ class ClipboardData {
private int _format;
private byte[] _value;
ClipboardData() {}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
int offset = lei.getReadIndex();
int size = lei.readInt();
@ -55,11 +53,11 @@ class ClipboardData {
lei.readFully(_value);
}
byte[] getValue() {
public byte[] getValue() {
return _value;
}
byte[] toByteArray() {
public byte[] toByteArray() {
byte[] result = new byte[LittleEndianConsts.INT_SIZE*2+_value.length];
LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(result,0);
try {
@ -71,8 +69,8 @@ class ClipboardData {
IOUtils.closeQuietly(bos);
}
}
void setValue( byte[] value ) {
public void setValue( byte[] value ) {
_value = value.clone();
}
}

View File

@ -30,18 +30,16 @@ import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@Internal
class CodePageString {
public class CodePageString {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
private final static POILogger LOG = POILogFactory.getLogger( CodePageString.class );
private byte[] _value;
CodePageString() {}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
int offset = lei.getReadIndex();
int size = lei.readInt();
_value = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
@ -70,7 +68,7 @@ class CodePageString {
TypedPropertyValue.skipPadding(lei);
}
String getJavaValue( int codepage ) throws UnsupportedEncodingException {
public String getJavaValue( int codepage ) throws UnsupportedEncodingException {
int cp = ( codepage == -1 ) ? Property.DEFAULT_CODEPAGE : codepage;
String result = CodePageUtil.getStringFromCodePage(_value, cp);
@ -92,16 +90,16 @@ class CodePageString {
return result.substring( 0, terminator );
}
int getSize() {
public int getSize() {
return LittleEndianConsts.INT_SIZE + _value.length;
}
void setJavaValue( String string, int codepage ) throws UnsupportedEncodingException {
public void setJavaValue( String string, int codepage ) throws UnsupportedEncodingException {
int cp = ( codepage == -1 ) ? Property.DEFAULT_CODEPAGE : codepage;
_value = CodePageUtil.getBytesInCodePage(string + "\0", cp);
}
int write( OutputStream out ) throws IOException {
public int write( OutputStream out ) throws IOException {
LittleEndian.putUInt( _value.length, out );
out.write( _value );
return LittleEndianConsts.INT_SIZE + _value.length;

View File

@ -20,14 +20,12 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
@Internal
class Currency {
public class Currency {
private static final int SIZE = 8;
private final byte[] _value = new byte[SIZE];
Currency() {}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
lei.readFully(_value);
}
}

View File

@ -20,14 +20,12 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
@Internal
class Date {
public class Date {
private static final int SIZE = 8;
private final byte[] _value = new byte[SIZE];
Date() {}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
lei.readFully(_value);
}
}

View File

@ -20,7 +20,7 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
@Internal
class Decimal {
public class Decimal {
/**
* Findbugs: UNR_UNREAD_FIELD
*/
@ -30,9 +30,7 @@ class Decimal {
private int field_4_hi32;
private long field_5_lo64;
Decimal() {}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
field_1_wReserved = lei.readShort();
field_2_scale = lei.readByte();
field_3_sign = lei.readByte();

View File

@ -20,10 +20,12 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
import org.apache.poi.util.LittleEndianConsts;
@Internal
public class Filetime {
/**
* The difference between the Windows epoch (1601-01-01
@ -39,47 +41,47 @@ public class Filetime {
private int _dwHighDateTime;
private int _dwLowDateTime;
Filetime() {}
Filetime( int low, int high ) {
public Filetime() {}
public Filetime( int low, int high ) {
_dwLowDateTime = low;
_dwHighDateTime = high;
}
Filetime( Date date ) {
public Filetime( Date date ) {
long filetime = Filetime.dateToFileTime(date);
_dwHighDateTime = (int) ((filetime >>> 32) & UINT_MASK);
_dwLowDateTime = (int) (filetime & UINT_MASK);
}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
_dwLowDateTime = lei.readInt();
_dwHighDateTime = lei.readInt();
}
long getHigh() {
public long getHigh() {
return _dwHighDateTime;
}
long getLow() {
public long getLow() {
return _dwLowDateTime;
}
byte[] toByteArray() {
public byte[] toByteArray() {
byte[] result = new byte[SIZE];
LittleEndian.putInt( result, 0 * LittleEndianConsts.INT_SIZE, _dwLowDateTime );
LittleEndian.putInt( result, 1 * LittleEndianConsts.INT_SIZE, _dwHighDateTime );
return result;
}
int write( OutputStream out ) throws IOException {
public int write( OutputStream out ) throws IOException {
LittleEndian.putInt( _dwLowDateTime, out );
LittleEndian.putInt( _dwHighDateTime, out );
return SIZE;
}
Date getJavaValue() {
public Date getJavaValue() {
long l = (((long)_dwHighDateTime) << 32) | (_dwLowDateTime & UINT_MASK);
return filetimeToDate( l );
}

View File

@ -20,15 +20,13 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
@Internal
class GUID {
public class GUID {
private int _data1;
private short _data2;
private short _data3;
private long _data4;
GUID() {}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
_data1 = lei.readInt();
_data2 = lei.readShort();
_data3 = lei.readShort();

View File

@ -19,6 +19,6 @@ package org.apache.poi.hpsf;
import org.apache.poi.util.Internal;
@Internal
class IndirectPropertyName extends CodePageString {
public class IndirectPropertyName extends CodePageString {
IndirectPropertyName() {}
}

View File

@ -27,22 +27,22 @@ import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@Internal
class TypedPropertyValue {
public class TypedPropertyValue {
private static final POILogger LOG = POILogFactory.getLogger( TypedPropertyValue.class );
private int _type;
private Object _value;
TypedPropertyValue( int type, Object value ) {
public TypedPropertyValue( int type, Object value ) {
_type = type;
_value = value;
}
Object getValue() {
public Object getValue() {
return _value;
}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
_type = lei.readShort();
short padding = lei.readShort();
if ( padding != 0 ) {
@ -52,7 +52,7 @@ class TypedPropertyValue {
readValue( lei );
}
void readValue( LittleEndianByteArrayInputStream lei ) {
public void readValue( LittleEndianByteArrayInputStream lei ) {
switch ( _type ) {
case Variant.VT_EMPTY:
case Variant.VT_NULL:

View File

@ -31,16 +31,14 @@ import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil;
@Internal
class UnicodeString {
public class UnicodeString {
private static final POILogger LOG = POILogFactory.getLogger( UnicodeString.class );
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000;
private byte[] _value;
UnicodeString() {}
void read(LittleEndianByteArrayInputStream lei) {
public void read(LittleEndianByteArrayInputStream lei) {
final int length = lei.readInt();
final int unicodeBytes = length*2;
_value = IOUtils.safelyAllocate(unicodeBytes, MAX_RECORD_LENGTH);
@ -66,11 +64,11 @@ class UnicodeString {
TypedPropertyValue.skipPadding(lei);
}
byte[] getValue() {
public byte[] getValue() {
return _value;
}
String toJavaString() {
public String toJavaString() {
if ( _value.length == 0 ) {
return null;
}
@ -95,11 +93,11 @@ class UnicodeString {
return result.substring( 0, terminator );
}
void setJavaValue( String string ) throws UnsupportedEncodingException {
public void setJavaValue( String string ) throws UnsupportedEncodingException {
_value = CodePageUtil.getBytesInCodePage(string + "\0", CodePageUtil.CP_UNICODE);
}
int write( OutputStream out ) throws IOException {
public int write( OutputStream out ) throws IOException {
LittleEndian.putUInt( _value.length / 2, out );
out.write( _value );
return LittleEndianConsts.INT_SIZE + _value.length;

View File

@ -22,16 +22,14 @@ import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@Internal
class VariantBool {
public class VariantBool {
private final static POILogger LOG = POILogFactory.getLogger( VariantBool.class );
static final int SIZE = 2;
private boolean _value;
VariantBool() {}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
short value = lei.readShort();
switch (value) {
case 0:
@ -47,11 +45,11 @@ class VariantBool {
}
}
boolean getValue() {
public boolean getValue() {
return _value;
}
void setValue( boolean value ) {
public void setValue( boolean value ) {
this._value = value;
}
}

View File

@ -26,16 +26,16 @@ import org.apache.poi.util.LittleEndianByteArrayInputStream;
* Holder for vector-type properties
*/
@Internal
class Vector {
public class Vector {
private final short _type;
private TypedPropertyValue[] _values;
Vector( short type ) {
public Vector( short type ) {
this._type = type;
}
void read( LittleEndianByteArrayInputStream lei ) {
public void read( LittleEndianByteArrayInputStream lei ) {
final long longLength = lei.readUInt();
if ( longLength > Integer.MAX_VALUE ) {
@ -61,7 +61,7 @@ class Vector {
_values = values.toArray(new TypedPropertyValue[values.size()]);
}
TypedPropertyValue[] getValues(){
public TypedPropertyValue[] getValues(){
return _values;
}
}

View File

@ -22,14 +22,14 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
@Internal
class VersionedStream
public class VersionedStream
{
private final GUID _versionGuid = new GUID();
private final IndirectPropertyName _streamName = new IndirectPropertyName();
VersionedStream() {}
void read( LittleEndianByteArrayInputStream lei ) {
public VersionedStream() {}
public void read( LittleEndianByteArrayInputStream lei ) {
_versionGuid.read(lei);
_streamName.read(lei);
}