mirror of
https://github.com/corda/corda.git
synced 2025-06-19 07:38:22 +00:00
Added java.util.Formatter implementation. Basic/common formats work,
such as %s, %d, %x... also width, left justify, zerofill flags are implemented. Many of the other formats do not work, see the comments in avian.FormatString javadoc and look for FIXME and TODO items for more information on features that are known to not work correctly.
This commit is contained in:
@ -78,6 +78,25 @@ public class PrintStream extends OutputStream {
|
||||
print(String.valueOf(s));
|
||||
}
|
||||
|
||||
public synchronized void printf(java.util.Locale locale, String format, Object... args) {
|
||||
// should this be cached in an instance variable??
|
||||
final java.util.Formatter formatter = new java.util.Formatter(this);
|
||||
formatter.format(locale, format, args);
|
||||
}
|
||||
|
||||
public synchronized void printf(String format, Object... args) {
|
||||
final java.util.Formatter formatter = new java.util.Formatter(this);
|
||||
formatter.format(format, args);
|
||||
}
|
||||
|
||||
public void format(String format, Object... args) {
|
||||
printf(format, args);
|
||||
}
|
||||
|
||||
public void format(java.util.Locale locale, String format, Object... args) {
|
||||
printf(locale, format, args);
|
||||
}
|
||||
|
||||
public synchronized void println(String s) {
|
||||
try {
|
||||
out.write(s.getBytes());
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
package java.io;
|
||||
|
||||
public abstract class Writer implements Closeable, Flushable {
|
||||
public abstract class Writer implements Closeable, Flushable, Appendable {
|
||||
public void write(int c) throws IOException {
|
||||
char[] buffer = new char[] { (char) c };
|
||||
write(buffer);
|
||||
@ -33,6 +33,30 @@ public abstract class Writer implements Closeable, Flushable {
|
||||
public abstract void write(char[] buffer, int offset, int length)
|
||||
throws IOException;
|
||||
|
||||
public Appendable append(final char c) throws IOException {
|
||||
write((int)c);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Appendable append(final CharSequence sequence) throws IOException {
|
||||
return append(sequence, 0, sequence.length());
|
||||
}
|
||||
|
||||
public Appendable append(CharSequence sequence, int start, int end)
|
||||
throws IOException {
|
||||
final int length = end - start;
|
||||
if (sequence instanceof String) {
|
||||
write((String)sequence, start, length);
|
||||
} else {
|
||||
final char[] charArray = new char[length];
|
||||
for (int i = start; i < end; i++) {
|
||||
charArray[i] = sequence.charAt(i);
|
||||
}
|
||||
write(charArray, 0, length);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract void flush() throws IOException;
|
||||
|
||||
public abstract void close() throws IOException;
|
||||
|
Reference in New Issue
Block a user