01: package tide.editor.bookmarks;
02:
03: import snow.utils.storage.*;
04:
05: public class SourceBookmark implements Comparable<SourceBookmark> // { name, line
06: {
07: final private long created;
08: final private String javaName;
09: private String remark = "";
10: private int linePosition = -1;
11: private int columnPosition = -1;
12: public boolean isValid = true;
13:
14: /** Creates a new one
15: */
16: public SourceBookmark(String javaName, int linePosition,
17: int columnPosition, String remark) {
18: created = System.currentTimeMillis();
19: this .javaName = javaName;
20: this .linePosition = linePosition;
21: this .columnPosition = columnPosition;
22: this .remark = (remark != null ? remark : "");
23: }
24:
25: public SourceBookmark(StorageVector rep) {
26: int version = (Integer) rep.get(0);
27: javaName = (String) rep.get(1);
28: remark = (String) rep.get(2);
29: if (version > 1) {
30: linePosition = (Integer) rep.get(3);
31: columnPosition = (Integer) rep.get(4);
32: }
33: if (rep.size() > 5) {
34: created = (Long) rep.get(5);
35: } else {
36: created = System.currentTimeMillis();
37: }
38: }
39:
40: public String getJavaName() {
41: return javaName;
42: }
43:
44: public int getLinePosition() {
45: return linePosition;
46: }
47:
48: public int getColumnPosition() {
49: return columnPosition;
50: }
51:
52: public String getRemark() {
53: return remark;
54: }
55:
56: public void setRemark(String r) {
57: if (r == null)
58: r = "";
59: remark = r;
60: }
61:
62: public long getCreated() {
63: return created;
64: }
65:
66: public void setLinePosition(int lp) {
67: this .linePosition = lp;
68: }
69:
70: public StorageVector getStorageRepresentation() {
71: StorageVector sv = new StorageVector();
72: sv.add(2);
73: sv.add(javaName);
74: sv.add(remark);
75: sv.add(linePosition);
76: sv.add(columnPosition);
77: sv.add(created);
78: return sv;
79: }
80:
81: /** Can be used to print
82: */
83: @Override
84: public String toString() {
85: return javaName + ".java:" + linePosition + ":"
86: + columnPosition + ": " + remark;
87: }
88:
89: public int compareTo(SourceBookmark b2) {
90: int c1 = b2.getJavaName().compareTo(getJavaName());
91: if (c1 != 0)
92: return c1;
93: return Integer.valueOf(b2.linePosition).compareTo(linePosition);
94: }
95:
96: }
|