All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.drew.imaging.riff.RiffHandler Maven / Gradle / Ivy

Go to download

Java library for extracting EXIF, IPTC, XMP, ICC and other metadata from image and video files.

There is a newer version: 2.19.0
Show newest version
/*
 * Copyright 2002-2019 Drew Noakes and contributors
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 *
 * More information about this project is available at:
 *
 *    https://drewnoakes.com/code/exif/
 *    https://github.com/drewnoakes/metadata-extractor
 */
package com.drew.imaging.riff;

import com.drew.lang.annotations.NotNull;

/**
 * Interface of an class capable of handling events raised during the reading of a RIFF file
 * via {@link RiffReader}.
 *
 * @author Drew Noakes https://drewnoakes.com
 */
public interface RiffHandler
{
    /**
     * Gets whether the specified RIFF identifier is of interest to this handler.
     * Returning false causes processing to stop after reading only
     * the first twelve bytes of data.
     *
     * @param identifier The four character code identifying the type of RIFF data
     * @return true if processing should continue, otherwise false
     */
    boolean shouldAcceptRiffIdentifier(@NotNull String identifier);

    /**
     * Gets whether this handler is interested in the specific chunk type.
     * Returns true if the data should be copied into an array and passed
     * to {@link RiffHandler#processChunk(String, byte[])}, or false to avoid
     * the copy and skip to the next chunk in the file, if any.
     *
     * @param fourCC the four character code of this chunk
     * @return true if {@link RiffHandler#processChunk(String, byte[])} should be called, otherwise false
     */
    boolean shouldAcceptChunk(@NotNull String fourCC);

    /**
     * Gets whether this handler is interested in the specific list type.
     * Returns true if the chunks should continue being processed,
     * or false to avoid any unknown chunks within the list.
     *
     * @param fourCC the four character code of this chunk
     * @return true if {@link RiffHandler#processChunk(String, byte[])} should be called, otherwise false
     */
    boolean shouldAcceptList(@NotNull String fourCC);

    /**
     * Perform whatever processing is necessary for the type of chunk with its
     * payload.
     *
     * This is only called if a previous call to {@link RiffHandler#shouldAcceptChunk(String)}
     * with the same fourCC returned true.
     *
     * @param fourCC the four character code of the chunk
     * @param payload they payload of the chunk as a byte array
     */
    void processChunk(@NotNull String fourCC, @NotNull byte[] payload);

    /**
     * Registers an error message for consumption after extraction.
     * @param message the error message
     */
    void addError(@NotNull String message);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy