## modules/graphics/src/main/java/com/sun/javafx/css/parser/CSSParser.java

Print this page

    rev 4839 : RT-2529: Locale specific runtime errors (Turkish)

    @@ -36,10 +36,11 @@
     import java.text.MessageFormat;
     import java.util.ArrayList;
     import java.util.Collections;
     import java.util.HashMap;
     import java.util.List;
    +import java.util.Locale;
     import java.util.Map;
     import javafx.geometry.Insets;
     import javafx.scene.effect.BlurType;
     import javafx.scene.effect.Effect;
     import javafx.scene.layout.BackgroundPosition;

    @@ -695,11 +696,11 @@
         // Parsing routines
         //
         ////////////////////////////////////////////////////////////////////////////

         ParsedValueImpl valueFor(String property, Term root) throws ParseException {
    -        final String prop = property.toLowerCase();
    +        final String prop = property.toLowerCase(Locale.ROOT);
             properties.put(prop, prop);
             if (root == null || root.token == null) {
                 error(root, "Expected value for property \'" + prop + "\'");
             }

    @@ -847,11 +848,11 @@
                 break;
             case CSSLexer.STRING:
             case CSSLexer.IDENT:
                 boolean isIdent = ttype == CSSLexer.IDENT;
                 final String str = stripQuotes(token.getText());
    -            final String text = str.toLowerCase();
    +            final String text = str.toLowerCase(Locale.ROOT);
                 if ("ladder".equals(text)) {
                     value = ladder(root);
                 } else if ("linear".equals(text)) {
                     value = linearGradient(root);
                 } else if ("radial".equals(text)) {

    @@ -1402,11 +1403,11 @@
                 root.token.getText() == null ||
                 root.token.getText().isEmpty()) {
                 final String msg = "Expected \'gaussian\', \'one-pass-box\', \'two-pass-box\', or \'three-pass-box\'";
                 error(root, msg);
             }
    -        final String blurStr = root.token.getText().toLowerCase();
    +        final String blurStr = root.token.getText().toLowerCase(Locale.ROOT);
             BlurType blurType = BlurType.THREE_PASS_BOX;
             if ("gaussian".equals(blurStr)) {
                 blurType = BlurType.GAUSSIAN;
             } else if ("one-pass-box".equals(blurStr)) {
                 blurType = BlurType.ONE_PASS_BOX;

    @@ -1526,11 +1527,11 @@
         // returns null if the Term is null or is not a cycle method.
         private ParsedValueImpl<String, CycleMethod> cycleMethod(final Term root) {
             CycleMethod cycleMethod = null;
             if (root != null && root.token.getType() == CSSLexer.IDENT) {

    -            final String text = root.token.getText().toLowerCase();
    +            final String text = root.token.getText().toLowerCase(Locale.ROOT);
                 if ("repeat".equals(text)) {
                     cycleMethod = CycleMethod.REPEAT;
                 } else if ("reflect".equals(text)) {
                     cycleMethod = CycleMethod.REFLECT;
                 } else if ("no-cycle".equals(text)) {

    @@ -1730,11 +1731,11 @@
                 int startX = 0;
                 int startY = 0;
                 int endX = 0;
                 int endY = 0;

    -            String sideOrCorner1 = arg.token.getText().toLowerCase();
    +            String sideOrCorner1 = arg.token.getText().toLowerCase(Locale.ROOT);
                 // The keywords denote the direction.
                 if ("top".equals(sideOrCorner1)) {
                     // going toward the top, then start at the bottom
                     startY = 100;
                     endY = 0;

    @@ -1763,11 +1764,11 @@
                     arg = arg.nextInSeries;
                     if (arg.token != null &&
                         arg.token.getType() == CSSLexer.IDENT &&
                         !arg.token.getText().isEmpty()) {

    -                    String sideOrCorner2 = arg.token.getText().toLowerCase();
    +                    String sideOrCorner2 = arg.token.getText().toLowerCase(Locale.ROOT);

                         // if right or left has already been given,
                         // then either startX or endX will not be zero.
                         if ("right".equals(sideOrCorner2) &&
                             startX == 0 && endX == 0) {

    @@ -1889,11 +1890,11 @@
             if (term.token == null) error(term, "Expected \'focus-angle <number>\', \'focus-distance <number>\', \'center (<number>,<number>)\' or \'<size>\'");

             ParsedValueImpl<?,Size> focusAngle = null;
             if (term.token.getType() == CSSLexer.IDENT) {
    -            final String keyword = term.token.getText().toLowerCase();
    +            final String keyword = term.token.getText().toLowerCase(Locale.ROOT);
                 if ("focus-angle".equals(keyword)) {

                     prev = term;
                     if ((term = term.nextInSeries) == null) error(prev, "Expected \'<number>\'");
                     if (term.token == null) error(prev, "Expected \'<number>\'");

    @@ -1906,11 +1907,11 @@
                 }
             }

             ParsedValueImpl<?,Size> focusDistance = null;
             if (term.token.getType() == CSSLexer.IDENT) {
    -            final String keyword = term.token.getText().toLowerCase();
    +            final String keyword = term.token.getText().toLowerCase(Locale.ROOT);
                 if ("focus-distance".equals(keyword)) {

                     prev = term;
                     if ((term = term.nextInSeries) == null) error(prev, "Expected \'<number>\'");
                     if (term.token == null) error(prev, "Expected \'<number>\'");

    @@ -1923,11 +1924,11 @@
                 }
             }

             ParsedValueImpl<?,Size>[] centerPoint = null;
             if (term.token.getType() == CSSLexer.IDENT) {
    -            final String keyword = term.token.getText().toLowerCase();
    +            final String keyword = term.token.getText().toLowerCase(Locale.ROOT);
                 if ("center".equals(keyword)) {

                     prev = term;
                     if ((term = term.nextInSeries) == null) error(prev, "Expected \'(<number>,<number>)\'");
                     if (term.token == null ||

    @@ -2546,12 +2547,12 @@
                         top = ZERO_PERCENT;
                         bottom = ZERO_PERCENT;
                     }
                 } else if( valueOne != null && valueTwo != null && valueThree == null && valueFour == null ) {
                     // 2 values
    -                String v1 = valueOne.getText().toLowerCase();
    -                String v2 = valueTwo.getText().toLowerCase();
    +                String v1 = valueOne.getText().toLowerCase(Locale.ROOT);
    +                String v2 = valueTwo.getText().toLowerCase(Locale.ROOT);

                     if( ! isPositionKeyWord(v1) ) {
                         left = parseSize(termOne);
                         right = ZERO_PERCENT;

    @@ -2610,13 +2611,13 @@
                         } else {
                             error(termTwo,"Expected 'top', 'bottom', 'center' or <size>");
                         }
                     }
                 } else if( valueOne != null && valueTwo != null && valueThree != null && valueFour == null ) {
    -                String v1 = valueOne.getText().toLowerCase();
    -                String v2 = valueTwo.getText().toLowerCase();
    -                String v3 = valueThree.getText().toLowerCase();
    +                String v1 = valueOne.getText().toLowerCase(Locale.ROOT);
    +                String v2 = valueTwo.getText().toLowerCase(Locale.ROOT);
    +                String v3 = valueThree.getText().toLowerCase(Locale.ROOT);

                     if( ! isPositionKeyWord(v1) || "center".equals(v1) ) {
                         // 1 is horizontal
                         // means 2 & 3 are vertical
                         if( "center".equals(v1) ) {

    @@ -2688,14 +2689,14 @@
                                 error(termThree,"Expected <size>");
                             }
                         }
                     }
                 } else {
    -                String v1 = valueOne.getText().toLowerCase();
    -                String v2 = valueTwo.getText().toLowerCase();
    -                String v3 = valueThree.getText().toLowerCase();
    -                String v4 = valueFour.getText().toLowerCase();
    +                String v1 = valueOne.getText().toLowerCase(Locale.ROOT);
    +                String v2 = valueTwo.getText().toLowerCase(Locale.ROOT);
    +                String v3 = valueThree.getText().toLowerCase(Locale.ROOT);
    +                String v4 = valueFour.getText().toLowerCase(Locale.ROOT);

                     if( (v1.equals("left") || v1.equals("right")) && (v3.equals("top") || v3.equals("bottom") ) && ! isPositionKeyWord(v2) && ! isPositionKeyWord(v4) ) {
                         if( v1.equals("left") ) {
                             left = parseSize(termTwo);
                             right = ZERO_PERCENT;

    @@ -2751,11 +2752,11 @@
             if (term.token == null ||
                 term.token.getType() != CSSLexer.IDENT ||
                 term.token.getText() == null ||
                 term.token.getText().isEmpty()) error(term, "Expected \'<repeat-style>\'");

    -        String text = term.token.getText().toLowerCase();
    +        String text = term.token.getText().toLowerCase(Locale.ROOT);
             if ("repeat-x".equals(text)) {
                 xAxis = BackgroundRepeat.REPEAT;
                 yAxis = BackgroundRepeat.NO_REPEAT;
             } else if ("repeat-y".equals(text)) {
                 xAxis = BackgroundRepeat.NO_REPEAT;

    @@ -2783,11 +2784,11 @@
                  term.token != null &&
                  term.token.getType() == CSSLexer.IDENT &&
                  term.token.getText() != null &&
                  !term.token.getText().isEmpty()) {

    -            text = term.token.getText().toLowerCase();
    +            text = term.token.getText().toLowerCase(Locale.ROOT);
                 if ("repeat-x".equals(text)) {
                     error(term, "Unexpected \'repeat-x\'");
                 } else if ("repeat-y".equals(text)) {
                     error(term, "Unexpected \'repeat-y\'");
                 } else if ("repeat".equals(text)) {

    @@ -2853,11 +2854,11 @@
             Term term = root;
             if (term.token == null) error(term, "Expected \'<bg-size>\'");

             if (term.token.getType() == CSSLexer.IDENT) {
                 final String text =
    -                (term.token.getText() != null) ? term.token.getText().toLowerCase() : null;
    +                (term.token.getText() != null) ? term.token.getText().toLowerCase(Locale.ROOT) : null;

                 if ("auto".equals(text)) {
                     // We don't do anything because width / height are already initialized
                 } else if ("cover".equals(text)) {
                     cover = true;

    @@ -2879,11 +2880,11 @@
             if ((term = term.nextInSeries) != null) {
                 if (cover || contain) error(term, "Unexpected \'<bg-size>\'");

                 if (term.token.getType() == CSSLexer.IDENT) {
                     final String text =
    -                    (term.token.getText() != null) ? term.token.getText().toLowerCase() : null;
    +                    (term.token.getText() != null) ? term.token.getText().toLowerCase(Locale.ROOT) : null;

                     if ("auto".equals(text)) {
                         height = null;
                     } else if ("cover".equals(text)) {
                         error(term, "Unexpected \'cover\'");

    @@ -3000,11 +3001,11 @@
                  term.token != null &&
                  term.token.getType() == CSSLexer.IDENT &&
                  term.token.getText() != null &&
                  !term.token.getText().isEmpty()) {

    -            return term.token.getText().toLowerCase();
    +            return term.token.getText().toLowerCase(Locale.ROOT);
             }
             return null;
         }

         //<border-style> [ , <border-style> ]*

    @@ -3140,11 +3141,11 @@
             if (root.token == null ||
                 root.token.getType() != CSSLexer.IDENT ||
                 root.token.getText() == null ||
                 root.token.getText().isEmpty()) error(root, "Expected \'<border-style>\'");

    -        final String text = root.token.getText().toLowerCase();
    +        final String text = root.token.getText().toLowerCase(Locale.ROOT);

             if ("none".equals(text)) {
                 return BorderStyleConverter.NONE;
             } else if ("hidden".equals(text)) {
                 // The "hidden" mode doesn't make sense for FX, because it is the

    @@ -3447,11 +3448,11 @@
             final Token token = root.token;
             if (token == null || !isSize(token)) error(root, "Expected \'<font-size>\'");

             Size size = null;
             if (token.getType() == CSSLexer.IDENT) {
    -            final String ident = token.getText().toLowerCase();
    +            final String ident = token.getText().toLowerCase(Locale.ROOT);
                 double value = -1;
                 if ("inherit".equals(ident)) {
                     value = 100;
                 } else if ("xx-small".equals(ident)) {
                     value = 60;

    @@ -3495,11 +3496,11 @@
             if (token == null ||
                 token.getType() != CSSLexer.IDENT ||
                 token.getText() == null ||
                 token.getText().isEmpty()) error(root, "Expected \'<font-style>\'");

    -        final String ident = token.getText().toLowerCase();
    +        final String ident = token.getText().toLowerCase(Locale.ROOT);
             String posture = FontPosture.REGULAR.name();

             if ("normal".equals(ident)) {
                 posture = FontPosture.REGULAR.name();
             } else if ("italic".equals(ident)) {

    @@ -3522,11 +3523,11 @@
             final Token token = root.token;
             if (token == null ||
                 token.getText() == null ||
                 token.getText().isEmpty()) error(root, "Expected \'<font-weight>\'");

    -        final String ident = token.getText().toLowerCase();
    +        final String ident = token.getText().toLowerCase(Locale.ROOT);
             String weight = FontWeight.NORMAL.name();

             if ("inherit".equals(ident)) {
                 weight = FontWeight.NORMAL.name();
             } else if ("normal".equals(ident)) {

    @@ -3570,11 +3571,11 @@
                 (token.getType() != CSSLexer.IDENT &&
                  token.getType() != CSSLexer.STRING) ||
                 (text = token.getText()) == null ||
                 text.isEmpty()) error(root, "Expected \'<font-family>\'");

    -        final String fam = stripQuotes(text.toLowerCase());
    +        final String fam = stripQuotes(text.toLowerCase(Locale.ROOT));
             if ("inherit".equals(fam)) {
                 return new ParsedValueImpl<String,String>("inherit", StringConverter.getInstance());
             } else if ("serif".equals(fam) ||
                 "sans-serif".equals(fam) ||
                 "cursive".equals(fam) ||