mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
Added several useful classes
This commit is contained in:
parent
bd6f2913c5
commit
c174ce34b6
25
classpath/java/io/ByteArrayInputStream.java
Normal file
25
classpath/java/io/ByteArrayInputStream.java
Normal file
@ -0,0 +1,25 @@
|
||||
package java.io;
|
||||
|
||||
public class ByteArrayInputStream extends InputStream {
|
||||
private final byte[] array;
|
||||
private int position;
|
||||
private final int length;
|
||||
|
||||
public ByteArrayInputStream(byte[] array, int offset, int length) {
|
||||
this.array = array;
|
||||
position = offset;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public int read() {
|
||||
if (position < length) {
|
||||
return array[position++] & 0xff;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public int available() {
|
||||
returns length - position;
|
||||
}
|
||||
}
|
38
classpath/java/lang/Enum.java
Normal file
38
classpath/java/lang/Enum.java
Normal file
@ -0,0 +1,38 @@
|
||||
package java.lang;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public abstract class Enum<E extends Enum<E>> {
|
||||
private final String name;
|
||||
private final int ordinal;
|
||||
|
||||
public Enum(String name, int ordinal) {
|
||||
this.name = name;
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public int compareTo(E other) {
|
||||
return ordinal - other.ordinal;
|
||||
}
|
||||
|
||||
public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name) {
|
||||
if (name != null) {
|
||||
try {
|
||||
Method method = enumType.getMethod("values");
|
||||
Enum values[] = (Enum[])(method.invoke(null));
|
||||
for (Enum value : values) {
|
||||
if (name.equals(value.name)) {
|
||||
return (T) value;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return ordinal;
|
||||
}
|
||||
}
|
11
classpath/java/lang/IncompatibleClassChangeError.java
Normal file
11
classpath/java/lang/IncompatibleClassChangeError.java
Normal file
@ -0,0 +1,11 @@
|
||||
package java.lang;
|
||||
|
||||
public class IncompatibleClassChangeError extends LinkageError {
|
||||
public IncompatibleClassChangeError(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public IncompatibleClassChangeError() {
|
||||
super();
|
||||
}
|
||||
}
|
11
classpath/java/lang/NoSuchFieldError.java
Normal file
11
classpath/java/lang/NoSuchFieldError.java
Normal file
@ -0,0 +1,11 @@
|
||||
package java.lang;
|
||||
|
||||
public class NoSuchFieldError extends IncompatibleClassChangeError {
|
||||
public NoSuchFieldError(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public NoSuchFieldError() {
|
||||
super();
|
||||
}
|
||||
}
|
4
classpath/java/lang/annotation/Annotation.java
Normal file
4
classpath/java/lang/annotation/Annotation.java
Normal file
@ -0,0 +1,4 @@
|
||||
package java.lang.annotation;
|
||||
|
||||
public interface Annotation {
|
||||
}
|
5
classpath/java/util/Comparator.java
Normal file
5
classpath/java/util/Comparator.java
Normal file
@ -0,0 +1,5 @@
|
||||
package java.util;
|
||||
|
||||
public interface Comparator<T> {
|
||||
public int compare(T o1, T o2);
|
||||
}
|
17
classpath/java/util/Date.java
Normal file
17
classpath/java/util/Date.java
Normal file
@ -0,0 +1,17 @@
|
||||
package java.util;
|
||||
|
||||
public class Date {
|
||||
public final long when;
|
||||
|
||||
public Date() {
|
||||
when = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public Date(long when) {
|
||||
this.when = when;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return when;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user