X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2Fsource%2FFileSource.java;h=9aff8d401289cb9ed4644c83265b7e626a8acbb2;hb=cbeadf6d9eea57ab98cacd60e2419dd3c18bef89;hp=08139d588ef3b611f79aea259610e143d8f69bf8;hpb=9a5bbdb694cda8f4bc0794aea136b993399961dd;p=sonitus.git
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 08139d5..9aff8d4 100644
--- a/src/main/java/net/pterodactylus/sonitus/data/source/FileSource.java
+++ b/src/main/java/net/pterodactylus/sonitus/data/source/FileSource.java
@@ -27,6 +27,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import net.pterodactylus.sonitus.data.AbstractControlledComponent;
import net.pterodactylus.sonitus.data.Controller;
import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Source;
@@ -40,14 +41,11 @@ import com.google.common.base.Optional;
*
* @author David âBombeâ Roden
*/
-public class FileSource implements Source {
+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;
@@ -60,16 +58,17 @@ public class FileSource 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));
}
}
@@ -78,7 +77,7 @@ public class FileSource implements Source {
//
@Override
- public List controllers() {
+ public List> controllers() {
return Collections.emptyList();
}
@@ -96,18 +95,13 @@ public class FileSource 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());
}
}