first commit
This commit is contained in:
commit
4d332ef662
27586 changed files with 3281783 additions and 0 deletions
|
|
@ -0,0 +1,39 @@
|
|||
package javax.mail;
|
||||
|
||||
public class MessageContext {
|
||||
private Part part;
|
||||
|
||||
public MessageContext(Part part) {
|
||||
this.part = part;
|
||||
}
|
||||
|
||||
public Part getPart() {
|
||||
return this.part;
|
||||
}
|
||||
|
||||
public Message getMessage() {
|
||||
try {
|
||||
return getMessage(this.part);
|
||||
} catch (MessagingException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Message getMessage(Part p) throws MessagingException {
|
||||
while (p != null) {
|
||||
if (p instanceof Message)
|
||||
return (Message)p;
|
||||
BodyPart bp = (BodyPart)p;
|
||||
Multipart mp = bp.getParent();
|
||||
if (mp == null)
|
||||
return null;
|
||||
p = mp.getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Session getSession() {
|
||||
Message msg = getMessage();
|
||||
return (msg != null) ? msg.getSession() : null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue