mirror of
https://github.com/corda/corda.git
synced 2025-01-21 03:55:00 +00:00
Merge remote-tracking branch 'github/master'
This commit is contained in:
commit
2687333a37
@ -72,12 +72,16 @@ public class File implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
private static String normalize(String path) {
|
||||
if ("\\".equals(FileSeparator)) {
|
||||
return path.replace('/', '\\');
|
||||
} else {
|
||||
return path;
|
||||
private static String stripSeparators(String p) {
|
||||
while (p.endsWith(FileSeparator)) {
|
||||
p = p.substring(0, p.length() - 1);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
private static String normalize(String path) {
|
||||
return stripSeparators
|
||||
("\\".equals(FileSeparator) ? path.replace('/', '\\') : path);
|
||||
}
|
||||
|
||||
public static native boolean rename(String old, String new_);
|
||||
@ -148,13 +152,9 @@ public class File implements Serializable {
|
||||
}
|
||||
|
||||
public String getParent() {
|
||||
String p = path;
|
||||
while (p.endsWith(FileSeparator)) {
|
||||
p = p.substring(0, p.length() - 1);
|
||||
}
|
||||
int index = p.lastIndexOf(FileSeparator);
|
||||
int index = path.lastIndexOf(FileSeparator);
|
||||
if (index >= 0) {
|
||||
return p.substring(0, index);
|
||||
return normalize(path.substring(0, index));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -28,8 +28,14 @@ public class MessageFormat extends Format {
|
||||
public StringBuffer format(Object[] args, StringBuffer target,
|
||||
FieldPosition p)
|
||||
{
|
||||
// todo
|
||||
return target.append(pattern);
|
||||
// todo: handle other format substitutions and escapes, and make
|
||||
// this more efficient:
|
||||
String result = pattern;
|
||||
int length = args.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
result = result.replace("{" + i + "}", String.valueOf(args[i]));
|
||||
}
|
||||
return target.append(result);
|
||||
}
|
||||
|
||||
public StringBuffer format(Object args, StringBuffer target, FieldPosition p)
|
||||
|
@ -139,5 +139,12 @@ public class Strings {
|
||||
|
||||
testDecode(false);
|
||||
testDecode(true);
|
||||
|
||||
expect
|
||||
(java.text.MessageFormat.format
|
||||
("{0} enjoy {1} {2}. do {4}? {4} do?",
|
||||
"I", "grape", "nuts", "foobar",
|
||||
new Object() { public String toString() { return "you"; } })
|
||||
.equals("I enjoy grape nuts. do you? you do?"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user