01: package org.claros.intouch.webdisk.models;
02:
03: import java.io.File;
04:
05: public abstract class ClarosWebDskObject implements Comparable {
06: protected File file;
07: protected String name;
08: protected String path;
09:
10: /**
11: * @param tmp
12: */
13: public ClarosWebDskObject(File tmp) {
14: name = tmp.getName();
15: file = tmp;
16: path = tmp.getAbsolutePath();
17: }
18:
19: /**
20: * @return Returns the file.
21: */
22: public File getFile() {
23: return file;
24: }
25:
26: /**
27: * @param file The file to set.
28: */
29: public void setFile(File file) {
30: this .file = file;
31: }
32:
33: /**
34: * @return Returns the name.
35: */
36: public String getName() {
37: return name;
38: }
39:
40: /**
41: * @param name The name to set.
42: */
43: public void setName(String name) {
44: this .name = name;
45: }
46:
47: /* (non-Javadoc)
48: * @see java.lang.Comparable#compareTo(java.lang.Object)
49: */
50: public int compareTo(Object arg0) {
51: if (this instanceof ClarosWebDskFolder
52: && arg0 instanceof ClarosWebDskFile) {
53: return -1;
54: } else if (this instanceof ClarosWebDskFolder
55: && arg0 instanceof ClarosWebDskFolder) {
56: return this .path.compareTo(((ClarosWebDskFolder) arg0)
57: .getPath());
58: } else if (this instanceof ClarosWebDskFile
59: && arg0 instanceof ClarosWebDskFolder) {
60: return 1;
61: } else if (this instanceof ClarosWebDskFile
62: && arg0 instanceof ClarosWebDskFile) {
63: return this .path.compareTo(((ClarosWebDskFile) arg0)
64: .getPath());
65: }
66: return 0;
67: }
68:
69: public String getPath() {
70: return path;
71: }
72:
73: public void setPath(String path) {
74: this .path = path;
75: }
76:
77: public String toString() {
78: if (this instanceof ClarosWebDskFolder) {
79: return "folder:" + path;
80: } else if (this instanceof ClarosWebDskFile) {
81: return "file:" + path;
82: }
83: return "";
84: }
85: }
|