|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgate.email.EmailDocumentHandler
This class implements the behaviour of the Email reader It takes the Gate Document representing a list with e-mails and creates Gate annotations on it.
Field Summary | |
private AnnotationSet |
basicAS
|
private String |
content
|
private Collection |
day
|
private static boolean |
DEBUG
Debug flag |
private long |
documentSize
|
private Map |
element2StringMap
|
private int |
emails
|
private static int |
EMAILS_RATE
|
private String |
fieldName
|
private Document |
gateDocument
|
private Map |
markupElementsMap
|
private Collection |
month
|
protected List |
myStatusListeners
|
private String |
tmpDocContent
|
private Collection |
zone
|
Constructor Summary | |
EmailDocumentHandler()
Constructor used in tests mostly |
|
EmailDocumentHandler(Document aGateDocument,
Map aMarkupElementsMap,
Map anElement2StringMap)
Constructor initialises some private fields |
Method Summary | |
void |
addStatusListener(StatusListener listener)
This methos is called when a listener is registered with this class |
void |
annotateMessages()
Reads the Gate Document line by line and does the folowing things: Each line is analized in order to detect where an e-mail starts. |
private boolean |
canCreateAnnotation(long start,
long end,
long gateDocumentSize)
This method verifies if an Annotation can be created. |
private boolean |
containsSemicolon(String aString)
This method checks if a String contains a semicolon char |
private boolean |
containsWhiteSpaces(String aString)
This method checks if a String contains white spaces. |
private void |
createAnnotation(String anAnnotationName,
long anAnnotationStart,
long anAnnotationEnd,
FeatureMap aFeatureMap)
This method creates a gate annotation given its name, start, end and feature map. |
private int |
detectNLSize()
This method detects if the text file which contains e-mail messages is under MSDOS or UNIX format. |
protected void |
fireStatusChangedEvent(String text)
This methos is called whenever we need to inform the listener about an event. |
private String |
getFieldName()
This method returns the value of the member fieldName. |
private boolean |
hasAMeaning(String aToken)
This method tests a token if is Day, Month, Zone, Time, Year |
private boolean |
isTime(String aToken)
Tests a token if is in time format HH:MM:SS |
private boolean |
lineBeginsMessage(String aTextLine)
Tests if the line begins an e-mail message |
private boolean |
lineBeginsWithField(String aTextLine)
Tests if the line begins with a field from the e-mail header If the answer is true then it also sets the member fieldName with the value of this e-mail header field. |
void |
removeStatusListener(StatusListener listener)
This methos is called when a listener is removed |
private void |
setUp()
Initialises the collections with data used by method lineBeginsMessage() |
private void |
testContainsSemicolon()
Test containsSemicolon |
private void |
testContainsWhiteSpaces()
Test containsWhiteSpaces |
private void |
testHasAMeaning()
Test hasAMeaning |
private void |
testIsTime()
Test isTime |
private void |
testLineBeginsMessage()
Test lineBeginsMessage |
private void |
testLineBeginsWithField()
Test lineBeginsWithField |
void |
testSelf()
Test final |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final boolean DEBUG
private String content
private long documentSize
private static final int EMAILS_RATE
private String tmpDocContent
private Document gateDocument
private AnnotationSet basicAS
private Map markupElementsMap
private Map element2StringMap
protected List myStatusListeners
private int emails
private String fieldName
private Collection day
private Collection month
private Collection zone
Constructor Detail |
public EmailDocumentHandler()
public EmailDocumentHandler(Document aGateDocument, Map aMarkupElementsMap, Map anElement2StringMap)
Method Detail |
public void annotateMessages() throws IOException, InvalidOffsetException
IOException
InvalidOffsetException
private int detectNLSize()
private void createAnnotation(String anAnnotationName, long anAnnotationStart, long anAnnotationEnd, FeatureMap aFeatureMap) throws InvalidOffsetException
InvalidOffsetException
private boolean canCreateAnnotation(long start, long end, long gateDocumentSize)
private boolean lineBeginsMessage(String aTextLine)
aTextLine
- a line from the file containing the e-mail messages
private boolean lineBeginsWithField(String aTextLine)
aTextLine
- a line from the file containing the e-mail text
private boolean containsWhiteSpaces(String aString)
private boolean containsSemicolon(String aString)
private boolean hasAMeaning(String aToken)
private boolean isTime(String aToken)
private void setUp()
private String getFieldName()
public void addStatusListener(StatusListener listener)
public void removeStatusListener(StatusListener listener)
protected void fireStatusChangedEvent(String text)
private void testContainsSemicolon()
private void testContainsWhiteSpaces()
private void testHasAMeaning()
private void testIsTime()
private void testLineBeginsMessage()
private void testLineBeginsWithField()
public void testSelf()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |