Skip to content

Commit

Permalink
toLowerCase either needs hardcode text or use Locale.ROOT because of …
Browse files Browse the repository at this point in the history
…Locale (tr_TR) issues
  • Loading branch information
tbee committed May 14, 2023
1 parent 341e16b commit 39ab4d5
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 11 deletions.
12 changes: 11 additions & 1 deletion core/src/main/java/net/miginfocom/layout/AlignX.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package net.miginfocom.layout;

public enum AlignX {
LEADING, LEFT, CENTER, RIGHT, TRAILING;
LEADING("leading"), LEFT("left"), CENTER("center"), RIGHT("right"), TRAILING("trailing");

private final String code; // toString().toLowerCase() is not an alternative because of Locale issues (e.g. tr_TR)

private AlignX(String code) {
this.code = code;
}

public String code() {
return code;
}
}
12 changes: 11 additions & 1 deletion core/src/main/java/net/miginfocom/layout/AlignY.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package net.miginfocom.layout;

public enum AlignY {
TOP, CENTER, BOTTOM, BASELINE;
TOP("top"), CENTER("center"), BOTTOM("bottom"), BASELINE("baseline");

private final String code; // toString().toLowerCase() is not an alternative because of Locale issues (e.g. tr_TR)

private AlignY(String code) {
this.code = code;
}

public String code() {
return code;
}
}
4 changes: 2 additions & 2 deletions core/src/main/java/net/miginfocom/layout/CC.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public final CC alignX(String align)
* @return <code>this</code> so it is possible to chain calls.
*/
public final CC alignX(AlignX align) {
return alignX(align == null ? null : align.toString().toLowerCase());
return alignX(align == null ? null : align.code());
}

/** The grow priority compared to other components in the same cell.
Expand Down Expand Up @@ -523,7 +523,7 @@ public final CC alignY(String align)
*/
public final CC alignY(AlignY align)
{
return alignY(align == null ? null : align.toString().toLowerCase());
return alignY(align == null ? null : align.code());
}

/** The grow priority compared to other components in the same cell.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
/*
* License (BSD):
Expand Down Expand Up @@ -315,7 +316,7 @@ private static AC parseAxisConstraint(String s, boolean isCols)
if (s.length() == 0)
return new AC(); // Short circuit for performance.

s = s.toLowerCase();
s = s.toLowerCase(Locale.ROOT);

ArrayList<String> parts = getRowColAndGapsTrimmed(s);

Expand Down Expand Up @@ -1441,7 +1442,7 @@ private static ArrayList<String> getRowColAndGapsTrimmed(String s)
*/
public static String prepare(String s)
{
return s != null ? s.trim().toLowerCase() : "";
return s != null ? s.trim().toLowerCase(Locale.ROOT) : "";
}

// /** Tests to serialize and deserialize the object with both XMLEncoder/Decoder and through Serializable
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/net/miginfocom/layout/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ private void wrap(int[] cellXY, BoundSize gapSize)
private static void sortCellsByPlatform(Collection<Cell> cells, ContainerWrapper parent)
{
String order = PlatformDefaults.getButtonOrder();
String orderLo = order.toLowerCase();
String orderLo = order.toLowerCase(Locale.ROOT);

int unrelSize = PlatformDefaults.convertToPixels(1, "u", true, 0, parent, null);

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/net/miginfocom/layout/LC.java
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ public final LC alignX(String align)
* @return <code>this</code> so it is possible to chain calls.
*/
public final LC alignX(AlignX align) {
return alignX(align == null ? null : align.toString().toLowerCase());
return alignX(align == null ? null : align.code());
}

/** Same functionality as <code>setAlignY(ConstraintParser.parseUnitValueOrAlign(align, false))</code> only this method returns <code>this</code> for chaining multiple calls.
Expand All @@ -869,7 +869,7 @@ public final LC alignY(String align)
*/
public final LC alignY(AlignY align)
{
return alignY(align == null ? null : align.toString().toLowerCase());
return alignY(align == null ? null : align.code());
}

/** Sets both the alignX and alignY as the same time.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.miginfocom.layout;

import java.util.HashMap;
import java.util.Locale;

/*
* License (BSD):
Expand Down Expand Up @@ -529,7 +530,7 @@ public static UnitValue getUnitValueY(String unit)
public static void setUnitValue(String[] unitStrings, UnitValue x, UnitValue y)
{
for (String unitString : unitStrings) {
String s = unitString.toLowerCase().trim();
String s = unitString.toLowerCase(Locale.ROOT).trim();
if (x != null)
HOR_DEFS.put(s, x);
if (y != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.tbee.javafx.scene.layout.test;

import java.util.List;
import java.util.Locale;

import javafx.scene.Parent;
import javafx.scene.Scene;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void before() {
}

private boolean isUnix() {
String OS = System.getProperty("os.name").toLowerCase();
String OS = System.getProperty("os.name").toLowerCase(Locale.ROOT);
return (OS.contains("nix") || OS.contains("nux") || OS.contains("aix"));
}

Expand Down

0 comments on commit 39ab4d5

Please sign in to comment.