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; }
r.displayName = (chunks.recipientDisplayNameChunk != null) ? chunks.recipientDisplayNameChunk.toString() : null; r.name = (chunks.recipientNameChunk != null) ? chunks.recipientNameChunk.toString() : null; r.emailAddress = chunks.getRecipientEmailAddress(); List<PropertyValue> vals = chunks.getProperties().get(MAPIProperty.RECIPIENT_TYPE);
/** * Sets the Encoding that will be used to decode any "7 bit" (non unicode) * data. This doesn't appear to be stored anywhere specific in the file, so * you may need to guess by looking at headers etc */ public void set7BitEncoding(String encoding) { this.encoding7Bit = encoding; // Re-read the String if we're a 7 bit one if (getType() == Types.ASCII_STRING) { parseString(); } }
private void parseString() { String tmpValue; if (getType() == Types.ASCII_STRING) { tmpValue = parseAs7BitData(rawValue, encoding7Bit); } else if (getType() == Types.UNICODE_STRING) { tmpValue = StringUtil.getFromUnicodeLE(rawValue); } else { throw new IllegalArgumentException("Invalid type " + getType() + " for String Chunk"); } // Clean up this.value = tmpValue.replace("\0", ""); }
data = ((ByteChunk) htmlChunk).getValue(); } else if (htmlChunk instanceof StringChunk) { data = ((StringChunk) htmlChunk).getRawValue(); xhtml.element("p", ((StringChunk) textChunk).getValue());
public class MessageReader { private static final int SUBJECT_CHUNK = 0x0037; private static final int BILLING_INFORMATION_CHUNK = 0x800A; public static void main(String[] argv) { try { MAPIMessage mapiMessage = new MAPIMessage("MessageWithBillingInformation.msg"); System.out.println(mapiMessage.getStringFromChunk(new StringChunk(SUBJECT_CHUNK, true))); System.out.println(mapiMessage.getStringFromChunk(new StringChunk(BILLING_INFORMATION_CHUNK, true))); } catch (IOException e) { e.printStackTrace(); } catch (ChunkNotFoundException e) { e.printStackTrace(); } }
/** * Returns the data, formatted as a string assuming it was a non-unicode * string. If your data isn't in fact stored as basically ASCII, don't * expect this to return much of any sense.... * * @return the data formatted as a string */ public String getAs7bitString() { return StringChunk.parseAs7BitData(value); } }
/** * Sets the Encoding that will be used to * decode any "7 bit" (non unicode) data. * This doesn't appear to be stored anywhere * specific in the file, so you may need * to guess by looking at headers etc */ public void set7BitEncoding(String encoding) { this.encoding7Bit = encoding; // Re-read the String if we're a 7 bit one if(type == Types.ASCII_STRING) { parseString(); } }
private void storeString() { if (getType() == Types.ASCII_STRING) { rawValue = value.getBytes(Charset.forName(encoding7Bit)); } else if (getType() == Types.UNICODE_STRING) { rawValue = StringUtil.getToUnicodeLE(value); } else { throw new IllegalArgumentException("Invalid type " + getType() + " for String Chunk"); } }
public void setValue(String str) { this.value = str; storeString(); }
for(Chunk c : mainChunks.getAll()) { if(c instanceof StringChunk) { ((StringChunk)c).set7BitEncoding(charset); for(Chunk c : nameIdChunks.getAll()) { if(c instanceof StringChunk) { ((StringChunk)c).set7BitEncoding(charset); for(Chunk c : rc.getAll()) { if(c instanceof StringChunk) { ((StringChunk)c).set7BitEncoding(charset);
data = ((ByteChunk) htmlChunk).getValue(); } else if (htmlChunk instanceof StringChunk) { data = ((StringChunk) htmlChunk).getRawValue(); xhtml.element("p", ((StringChunk) textChunk).getValue());
case Types.ASCII_STRING: case Types.UNICODE_STRING: chunk = new StringChunk(namePrefix, chunkId, type); break;
/** * Parses as non-unicode, supposedly 7 bit CP1252 data and returns the * string that that yields. */ protected static String parseAs7BitData(byte[] data) { return parseAs7BitData(data, DEFAULT_ENCODING); }
@Override public void readValue(InputStream value) throws IOException { rawValue = IOUtils.toByteArray(value); parseString(); }
for(Chunk c : mainChunks.getAll()) { if(c instanceof StringChunk) { if( ((StringChunk)c).getType() == Types.ASCII_STRING ) { return true; for(Chunk c : nameIdChunks.getAll()) { if(c instanceof StringChunk) { if( ((StringChunk)c).getType() == Types.ASCII_STRING ) { return true; for(Chunk c : rc.getAll()) { if(c instanceof StringChunk) { if( ((StringChunk)c).getType() == Types.ASCII_STRING ) { return true;
public void setValue(String str) { this.value = str; storeString(); }
for(Chunk c : mainChunks.getChunks()) { if(c instanceof StringChunk) { ((StringChunk)c).set7BitEncoding(charset); for(Chunk c : nameIdChunks.getChunks()) { if(c instanceof StringChunk) { ((StringChunk)c).set7BitEncoding(charset); for(Chunk c : rc.getAll()) { if(c instanceof StringChunk) { ((StringChunk)c).set7BitEncoding(charset);