亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? contentstorage.java

?? 手機(jī)郵箱撒的方式方式方式的
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*MujMail - Simple mail client for J2MECopyright (C) 2008 David Hauzar <david.hauzar.mujmail@gmail.com>This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, bufferContent to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */package mujmail;import mujmail.util.Decode;import mujmail.util.OutputBuffer;import mujmail.protocols.MailSender;import mujmail.connections.ConnectionInterface;import java.io.DataInputStream;import java.io.DataOutputStream;import mujmail.util.Functions;/** * Persistently stores the content of body part. Part of  * <code>BodyPart</code>. *   * It is possible to incrementally add the content to existing * content without keeping existent content in heap memory. This is  * important for example when reading the content from SMTP connection. *  * Provides methods for adding content to the storage, for * buffered adding content to the storage - this case the content * is stored when more content for storing is collected - as well * as methods for reading or deleting the content. * Than provides information about the content contained in this * storage.    *  * Object of this type is contained in object {@link BodyPart}. *  * This object is stored persistently in RMS database. It's loading * and saving does object of instance {@link BodyPart} that * contains this storage. *  * @author David Hauzar */public abstract class ContentStorage {    /** Flag signals if we want to print debug prints */    private static final boolean DEBUG = false;    public static final String SOURCE_FILE = "ContentStorage";    //private static final long MAX_SIZE_OF_BODYPART = Long.MAX_VALUE;    private long size = 0;    private BodyPart bodyPart;    private final BufferedContentAdder buffer = new BufferedContentAdder();        /**     *      * @param bodyPart the body part which content is stored in this storage     */    protected ContentStorage(BodyPart bodyPart){        this.bodyPart = bodyPart;    }        /**     * Gets the name of the bodypart which content this storage holds.     * @return the name of the bodypart that content this storage holds.     */    protected String getName() {        return bodyPart.getHeader().getName();    }    /**     *      * @param bodyPart the body part which content is stored in this storage     * @param size the size of the content stored in the storage     */    protected ContentStorage(BodyPart bodyPart, long size) {        this.bodyPart = bodyPart;        this.size = size;    }        /**     * It is important to lower the likelihood of throwing OutOfMemory exception     * while calling method addToContent or addToContentRaw. This means that     * allocating objects in these methods is undesirable. This method should     * preallocate objects needed in addToContent or addToContentRaw.     *      * It is ensured that this method will be called after saving the content      * to the storage and releasing the data kept in the buffer so it is     * unlikely to OutOfMemoryException to be thrown there.     */    protected abstract void preallocateToNextSaving();        /**     *      * @return true if the content is yet preallocated to next saving.     */    protected abstract boolean preallocatedToNextSaving();        /**     * Ensures that te objects are really preallocated before calling addToContent     * or addToContentRaw.     */    private void ensurePrealocating() {        if (!preallocatedToNextSaving()) {            preallocateToNextSaving();        }    }    /**     * Initialize class by copying another instance.     * If copyMode is DEEP_COPY copies the content.     * Note that if the mode is SHALLOW_COPY it the body part which content     * will is stored in this ContentStorage should be in the same box as original     * storage.     * @param bp the body part which content is stored in this storage     * @param copy AttachmentPart instance to copy     * @param copyMode defines copying mode     */    protected ContentStorage(BodyPart bodyPart, ContentStorage copy, CopyingModes copyMode) {        this.bodyPart = bodyPart;        if (copyMode == CopyingModes.NO_COPY) {            // the instance is yet created            return;        }        if (copyMode == CopyingModes.DEEP_COPY) {            addContent(copy, false);            return;        }    }        /**     * Creates new instance of storage of type identified with given     * number.     * @param storageTypeNumber the number which identify the storage type     *  of which we want to create an instance     * @return the storage of given type     */    public static ContentStorage createStorageInstance(BodyPart bodyPart, byte storageTypeNumber) {        //#ifdef MUJMAIL_FS        if (storageTypeNumber == StorageTypes.FS_STORAGE.getStorageTypeNumber()) {            return new FSStorage(bodyPart);        }        //#endif        if (storageTypeNumber == StorageTypes.RMS_STORAGE.getStorageTypeNumber()) {            return new RMSStorage(bodyPart);        }        throw new RuntimeException("not implemented storage type");    }    /**     * Gets the body part which content is stored in the storage.     * @return     */    protected BodyPart getBodyPart() { return bodyPart; }    /**     * Returns the storage type of given storage     * @return     */    public abstract StorageTypes getStorageType();    /**     * Returns new instance of storage which is copy of this instance     * of the storage.     * @return new instance of storage which is copy of this instance     */    public abstract ContentStorage copy(BodyPart bp, CopyingModes copyMode);    /**     * Checks whether it is allowed to make a copy of this instance with given     * copy mode.     * @param bp     * @param copyMode     */    protected boolean checkCopy(BodyPart bp, CopyingModes copyMode) {        if (copyMode == CopyingModes.SHALLOW_COPY && bp.getBox() != getBodyPart().getBox()) {            return false;        }        return true;    }    /**     * Loads information about this storage from input stream (of RMS database).     * Does not load the content of storage, loads only information about     * the storage.     * @param inputStream the input stream in which are stored information     *  about this storage.     * @throws java.lang.Exception can occur while reading inputStream     */    public void loadStorage(DataInputStream inputStream) throws Exception {        setSize( inputStream.readLong() );    }    /**     * Saves information about this storage to output stream (RMS database)     * Does not save the content of the storage, saves only information about     * this storage.     * @param outputStream the output stream to which the information about     *  this body part will be saved     * @throws java.lang.Exception can occur while writing to the outputStream     */    public void saveStorageHeader(DataOutputStream outputStream) throws Exception {        outputStream.writeLong(getSize());    }    /**     * Deletes the content of this bodypart.     */    public void deleteContent() {        setSize(0);        buffer.clearCache();        if (!bodyPart.convertedContentMode()) {             bodyPart.setBodyState(BodyPart.BS_EMPTY);        }                deleteContentFromStorage();    }        /**     * Deletes the content from storage. Called from method      * {@link #deleteContent()}}.     */    protected abstract void deleteContentFromStorage();    public void addContent(ContentStorage copy, boolean safeMode) {        // TODO: redefine this method in class RMS storage        // in case of RMS store it can be make too big records because         // getContent() or getContentRaw() returns not content from one record         // but from the maximum number of records that can be in RAM memory        try {            if (copy.isContentRaw()) {               addToContentEnsurePreallocating(copy.getContentRaw(), safeMode);               while (!copy.willReturnFirstContent()) {                   addToContentEnsurePreallocating(copy.getContentRaw(), safeMode);               }            } else {                addToContentEnsurePreallocating(copy.getContent(), safeMode);                while (!copy.willReturnFirstContent()) {                   addToContentEnsurePreallocating(copy.getContent(), safeMode);                }            }        } catch (Throwable e) {            getBodyPart().setBodyState(BodyPart.BS_EMPTY);            size = 0;            getBodyPart().getBox().report("+" + e.getMessage() + getBodyPart().getMessageHeader().getSubject(), SOURCE_FILE); //dont notice the user about the error        }    }        protected String conditionallyAppend(String appendTo, String append, boolean shouldAppend) {        if (shouldAppend) {            return appendTo + append;        } else {            return appendTo;        }    }        /**     * According to the encoding and charset of the bodypart that content this     * storage stores, decode given data.     * @param data the data to be decoded     * @return data decoded according to encoding and charset of the bodypart     *  that stores this storage.     * @throws mujmail.MyException     */    private String decodeNotRawBodypartData(String data) throws MyException {        if (bodyPart.getHeader().getEncoding() == BodyPart.ENC_BASE64) {            return Decode.decodeBase64(data, bodyPart.getHeader().getCharSet());        } else if (bodyPart.getHeader().getEncoding() == BodyPart.ENC_QUOTEDPRINTABLE) {            return Decode.decodeQuotedPrintable(data, bodyPart.getHeader().getCharSet());        } else if (bodyPart.getHeader().getEncoding() == BodyPart.ENC_8BIT || bodyPart.getHeader().getCharSet() != BodyPart.CH_NORMAL) { //8bit or not usascii            return Decode.decode8bitCharset(data, bodyPart.getHeader().getCharSet());        } else { // 7- bit charset 	            return data;        }    }        /**     * <p>     * Adds given string to the storage.     * Writes data not necessary immediately but only if bigger content for writing     * is collected.     * Note that it is necessary to call method {@link #flushBuffer()} to store data      * persistently before reading it.     * </p>     * <p>     * Stores it according to encoding of the body part which content this storage     * stores either as a raw data or as a text data.     * </p>     * @param bf the string which content store.     */    public void addToContentBuffered(String bf) throws Exception {        buffer.bufferContent(bf);    }        /**     * Adds given string to the storage.     * Writes immediately.     *      * Stores it according to encoding of the body part which content this storage     * stores either as a raw data or as a text data.     * @param bf the string which content store.     */    public void addToContent(String bf) throws Exception {        addToContentBuffered(bf);        flushBuffer();            }        /**     * Stores data written in a buffer persistently. The data can be stored in     * buffer when method addToContentBuffered is called.     * @throws java.lang.Exception     */    public void flushBuffer() throws Exception {        buffer.flush();    }    /**     * Returns true if the content stored in this storage is raw data.     * @return true if the content stored in this storage is raw data     */    public boolean isContentRaw() {        if (getBodyPart().convertedContentMode()) {            return true;        } else {            return (bodyPart.getHeader().getEncoding() == BodyPart.ENC_BASE64 &&                     bodyPart.getHeader().getCharSet() == BodyPart.CH_NORMAL) ?                         true :                         false;        }    }    /**     * Adds given string to the content of the bodypart.     * If passed content cannot be saved tries to shorten the content and     * save it partially.     *     * This method neither sets the size of the bodypart nor the state of the     * bodypart. This is done by methods inside class <code>ContentStorage<code/>     * that calls this method.     *      * This is a low-level method, saves bodypart always as a text data regardless     * of the body part header. More high level method is addToContent(String).     *     * Before calling this method, method {@link #ensurePrealocating} is always     * called.     *      * @param content the content of the bodypart     * @param safeMode if save mode is true, the content will be not saved     *  to new persistent storage, but to temporary one     * @return the size of content that was added to the content.     *  content.length if all the content was written.     */    protected abstract long addToContent(String content, boolean safeMode) throws Exception;    /**     * Checks whether the size of bydypart with added content would be less or     * equal than given limit.     * If the size of bodypart with added content and the bodypart is not      * partially savebale. If it is partially saveable, sets its state to      * <code>BodyPart.BS_PARTIAL</code>. Than, it throws and exception.     *     * @param sizeOfAdded the size of added content to bodypart     * @throws java.lang.Exception if the size of bodypart with added content     *  is bigger than the limit.     */    /*     * TODO: (David) this method is no more needed since the size of bodypart     * is now checked while downloading the mail.    private void checkSizeOfBodyPart(long sizeOfAdded) throws Exception {        if (getSize() + sizeOfAdded > MAX_SIZE_OF_BODYPART) {             if (!MessageHeader.canBePartiallySaved(getBodyPart())) {                deleteContent();            } else {                getBodyPart().setBodyState(BodyPart.BS_PARTIAL);            }            throw new Exception("The size of this bodypart is larger than given limit.");        }    }     */    /**

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩视频一区二区三区在线播放| 国产高清不卡二三区| 色综合网色综合| 综合精品久久久| 91性感美女视频| 亚洲人精品午夜| 欧美三区在线观看| 日本亚洲三级在线| 欧美精品一区二区三区高清aⅴ | 黄色成人免费在线| 久久综合狠狠综合久久综合88 | 国产精品一区二区视频| 国产精品国产三级国产专播品爱网 | 国产精品久久久久久久久免费相片 | 日韩一区二区三区高清免费看看| 麻豆精品蜜桃视频网站| 久久久.com| 欧美色综合网站| 国产自产2019最新不卡| 自拍偷拍亚洲综合| 欧美一级二级三级蜜桃| 国产乱对白刺激视频不卡| 亚洲欧美一区二区三区孕妇| 欧美精品乱码久久久久久| 国产美女精品一区二区三区| 亚洲人成精品久久久久| 欧美v日韩v国产v| 一本一道波多野结衣一区二区| 日本成人在线网站| 亚洲天堂免费在线观看视频| 欧美精品xxxxbbbb| 成人一区在线看| 日本亚洲最大的色成网站www| 中文字幕在线一区免费| 日韩欧美中文一区| 99久久99久久精品国产片果冻 | 欧美日韩激情一区| 成人黄动漫网站免费app| 日韩精品成人一区二区在线| 国产精品久久久久影视| 26uuu国产一区二区三区| 91福利在线观看| 国产成人av电影在线| 日本vs亚洲vs韩国一区三区二区| 中文幕一区二区三区久久蜜桃| 91精品国产福利| 色婷婷久久综合| 成人午夜视频在线| 久久疯狂做爰流白浆xx| 亚洲成人黄色小说| 亚洲欧洲三级电影| 国产区在线观看成人精品| 日韩一区二区三区视频| 欧洲av一区二区嗯嗯嗯啊| 国产aⅴ综合色| 国产九色sp调教91| 免费成人美女在线观看| 亚洲一区二区三区爽爽爽爽爽| 国产精品福利电影一区二区三区四区| 欧美成人a∨高清免费观看| 欧美日本国产视频| 在线观看视频一区二区欧美日韩| 成人av网在线| 国产91丝袜在线播放| 国产一区二区免费在线| 美日韩黄色大片| 蜜臀av性久久久久蜜臀aⅴ| 天天影视色香欲综合网老头| 一区二区三区精品在线观看| 亚洲日本在线a| 亚洲欧美日韩一区二区| 最新久久zyz资源站| 国产精品免费看片| 国产精品精品国产色婷婷| 中文久久乱码一区二区| 国产精品毛片高清在线完整版 | 国产精品久久夜| 国产欧美日韩久久| 国产欧美日韩麻豆91| 国产日韩亚洲欧美综合| 国产精品污www在线观看| 国产欧美一区二区三区网站| 日本一区二区在线不卡| 欧美激情中文不卡| 亚洲人成7777| 亚洲福利国产精品| 丝袜亚洲另类丝袜在线| 免费成人在线影院| 国产成人丝袜美腿| av亚洲精华国产精华精华| 一本大道久久a久久综合| 欧美日韩一区高清| 日韩精品一区二区在线观看| 久久久亚洲高清| 日韩毛片高清在线播放| 亚洲制服丝袜av| 欧美aaaaaa午夜精品| 国产激情精品久久久第一区二区 | 久久网站最新地址| 国产精品久久久99| 亚洲午夜久久久久久久久电影网| 日韩制服丝袜先锋影音| 国产精品综合在线视频| 91网上在线视频| 在线成人av网站| 久久久久久久综合狠狠综合| 136国产福利精品导航| 亚洲第一在线综合网站| 久久国产人妖系列| 99热精品国产| 日韩免费视频一区| 一区免费观看视频| 蜜桃视频第一区免费观看| 成人白浆超碰人人人人| 7777精品伊人久久久大香线蕉的 | 欧美另类一区二区三区| 国产亚洲一二三区| 亚洲综合在线电影| 国内成人自拍视频| 91精品91久久久中77777| 精品99一区二区| 亚洲一区在线看| 国产成人高清在线| 欧美精品xxxxbbbb| 中文字幕一区二区三区蜜月| 蜜臀精品久久久久久蜜臀| 色琪琪一区二区三区亚洲区| 久久免费国产精品| 午夜精品久久一牛影视| 91一区一区三区| 久久色中文字幕| 亚洲成av人影院在线观看网| 成人黄色小视频在线观看| 日韩欧美国产不卡| 亚洲国产精品久久久久秋霞影院| 国产成人在线视频网站| 欧美一级欧美一级在线播放| 亚洲精品一卡二卡| 成人精品免费看| 精品sm在线观看| 免费国产亚洲视频| 欧美美女黄视频| 亚洲国产成人av好男人在线观看| 国产在线观看一区二区| 欧美一区二区三区四区久久| 亚洲乱码国产乱码精品精小说| 国产黑丝在线一区二区三区| 日韩视频免费直播| 日韩黄色免费电影| 欧美午夜在线观看| 依依成人精品视频| 99国产精品99久久久久久| 欧美国产精品一区二区| 国产综合色视频| 精品处破学生在线二十三| 日韩av一区二区三区| 欧美婷婷六月丁香综合色| 亚洲美女淫视频| 91看片淫黄大片一级在线观看| 日本一区二区视频在线| 成人综合日日夜夜| 国产精品色噜噜| 不卡视频免费播放| 中文字幕永久在线不卡| 91老师片黄在线观看| 亚洲精品欧美激情| 在线观看视频一区二区| 亚洲成人av福利| 在线成人av网站| 久久精品国产第一区二区三区| 日韩午夜电影在线观看| 久草这里只有精品视频| 精品国精品国产| 国产精品一区二区三区99| 国产喷白浆一区二区三区| fc2成人免费人成在线观看播放 | 国产亚洲欧美一区在线观看| 国产揄拍国内精品对白| 国产日韩精品一区二区三区在线| 国产一区二区h| 国产精品视频在线看| 91免费观看国产| 亚洲最大的成人av| 日韩免费在线观看| 国产成人av电影免费在线观看| 亚洲视频精选在线| 在线播放视频一区| 国产一区二区三区黄视频| 国产精品无圣光一区二区| 欧美在线看片a免费观看| 秋霞电影一区二区| 国产日本欧美一区二区| 一本色道亚洲精品aⅴ| 午夜精品免费在线| 国产欧美视频一区二区| 日本韩国欧美一区| 蜜桃精品视频在线观看| 日本一区二区高清| 欧美色中文字幕| 国产精品一区一区|