DfsObjectRepresentation.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.StoredObjectRepresentation;
  12. import org.eclipse.jgit.lib.ObjectId;

  13. class DfsObjectRepresentation extends StoredObjectRepresentation {
  14.     final DfsPackFile pack;
  15.     int format;
  16.     long offset;
  17.     long length;
  18.     ObjectId baseId;

  19.     DfsObjectRepresentation(DfsPackFile pack) {
  20.         this.pack = pack;
  21.     }

  22.     /** {@inheritDoc} */
  23.     @Override
  24.     public int getFormat() {
  25.         return format;
  26.     }

  27.     /** {@inheritDoc} */
  28.     @Override
  29.     public int getWeight() {
  30.         return (int) Math.min(length, Integer.MAX_VALUE);
  31.     }

  32.     /** {@inheritDoc} */
  33.     @Override
  34.     public ObjectId getDeltaBase() {
  35.         return baseId;
  36.     }

  37.     /** {@inheritDoc} */
  38.     @Override
  39.     public boolean wasDeltaAttempted() {
  40.         switch (pack.getPackDescription().getPackSource()) {
  41.         case GC:
  42.         case GC_REST:
  43.         case GC_TXN:
  44.             return true;
  45.         default:
  46.             return false;
  47.         }
  48.     }
  49. }