in tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/onenote/OneNotePtr.java [1002:1148]
private PropertyValue deserializePropertyValueFromPropertyID(OneNotePropertyId propertyID,
ObjectSpaceObjectPropSet streams,
ObjectStreamCounters counters)
throws IOException, TikaException {
PropertyValue data = new PropertyValue();
data.propertyId = propertyID;
char val8;
long val16;
long val32 = 0;
long val64;
if (LOG.isDebugEnabled()) {
LOG.debug("\n{}<{}", getIndent(), propertyID);
}
++indentLevel;
try {
long type = propertyID.type;
switch ((int) type) {
case 0x1:
LOG.debug(" [] ");
return data;
case 0x2:
LOG.debug(" PropertyID bool({})", propertyID.inlineBool);
data.scalar = propertyID.inlineBool ? 1 : 0;
return data;
case 0x3:
val8 = deserializeLittleEndianChar();
data.scalar = val8;
LOG.debug(" PropertyID byte({})", data.scalar);
break;
case 0x4:
val16 = deserializeLittleEndianShort();
data.scalar = val16;
LOG.debug(" uint16 PropertyID short({})", data.scalar);
break;
case 0x5:
val32 = deserializeLittleEndianInt();
data.scalar = val32;
LOG.debug(" PropertyID int({})", data.scalar);
break;
case 0x6:
val64 = deserializeLittleEndianLong();
data.scalar = val64;
LOG.debug(" PropertyID long({})", data.scalar);
break;
case 0x7:
// If the value of the PropertyID.type element is "0x7" and the property
// specifies an array of elements, the value of
// the
// prtFourBytesOfLengthFollowedByData.cb element MUST be the sum of the
// sizes, in bytes, of each element in the array.
// Exceptions include:
// * The RgOutlineIndentDistance element, where the value of the
// prtFourBytesOfLengthFollowedByData.cb element
// MUST be: 4 + (4 × RgOutlineIndentDistance.count).
// * The TableColumnsLocked element, where the value of the
// prtFourBytesOfLengthFollowedByData.cb
// element MUST be: 1 + (TableColumnsLocked.cColumns + 7) / 8.
// * The TableColumnWidths element, where the value of the
// prtFourBytesOfLengthFollowedByData.cb
// element MUST be: 1 + (4 × TableColumnWidths.cColumns).
val32 = deserializeLittleEndianInt();
LOG.debug(" raw data: ({})[", val32);
data.rawData.stp = offset;
data.rawData.cb = 0;
if (offset + val32 > end) {
data.rawData.cb = end - offset;
offset = end;
throw new TikaException("Offset is past end of file.");
}
data.rawData.cb = val32;
offset += val32;
if (LOG.isDebugEnabled()) {
OneNotePtr content = new OneNotePtr(this);
content.reposition(data.rawData);
content.dumpHex();
}
LOG.debug("]");
break;
case 0x9:
case 0xb:
case 0xd:
val32 = deserializeLittleEndianInt();
// fallthrough
case 0x8:
case 0xa:
case 0xc:
if (type == 0x8 || type == 0xa || type == 0xc) {
val32 = 1;
}
List<CompactID> stream = streams.contextIDs.data;
String xtype = "contextID";
long s_count = counters.context_ids_count;
if (type == 0x8 || type == 0x9) {
stream = streams.oids.data;
s_count = counters.oids_count;
xtype = "OIDs";
}
if (type == 0xa || type == 0xb) {
stream = streams.osids.data;
s_count = counters.osids_count;
xtype = "OSIDS";
}
for (int i = 0; i < val32; ++i, ++s_count) {
int index = (int) s_count;
if (index < stream.size()) {
data.compactIDs.add(stream.get(index));
LOG.debug(" {}[{}]", xtype,
data.compactIDs.get(data.compactIDs.size() - 1));
} else {
throw new TikaException("SEGV");
}
}
break;
case 0x10:
val32 = deserializeLittleEndianInt();
OneNotePropertyId propId = deserializePropertyID();
LOG.debug(" UnifiedSubPropertySet {} {}", val32, propId);
data.propertySet.rgPridsData =
Stream.generate(PropertyValue::new).limit((int) val32)
.collect(Collectors.toList());
for (int i = 0; i < val32; ++i) {
try {
data.propertySet.rgPridsData.set(i,
deserializePropertyValueFromPropertyID(propId, streams,
counters));
} catch (IOException e) {
return data;
}
}
break;
case 0x11:
LOG.debug(" SubPropertySet");
data.propertySet = deserializePropertySet(counters, streams);
break;
default:
throw new TikaException("Invalid type: " + type);
}
LOG.debug(">");
return data;
} finally {
--indentLevel;
}
}