mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
classlib: Add nio's channel interfaces (#751)
- Add the basic java.nio.channels.Channel interfaces. - Add several nio exception types. - Add UncheckedIOException
This commit is contained in:
parent
010bb721f2
commit
6efade1b49
|
@ -0,0 +1,15 @@
|
|||
package org.teavm.classlib.java.io;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TUncheckedIOException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1645785175445590213L;
|
||||
|
||||
public TUncheckedIOException(IOException cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public TUncheckedIOException(String message, IOException cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.teavm.classlib.java.nio.channels;
|
||||
|
||||
public interface TByteChannel extends TReadableByteChannel, TWritableByteChannel {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.teavm.classlib.java.nio.channels;
|
||||
|
||||
import org.teavm.classlib.java.io.TCloseable;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface TChannel extends TCloseable {
|
||||
boolean isOpen();
|
||||
|
||||
void close() throws IOException;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.teavm.classlib.java.nio.channels;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TClosedChannelException extends IOException {
|
||||
private static final long serialVersionUID = 5928119801967419918L;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.teavm.classlib.java.nio.channels;
|
||||
|
||||
public class TNonReadableChannelException extends IllegalStateException {
|
||||
private static final long serialVersionUID = -2344456823086925506L;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.teavm.classlib.java.nio.channels;
|
||||
|
||||
public class TNonWritableChannelException extends IllegalStateException {
|
||||
private static final long serialVersionUID = -837317372114923332L;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.teavm.classlib.java.nio.channels;
|
||||
|
||||
import org.teavm.classlib.java.nio.TByteBuffer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface TReadableByteChannel extends TChannel {
|
||||
int read(TByteBuffer dst) throws IOException;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.teavm.classlib.java.nio.channels;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface TSeekableByteChannel extends TByteChannel {
|
||||
long position();
|
||||
|
||||
TSeekableByteChannel position(long newPosition) throws IOException;
|
||||
|
||||
long size() throws IOException;
|
||||
|
||||
TSeekableByteChannel truncate(long size) throws IOException;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.teavm.classlib.java.nio.channels;
|
||||
|
||||
import org.teavm.classlib.java.nio.TByteBuffer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface TWritableByteChannel extends TChannel {
|
||||
int write(TByteBuffer src) throws IOException;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.teavm.classlib.java.nio.file;
|
||||
|
||||
public class TAccessDeniedException extends TFileSystemException {
|
||||
private static final long serialVersionUID = 6428707745039365878L;
|
||||
|
||||
public TAccessDeniedException(String file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
public TAccessDeniedException(String file, String other, String reason) {
|
||||
super(file, other, reason);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package org.teavm.classlib.java.nio.file;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TFileSystemException extends IOException {
|
||||
private static final long serialVersionUID = 9093298181737952280L;
|
||||
|
||||
private final String file;
|
||||
private final String other;
|
||||
private final String reason;
|
||||
|
||||
public TFileSystemException(String file) {
|
||||
this.file = file;
|
||||
this.other = null;
|
||||
this.reason = null;
|
||||
}
|
||||
|
||||
public TFileSystemException(String file, String other, String reason) {
|
||||
super(reason);
|
||||
this.file = file;
|
||||
this.other = other;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public String getOtherFile() {
|
||||
return other;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
if (file == null && other == null) return reason;
|
||||
|
||||
StringBuilder out = new StringBuilder();
|
||||
if (file != null) out.append(file);
|
||||
if (other != null) out.append(" -> ").append(other);
|
||||
if (reason != null) out.append(": ").append(reason);
|
||||
return out.toString();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user