Methods Summary |
---|
public void | addHeaderField(java.lang.String name, java.lang.String val)Adds an arbitrary header key and value to this message's header.
header.append(name);
header.append(": ");
header.append(val);
header.append('\n");
|
public void | addReference(java.lang.String msgId)Adds a message-id to the list of messages that this message references (i.e. replies to)
if (references == null) {
references = new StringBuffer();
references.append("References: ");
}
references.append(msgId);
references.append("\t");
|
private void | flushSubjectCache()
simplifiedSubject = null;
|
public java.lang.String | getArticleId()
return articleId;
|
public int | getArticleNumber()
return articleNumber;
|
public java.lang.String | getDate()
return date;
|
public java.lang.String | getFrom()
return from;
|
public java.lang.String[] | getReferences()Returns the MessageId references as an array of Strings
if (references == null)
return new String[0];
ArrayList list = new ArrayList();
int terminator = references.toString().indexOf(':");
StringTokenizer st =
new StringTokenizer(references.substring(terminator), "\t");
while (st.hasMoreTokens()) {
list.add(st.nextToken());
}
return (String[]) list.toArray();
|
public java.lang.String | getSubject()
return subject;
|
public boolean | isDummy()
return (getSubject() == null);
|
public Threadable | makeDummy()
return (Threadable)new Article();
|
public java.lang.String | messageThreadId()
return articleId;
|
public java.lang.String[] | messageThreadReferences()
return getReferences();
|
public static void | printThread(org.apache.commons.net.nntp.Article article, int depth)Recursive method that traverses a pre-threaded graph (or tree)
of connected Article objects and prints them out.
for (int i = 0; i < depth; ++i)
System.out.print("==>");
System.out.println(article.getSubject() + "\t" + article.getFrom());
if (article.kid != null)
printThread(article.kid, depth + 1);
if (article.next != null)
printThread(article.next, depth);
|
public void | setArticleId(java.lang.String string)
articleId = string;
|
public void | setArticleNumber(int i)
articleNumber = i;
|
public void | setChild(Threadable child)
this.kid = (Article) child;
flushSubjectCache();
|
public void | setDate(java.lang.String string)
date = string;
|
public void | setFrom(java.lang.String string)
from = string;
|
public void | setNext(Threadable next)
this.next = (Article)next;
flushSubjectCache();
|
public void | setSubject(java.lang.String string)
subject = string;
|
public java.lang.String | simplifiedSubject()
if(simplifiedSubject == null)
simplifySubject();
return simplifiedSubject;
|
private void | simplifySubject()Attempts to parse the subject line for some typical reply signatures, and strip them out
int start = 0;
String subject = getSubject();
int len = subject.length();
boolean done = false;
while (!done) {
done = true;
// skip whitespace
// "Re: " breaks this
while (start < len && subject.charAt(start) == ' ") {
start++;
}
if (start < (len - 2)
&& (subject.charAt(start) == 'r" || subject.charAt(start) == 'R")
&& (subject.charAt(start + 1) == 'e" || subject.charAt(start + 1) == 'E")) {
if (subject.charAt(start + 2) == ':") {
start += 3; // Skip "Re:"
isReply = true;
done = false;
} else if (
start < (len - 2)
&&
(subject.charAt(start + 2) == '[" || subject.charAt(start + 2) == '(")) {
int i = start + 3;
while (i < len && subject.charAt(i) >= '0" && subject.charAt(i) <= '9")
i++;
if (i < (len - 1)
&& (subject.charAt(i) == ']" || subject.charAt(i) == ')")
&& subject.charAt(i + 1) == ':") {
start = i + 2;
isReply = true;
done = false;
}
}
}
if (simplifiedSubject == "(no subject)")
simplifiedSubject = "";
int end = len;
while (end > start && subject.charAt(end - 1) < ' ")
end--;
if (start == 0 && end == len)
simplifiedSubject = subject;
else
simplifiedSubject = subject.substring(start, end);
}
|
public boolean | subjectIsReply()
if(simplifiedSubject == null)
simplifySubject();
return isReply;
|