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
.Constants
;
46 import org
.spearce
.jgit
.lib
.ObjectId
;
48 /** Base object type accessed during revision walking. */
49 public abstract class RevObject
extends ObjectId
{
50 static final int PARSED
= 1;
54 RevObject(final AnyObjectId name
) {
58 abstract void parse(RevWalk walk
) throws MissingObjectException
,
59 IncorrectObjectTypeException
, IOException
;
62 * Get Git object type. See {@link Constants}.
66 public abstract int getType();
69 * Get the name of this object.
71 * @return unique hash of this object.
73 public ObjectId
getId() {
78 public boolean equals(final ObjectId o
) {
83 public boolean equals(final Object o
) {
88 * Test to see if the flag has been set on this object.
92 * @return true if the flag has been added to this object; false if not.
94 public boolean has(final RevFlag flag
) {
95 return (flags
& flag
.mask
) != 0;
99 * Test to see if any flag in the set has been set on this object.
103 * @return true if any flag in the set has been added to this object; false
106 public boolean hasAny(final RevFlagSet set
) {
107 return (flags
& set
.mask
) != 0;
111 * Test to see if all flags in the set have been set on this object.
115 * @return true if all flags of the set have been added to this object;
116 * false if some or none have been added.
118 public boolean hasAll(final RevFlagSet set
) {
119 return (flags
& set
.mask
) == set
.mask
;
123 * Add a flag to this object.
125 * If the flag is already set on this object then the method has no effect.
128 * the flag to mark on this object, for later testing.
130 public void add(final RevFlag flag
) {
135 * Add a set of flags to this object.
138 * the set of flags to mark on this object, for later testing.
140 public void add(final RevFlagSet set
) {
145 * Remove a flag from this object.
147 * If the flag is not set on this object then the method has no effect.
150 * the flag to remove from this object.
152 public void remove(final RevFlag flag
) {
157 * Remove a set of flags from this object.
160 * the flag to remove from this object.
162 public void remove(final RevFlagSet set
) {
166 /** Release as much memory as possible from this object. */
167 public void dispose() {
168 // Nothing needs to be done for most objects.