您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

BlobObjectChecker.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (C) 2017, 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.lib;
  11. import org.eclipse.jgit.errors.CorruptObjectException;
  12. /**
  13. * Verifies that a blob object is a valid object.
  14. * <p>
  15. * Unlike trees, commits and tags, there's no validity of blobs. Implementers
  16. * can optionally implement this blob checker to reject certain blobs.
  17. *
  18. * @since 4.9
  19. */
  20. public interface BlobObjectChecker {
  21. /** No-op implementation of {@link BlobObjectChecker}. */
  22. BlobObjectChecker NULL_CHECKER =
  23. new BlobObjectChecker() {
  24. @Override
  25. public void update(byte[] in, int p, int len) {
  26. // Empty implementation.
  27. }
  28. @Override
  29. public void endBlob(AnyObjectId id) {
  30. // Empty implementation.
  31. }
  32. };
  33. /**
  34. * Check a new fragment of the blob.
  35. *
  36. * @param in
  37. * input array of bytes.
  38. * @param offset
  39. * offset to start at from {@code in}.
  40. * @param len
  41. * length of the fragment to check.
  42. */
  43. void update(byte[] in, int offset, int len);
  44. /**
  45. * Finalize the blob checking.
  46. *
  47. * @param id
  48. * identity of the object being checked.
  49. * @throws org.eclipse.jgit.errors.CorruptObjectException
  50. * if any error was detected.
  51. */
  52. void endBlob(AnyObjectId id) throws CorruptObjectException;
  53. }