use of org.apache.poi.hmef.attribute.TNEFStringAttribute in project poi by apache.
the class HMEFDumper method dump.
private void dump() throws IOException {
int level;
int attachments = 0;
while (true) {
// Fetch the level
level = inp.read();
if (level == TNEFProperty.LEVEL_END_OF_FILE) {
break;
}
// Build the attribute
TNEFAttribute attr = TNEFAttribute.create(inp);
// Is it a new attachment?
if (level == TNEFProperty.LEVEL_ATTACHMENT && attr.getProperty() == TNEFProperty.ID_ATTACHRENDERDATA) {
attachments++;
System.out.println();
System.out.println("Attachment # " + attachments);
System.out.println();
}
// Print the attribute into
System.out.println("Level " + level + " : Type " + attr.getType() + " : ID " + attr.getProperty());
// Print the contents
String indent = " ";
if (attr instanceof TNEFStringAttribute) {
System.out.println(indent + indent + indent + ((TNEFStringAttribute) attr).getString());
}
if (attr instanceof TNEFDateAttribute) {
System.out.println(indent + indent + indent + ((TNEFDateAttribute) attr).getDate());
}
System.out.println(indent + "Data of length " + attr.getData().length);
if (attr.getData().length > 0) {
int len = attr.getData().length;
if (truncatePropertyData) {
len = Math.min(attr.getData().length, 48);
}
int loops = len / 16;
if (loops == 0)
loops = 1;
for (int i = 0; i < loops; i++) {
int thisLen = 16;
int offset = i * 16;
if (i == loops - 1) {
thisLen = len - offset;
}
byte[] data = new byte[thisLen];
System.arraycopy(attr.getData(), offset, data, 0, thisLen);
System.out.print(indent + HexDump.dump(data, 0, 0));
}
}
System.out.println();
if (attr.getProperty() == TNEFProperty.ID_MAPIPROPERTIES || attr.getProperty() == TNEFProperty.ID_ATTACHMENT) {
List<MAPIAttribute> attrs = MAPIAttribute.create(attr);
for (MAPIAttribute ma : attrs) {
System.out.println(indent + indent + ma);
}
System.out.println();
}
}
}
Aggregations