-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0c5744
commit f0317ba
Showing
5 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
engine/src/main/java/mscalc/engine/resource/JavaBundleResourceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package mscalc.engine.resource; | ||
|
||
import java.text.DecimalFormatSymbols; | ||
import java.util.Locale; | ||
import java.util.ResourceBundle; | ||
|
||
public class JavaBundleResourceProvider implements ResourceProvider { | ||
private final ResourceBundle bundle; | ||
private final DecimalFormatSymbols symbols; | ||
|
||
public JavaBundleResourceProvider() { | ||
var locale = Locale.US; | ||
|
||
this.bundle = ResourceBundle.getBundle("mscalc.engine.calc-engine", locale); | ||
this.symbols = new DecimalFormatSymbols(locale); | ||
} | ||
|
||
@Override | ||
public String getCEngineString(String id) { | ||
if (id.equals("sDecimal")) { | ||
return Character.toString(symbols.getDecimalSeparator()); | ||
} | ||
|
||
if (id.equals("sThousand")) { | ||
return Character.toString(symbols.getGroupingSeparator()); | ||
} | ||
|
||
if (id.equals("sGrouping")) | ||
{ | ||
// The following groupings are the onces that CalcEngine supports. | ||
// 0;0 0x000 - no grouping | ||
// 3;0 0x003 - group every 3 digits | ||
// 3;2;0 0x023 - group 1st 3 and then every 2 digits | ||
// 4;0 0x004 - group every 4 digits | ||
// 5;3;2;0 0x235 - group 5, then 3, then every 2 | ||
return "3;0"; // Currently hardcoded, TODO: Fix it, check LocalizationSettings in original Calc | ||
} | ||
|
||
return bundle.containsKey(id) ? bundle.getString(id) : ""; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
engine/src/main/java/mscalc/engine/resource/ResourceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package mscalc.engine.resource; | ||
|
||
public interface ResourceProvider { | ||
String getCEngineString(String id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package mscalc; | ||
|
||
import mscalc.engine.CCalcEngine; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class CCalcEngineTest { | ||
@Test | ||
public void foo() { | ||
CCalcEngine.OpCodeToString(100); | ||
} | ||
} |