07f45b7b502ef8bf19c61b67561cdfd05ab1e3c6
1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package com
.owncloud
.android
.oc_framework
.operations
;
20 import java
.io
.Serializable
;
22 import android
.os
.Parcel
;
23 import android
.os
.Parcelable
;
25 import com
.owncloud
.android
.oc_framework
.utils
.FileUtils
;
28 * Contains the data of a Remote File from a WebDavEntry
33 public class RemoteFile
implements Parcelable
, Serializable
{
35 /** Generated - should be refreshed every time the class changes!! */
36 private static final long serialVersionUID
= 7256606476031992757L;
38 private String mRemotePath
;
39 private String mMimeType
;
41 private long mCreationTimestamp
;
42 private long mModifiedTimestamp
;
49 public String
getRemotePath() {
53 public void setRemotePath(String remotePath
) {
54 this.mRemotePath
= remotePath
;
57 public String
getMimeType() {
61 public void setMimeType(String mimeType
) {
62 this.mMimeType
= mimeType
;
65 public long getLength() {
69 public void setLength(long length
) {
70 this.mLength
= length
;
73 public long getCreationTimestamp() {
74 return mCreationTimestamp
;
77 public void setCreationTimestamp(long creationTimestamp
) {
78 this.mCreationTimestamp
= creationTimestamp
;
81 public long getModifiedTimestamp() {
82 return mModifiedTimestamp
;
85 public void setModifiedTimestamp(long modifiedTimestamp
) {
86 this.mModifiedTimestamp
= modifiedTimestamp
;
89 public String
getEtag() {
93 public void setEtag(String etag
) {
98 * Create new {@link RemoteFile} with given path.
100 * The path received must be URL-decoded. Path separator must be OCFile.PATH_SEPARATOR, and it must be the first character in 'path'.
102 * @param path The remote path of the file.
104 public RemoteFile(String path
) {
106 if (path
== null
|| path
.length() <= 0 || !path
.startsWith(FileUtils
.PATH_SEPARATOR
)) {
107 throw new IllegalArgumentException("Trying to create a OCFile with a non valid remote path: " + path
);
113 * Used internally. Reset all file properties
115 private void resetData() {
119 mCreationTimestamp
= 0;
120 mModifiedTimestamp
= 0;
127 public static final Parcelable
.Creator
<RemoteFile
> CREATOR
= new Parcelable
.Creator
<RemoteFile
>() {
129 public RemoteFile
createFromParcel(Parcel source
) {
130 return new RemoteFile(source
);
134 public RemoteFile
[] newArray(int size
) {
135 return new RemoteFile
[size
];
141 * Reconstruct from parcel
143 * @param source The source parcel
145 private RemoteFile(Parcel source
) {
146 mRemotePath
= source
.readString();
147 mMimeType
= source
.readString();
148 mLength
= source
.readLong();
149 mCreationTimestamp
= source
.readLong();
150 mModifiedTimestamp
= source
.readLong();
151 mEtag
= source
.readString();
155 public int describeContents() {
156 return this.hashCode();
160 public void writeToParcel(Parcel dest
, int flags
) {
161 dest
.writeString(mRemotePath
);
162 dest
.writeString(mMimeType
);
163 dest
.writeLong(mLength
);
164 dest
.writeLong(mCreationTimestamp
);
165 dest
.writeLong(mModifiedTimestamp
);
166 dest
.writeString(mEtag
);