001package co.codewizards.cloudstore.core.dto;
002
003import java.util.ArrayList;
004import java.util.List;
005
006import javax.xml.bind.annotation.XmlRootElement;
007
008import co.codewizards.cloudstore.core.oio.File;
009
010@SuppressWarnings("serial")
011@XmlRootElement
012public class NormalFileDto extends RepoFileDto {
013
014        private long length;
015
016        private String sha1;
017
018        private List<FileChunkDto> fileChunkDtos;
019
020        private List<FileChunkDto> tempFileChunkDtos;
021
022        public NormalFileDto() { }
023
024        /**
025         * Gets the file size in bytes.
026         * <p>
027         * It reflects the {@link File#length() File.length} property.
028         * @return the file size in bytes. <code>0</code>, if this is a directory.
029         */
030        public long getLength() {
031                return length;
032        }
033        public void setLength(final long size) {
034                this.length = size;
035        }
036        /**
037         * Gets the <a href="http://en.wikipedia.org/wiki/SHA-1">SHA-1</a> of the file.
038         * @return the <a href="http://en.wikipedia.org/wiki/SHA-1">SHA-1</a> of the file.
039         */
040        public String getSha1() {
041                return sha1;
042        }
043        public void setSha1(final String sha) {
044                this.sha1 = sha;
045        }
046
047        public List<FileChunkDto> getFileChunkDtos() {
048                if (fileChunkDtos == null)
049                        fileChunkDtos = new ArrayList<FileChunkDto>();
050
051                return fileChunkDtos;
052        }
053        public void setFileChunkDtos(final List<FileChunkDto> fileChunkDtos) {
054                this.fileChunkDtos = fileChunkDtos;
055        }
056
057        public List<FileChunkDto> getTempFileChunkDtos() {
058                if (tempFileChunkDtos == null)
059                        tempFileChunkDtos = new ArrayList<FileChunkDto>();
060
061                return tempFileChunkDtos;
062        }
063        public void setTempFileChunkDtos(final List<FileChunkDto> tempFileChunkDtos) {
064                this.tempFileChunkDtos = tempFileChunkDtos;
065        }
066
067        @Override
068        protected String toString_getProperties() {
069                return super.toString_getProperties()
070                                + ", length=" + length
071                                + ", sha1=" + sha1;
072        }
073}