private byte[] getValue(Chunk chunk) { byte[] data = null; if (chunk instanceof ByteChunk) { data = ((ByteChunk) chunk).getValue(); } else if (chunk instanceof StringChunk) { data = ((StringChunk) chunk).getRawValue(); } return data; }
/** * Returns the data in a debug-friendly string format */ @Override public String toString() { return toDebugFriendlyString(value); }
/** * Gets the html body of this Outlook Message, if this email * contains a html version. * @return The string representation of the 'html' version of the body, if available. * @throws ChunkNotFoundException */ public String getHtmlBody() throws ChunkNotFoundException { if(mainChunks.htmlBodyChunkBinary != null) { return mainChunks.htmlBodyChunkBinary.getAs7bitString(); } return getStringFromChunk(mainChunks.htmlBodyChunkString); } @Deprecated
chunk = new ByteChunk(namePrefix, chunkId, type); break; case Types.DIRECTORY:
String search = recipientSearchChunk.getAs7bitString(); if(search.indexOf("SMTP:") != -1) { return search.substring(search.indexOf("SMTP:") + 5);
chunk = new ByteChunk(namePrefix, chunkId, type);
byte[] data = null; if (htmlChunk instanceof ByteChunk) { data = ((ByteChunk) htmlChunk).getValue(); } else if (htmlChunk instanceof StringChunk) { data = ((StringChunk) htmlChunk).getRawValue(); if (chunk.getValue() != null && chunk.getValue().length > 0) { MAPIRtfAttribute rtf = new MAPIRtfAttribute( MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue() ); Parser rtfParser =
String search = recipientSearchChunk.getAs7bitString(); int idx = search.indexOf("SMTP:"); if (idx >= 0) {
@Override public String toString() { Object v = getValue(); if (v == null) { return "(No value available)"; } if (v instanceof byte[]) { return ByteChunk.toDebugFriendlyString((byte[]) v); } else { // Just use the normal toString on the value return v.toString(); } }
/** * Returns the embedded object, if the attachment is an object based * embedding (image, document etc), or null if it's an embedded message */ public byte[] getEmbeddedAttachmentObject() { if (attachData != null) { return attachData.getValue(); } return null; }
/** * Gets the html body of this Outlook Message, if this email * contains a html version. * @return The string representation of the 'html' version of the body, if available. * @throws ChunkNotFoundException If the html-body chunk does not exist and * returnNullOnMissingChunk is set */ public String getHtmlBody() throws ChunkNotFoundException { if(mainChunks.getHtmlBodyChunkBinary() != null) { return mainChunks.getHtmlBodyChunkBinary().getAs7bitString(); } return getStringFromChunk(mainChunks.getHtmlBodyChunkString()); }
TikaInputStream.get(attachment.getAttachData().getValue()), filename, null, null, xhtml, true
private byte[] getValue(Chunk chunk) { byte[] data = null; if (chunk instanceof ByteChunk) { data = ((ByteChunk) chunk).getValue(); } else if (chunk instanceof StringChunk) { data = ((StringChunk) chunk).getRawValue(); } return data; }
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 */ public String getRtfBody() throws ChunkNotFoundException { ByteChunk chunk = mainChunks.rtfBodyChunk; if(chunk == null) { if(returnNullOnMissingChunk) { return null; } else { throw new ChunkNotFoundException(); } } try { MAPIRtfAttribute rtf = new MAPIRtfAttribute( MAPIProperty.RTF_COMPRESSED, Types.BINARY, chunk.getValue() ); return rtf.getDataString(); } catch(IOException e) { throw new RuntimeException("Shouldn't happen", e); } }
/** * Processes a single attachment: reads it from the Outlook MSG file and * writes it to disk as an individual file. * * @param attachment the chunk group describing the attachment * @param dir the directory in which to write the attachment file * @throws IOException when any of the file operations fails */ public void processAttachment(AttachmentChunks attachment, File dir) throws IOException { String fileName = attachment.getAttachFileName().toString(); if(attachment.getAttachLongFileName() != null) { fileName = attachment.getAttachLongFileName().toString(); } File f = new File(dir, fileName); OutputStream fileOut = null; try { fileOut = new FileOutputStream(f); fileOut.write(attachment.getAttachData().getValue()); } finally { if(fileOut != null) { fileOut.close(); } } }
for(AttachmentChunks attachment : msg.getAttachmentFiles()) { if(attachment.attachData != null) { byte[] data = attachment.attachData.getValue(); nonPOIFS.add( new ByteArrayInputStream(data) ); } else if(attachment.attachmentDirectory != null) {
/** * 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); } }
for (AttachmentChunks attachment : msg.getAttachmentFiles()) { if (attachment.getAttachData() != null) { byte[] data = attachment.getAttachData().getValue(); nonPOIFS.add( new ByteArrayInputStream(data) ); } else if (attachment.getAttachmentDirectory() != null) {
byte[] data = null; if (htmlChunk instanceof ByteChunk) { data = ((ByteChunk) htmlChunk).getValue(); } else if (htmlChunk instanceof StringChunk) { data = ((StringChunk) htmlChunk).getRawValue(); if (chunk.getValue() != null && chunk.getValue().length > 0) { MAPIRtfAttribute rtf = new MAPIRtfAttribute( MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue() ); Parser rtfParser =