2011-10-22 02:07:18 +00:00
|
|
|
/* ====================================================================
|
|
|
|
|
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.
|
|
|
|
|
==================================================================== */
|
2011-10-21 23:45:01 +00:00
|
|
|
package org.apache.poi.hpsf;
|
|
|
|
|
|
|
|
|
|
import org.apache.poi.util.Internal;
|
2017-05-02 23:24:50 +00:00
|
|
|
import org.apache.poi.util.LittleEndianByteArrayInputStream;
|
2011-10-21 23:45:01 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Holder for vector-type properties
|
|
|
|
|
*/
|
|
|
|
|
@Internal
|
2017-05-02 23:24:50 +00:00
|
|
|
class Vector {
|
2011-10-21 23:45:01 +00:00
|
|
|
private final short _type;
|
|
|
|
|
|
|
|
|
|
private TypedPropertyValue[] _values;
|
|
|
|
|
|
2017-05-02 23:24:50 +00:00
|
|
|
Vector( short type ) {
|
2011-10-21 23:45:01 +00:00
|
|
|
this._type = type;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 23:24:50 +00:00
|
|
|
void read( LittleEndianByteArrayInputStream lei ) {
|
|
|
|
|
final long longLength = lei.readUInt();
|
2011-10-21 23:45:01 +00:00
|
|
|
|
2017-05-02 23:24:50 +00:00
|
|
|
if ( longLength > Integer.MAX_VALUE ) {
|
|
|
|
|
throw new UnsupportedOperationException( "Vector is too long -- " + longLength );
|
|
|
|
|
}
|
2011-10-21 23:45:01 +00:00
|
|
|
final int length = (int) longLength;
|
|
|
|
|
|
|
|
|
|
_values = new TypedPropertyValue[length];
|
|
|
|
|
|
2017-05-02 23:24:50 +00:00
|
|
|
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);
|
2011-10-21 23:45:01 +00:00
|
|
|
}
|
2017-05-02 23:24:50 +00:00
|
|
|
_values[i] = value;
|
2011-10-21 23:45:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-15 07:49:25 +00:00
|
|
|
TypedPropertyValue[] getValues(){
|
|
|
|
|
return _values;
|
|
|
|
|
}
|
2011-10-21 23:45:01 +00:00
|
|
|
}
|