From a66114cfea62e68be59ed8add114350d8328b30e Mon Sep 17 00:00:00 2001 From: Tefek <493msi@gmail.com> Date: Sun, 18 Oct 2020 00:43:58 +0200 Subject: [PATCH] [PlutoLib] Dropped dead IO util classes --- .../io/asl/resource/type/ResourceImage.java | 58 -------------- .../resource/type/ResourceInputStream.java | 40 ---------- .../cz/tefek/pluto/io/asl/textio/TextIn.java | 78 ------------------- .../cz/tefek/pluto/io/asl/textio/TextOut.java | 28 ------- .../cz/tefek/pluto/io/logger/Severity.java | 39 ---------- 5 files changed, 243 deletions(-) delete mode 100644 plutolib/src/main/java/cz/tefek/pluto/io/asl/resource/type/ResourceImage.java delete mode 100644 plutolib/src/main/java/cz/tefek/pluto/io/asl/resource/type/ResourceInputStream.java delete mode 100644 plutolib/src/main/java/cz/tefek/pluto/io/asl/textio/TextIn.java delete mode 100644 plutolib/src/main/java/cz/tefek/pluto/io/asl/textio/TextOut.java delete mode 100644 plutolib/src/main/java/cz/tefek/pluto/io/logger/Severity.java diff --git a/plutolib/src/main/java/cz/tefek/pluto/io/asl/resource/type/ResourceImage.java b/plutolib/src/main/java/cz/tefek/pluto/io/asl/resource/type/ResourceImage.java deleted file mode 100644 index 11e0c5c..0000000 --- a/plutolib/src/main/java/cz/tefek/pluto/io/asl/resource/type/ResourceImage.java +++ /dev/null @@ -1,58 +0,0 @@ -package cz.tefek.pluto.io.asl.resource.type; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; - -import cz.tefek.pluto.io.asl.resource.Resource; -import cz.tefek.pluto.io.asl.resource.ResourceAddress; -import cz.tefek.pluto.io.asl.resource.ResourceHelper; -import cz.tefek.pluto.io.logger.Logger; -import cz.tefek.pluto.io.logger.SmartSeverity; - -/** - * {@link ResourceAddress} in, {@link BufferedImage} out. - * - * @author 493msi - */ -public class ResourceImage extends Resource -{ - public ResourceImage(ResourceAddress raddress, boolean virtual) - { - super(raddress, virtual); - } - - public ResourceImage(ResourceAddress raddress) - { - super(raddress, false); - } - - @Override - public BufferedImage loadFromFile() - { - try - { - return ImageIO.read(new File(this.address.toPath())); - } - catch (IOException e) - { - Logger.log(SmartSeverity.ERROR, "Could not load BufferedImage: " + this.address.toString() + ", will load placeholder."); - Logger.log(e); - - try - { - return ImageIO.read(new File(ResourceHelper.GLOBAL_ROOT + "data/assets/err/missingTex.png")); - } - catch (IOException e1) - { - Logger.log(SmartSeverity.ERROR, "Placeholder BufferedImage not found: " + ResourceHelper.GLOBAL_ROOT + "data/assets/err/missingTex.png"); - Logger.log("This is not good! :C"); - - Logger.log(e1); - } - - return null; - } - } -} diff --git a/plutolib/src/main/java/cz/tefek/pluto/io/asl/resource/type/ResourceInputStream.java b/plutolib/src/main/java/cz/tefek/pluto/io/asl/resource/type/ResourceInputStream.java deleted file mode 100644 index eeed8dc..0000000 --- a/plutolib/src/main/java/cz/tefek/pluto/io/asl/resource/type/ResourceInputStream.java +++ /dev/null @@ -1,40 +0,0 @@ -package cz.tefek.pluto.io.asl.resource.type; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; - -import cz.tefek.pluto.io.asl.resource.Resource; -import cz.tefek.pluto.io.asl.resource.ResourceAddress; -import cz.tefek.pluto.io.logger.Logger; -import cz.tefek.pluto.io.logger.SmartSeverity; - -/** - * {@link ResourceAddress} in, {@link InputStream} out. - * - * @author 493msi - */ -public class ResourceInputStream extends Resource -{ - public ResourceInputStream(ResourceAddress raddress) - { - super(raddress, false); - } - - @Override - protected InputStream loadFromFile() - { - try - { - return Files.newInputStream(this.address.toNIOPath()); - } - catch (IOException e) - { - Logger.log(SmartSeverity.ERROR, "Failed to open " + this.address + "!"); - Logger.log(e); - } - - return null; - } - -} diff --git a/plutolib/src/main/java/cz/tefek/pluto/io/asl/textio/TextIn.java b/plutolib/src/main/java/cz/tefek/pluto/io/asl/textio/TextIn.java deleted file mode 100644 index 57f1a2c..0000000 --- a/plutolib/src/main/java/cz/tefek/pluto/io/asl/textio/TextIn.java +++ /dev/null @@ -1,78 +0,0 @@ -package cz.tefek.pluto.io.asl.textio; - -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import cz.tefek.pluto.io.asl.resource.ResourceAddress; -import cz.tefek.pluto.io.logger.Logger; - -/** - * A simple text file reader. Apart from generic methods of loading, you can use - * a {@link ResourceAddress}. For writing use {@link TextOut}. - * - * @author 493msi - */ -public class TextIn -{ - public static String load(URL url) - { - try - { - load(url.toURI()); - } - catch (URISyntaxException e) - { - Logger.log(e); - } - - return null; - } - - public static String load(URI uri) - { - try - { - return Files.readString(Paths.get(uri)); - } - catch (Exception e) - { - Logger.log(e); - } - - return null; - } - - public static String load(Path path) - { - try - { - return Files.readString(path); - } - catch (Exception e) - { - Logger.log(e); - } - - return null; - } - - public static String loadInternal(String filename) - { - return load(TextIn.class.getResource("/" + filename)); - } - - public static String loadExternal(String filename) - { - return load(new File(filename).toURI()); - } - - public static String fromAddress(ResourceAddress address) - { - return load(address.toNIOPath()); - } -} diff --git a/plutolib/src/main/java/cz/tefek/pluto/io/asl/textio/TextOut.java b/plutolib/src/main/java/cz/tefek/pluto/io/asl/textio/TextOut.java deleted file mode 100644 index 8f47577..0000000 --- a/plutolib/src/main/java/cz/tefek/pluto/io/asl/textio/TextOut.java +++ /dev/null @@ -1,28 +0,0 @@ -package cz.tefek.pluto.io.asl.textio; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; - -/** - * Simplifies text writer creation. For reading use {@link TextIn}. - * - * @author 493msi - */ - -public class TextOut -{ - public static PrintStream createPrintStream(String filePath) throws IOException - { - PrintStream printstream = new PrintStream(createFOStream(filePath)); - - return printstream; - } - - public static FileOutputStream createFOStream(String filePath) throws IOException - { - FileOutputStream fos = new FileOutputStream(filePath); - - return fos; - } -} diff --git a/plutolib/src/main/java/cz/tefek/pluto/io/logger/Severity.java b/plutolib/src/main/java/cz/tefek/pluto/io/logger/Severity.java deleted file mode 100644 index 9fd47ba..0000000 --- a/plutolib/src/main/java/cz/tefek/pluto/io/logger/Severity.java +++ /dev/null @@ -1,39 +0,0 @@ -package cz.tefek.pluto.io.logger; - -/** - * Message severity. - * - * @author 493msi - * - * @deprecated Use {@link SmartSeverity} instead. - */ -@Deprecated -public enum Severity implements ISeverity -{ - INFO("[INFO] ", false), - WARNING("[WARNING] ", true), - ERROR("[ERROR] ", true), - EXCEPTION("[EXCEPTION] ", true), - NONE("", false); - - private String displayName; - private boolean usesStdErr; - - Severity(String name, boolean usesStdErr) - { - this.displayName = name; - this.usesStdErr = usesStdErr; - } - - @Override - public String getDisplayName() - { - return this.displayName; - } - - @Override - public boolean isStdErr() - { - return this.usesStdErr; - } -}