2 * Sonitus - MetadataBlock.java - Copyright © 2013 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sonitus.io.flac;
20 import java.io.IOException;
21 import java.io.InputStream;
26 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
28 public class MetadataBlock {
30 /** The header of the metadata block. */
31 private final Header header;
33 /** The data of the metadata block. */
34 private final Data data;
37 * Creates a new metadata block.
40 * The header of the metadata block
42 * The data of the metadata block
44 MetadataBlock(Header header, Data data) {
54 * Returns the header of this metadata block.
56 * @return The header of this metadata block
58 public Header header() {
63 * Returns the data of this metadata block.
65 * @return The data of this metadata block
76 * Parses the metadata block from the current position of the given input
80 * The input stream to parse the metadata block from
81 * @return The parsed metadata block
83 * if an I/O error occurs
85 public static MetadataBlock parse(InputStream inputStream) throws IOException {
86 Header header = Header.parse(inputStream);
87 Data data = Data.parse(inputStream, header.blockType(), header.length());
88 return new MetadataBlock(header, data);