1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.revwalk;
12
13 import java.io.IOException;
14
15 import org.eclipse.jgit.errors.IncorrectObjectTypeException;
16 import org.eclipse.jgit.errors.MissingObjectException;
17 import org.eclipse.jgit.lib.AnyObjectId;
18 import org.eclipse.jgit.lib.Constants;
19 import org.eclipse.jgit.lib.ObjectId;
20 import org.eclipse.jgit.lib.ObjectIdOwnerMap;
21
22
23
24
25 public abstract class RevObject extends ObjectIdOwnerMap.Entry {
26 static final int PARSED = 1;
27
28 int flags;
29
30 RevObject(AnyObjectId name) {
31 super(name);
32 }
33
34 abstract void parseHeaders(RevWalk walk) throws MissingObjectException,
35 IncorrectObjectTypeException, IOException;
36
37 abstract void parseBody(RevWalk walk) throws MissingObjectException,
38 IncorrectObjectTypeException, IOException;
39
40
41
42
43
44
45 public abstract int getType();
46
47
48
49
50
51
52 public final ObjectId getId() {
53 return this;
54 }
55
56
57
58
59
60
61
62
63 public final boolean has(RevFlag flag) {
64 return (flags & flag.mask) != 0;
65 }
66
67
68
69
70
71
72
73
74
75 public final boolean hasAny(RevFlagSet set) {
76 return (flags & set.mask) != 0;
77 }
78
79
80
81
82
83
84
85
86
87 public final boolean hasAll(RevFlagSet set) {
88 return (flags & set.mask) == set.mask;
89 }
90
91
92
93
94
95
96
97
98
99 public final void add(RevFlag flag) {
100 flags |= flag.mask;
101 }
102
103
104
105
106
107
108
109 public final void add(RevFlagSet set) {
110 flags |= set.mask;
111 }
112
113
114
115
116
117
118
119
120
121 public final void remove(RevFlag flag) {
122 flags &= ~flag.mask;
123 }
124
125
126
127
128
129
130
131 public final void remove(RevFlagSet set) {
132 flags &= ~set.mask;
133 }
134
135
136 @Override
137 public String toString() {
138 final StringBuilder s = new StringBuilder();
139 s.append(Constants.typeString(getType()));
140 s.append(' ');
141 s.append(name());
142 s.append(' ');
143 appendCoreFlags(s);
144 return s.toString();
145 }
146
147
148
149
150
151
152
153 protected void appendCoreFlags(StringBuilder s) {
154 s.append((flags & RevWalk.TOPO_DELAY) != 0 ? 'o' : '-');
155 s.append((flags & RevWalk.TEMP_MARK) != 0 ? 't' : '-');
156 s.append((flags & RevWalk.REWRITE) != 0 ? 'r' : '-');
157 s.append((flags & RevWalk.UNINTERESTING) != 0 ? 'u' : '-');
158 s.append((flags & RevWalk.SEEN) != 0 ? 's' : '-');
159 s.append((flags & RevWalk.PARSED) != 0 ? 'p' : '-');
160 }
161 }