git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@606169 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_0_3_BETA1
@@ -36,6 +36,7 @@ | |||
<!-- Don't forget to update status.xml too! --> | |||
<release version="3.0.2-FINAL" date="2007-??-??"> | |||
<action dev="POI-DEVELOPERS" type="add">44055 - [PATCH] Support for getting the from field from HSMF messages</action> | |||
<action dev="POI-DEVELOPERS" type="add">43551 - [PATCH] Support for 1904 date windowing in HSSF (previously only supported 1900 date windowing)</action> | |||
<action dev="POI-DEVELOPERS" type="add">41064 - [PATCH] Support for String continue records</action> | |||
<action dev="POI-DEVELOPERS" type="add">27511 - [PATCH] Support for data validation, via DVRecord and DVALRecord</action> |
@@ -33,6 +33,7 @@ | |||
<!-- Don't forget to update changes.xml too! --> | |||
<changes> | |||
<release version="3.0.2-FINAL" date="2007-??-??"> | |||
<action dev="POI-DEVELOPERS" type="add">44055 - [PATCH] Support for getting the from field from HSMF messages</action> | |||
<action dev="POI-DEVELOPERS" type="add">43551 - [PATCH] Support for 1904 date windowing in HSSF (previously only supported 1900 date windowing)</action> | |||
<action dev="POI-DEVELOPERS" type="add">41064 - [PATCH] Support for String continue records</action> | |||
<action dev="POI-DEVELOPERS" type="add">27511 - [PATCH] Support for data validation, via DVRecord and DVALRecord</action> |
@@ -48,15 +48,24 @@ public class MAPIMessage { | |||
/** | |||
* Constructor for reading MSG Files. | |||
* Constructor for reading MSG Files from the file system. | |||
* @param filename | |||
* @throws IOException | |||
*/ | |||
public MAPIMessage(String filename) throws IOException { | |||
InputStream in = new FileInputStream(new File(filename)); | |||
this(new FileInputStream(new File(filename))); | |||
} | |||
/** | |||
* Constructor for reading MSG Files from an input stream. | |||
* @param in | |||
* @throws IOException | |||
*/ | |||
public MAPIMessage(InputStream in) throws IOException { | |||
this.fs = new POIFSFileSystem(in); | |||
chunkParser = new POIFSChunkParser(this.fs); | |||
} | |||
/** | |||
* Gets a string value based on the passed chunk. | |||
@@ -101,6 +110,16 @@ public class MAPIMessage { | |||
return getStringFromChunk(Chunks.getInstance().displayToChunk); | |||
} | |||
/** | |||
* Gets the display value of the "FROM" line of the outlook message | |||
* This is not the actual address that was sent from but the formated display of the user name. | |||
* @return | |||
* @throws ChunkNotFoundException | |||
*/ | |||
public String getDisplayFrom() throws ChunkNotFoundException { | |||
return getStringFromChunk(Chunks.getInstance().displayFromChunk); | |||
} | |||
/** | |||
* Gets the display value of the "TO" line of the outlook message | |||
* This is not the actual list of addresses/values that will be sent to if you click Reply in the email. |
@@ -29,6 +29,7 @@ public class Chunks { | |||
public StringChunk textBodyChunk = new StringChunk(0x1000); //BODY Chunk, for plain/text messages | |||
public StringChunk subjectChunk = new StringChunk(0x0037); //Subject link chunk, in plain/text | |||
public StringChunk displayToChunk = new StringChunk(0x0E04); //Value that is in the TO field (not actually the addresses as they are stored in recip directory nodes | |||
public StringChunk displayFromChunk = new StringChunk(0x0C1A); //Value that is in the FROM field | |||
public StringChunk displayCCChunk = new StringChunk(0x0E03); //value that shows in the CC field | |||
public StringChunk displayBCCChunk = new StringChunk(0x0E02); //Value that shows in the BCC field | |||
public StringChunk conversationTopic = new StringChunk(0x0070); //Sort of like the subject line, but without the RE: and FWD: parts. |
@@ -83,6 +83,21 @@ public class TestBlankFileRead extends TestCase { | |||
TestCase.assertEquals(obtained, expected); | |||
} | |||
/** | |||
* Test to see if we can read the FROM Chunk. | |||
* @throws ChunkNotFoundException | |||
* | |||
*/ | |||
public void testReadDisplayFrom() throws ChunkNotFoundException { | |||
try { | |||
mapiMessage.getDisplayFrom(); | |||
} catch(ChunkNotFoundException exp) { | |||
return; | |||
} | |||
TestCase.fail("Should have thrown a ChunkNotFoundException but didn't"); | |||
} | |||
/** | |||
* Test to see if we can read the CC Chunk. | |||
* @throws ChunkNotFoundException |
@@ -66,6 +66,18 @@ private MAPIMessage mapiMessage; | |||
TestCase.assertEquals(obtained, expected); | |||
} | |||
/** | |||
* Test to see if we can read the From Chunk. | |||
* @throws ChunkNotFoundException | |||
* | |||
*/ | |||
public void testReadDisplayFrom() throws ChunkNotFoundException { | |||
String obtained = mapiMessage.getDisplayFrom(); | |||
String expected = "Travis Ferguson"; | |||
TestCase.assertEquals(obtained, expected); | |||
} | |||
/** | |||
* Test to see if we can read the CC Chunk. | |||
* @throws ChunkNotFoundException |