Просмотр исходного кода

new "net.assira.io" - uniform I/O interfaces

Ranides Atterwim 10 лет назад
Родитель
Сommit
9ed331de72

+ 23 - 0
assira.drafts/src/main/java/net/ranides/assira/io/ByteReader.java

@@ -0,0 +1,23 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.io;
+
+import java.io.IOException;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface ByteReader extends RandomStream {
+    
+    byte readByte() throws IOException;
+    
+    void readBytes(byte[] target) throws IOException;
+    
+    void readBytes(byte[] target, int offset, int length) throws IOException;
+    
+}

+ 15 - 0
assira.drafts/src/main/java/net/ranides/assira/io/ByteStream.java

@@ -0,0 +1,15 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.io;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface ByteStream extends ByteReader, ByteWriter {
+    
+}

+ 22 - 0
assira.drafts/src/main/java/net/ranides/assira/io/ByteWriter.java

@@ -0,0 +1,22 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.io;
+
+import java.io.IOException;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface ByteWriter {
+ 
+    void writeByte(byte value) throws IOException;
+    
+    void writeBytes(byte[] value) throws IOException;
+    
+    void writeBytes(byte[] value, int offset, int length) throws IOException;
+}

+ 29 - 0
assira.drafts/src/main/java/net/ranides/assira/io/CharReader.java

@@ -0,0 +1,29 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.io;
+
+import java.io.IOException;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface CharReader {
+    
+    char readChar() throws IOException;
+    
+    void readChars(char[] target) throws IOException;
+    
+    void readChars(char[] target, int offset, int length) throws IOException;
+    
+    String readString() throws IOException;
+    
+    String readString(int length) throws IOException;
+    
+    String readLine() throws IOException;
+    
+}

+ 15 - 0
assira.drafts/src/main/java/net/ranides/assira/io/CharStream.java

@@ -0,0 +1,15 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.io;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface CharStream extends CharReader, CharWriter {
+    
+}

+ 26 - 0
assira.drafts/src/main/java/net/ranides/assira/io/CharWriter.java

@@ -0,0 +1,26 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.io;
+
+import java.io.IOException;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface CharWriter {
+    
+    void writeChar(char value) throws IOException;
+    
+    void writeChars(char[] value) throws IOException;
+    
+    void writeChars(char[] value, int offset, int length) throws IOException;
+    
+    void writeString(String value) throws IOException;
+    
+    void writeLine(String value) throws IOException;
+}

+ 29 - 0
assira.drafts/src/main/java/net/ranides/assira/io/DataReader.java

@@ -0,0 +1,29 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.io;
+
+import java.io.IOException;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface DataReader extends ByteReader, CharReader {
+    
+    boolean readBool() throws IOException;
+    
+    int readInt() throws IOException;
+    
+    short readShort() throws IOException;
+    
+    long readLong() throws IOException;
+    
+    float readFloat() throws IOException;
+    
+    double readDouble() throws IOException;
+    
+}

+ 15 - 0
assira.drafts/src/main/java/net/ranides/assira/io/DataStream.java

@@ -0,0 +1,15 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.io;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface DataStream extends DataReader, DataWriter {
+    
+}

+ 29 - 0
assira.drafts/src/main/java/net/ranides/assira/io/DataWriter.java

@@ -0,0 +1,29 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.io;
+
+import java.io.IOException;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface DataWriter extends ByteWriter, CharWriter {
+    
+    void writeBool(boolean value) throws IOException;
+    
+    void writeInt(int value) throws IOException;
+    
+    void writeShort(short value) throws IOException;
+    
+    void writeLong(long value) throws IOException;
+    
+    void writeFloat(float value) throws IOException;
+    
+    void writeDouble(double value) throws IOException;
+    
+}

+ 23 - 0
assira.drafts/src/main/java/net/ranides/assira/io/RandomStream.java

@@ -0,0 +1,23 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.io;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface RandomStream {
+    
+    long position(long position);
+    
+    long position();
+    
+    long skip(long count);
+    
+    long size();
+    
+}