RevBlob.java

  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. package org.eclipse.jgit.revwalk;

  13. import java.io.IOException;

  14. import org.eclipse.jgit.errors.IncorrectObjectTypeException;
  15. import org.eclipse.jgit.errors.MissingObjectException;
  16. import org.eclipse.jgit.lib.AnyObjectId;
  17. import org.eclipse.jgit.lib.Constants;

  18. /**
  19.  * A binary file, or a symbolic link.
  20.  */
  21. public class RevBlob extends RevObject {
  22.     /**
  23.      * Create a new blob reference.
  24.      *
  25.      * @param id
  26.      *            object name for the blob.
  27.      */
  28.     protected RevBlob(AnyObjectId id) {
  29.         super(id);
  30.     }

  31.     /** {@inheritDoc} */
  32.     @Override
  33.     public final int getType() {
  34.         return Constants.OBJ_BLOB;
  35.     }

  36.     @Override
  37.     void parseHeaders(RevWalk walk) throws MissingObjectException,
  38.             IncorrectObjectTypeException, IOException {
  39.         if (walk.reader.has(this))
  40.             flags |= PARSED;
  41.         else
  42.             throw new MissingObjectException(this, getType());
  43.     }

  44.     @Override
  45.     void parseBody(RevWalk walk) throws MissingObjectException,
  46.             IncorrectObjectTypeException, IOException {
  47.         if ((flags & PARSED) == 0)
  48.             parseHeaders(walk);
  49.     }
  50. }