DfsObjectToPack.java

  1. /*
  2.  * Copyright (C) 2011, 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.dfs;

  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 DfsObjDatabase}. */
  15. class DfsObjectToPack extends ObjectToPack {
  16.     private static final int FLAG_FOUND = 1 << 0;

  17.     /** Pack to reuse compressed data from, otherwise null. */
  18.     DfsPackFile pack;

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

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

  23.     DfsObjectToPack(AnyObjectId src, int type) {
  24.         super(src, type);
  25.     }

  26.     final boolean isFound() {
  27.         return isExtendedFlag(FLAG_FOUND);
  28.     }

  29.     final void setFound() {
  30.         setExtendedFlag(FLAG_FOUND);
  31.     }

  32.     /** {@inheritDoc} */
  33.     @Override
  34.     protected void clearReuseAsIs() {
  35.         super.clearReuseAsIs();
  36.         pack = null;
  37.     }

  38.     /** {@inheritDoc} */
  39.     @Override
  40.     public void select(StoredObjectRepresentation ref) {
  41.         DfsObjectRepresentation ptr = (DfsObjectRepresentation) ref;
  42.         this.pack = ptr.pack;
  43.         this.offset = ptr.offset;
  44.         this.length = ptr.length;
  45.     }
  46. }