mirror of
https://github.com/corda/corda.git
synced 2025-01-22 20:38:05 +00:00
add additional methods and fields to class library
This commit is contained in:
parent
8e1ec5794f
commit
7dd9b96717
@ -21,6 +21,10 @@ public class ByteArrayInputStream extends InputStream {
|
|||||||
this.limit = offset + length;
|
this.limit = offset + length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ByteArrayInputStream(byte[] array) {
|
||||||
|
this(array, 0, array.length);
|
||||||
|
}
|
||||||
|
|
||||||
public int read() {
|
public int read() {
|
||||||
if (position < limit) {
|
if (position < limit) {
|
||||||
return array[position++] & 0xff;
|
return array[position++] & 0xff;
|
||||||
|
@ -52,5 +52,17 @@ public abstract class InputStream {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void mark(int limit) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() throws IOException {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean markSupported() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void close() throws IOException { }
|
public void close() throws IOException { }
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Character implements Comparable<Character> {
|
public final class Character implements Comparable<Character> {
|
||||||
|
public static final int MIN_RADIX = 2;
|
||||||
|
public static final int MAX_RADIX = 36;
|
||||||
|
|
||||||
public static final Class TYPE = Class.forCanonicalName("C");
|
public static final Class TYPE = Class.forCanonicalName("C");
|
||||||
|
|
||||||
private final char value;
|
private final char value;
|
||||||
@ -67,6 +70,23 @@ public final class Character implements Comparable<Character> {
|
|||||||
return c >= '0' && c <= '9';
|
return c >= '0' && c <= '9';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int digit(char c, int radix) {
|
||||||
|
int digit = 0;
|
||||||
|
if ((c >= '0') && (c <= '9')) {
|
||||||
|
digit = c - '0';
|
||||||
|
} else if ((c >= 'a') && (c <= 'z')) {
|
||||||
|
digit = c - 'a' + 10;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (digit < radix) {
|
||||||
|
return digit;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isLetter(char c) {
|
public static boolean isLetter(char c) {
|
||||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,10 @@ public final class Integer extends Number implements Comparable<Integer> {
|
|||||||
return Long.toString(((long) v) & 0xFFFFFFFFL, 16);
|
return Long.toString(((long) v) & 0xFFFFFFFFL, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String toBinaryString(int v) {
|
||||||
|
return Long.toString(((long) v) & 0xFFFFFFFFL, 2);
|
||||||
|
}
|
||||||
|
|
||||||
public byte byteValue() {
|
public byte byteValue() {
|
||||||
return (byte) value;
|
return (byte) value;
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,11 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Long extends Number implements Comparable<Long> {
|
public final class Long extends Number implements Comparable<Long> {
|
||||||
public static final Class TYPE = Class.forCanonicalName("J");
|
public static final Long MIN_VALUE = -9223372036854775808l;
|
||||||
public static final Long MAX_VALUE = 9223372036854775807l;
|
public static final Long MAX_VALUE = 9223372036854775807l;
|
||||||
|
|
||||||
|
public static final Class TYPE = Class.forCanonicalName("J");
|
||||||
|
|
||||||
private final long value;
|
private final long value;
|
||||||
|
|
||||||
public Long(long value) {
|
public Long(long value) {
|
||||||
@ -131,17 +133,14 @@ public final class Long extends Number implements Comparable<Long> {
|
|||||||
|
|
||||||
for (; i < s.length(); ++i) {
|
for (; i < s.length(); ++i) {
|
||||||
char c = s.charAt(i);
|
char c = s.charAt(i);
|
||||||
if (((c >= '0') && (c <= '9')) ||
|
int digit = Character.digit(c, radix);
|
||||||
((c >= 'a') && (c <= 'z'))) {
|
if (digit >= 0) {
|
||||||
long digit = ((c >= '0' && c <= '9') ? (c - '0') : (c - 'a' + 10));
|
|
||||||
if (digit < radix) {
|
|
||||||
number += digit * pow(radix, (s.length() - i - 1));
|
number += digit * pow(radix, (s.length() - i - 1));
|
||||||
continue;
|
} else {
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new NumberFormatException("invalid character " + c + " code " +
|
throw new NumberFormatException("invalid character " + c + " code " +
|
||||||
(int) c);
|
(int) c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (negative) {
|
if (negative) {
|
||||||
number = -number;
|
number = -number;
|
||||||
|
@ -37,6 +37,10 @@ public class Vector<T> implements List<T> {
|
|||||||
list.add(index, element);
|
list.add(index, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void insertElementAt(T element, int index) {
|
||||||
|
add(index, element);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized boolean add(T element) {
|
public synchronized boolean add(T element) {
|
||||||
return list.add(element);
|
return list.add(element);
|
||||||
}
|
}
|
||||||
@ -57,6 +61,10 @@ public class Vector<T> implements List<T> {
|
|||||||
return list.set(index, value);
|
return list.set(index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T setElementAt(T value, int index) {
|
||||||
|
return set(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
public T elementAt(int index) {
|
public T elementAt(int index) {
|
||||||
return get(index);
|
return get(index);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user