View Javadoc
1   /*
2    * Copyright (C) 2009, Google Inc.
3    * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
4    * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
5    *
6    * This program and the accompanying materials are made available under the
7    * terms of the Eclipse Distribution License v. 1.0 which is available at
8    * https://www.eclipse.org/org/documents/edl-v10.php.
9    *
10   * SPDX-License-Identifier: BSD-3-Clause
11   */
12  
13  package org.eclipse.jgit.revwalk;
14  
15  import java.io.IOException;
16  
17  import org.eclipse.jgit.errors.IncorrectObjectTypeException;
18  import org.eclipse.jgit.errors.MissingObjectException;
19  import org.eclipse.jgit.lib.AnyObjectId;
20  import org.eclipse.jgit.lib.Constants;
21  
22  /**
23   * A reference to a tree of subtrees/files.
24   */
25  public class RevTree extends RevObject {
26  	/**
27  	 * Create a new tree reference.
28  	 *
29  	 * @param id
30  	 *            object name for the tree.
31  	 */
32  	protected RevTree(AnyObjectId id) {
33  		super(id);
34  	}
35  
36  	/** {@inheritDoc} */
37  	@Override
38  	public final int getType() {
39  		return Constants.OBJ_TREE;
40  	}
41  
42  	@Override
43  	void parseHeaders(RevWalk walk) throws MissingObjectException,
44  			IncorrectObjectTypeException, IOException {
45  		if (walk.reader.has(this))
46  			flags |= PARSED;
47  		else
48  			throw new MissingObjectException(this, getType());
49  	}
50  
51  	@Override
52  	void parseBody(RevWalk walk) throws MissingObjectException,
53  			IncorrectObjectTypeException, IOException {
54  		if ((flags & PARSED) == 0)
55  			parseHeaders(walk);
56  	}
57  }