LocalObjectToPack.java

  1. /*
  2.  * Copyright (C) 2010, Google Inc. and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */

  10. package org.eclipse.jgit.internal.storage.file;

  11. import org.eclipse.jgit.internal.storage.pack.ObjectToPack;
  12. import org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation;
  13. import org.eclipse.jgit.lib.AnyObjectId;

  14. /** {@link ObjectToPack} for {@link ObjectDirectory}. */
  15. class LocalObjectToPack extends ObjectToPack {
  16.     /** Pack to reuse compressed data from, otherwise null. */
  17.     Pack pack;

  18.     /** Offset of the object's header in {@link #pack}. */
  19.     long offset;

  20.     /** Length of the data section of the object. */
  21.     long length;

  22.     LocalObjectToPack(AnyObjectId src, int type) {
  23.         super(src, type);
  24.     }

  25.     /** {@inheritDoc} */
  26.     @Override
  27.     protected void clearReuseAsIs() {
  28.         super.clearReuseAsIs();
  29.         pack = null;
  30.     }

  31.     /** {@inheritDoc} */
  32.     @Override
  33.     public void select(StoredObjectRepresentation ref) {
  34.         LocalObjectRepresentation ptr = (LocalObjectRepresentation) ref;
  35.         this.pack = ptr.pack;
  36.         this.offset = ptr.offset;
  37.         this.length = ptr.length;
  38.     }
  39. }