70c9dc1ba8dfab3c967f1230f653debeeb536e13
1 /* ownCloud webDAV Library for Android is available under MIT license
2 * Copyright (C) 2014 ownCloud (http://www.owncloud.org/)
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 package com
.owncloud
.android
.oc_framework
.operations
;
27 import java
.io
.Serializable
;
29 import android
.os
.Parcel
;
30 import android
.os
.Parcelable
;
32 import com
.owncloud
.android
.oc_framework
.network
.webdav
.WebdavEntry
;
33 import com
.owncloud
.android
.oc_framework
.utils
.FileUtils
;
36 * Contains the data of a Remote File from a WebDavEntry
41 public class RemoteFile
implements Parcelable
, Serializable
{
43 /** Generated - should be refreshed every time the class changes!! */
44 private static final long serialVersionUID
= 532139091191390616L;
46 private String mRemotePath
;
47 private String mMimeType
;
49 private long mCreationTimestamp
;
50 private long mModifiedTimestamp
;
57 public String
getRemotePath() {
61 public void setRemotePath(String remotePath
) {
62 this.mRemotePath
= remotePath
;
65 public String
getMimeType() {
69 public void setMimeType(String mimeType
) {
70 this.mMimeType
= mimeType
;
73 public long getLength() {
77 public void setLength(long length
) {
78 this.mLength
= length
;
81 public long getCreationTimestamp() {
82 return mCreationTimestamp
;
85 public void setCreationTimestamp(long creationTimestamp
) {
86 this.mCreationTimestamp
= creationTimestamp
;
89 public long getModifiedTimestamp() {
90 return mModifiedTimestamp
;
93 public void setModifiedTimestamp(long modifiedTimestamp
) {
94 this.mModifiedTimestamp
= modifiedTimestamp
;
97 public String
getEtag() {
101 public void setEtag(String etag
) {
106 * Create new {@link RemoteFile} with given path.
108 * The path received must be URL-decoded. Path separator must be OCFile.PATH_SEPARATOR, and it must be the first character in 'path'.
110 * @param path The remote path of the file.
112 public RemoteFile(String path
) {
114 if (path
== null
|| path
.length() <= 0 || !path
.startsWith(FileUtils
.PATH_SEPARATOR
)) {
115 throw new IllegalArgumentException("Trying to create a OCFile with a non valid remote path: " + path
);
120 public RemoteFile(WebdavEntry we
) {
121 this(we
.decodedPath());
122 this.setCreationTimestamp(we
.createTimestamp());
123 this.setLength(we
.contentLength());
124 this.setMimeType(we
.contentType());
125 this.setModifiedTimestamp(we
.modifiedTimestamp());
126 this.setEtag(we
.etag());
130 * Used internally. Reset all file properties
132 private void resetData() {
136 mCreationTimestamp
= 0;
137 mModifiedTimestamp
= 0;
144 public static final Parcelable
.Creator
<RemoteFile
> CREATOR
= new Parcelable
.Creator
<RemoteFile
>() {
146 public RemoteFile
createFromParcel(Parcel source
) {
147 return new RemoteFile(source
);
151 public RemoteFile
[] newArray(int size
) {
152 return new RemoteFile
[size
];
158 * Reconstruct from parcel
160 * @param source The source parcel
162 private RemoteFile(Parcel source
) {
163 mRemotePath
= source
.readString();
164 mMimeType
= source
.readString();
165 mLength
= source
.readLong();
166 mCreationTimestamp
= source
.readLong();
167 mModifiedTimestamp
= source
.readLong();
168 mEtag
= source
.readString();
172 public int describeContents() {
173 return this.hashCode();
177 public void writeToParcel(Parcel dest
, int flags
) {
178 dest
.writeString(mRemotePath
);
179 dest
.writeString(mMimeType
);
180 dest
.writeLong(mLength
);
181 dest
.writeLong(mCreationTimestamp
);
182 dest
.writeLong(mModifiedTimestamp
);
183 dest
.writeString(mEtag
);