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