Search in sources :

Example 1 with TNEFDateAttribute

use of org.apache.poi.hmef.attribute.TNEFDateAttribute 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();
        }
    }
}
Also used : TNEFAttribute(org.apache.poi.hmef.attribute.TNEFAttribute) MAPIAttribute(org.apache.poi.hmef.attribute.MAPIAttribute) TNEFStringAttribute(org.apache.poi.hmef.attribute.TNEFStringAttribute) TNEFDateAttribute(org.apache.poi.hmef.attribute.TNEFDateAttribute)

Aggregations

MAPIAttribute (org.apache.poi.hmef.attribute.MAPIAttribute)1 TNEFAttribute (org.apache.poi.hmef.attribute.TNEFAttribute)1 TNEFDateAttribute (org.apache.poi.hmef.attribute.TNEFDateAttribute)1 TNEFStringAttribute (org.apache.poi.hmef.attribute.TNEFStringAttribute)1