void read( LittleEndianByteArrayInputStream lei ) { _size = lei.readUInt(); _indexOffset = lei.readInt(); } }
public void read( LittleEndianByteArrayInputStream lei ) { final long longLength = lei.readUInt(); if ( longLength > Integer.MAX_VALUE ) { throw new UnsupportedOperationException( "Vector is too long -- " + longLength ); } final int length = (int) longLength; //BUG-61295 -- avoid OOM on corrupt file. Build list instead //of allocating array of length "length". //If the length is corrupted and crazily big but < Integer.MAX_VALUE, //this will trigger a RuntimeException "Buffer overrun" in lei.checkPosition List<TypedPropertyValue> values = new ArrayList<>(); int paddedType = (_type == Variant.VT_VARIANT) ? 0 : _type; for ( int i = 0; i < length; i++ ) { TypedPropertyValue value = new TypedPropertyValue(paddedType, null); if (paddedType == 0) { value.read(lei); } else { value.readValue(lei); } values.add(value); } _values = values.toArray(new TypedPropertyValue[values.size()]); }
/** * Creates a {@link Property} instance by reading its bytes * from the property set stream. * * @param id The property's ID. * @param leis The bytes the property set stream consists of. * @param length The property's type/value pair's length in bytes. * @param codepage The section's and thus the property's * codepage. It is needed only when reading string values. * @exception UnsupportedEncodingException if the specified codepage is not * supported. */ public Property(final long id, LittleEndianByteArrayInputStream leis, final int length, final int codepage) throws UnsupportedEncodingException { this.id = id; /* * ID 0 is a special case since it specifies a dictionary of * property IDs and property names. */ if (id == 0) { throw new UnsupportedEncodingException("Dictionary not allowed here"); } type = leis.readUInt(); try { value = VariantSupport.read(leis, length, (int) type, codepage); } catch (UnsupportedVariantTypeException ex) { VariantSupport.writeUnsupportedTypeMessage(ex); value = ex.getValue(); } }
void read( LittleEndianByteArrayInputStream lei ) { _type = lei.readInt(); long numDimensionsUnsigned = lei.readUInt(); if ( !( 1 <= numDimensionsUnsigned && numDimensionsUnsigned <= 31 ) ) { String msg = "Array dimension number "+numDimensionsUnsigned+" is not in [1; 31] range"; throw new IllegalPropertySetDataException(msg); } int numDimensions = (int) numDimensionsUnsigned; _dimensions = new ArrayDimension[numDimensions]; for ( int i = 0; i < numDimensions; i++ ) { ArrayDimension ad = new ArrayDimension(); ad.read(lei); _dimensions[i] = ad; } }
case Variant.VT_UI4: case Variant.VT_ERROR: _value = lei.readUInt(); break;
void read( LittleEndianByteArrayInputStream lei ) { _size = lei.readUInt(); _indexOffset = lei.readInt(); } }
public void read( LittleEndianByteArrayInputStream lei ) { final long longLength = lei.readUInt(); if ( longLength > Integer.MAX_VALUE ) { throw new UnsupportedOperationException( "Vector is too long -- " + longLength ); } final int length = (int) longLength; //BUG-61295 -- avoid OOM on corrupt file. Build list instead //of allocating array of length "length". //If the length is corrupted and crazily big but < Integer.MAX_VALUE, //this will trigger a RuntimeException "Buffer overrun" in lei.checkPosition List<TypedPropertyValue> values = new ArrayList<>(); int paddedType = (_type == Variant.VT_VARIANT) ? 0 : _type; for ( int i = 0; i < length; i++ ) { TypedPropertyValue value = new TypedPropertyValue(paddedType, null); if (paddedType == 0) { value.read(lei); } else { value.readValue(lei); } values.add(value); } _values = values.toArray(new TypedPropertyValue[values.size()]); }
/** * Creates a {@link Property} instance by reading its bytes * from the property set stream. * * @param id The property's ID. * @param leis The bytes the property set stream consists of. * @param length The property's type/value pair's length in bytes. * @param codepage The section's and thus the property's * codepage. It is needed only when reading string values. * @exception UnsupportedEncodingException if the specified codepage is not * supported. */ public Property(final long id, LittleEndianByteArrayInputStream leis, final int length, final int codepage) throws UnsupportedEncodingException { this.id = id; /* * ID 0 is a special case since it specifies a dictionary of * property IDs and property names. */ if (id == 0) { throw new UnsupportedEncodingException("Dictionary not allowed here"); } type = leis.readUInt(); try { value = VariantSupport.read(leis, length, (int) type, codepage); } catch (UnsupportedVariantTypeException ex) { VariantSupport.writeUnsupportedTypeMessage(ex); value = ex.getValue(); } }
void read( LittleEndianByteArrayInputStream lei ) { _type = lei.readInt(); long numDimensionsUnsigned = lei.readUInt(); if ( !( 1 <= numDimensionsUnsigned && numDimensionsUnsigned <= 31 ) ) { String msg = "Array dimension number "+numDimensionsUnsigned+" is not in [1; 31] range"; throw new IllegalPropertySetDataException(msg); } int numDimensions = (int) numDimensionsUnsigned; _dimensions = new ArrayDimension[numDimensions]; for ( int i = 0; i < numDimensions; i++ ) { ArrayDimension ad = new ArrayDimension(); ad.read(lei); _dimensions[i] = ad; } }
case Variant.VT_UI4: case Variant.VT_ERROR: _value = lei.readUInt(); break;