001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: https://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: https://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.gwt.shared;
029
030import com.google.gwt.user.client.rpc.IsSerializable;
031
032/**
033 * A bean that holds the upload progress infos.<p>
034 *
035 * @since 8.0.0
036 */
037public class CmsUploadProgessInfo implements IsSerializable {
038
039    /** A enum for the upload state. */
040    public static enum UPLOAD_STATE {
041
042        /** Upload is finished. */
043        finished,
044        /** Upload not started. */
045        notStarted,
046        /** Upload is running. */
047        running
048    }
049
050    /** Stores the bytes that are already read. */
051    private long m_bytesRead;
052
053    /** The total content length. */
054    private long m_contentLength;
055
056    /** The index of the current file. */
057    private int m_currentFile;
058
059    /** The current percentage. */
060    private int m_percent;
061
062    /** Stores the state. */
063    private UPLOAD_STATE m_state;
064
065    /**
066     * Default constructor.<p>
067     */
068    public CmsUploadProgessInfo() {
069
070        // noop
071    }
072
073    /**
074     * Constructor with parameters.<p>
075     *
076     * @param currentFile the current file count
077     * @param percent the progress in percent
078     * @param state the state
079     * @param contentLength the content length of the upload request
080     * @param bytesRead the count of bytes read so far
081     */
082    public CmsUploadProgessInfo(int currentFile, int percent, UPLOAD_STATE state, long contentLength, long bytesRead) {
083
084        m_currentFile = currentFile;
085        m_percent = percent;
086        m_state = state;
087        m_contentLength = contentLength;
088        m_bytesRead = bytesRead;
089    }
090
091    /**
092     * Returns the bytesRead.<p>
093     *
094     * @return the bytesRead
095     */
096    public long getBytesRead() {
097
098        return m_bytesRead;
099    }
100
101    /**
102     * Returns the contentLength.<p>
103     *
104     * @return the contentLength
105     */
106    public long getContentLength() {
107
108        return m_contentLength;
109    }
110
111    /**
112     * Returns the currentFile.<p>
113     *
114     * @return the currentFile
115     */
116    public int getCurrentFile() {
117
118        return m_currentFile;
119    }
120
121    /**
122     * Returns the percent.<p>
123     *
124     * @return the percent
125     */
126    public int getPercent() {
127
128        return m_percent;
129    }
130
131    /**
132     * Returns the state.<p>
133     *
134     * @return the state
135     */
136    public UPLOAD_STATE getState() {
137
138        return m_state;
139    }
140
141    /**
142     * Sets the bytesRead.<p>
143     *
144     * @param bytesRead the bytesRead to set
145     */
146    public void setBytesRead(long bytesRead) {
147
148        m_bytesRead = bytesRead;
149    }
150
151    /**
152     * Sets the contentLength.<p>
153     *
154     * @param contentLength the contentLength to set
155     */
156    public void setContentLength(long contentLength) {
157
158        m_contentLength = contentLength;
159    }
160
161    /**
162     * Sets the currentFile.<p>
163     *
164     * @param currentFile the currentFile to set
165     */
166    public void setCurrentFile(int currentFile) {
167
168        m_currentFile = currentFile;
169    }
170
171    /**
172     * Sets the percent.<p>
173     *
174     * @param percent the percent to set
175     */
176    public void setPercent(int percent) {
177
178        m_percent = percent;
179    }
180
181    /**
182     * Sets the state.<p>
183     *
184     * @param state the state to set
185     */
186    public void setState(UPLOAD_STATE state) {
187
188        m_state = state;
189    }
190}