FileObjectDatabase.java

  1. /*
  2.  * Copyright (C) 2010, 2022 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 java.io.File;
  12. import java.io.IOException;
  13. import java.util.Collection;
  14. import java.util.Set;

  15. import org.eclipse.jgit.internal.storage.pack.ObjectToPack;
  16. import org.eclipse.jgit.internal.storage.pack.PackWriter;
  17. import org.eclipse.jgit.lib.AbbreviatedObjectId;
  18. import org.eclipse.jgit.lib.AnyObjectId;
  19. import org.eclipse.jgit.lib.Config;
  20. import org.eclipse.jgit.lib.ObjectDatabase;
  21. import org.eclipse.jgit.lib.ObjectId;
  22. import org.eclipse.jgit.lib.ObjectLoader;
  23. import org.eclipse.jgit.lib.ObjectReader;
  24. import org.eclipse.jgit.util.FS;

  25. abstract class FileObjectDatabase extends ObjectDatabase {
  26.     enum InsertLooseObjectResult {
  27.         INSERTED, EXISTS_PACKED, EXISTS_LOOSE, FAILURE;
  28.     }

  29.     /** {@inheritDoc} */
  30.     @Override
  31.     public ObjectReader newReader() {
  32.         return new WindowCursor(this);
  33.     }

  34.     /** {@inheritDoc} */
  35.     @Override
  36.     public ObjectDirectoryInserter newInserter() {
  37.         return new ObjectDirectoryInserter(this, getConfig());
  38.     }

  39.     abstract void resolve(Set<ObjectId> matches, AbbreviatedObjectId id)
  40.             throws IOException;

  41.     abstract Config getConfig();

  42.     abstract FS getFS();

  43.     abstract void selectObjectRepresentation(PackWriter packer,
  44.             ObjectToPack otp, WindowCursor curs) throws IOException;

  45.     abstract File getDirectory();

  46.     abstract File fileFor(AnyObjectId id);

  47.     abstract ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId)
  48.             throws IOException;

  49.     abstract long getObjectSize(WindowCursor curs, AnyObjectId objectId)
  50.             throws IOException;

  51.     abstract ObjectLoader openLooseObject(WindowCursor curs, AnyObjectId id)
  52.             throws IOException;

  53.     abstract InsertLooseObjectResult insertUnpackedObject(File tmp,
  54.             ObjectId id, boolean createDuplicate) throws IOException;

  55.     abstract Pack openPack(File pack) throws IOException;

  56.     abstract Collection<Pack> getPacks();
  57. }