Debian Codegraph @

src/com/drew/imaging/quicktime/QuickTimeHandler.java

raw symbols SCIP
1 /*
2 * Copyright 2002-2019 Drew Noakes and contributors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * More information about this project is available at:
17 *
18 * https://drewnoakes.com/code/exif/
19 * https://github.com/drewnoakes/metadata-extractor
20 */
21 package com.drew.imaging.quicktime;
22
23 import com.drew.lang.annotations.NotNull;
24 import com.drew.lang.annotations.Nullable;
25 import com.drew.metadata.Metadata;
26 import com.drew.metadata.mov.QuickTimeContext;
27 import com.drew.metadata.mov.QuickTimeDirectory;
28 import com.drew.metadata.mov.atoms.Atom;
29
30 import java.io.IOException;
31
32 /**
33 * @author Payton Garland
34 */
35 public abstract class QuickTimeHandler<T extends QuickTimeDirectory>
36 {
37 @NotNull protected Metadata metadata;
38 @NotNull protected T directory;
39
40 public QuickTimeHandler(@NotNull Metadata metadata)
41 {
42 this.metadata = metadata;
43 this.directory = createDirectory();
44 metadata.addDirectory(directory);
45 }
46
47 @NotNull
48 protected abstract T createDirectory();
49
50 protected abstract boolean shouldAcceptAtom(@NotNull Atom atom);
51
52 protected abstract boolean shouldAcceptContainer(@NotNull Atom atom);
53
54 protected abstract QuickTimeHandler<?> processAtom(@NotNull Atom atom, @Nullable byte[] payload, QuickTimeContext context) throws IOException;
55
56 protected QuickTimeHandler<?> processContainer(@NotNull Atom atom, QuickTimeContext context) throws IOException
57 {
58 return processAtom(atom, null, context);
59 }
60
61 public void addError(@NotNull String message)
62 {
63 directory.addError(message);
64 }
65 }