X-Git-Url: https://git.pterodactylus.net/?p=sonitus.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2Fsource%2FFileSource.java;h=9aff8d401289cb9ed4644c83265b7e626a8acbb2;hp=2829a4205c74089cd4b97af61661ab71ec08e517;hb=cbeadf6d9eea57ab98cacd60e2419dd3c18bef89;hpb=87436ac0b103a112722c1df835e11ec928e57d38 diff --git a/src/main/java/net/pterodactylus/sonitus/data/source/FileSource.java b/src/main/java/net/pterodactylus/sonitus/data/source/FileSource.java index 2829a42..9aff8d4 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/source/FileSource.java +++ b/src/main/java/net/pterodactylus/sonitus/data/source/FileSource.java @@ -46,9 +46,6 @@ public class FileSource extends AbstractControlledComponent implements Source { /** The path of the file. */ private final String path; - /** The identified metadata of the file. */ - private final Metadata metadata; - /** The input stream. */ private InputStream fileInputStream; @@ -61,16 +58,17 @@ public class FileSource extends AbstractControlledComponent implements Source { * if the file can not be found, or an I/O error occurs */ public FileSource(String path) throws IOException { + super(path); this.path = checkNotNull(path, "path must not be null"); fileInputStream = new FileInputStream(path); /* identify file type. */ Optional identifyingInputStream = IdentifyingInputStream.create(new FileInputStream(path)); if (identifyingInputStream.isPresent()) { - metadata = identifyingInputStream.get().metadata(); + metadataUpdated(identifyingInputStream.get().metadata()); } else { /* fallback. */ - metadata = new Metadata().name(path); + metadataUpdated(new Metadata().name(path)); } } @@ -79,11 +77,6 @@ public class FileSource extends AbstractControlledComponent implements Source { // @Override - public String name() { - return path; - } - - @Override public List> controllers() { return Collections.emptyList(); } @@ -102,18 +95,13 @@ public class FileSource extends AbstractControlledComponent implements Source { return Arrays.copyOf(buffer, read); } - @Override - public Metadata metadata() { - return metadata; - } - // // OBJECT METHODS // @Override public String toString() { - return String.format("%s (%s)", path, metadata); + return String.format("%s (%s)", path, metadata()); } }