mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Add missing import, support another format type
This commit is contained in:
parent
338c56e6ae
commit
c785f8985e
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
This file is
|
This file is
|
||||||
@ -28,7 +28,9 @@
|
|||||||
<Return>System.String</Return>
|
<Return>System.String</Return>
|
||||||
</Method>
|
</Method>
|
||||||
<Method>
|
<Method>
|
||||||
<Imports />
|
<Imports>
|
||||||
|
<Import>CS2JNet.System.IntegerSupport</Import>
|
||||||
|
</Imports>
|
||||||
<Java>IntegerSupport.mkString(${this}, ${str})</Java>
|
<Java>IntegerSupport.mkString(${this}, ${str})</Java>
|
||||||
<Params>
|
<Params>
|
||||||
<Param>
|
<Param>
|
||||||
@ -53,7 +55,7 @@
|
|||||||
</Method>
|
</Method>
|
||||||
<Method>
|
<Method>
|
||||||
<Imports>
|
<Imports>
|
||||||
<Import>CS2JNet.System.*</Import>
|
<Import>CS2JNet.System.IntegerSupport</Import>
|
||||||
</Imports>
|
</Imports>
|
||||||
<Java>IntegerSupport.parse(${str}, ${style})</Java>
|
<Java>IntegerSupport.parse(${str}, ${style})</Java>
|
||||||
<Params>
|
<Params>
|
||||||
|
@ -52,15 +52,32 @@ public class IntegerSupport {
|
|||||||
|
|
||||||
public static String mkString(int i, String style) throws NotImplementedException
|
public static String mkString(int i, String style) throws NotImplementedException
|
||||||
{
|
{
|
||||||
if (style.toLowerCase().equals("x")) {
|
if (style.toLowerCase().equals("x")) {
|
||||||
String retStr = Integer.toHexString(i);
|
String retStr = Integer.toHexString(i);
|
||||||
if (style.equals("X")) {
|
if (style.equals("X")) {
|
||||||
return retStr.toUpperCase();
|
return retStr.toUpperCase();
|
||||||
}
|
}
|
||||||
return retStr;
|
return retStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (style.toLowerCase().startsWith("d")) {
|
||||||
|
String width = "";
|
||||||
|
if (style.length() > 1)
|
||||||
|
width = "0" + String.valueOf(Integer.valueOf(style.substring(1)) + (i < 0 ? 1 : 0));
|
||||||
|
String fmt = "%0$"+width+"d";
|
||||||
|
String retStr = String.format(fmt, i);
|
||||||
|
return retStr;
|
||||||
|
}
|
||||||
|
|
||||||
throw new NotImplementedException("IntegerSupport.mkString does not support format string '" + style + "'");
|
throw new NotImplementedException("IntegerSupport.mkString does not support format string '" + style + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws NotImplementedException {
|
||||||
|
int integral = 8395;
|
||||||
|
System.out.printf("D: %0$s\n", mkString(integral, "D"));
|
||||||
|
System.out.printf("D: %0$s\n", mkString(integral, "D6"));
|
||||||
|
System.out.printf("D: %0$s\n", mkString(-integral, "D6"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user