📄 pop3message.java
字号:
try {
synchronized (this) {
return folder.getProtocol().top(msgnum, n);
}
} catch (EOFException eex) {
folder.close(false);
throw new FolderClosedException(folder, eex.toString());
} catch (IOException ex) {
throw new MessagingException("error getting size", ex);
}
}
/**
* Get all the headers for this header_name. Note that certain
* headers may be encoded as per RFC 2047 if they contain
* non US-ASCII characters and these should be decoded. <p>
*
* @param name name of header
* @return array of headers
* @exception MessagingException
* @see javax.mail.internet.MimeUtility
*/
public String[] getHeader(String name)
throws MessagingException {
if (headers == null)
loadHeaders();
return headers.getHeader(name);
}
/**
* Get all the headers for this header name, returned as a single
* String, with headers separated by the delimiter. If the
* delimiter is <code>null</code>, only the first header is
* returned.
*
* @param name the name of this header
* @param delimiter delimiter between returned headers
* @return the value fields for all headers with
* this name
* @exception MessagingException
*/
public String getHeader(String name, String delimiter)
throws MessagingException {
if (headers == null)
loadHeaders();
return headers.getHeader(name, delimiter);
}
/**
* Set the value for this header_name. Throws IllegalWriteException
* because POP3 messages are read-only.
*
* @param name header name
* @param value header value
* @see javax.mail.internet.MimeUtility
* @exception IllegalWriteException because the underlying
* implementation does not support modification
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
*/
public void setHeader(String name, String value)
throws MessagingException {
// XXX - should check for read-only folder?
throw new IllegalWriteException("POP3 messages are read-only");
}
/**
* Add this value to the existing values for this header_name.
* Throws IllegalWriteException because POP3 messages are read-only.
*
* @param name header name
* @param value header value
* @see javax.mail.internet.MimeUtility
* @exception IllegalWriteException because the underlying
* implementation does not support modification
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
*/
public void addHeader(String name, String value)
throws MessagingException {
// XXX - should check for read-only folder?
throw new IllegalWriteException("POP3 messages are read-only");
}
/**
* Remove all headers with this name.
* Throws IllegalWriteException because POP3 messages are read-only.
*
* @exception IllegalWriteException because the underlying
* implementation does not support modification
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
*/
public void removeHeader(String name)
throws MessagingException {
// XXX - should check for read-only folder?
throw new IllegalWriteException("POP3 messages are read-only");
}
/**
* Return all the headers from this Message as an enumeration
* of Header objects. <p>
*
* Note that certain headers may be encoded as per RFC 2047
* if they contain non US-ASCII characters and these should
* be decoded. <p>
*
* @return array of header objects
* @exception MessagingException
* @see javax.mail.internet.MimeUtility
*/
public Enumeration getAllHeaders() throws MessagingException {
if (headers == null)
loadHeaders();
return headers.getAllHeaders();
}
/**
* Return matching headers from this Message as an Enumeration of
* Header objects.
*
* @exception MessagingException
*/
public Enumeration getMatchingHeaders(String[] names)
throws MessagingException {
if (headers == null)
loadHeaders();
return headers.getMatchingHeaders(names);
}
/**
* Return non-matching headers from this Message as an
* Enumeration of Header objects.
*
* @exception MessagingException
*/
public Enumeration getNonMatchingHeaders(String[] names)
throws MessagingException {
if (headers == null)
loadHeaders();
return headers.getNonMatchingHeaders(names);
}
/**
* Add a raw RFC822 header-line.
* Throws IllegalWriteException because POP3 messages are read-only.
*
* @exception IllegalWriteException because the underlying
* implementation does not support modification
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
*/
public void addHeaderLine(String line) throws MessagingException {
// XXX - should check for read-only folder?
throw new IllegalWriteException("POP3 messages are read-only");
}
/**
* Get all header lines as an Enumeration of Strings. A Header
* line is a raw RFC822 header-line, containing both the "name"
* and "value" field.
*
* @exception MessagingException
*/
public Enumeration getAllHeaderLines() throws MessagingException {
if (headers == null)
loadHeaders();
return headers.getAllHeaderLines();
}
/**
* Get matching header lines as an Enumeration of Strings.
* A Header line is a raw RFC822 header-line, containing both
* the "name" and "value" field.
*
* @exception MessagingException
*/
public Enumeration getMatchingHeaderLines(String[] names)
throws MessagingException {
if (headers == null)
loadHeaders();
return headers.getMatchingHeaderLines(names);
}
/**
* Get non-matching header lines as an Enumeration of Strings.
* A Header line is a raw RFC822 header-line, containing both
* the "name" and "value" field.
*
* @exception MessagingException
*/
public Enumeration getNonMatchingHeaderLines(String[] names)
throws MessagingException {
if (headers == null)
loadHeaders();
return headers.getNonMatchingHeaderLines(names);
}
/**
* POP3 message can't be changed. This method throws
* IllegalWriteException.
*
* @exception IllegalWriteException because the underlying
* implementation does not support modification
*/
public void saveChanges() throws MessagingException {
// POP3 Messages are read-only
throw new IllegalWriteException("POP3 messages are read-only");
}
/**
* Load the headers for this message into the InternetHeaders object.
* The headers are fetched using the POP3 TOP command.
*/
private void loadHeaders() throws MessagingException {
try {
synchronized (this) {
if (headers != null) // check again under lock
return;
InputStream hdrs = null;
if (((POP3Store)(folder.getStore())).disableTop ||
(hdrs = folder.getProtocol().top(msgnum, 0)) == null) {
// possibly because the TOP command isn't supported,
// load headers as a side effect of loading the entire
// content.
InputStream cs = getContentStream();
cs.close();
} else {
hdrSize = hdrs.available();
headers = new InternetHeaders(hdrs);
}
}
} catch (EOFException eex) {
folder.close(false);
throw new FolderClosedException(folder, eex.toString());
} catch (IOException ex) {
throw new MessagingException("error loading POP3 headers", ex);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -