2 * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the following
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * - Neither the name of the Git Development Community nor the
19 * names of its contributors may be used to endorse or promote
20 * products derived from this software without specific prior
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 package org
.spearce
.jgit
.revwalk
;
40 import java
.io
.IOException
;
42 import org
.spearce
.jgit
.errors
.IncorrectObjectTypeException
;
43 import org
.spearce
.jgit
.errors
.MissingObjectException
;
44 import org
.spearce
.jgit
.lib
.AnyObjectId
;
45 import org
.spearce
.jgit
.lib
.ObjectId
;
47 /** Base object type accessed during revision walking. */
48 public abstract class RevObject
extends ObjectId
{
49 static final int PARSED
= 1;
53 RevObject(final AnyObjectId name
) {
57 abstract void parse(RevWalk walk
) throws MissingObjectException
,
58 IncorrectObjectTypeException
, IOException
;
61 * Get the name of this object.
63 * @return unique hash of this object.
65 public ObjectId
getId() {
70 public boolean equals(final ObjectId o
) {
75 public boolean equals(final Object o
) {
80 * Test to see if the flag has been set on this object.
84 * @return true if the flag has been added to this object; false if not.
86 public boolean has(final RevFlag flag
) {
87 return (flags
& flag
.mask
) != 0;
91 * Test to see if any flag in the set has been set on this object.
95 * @return true if any flag in the set has been added to this object; false
98 public boolean hasAny(final RevFlagSet set
) {
99 return (flags
& set
.mask
) != 0;
103 * Test to see if all flags in the set have been set on this object.
107 * @return true if all flags of the set have been added to this object;
108 * false if some or none have been added.
110 public boolean hasAll(final RevFlagSet set
) {
111 return (flags
& set
.mask
) == set
.mask
;
115 * Add a flag to this object.
117 * If the flag is already set on this object then the method has no effect.
120 * the flag to mark on this object, for later testing.
122 public void add(final RevFlag flag
) {
127 * Add a set of flags to this object.
130 * the set of flags to mark on this object, for later testing.
132 public void add(final RevFlagSet set
) {
137 * Remove a flag from this object.
139 * If the flag is not set on this object then the method has no effect.
142 * the flag to remove from this object.
144 public void remove(final RevFlag flag
) {
149 * Remove a set of flags from this object.
152 * the flag to remove from this object.
154 public void remove(final RevFlagSet set
) {
158 /** Release as much memory as possible from this object. */
159 public void dispose() {
160 // Nothing needs to be done for most objects.