MCPcopy Create free account
hub / github.com/M66B/FairEmail / getHeader

Method getHeader

app/src/main/java/com/sun/mail/imap/IMAPMessage.java:935–985  ·  view source on GitHub ↗

Get the named header.

(String name)

Source from the content-addressed store, hash-verified

933 * Get the named header.
934 */
935 @Override
936 public String[] getHeader(String name) throws MessagingException {
937 checkExpunged();
938
939 if (isHeaderLoaded(name)) // already loaded ?
940 return headers.getHeader(name);
941
942 // Load this particular header
943 InputStream is = null;
944
945 // Acquire MessageCacheLock, to freeze seqnum.
946 synchronized(getMessageCacheLock()) {
947 try {
948 IMAPProtocol p = getProtocol();
949
950 // This message could be expunged when we were waiting
951 // to acquire the lock ...
952 checkExpunged();
953
954 if (p.isREV1()) {
955 BODY b = p.peekBody(getSequenceNumber(),
956 toSection("HEADER.FIELDS (" + name + ")")
957 );
958 if (b != null)
959 is = b.getByteArrayInputStream();
960 } else {
961 RFC822DATA rd = p.fetchRFC822(getSequenceNumber(),
962 "HEADER.LINES (" + name + ")");
963 if (rd != null)
964 is = rd.getByteArrayInputStream();
965 }
966 } catch (ConnectionException cex) {
967 throw new FolderClosedException(folder, cex.getMessage());
968 } catch (ProtocolException pex) {
969 forceCheckExpunged();
970 throw new MessagingException(pex.getMessage(), pex);
971 }
972 }
973
974 // if we get this far without "is" being set, something has gone
975 // wrong; prevent a later NullPointerException and return null here
976 if (is == null)
977 return null;
978
979 if (headers == null)
980 headers = new InternetHeaders();
981 headers.load(is, allowutf8); // load this header into the Headers object.
982 setHeaderLoaded(name); // Mark this header as loaded
983
984 return headers.getHeader(name);
985 }
986
987 /**
988 * Get the named header.

Callers 1

getContentTypeMethod · 0.95

Calls 15

checkExpungedMethod · 0.95
isHeaderLoadedMethod · 0.95
getMessageCacheLockMethod · 0.95
getProtocolMethod · 0.95
isREV1Method · 0.95
peekBodyMethod · 0.95
getSequenceNumberMethod · 0.95
toSectionMethod · 0.95
fetchRFC822Method · 0.95
forceCheckExpungedMethod · 0.95

Tested by

no test coverage detected