public class OCFile {
- private long id_;
- private long parent_id_;
- private long length_;
- private long creation_timestamp_;
- private long modified_timestamp_;
- private String path_;
- private String storage_path_;
- private String mimetype_;
- private boolean update_while_saving_;
+ private long id;
+ private long parentId;
+ private long length;
+ private long creationTimestamp;
+ private long modifiedTimestamp;
+ private String remotePath;
+ private String localPath;
+ private String mimeType;
+ private boolean needsUpdating;
/**
* Create new {@link OCFile} with given path
*/
public OCFile(String path) {
resetData();
- update_while_saving_ = false;
- path_ = path;
+ needsUpdating = false;
+ remotePath = path;
}
/**
* @return the file ID
*/
public long getFileId() {
- return id_;
+ return id;
}
/**
* @return The path
*/
public String getPath() {
- return path_;
+ return remotePath;
}
/**
* @return true, if the file exists in the database
*/
public boolean fileExists() {
- return id_ != -1;
+ return id != -1;
}
/**
* @return true if it is a directory
*/
public boolean isDirectory() {
- return mimetype_ != null && mimetype_.equals("DIR");
+ return mimeType != null && mimeType.equals("DIR");
}
/**
* @return true if it is
*/
public boolean isDownloaded() {
- return storage_path_ != null;
+ return localPath != null;
}
/**
* @return The local path to the file
*/
public String getStoragePath() {
- return storage_path_;
+ return localPath;
}
/**
* to set
*/
public void setStoragePath(String storage_path) {
- storage_path_ = storage_path;
+ localPath = storage_path;
}
/**
* @return A UNIX timestamp of the time that file was created
*/
public long getCreationTimestamp() {
- return creation_timestamp_;
+ return creationTimestamp;
}
/**
* to set
*/
public void setCreationTimestamp(long creation_timestamp) {
- creation_timestamp_ = creation_timestamp;
+ creationTimestamp = creation_timestamp;
}
/**
* @return A UNIX timestamp of the modification time
*/
public long getModificationTimestamp() {
- return modified_timestamp_;
+ return modifiedTimestamp;
}
/**
* to set
*/
public void setModificationTimestamp(long modification_timestamp) {
- modified_timestamp_ = modification_timestamp;
+ modifiedTimestamp = modification_timestamp;
}
/**
* @return The name of the file
*/
public String getFileName() {
- if (path_ != null) {
- File f = new File(path_);
+ if (remotePath != null) {
+ File f = new File(remotePath);
return f.getName().equals("") ? "/" : f.getName();
}
return null;
* @return the Mimetype as a String
*/
public String getMimetype() {
- return mimetype_;
+ return mimeType;
}
/**
*/
public void addFile(OCFile file) throws IllegalStateException {
if (isDirectory()) {
- file.parent_id_ = id_;
- update_while_saving_ = true;
+ file.parentId = id;
+ needsUpdating = true;
return;
}
throw new IllegalStateException("This is not a directory where you can add stuff to!");
* Used internally. Reset all file properties
*/
private void resetData() {
- id_ = -1;
- path_ = null;
- parent_id_ = 0;
- storage_path_ = null;
- mimetype_ = null;
- length_ = 0;
- creation_timestamp_ = 0;
- modified_timestamp_ = 0;
+ id = -1;
+ remotePath = null;
+ parentId = 0;
+ localPath = null;
+ mimeType = null;
+ length = 0;
+ creationTimestamp = 0;
+ modifiedTimestamp = 0;
}
+ /**
+ * Sets the ID of the file
+ * @param file_id to set
+ */
public void setFileId(long file_id) {
- id_ = file_id;
+ id = file_id;
}
+ /**
+ * Sets the Mime-Type of the
+ * @param mimetype to set
+ */
public void setMimetype(String mimetype) {
- mimetype_ = mimetype;
+ mimeType = mimetype;
}
+ /**
+ * Sets the ID of the parent folder
+ * @param parent_id to set
+ */
public void setParentId(long parent_id) {
- parent_id_ = parent_id;
+ parentId = parent_id;
}
+ /**
+ * Sets the file size in bytes
+ * @param file_len to set
+ */
public void setFileLength(long file_len) {
- length_ = file_len;
+ length = file_len;
}
+ /**
+ * Returns the size of the file in bytes
+ * @return The filesize in bytes
+ */
public long getFileLength() {
- return length_;
+ return length;
}
+ /**
+ * Returns the ID of the parent Folder
+ * @return The ID
+ */
public long getParentId() {
- return parent_id_;
+ return parentId;
}
+ /**
+ * Check, if this file needs updating
+ * @return
+ */
public boolean needsUpdatingWhileSaving() {
- return update_while_saving_;
+ return needsUpdating;
}
}