⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mockmimemessage.java

📁 java mail,java mailjava mailjava mailjava mail
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public String getFileName() throws MessagingException {        return m_fileName;    }    public void setFileName(String fileName) throws MessagingException {        m_fileName = fileName;    }    public InputStream getInputStream() throws IOException, MessagingException {        return null; // trivial implementation    }    protected InputStream getContentStream() throws MessagingException {        return null; // trivial implementation    }    public InputStream getRawInputStream() throws MessagingException {        return null; // trivial implementation    }    public synchronized DataHandler getDataHandler() throws MessagingException {        return m_dataHandler;    }    public synchronized void setDataHandler(DataHandler dataHandler) throws MessagingException {        m_dataHandler = dataHandler;    }    public Object getContent() throws IOException, MessagingException {        return m_content;    }    public void setContent(Object object, String mimeType) throws MessagingException {        m_content = object;  // trivial implementation    }    public void setText(String string) throws MessagingException {        setContent(string, "text/plain");    }    public void setText(String string, String charset) throws MessagingException {        try {            setContent(new String(string.getBytes(charset)) , "text/plain");        } catch (UnsupportedEncodingException e) {            throw new MessagingException("setting text content failed", e);        }    }    public void setContent(Multipart multipart) throws MessagingException {        m_content = multipart;    }    public Message reply(boolean b) throws MessagingException {        return new MockMimeMessage(this); // trivial implementation    }    public void writeTo(OutputStream outputStream) throws IOException, MessagingException {        ; // trivial implementation    }    public void writeTo(OutputStream outputStream, String[] strings) throws IOException, MessagingException {        ; // trivial implementation    }    public String[] getHeader(String name) throws MessagingException {        String value = (String) m_contentHeaders.get(name);        if (value == null) return null;        return new String[] {value};    }    public String getHeader(String name, String delimiter) throws MessagingException {        String[] header = getHeader(name);        if (header == null || header.length == 0) return null;        return header[0];    }    public void setHeader(String name, String value) throws MessagingException {        addHeader(name, value);    }    public void addHeader(String name, String value) throws MessagingException {        m_contentHeaders.put(name, value);    }    public void removeHeader(String name) throws MessagingException {        m_contentHeaders.remove(name);    }    public Enumeration getAllHeaders() throws MessagingException {        return Collections.enumeration(m_contentHeaders.values());    }    public Enumeration getMatchingHeaders(String[] names) throws MessagingException {        ArrayList matchingHeaders = new ArrayList();        for (int i = 0; i < names.length; i++) {            String name = names[i];            String value = getHeader(name, null);            if (value == null) continue;            matchingHeaders.add(value);        }        return Collections.enumeration(matchingHeaders);     }    public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException {        List existingHeaders = Arrays.asList(names);        ArrayList nonMatchingHeaders = new ArrayList();                Iterator iterator = m_contentHeaders.keySet().iterator();        while (iterator.hasNext()) {            String name = (String) iterator.next();            if (existingHeaders.contains(name)) continue;            String value = getHeader(name, null);            if (value == null) continue;            nonMatchingHeaders.add(value);        }        return Collections.enumeration(nonMatchingHeaders);     }    public void addHeaderLine(String headerLine) throws MessagingException {        int separatorIndex = headerLine.indexOf(":");        if (separatorIndex < 0) throw new MessagingException("header line does not conform to standard");                addHeader(headerLine.substring(0,separatorIndex), headerLine.substring(separatorIndex,headerLine.length()));    }    public Enumeration getAllHeaderLines() throws MessagingException {        return Collections.enumeration(getHeadersAsStrings(m_contentHeaders));    }    private ArrayList getHeadersAsStrings(HashMap contentHeaders) {        ArrayList headerLines = new ArrayList();        Iterator iterator = contentHeaders.keySet().iterator();        while (iterator.hasNext()) {            String key = (String) iterator.next();            String value = (String) contentHeaders.get(key);            headerLines.add(key + ":" + value);        }        return headerLines;    }    public Enumeration getMatchingHeaderLines(String[] names) throws MessagingException {        ArrayList matchingHeaders = new ArrayList();        for (int i = 0; i < names.length; i++) {            String name = names[i];            String value = getHeader(name, null);            if (value == null) continue;            matchingHeaders.add(name + ":" + value);        }        return Collections.enumeration(matchingHeaders);     }    public Enumeration getNonMatchingHeaderLines(String[] names) throws MessagingException {        List existingHeaders = names != null ? Arrays.asList(names) : null;        ArrayList nonMatchingHeaders = new ArrayList();                Iterator iterator = m_contentHeaders.keySet().iterator();        while (iterator.hasNext()) {            String name = (String) iterator.next();            if (existingHeaders!=null && existingHeaders.contains(name)) continue;            String value = getHeader(name, null);            if (value == null) continue;            nonMatchingHeaders.add(name + ":" + value);        }        return Collections.enumeration(nonMatchingHeaders);     }    public synchronized Flags getFlags() throws MessagingException {        return new Flags(m_setFlags);    }    public synchronized boolean isSet(Flags.Flag flag) throws MessagingException {        return m_setFlags.contains(flag);    }    public synchronized void setFlags(Flags flags, boolean set) throws MessagingException {        if (set) m_setFlags.add(flags);        else m_setFlags.remove(flags);    }    public void saveChanges() throws MessagingException {        ; // trivial implementation    }    protected void updateHeaders() throws MessagingException {        ; // trivial implementation     }    protected InternetHeaders createInternetHeaders(InputStream inputStream) throws MessagingException {        return new InternetHeaders();    }    public void setRecipient(Message.RecipientType recipientType, Address address) throws MessagingException {        setRecipients(recipientType, new Address[]{address});    }    public void addRecipient(Message.RecipientType recipientType, Address address) throws MessagingException {        setRecipients(recipientType, new Address[]{address});    }    public void setFlag(Flags.Flag flag, boolean set) throws MessagingException {        if (set) m_setFlags.add(flag);        else m_setFlags.remove(flag);    }    public int getMessageNumber() {        return m_iMessageNumber;    }    protected void setMessageNumber(int i) {        m_iMessageNumber = i;    }    public Folder getFolder() {        return null;    }    public boolean isExpunged() {        return m_bIsExpunged;    }    protected void setExpunged(boolean b) {        m_bIsExpunged = b;    }    public void setShouldMatch(boolean doMatch) {        m_doMatch = doMatch;    }        public boolean match(SearchTerm searchTerm) throws MessagingException {        return m_doMatch;     }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -