public MAPIStringAttribute(MAPIProperty property, int type, byte[] data) { super(property, type, data); String tmpData = null; if(type == Types.ASCII_STRING.getId()) { tmpData = new String(data, Charset.forName(CODEPAGE)); } else if(type == Types.UNICODE_STRING.getId()) { tmpData = StringUtil.getFromUnicodeLE(data); } else { throw new IllegalArgumentException("Not a string type " + type); } // Strip off the null terminator if present if(tmpData.endsWith("\0")) { tmpData = tmpData.substring(0, tmpData.length()-1); } this.data = tmpData; }
public static MAPIType createCustom(int typeId) { // Check they're not being silly, and asking for a built-in one... if (getById(typeId) != null) { return getById(typeId); } // Try to get an existing definition of this MAPIType type = customTypes.get(typeId); // If none, do a thread-safe creation if (type == null) { synchronized (customTypes) { type = customTypes.get(typeId); if (type == null) { type = new MAPIType(typeId, -1); } } } return type; } }
/** * Creates a string to use to identify this chunk in the POI file system * object. */ public String getEntryName() { String type = this.type.asFileEnding(); String chunkId = Integer.toHexString(this.chunkId); while (chunkId.length() < 4) { chunkId = "0" + chunkId; } return this.namePrefix + chunkId.toUpperCase(Locale.ROOT) + type.toUpperCase(Locale.ROOT); }
ByteChunk chunk = (ByteChunk) rtfChunk; MAPIRtfAttribute rtf = new MAPIRtfAttribute( MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue() ); RTFParser rtfParser = new RTFParser();
MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue() ); Parser rtfParser =
int length = type.getLength(); if (!type.isFixedLength()) { isPointer = true; length = 8;
MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue() ); Parser rtfParser =
" " + idName + " - " + chunk.getType().getName() ); out.println(
ByteChunk chunk = (ByteChunk) rtfChunk; MAPIRtfAttribute rtf = new MAPIRtfAttribute( MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue() );
/** * Gets the RTF Rich Message body of this Outlook Message, if this email * contains a RTF (rich) version. * @return The string representation of the 'RTF' version of the body, if available. * @throws ChunkNotFoundException If the rtf-body chunk does not exist and * returnNullOnMissingChunk is set */ public String getRtfBody() throws ChunkNotFoundException { ByteChunk chunk = mainChunks.getRtfBodyChunk(); if(chunk == null) { if(returnNullOnMissingChunk) { return null; } else { throw new ChunkNotFoundException(); } } try { MAPIRtfAttribute rtf = new MAPIRtfAttribute( MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue() ); return rtf.getDataString(); } catch(IOException e) { throw new RuntimeException("Shouldn't happen", e); } }
/** * Creates all the chunks for a given Directory, but * doesn't recurse or descend */ protected static void processChunks(DirectoryNode node, ChunkGroup grouping) { for(Entry entry : node) { if(entry instanceof DocumentNode) { process(entry, grouping); } else if(entry instanceof DirectoryNode) { if(entry.getName().endsWith(Types.DIRECTORY.asFileEnding())) { process(entry, grouping); } } } }
private static int getLength(MAPIType type, InputStream inp) throws IOException { if (type.isFixedLength()) { return type.getLength(); } if (type == Types.ASCII_STRING || type == Types.UNICODE_STRING || type == Types.DIRECTORY || type == Types.BINARY) { // Need to read the length, as it varies return LittleEndian.readInt(inp); } else { throw new IllegalArgumentException("Unknown type " + type); } } private static void skipToBoundary(int length, InputStream inp) throws IOException {
private void list(ArrayList<MAPIProperty> list, PrintStream out) { for(MAPIProperty attr : list) { String id = Integer.toHexString(attr.id); while(id.length() < 4) { id = "0"+id; } int typeId = attr.usualType.getId(); String typeIdStr = Integer.toString(typeId); if (typeId > 0) { typeIdStr = typeIdStr + " / 0x" + Integer.toHexString(typeId); } out.println("0x" + id + " - " + attr.name); out.println(" " + attr.id + " - " + attr.usualType.getName() + " (" + typeIdStr + ") - " + attr.mapiProperty); } }
@Override public String toString() { return id + " / 0x" + asFileEnding() + " - " + name + " @ " + length; }
public String asFileName() { String str = Integer.toHexString(id).toUpperCase(Locale.ROOT); while (str.length() < 4) { str = "0" + str; } return str + usualType.asFileEnding(); }
private String getFileName(MAPIProperty property, MAPIType actualType) { String str = Integer.toHexString(property.id).toUpperCase(Locale.ROOT); while (str.length() < 4) { str = "0" + str; } MAPIType type = getTypeMapping(actualType); return str + type.asFileEnding(); }
MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue() ); Parser rtfParser =
ByteChunk chunk = (ByteChunk) rtfChunk; MAPIRtfAttribute rtf = new MAPIRtfAttribute( MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue() );