1
0
mirror of https://github.com/twiglet/cs2j.git synced 2025-01-18 13:15:17 +01:00

support for new String('x',5) === "xxxxx"

This commit is contained in:
Kevin Glynn 2010-07-14 15:51:49 -05:00
parent 749a91af39
commit f718a71970
2 changed files with 20 additions and 6 deletions

View File

@ -14,16 +14,19 @@
<Constructors>
<Constructor>
<Params>
<Param>
<Name>length</Name>
<Type>System.Int32</Type>
</Param>
<Param>
<Name>char</Name>
<Type>System.Char</Type>
</Param>
<Param>
<Name>length</Name>
<Type>System.Int32</Type>
</Param>
</Params>
<Java>new String(${length}, ${char}) /* FIX ME */</Java>
<Imports>
<Import>RusticiSoftware.System.StringSupport</Import>
</Imports>
<Java>StringSupport.mkString(${char}, ${length})</Java>
</Constructor>
<Constructor>
<Params>

View File

@ -338,6 +338,15 @@ public class StringSupport {
}
return index;
}
// in C# new String('x',50)
public static String mkString(char c, int count) {
char[] chars = new char[count];
for (int i = 0; i < count; i++) {
chars[i] = c;
}
return new String(chars);
}
public static void Testmain(String[] args)
{
@ -373,5 +382,7 @@ public class StringSupport {
splitFred = Split("=fred",'=');
System.out.println("Split(\"=fred\", '=') = [\"" + splitFred[0] + "\", \"" + splitFred[1] + "\"]");
}
}
}