001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://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: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://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, /** Upload not started. */
044        notStarted, /** Upload is running. */
045        running
046    }
047
048    /** Stores the bytes that are already read. */
049    private long m_bytesRead;
050
051    /** The total content length. */
052    private long m_contentLength;
053
054    /** The index of the current file. */
055    private int m_currentFile;
056
057    /** The current percentage. */
058    private int m_percent;
059
060    /** Stores the state. */
061    private UPLOAD_STATE m_state;
062
063    /**
064     * Default constructor.<p>
065     */
066    public CmsUploadProgessInfo() {
067
068        // noop
069    }
070
071    /**
072     * Constructor with parameters.<p>
073     *
074     * @param currentFile the current file count
075     * @param percent the progress in percent
076     * @param state the state
077     * @param contentLength the content length of the upload request
078     * @param bytesRead the count of bytes read so far
079     */
080    public CmsUploadProgessInfo(int currentFile, int percent, UPLOAD_STATE state, long contentLength, long bytesRead) {
081
082        m_currentFile = currentFile;
083        m_percent = percent;
084        m_state = state;
085        m_contentLength = contentLength;
086        m_bytesRead = bytesRead;
087    }
088
089    /**
090     * Returns the bytesRead.<p>
091     *
092     * @return the bytesRead
093     */
094    public long getBytesRead() {
095
096        return m_bytesRead;
097    }
098
099    /**
100     * Returns the contentLength.<p>
101     *
102     * @return the contentLength
103     */
104    public long getContentLength() {
105
106        return m_contentLength;
107    }
108
109    /**
110     * Returns the currentFile.<p>
111     *
112     * @return the currentFile
113     */
114    public int getCurrentFile() {
115
116        return m_currentFile;
117    }
118
119    /**
120     * Returns the percent.<p>
121     *
122     * @return the percent
123     */
124    public int getPercent() {
125
126        return m_percent;
127    }
128
129    /**
130     * Returns the state.<p>
131     *
132     * @return the state
133     */
134    public UPLOAD_STATE getState() {
135
136        return m_state;
137    }
138
139    /**
140     * Sets the bytesRead.<p>
141     *
142     * @param bytesRead the bytesRead to set
143     */
144    public void setBytesRead(long bytesRead) {
145
146        m_bytesRead = bytesRead;
147    }
148
149    /**
150     * Sets the contentLength.<p>
151     *
152     * @param contentLength the contentLength to set
153     */
154    public void setContentLength(long contentLength) {
155
156        m_contentLength = contentLength;
157    }
158
159    /**
160     * Sets the currentFile.<p>
161     *
162     * @param currentFile the currentFile to set
163     */
164    public void setCurrentFile(int currentFile) {
165
166        m_currentFile = currentFile;
167    }
168
169    /**
170     * Sets the percent.<p>
171     *
172     * @param percent the percent to set
173     */
174    public void setPercent(int percent) {
175
176        m_percent = percent;
177    }
178
179    /**
180     * Sets the state.<p>
181     *
182     * @param state the state to set
183     */
184    public void setState(UPLOAD_STATE state) {
185
186        m_state = state;
187    }
188}