Regalamiunsorriso/rus/WEB-INF/lib/javax.mail_src/javax/mail/MessageContext.java

39 lines
794 B
Java
Raw Normal View History

2026-03-14 20:04:39 +01:00
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;
}
}