## 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,45 ****
    --- 36,46 ----
      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,705 ****
          // Parsing routines
          //
          ////////////////////////////////////////////////////////////////////////////

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

    --- 696,706 ----
          // Parsing routines
          //
          ////////////////////////////////////////////////////////////////////////////

          ParsedValueImpl valueFor(String property, Term root) throws ParseException {
    !         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,857 ****
                  break;
              case CSSLexer.STRING:
              case CSSLexer.IDENT:
                  boolean isIdent = ttype == CSSLexer.IDENT;
                  final String str = stripQuotes(token.getText());
    !             final String text = str.toLowerCase();
                  if ("ladder".equals(text)) {
                      value = ladder(root);
                  } else if ("linear".equals(text)) {
                      value = linearGradient(root);
                  } else if ("radial".equals(text)) {
    --- 848,858 ----
                  break;
              case CSSLexer.STRING:
              case CSSLexer.IDENT:
                  boolean isIdent = ttype == CSSLexer.IDENT;
                  final String str = stripQuotes(token.getText());
    !             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,1412 ****
                  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();
              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;
    --- 1403,1413 ----
                  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(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,1536 ****
          // 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();
                  if ("repeat".equals(text)) {
                      cycleMethod = CycleMethod.REPEAT;
                  } else if ("reflect".equals(text)) {
                      cycleMethod = CycleMethod.REFLECT;
                  } else if ("no-cycle".equals(text)) {
    --- 1527,1537 ----
          // 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(Locale.ROOT);
                  if ("repeat".equals(text)) {
                      cycleMethod = CycleMethod.REPEAT;
                  } else if ("reflect".equals(text)) {
                      cycleMethod = CycleMethod.REFLECT;
                  } else if ("no-cycle".equals(text)) {
    *** 1730,1740 ****
                  int startX = 0;
                  int startY = 0;
                  int endX = 0;
                  int endY = 0;

    !             String sideOrCorner1 = arg.token.getText().toLowerCase();
                  // The keywords denote the direction.
                  if ("top".equals(sideOrCorner1)) {
                      // going toward the top, then start at the bottom
                      startY = 100;
                      endY = 0;
    --- 1731,1741 ----
                  int startX = 0;
                  int startY = 0;
                  int endX = 0;
                  int endY = 0;

    !             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,1773 ****
                      arg = arg.nextInSeries;
                      if (arg.token != null &&
                          arg.token.getType() == CSSLexer.IDENT &&
                          !arg.token.getText().isEmpty()) {

    !                     String sideOrCorner2 = arg.token.getText().toLowerCase();

                          // 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) {
    --- 1764,1774 ----
                      arg = arg.nextInSeries;
                      if (arg.token != null &&
                          arg.token.getType() == CSSLexer.IDENT &&
                          !arg.token.getText().isEmpty()) {

    !                     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,1899 ****
              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();
                  if ("focus-angle".equals(keyword)) {

                      prev = term;
                      if ((term = term.nextInSeries) == null) error(prev, "Expected \'<number>\'");
                      if (term.token == null) error(prev, "Expected \'<number>\'");
    --- 1890,1900 ----
              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(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,1916 ****
                  }
              }

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

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

              ParsedValueImpl<?,Size> focusDistance = null;
              if (term.token.getType() == CSSLexer.IDENT) {
    !             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,1933 ****
                  }
              }

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

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

              ParsedValueImpl<?,Size>[] centerPoint = null;
              if (term.token.getType() == CSSLexer.IDENT) {
    !             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,2557 ****
                          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();

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

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

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

    *** 2610,2622 ****
                          } 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();

                      if( ! isPositionKeyWord(v1) || "center".equals(v1) ) {
                          // 1 is horizontal
                          // means 2 & 3 are vertical
                          if( "center".equals(v1) ) {
    --- 2611,2623 ----
                          } else {
                              error(termTwo,"Expected 'top', 'bottom', 'center' or <size>");
                          }
                      }
                  } else if( valueOne != null && valueTwo != null && valueThree != null && valueFour == null ) {
    !                 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,2701 ****
                                  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();

                      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;
    --- 2689,2702 ----
                                  error(termThree,"Expected <size>");
                              }
                          }
                      }
                  } else {
    !                 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,2761 ****
              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();
              if ("repeat-x".equals(text)) {
                  xAxis = BackgroundRepeat.REPEAT;
                  yAxis = BackgroundRepeat.NO_REPEAT;
              } else if ("repeat-y".equals(text)) {
                  xAxis = BackgroundRepeat.NO_REPEAT;
    --- 2752,2762 ----
              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(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,2793 ****
                   term.token != null &&
                   term.token.getType() == CSSLexer.IDENT &&
                   term.token.getText() != null &&
                   !term.token.getText().isEmpty()) {

    !             text = term.token.getText().toLowerCase();
                  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)) {
    --- 2784,2794 ----
                   term.token != null &&
                   term.token.getType() == CSSLexer.IDENT &&
                   term.token.getText() != null &&
                   !term.token.getText().isEmpty()) {

    !             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,2863 ****
              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;

                  if ("auto".equals(text)) {
                      // We don't do anything because width / height are already initialized
                  } else if ("cover".equals(text)) {
                      cover = true;
    --- 2854,2864 ----
              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(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,2889 ****
              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;

                      if ("auto".equals(text)) {
                          height = null;
                      } else if ("cover".equals(text)) {
                          error(term, "Unexpected \'cover\'");
    --- 2880,2890 ----
              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(Locale.ROOT) : null;

                      if ("auto".equals(text)) {
                          height = null;
                      } else if ("cover".equals(text)) {
                          error(term, "Unexpected \'cover\'");
    *** 3000,3010 ****
                   term.token != null &&
                   term.token.getType() == CSSLexer.IDENT &&
                   term.token.getText() != null &&
                   !term.token.getText().isEmpty()) {

    !             return term.token.getText().toLowerCase();
              }
              return null;
          }

          //<border-style> [ , <border-style> ]*
    --- 3001,3011 ----
                   term.token != null &&
                   term.token.getType() == CSSLexer.IDENT &&
                   term.token.getText() != null &&
                   !term.token.getText().isEmpty()) {

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

          //<border-style> [ , <border-style> ]*
    *** 3140,3150 ****
              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();

              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
    --- 3141,3151 ----
              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(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,3457 ****
              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();
                  double value = -1;
                  if ("inherit".equals(ident)) {
                      value = 100;
                  } else if ("xx-small".equals(ident)) {
                      value = 60;
    --- 3448,3458 ----
              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(Locale.ROOT);
                  double value = -1;
                  if ("inherit".equals(ident)) {
                      value = 100;
                  } else if ("xx-small".equals(ident)) {
                      value = 60;
    *** 3495,3505 ****
              if (token == null ||
                  token.getType() != CSSLexer.IDENT ||
                  token.getText() == null ||
                  token.getText().isEmpty()) error(root, "Expected \'<font-style>\'");

    !         final String ident = token.getText().toLowerCase();
              String posture = FontPosture.REGULAR.name();

              if ("normal".equals(ident)) {
                  posture = FontPosture.REGULAR.name();
              } else if ("italic".equals(ident)) {
    --- 3496,3506 ----
              if (token == null ||
                  token.getType() != CSSLexer.IDENT ||
                  token.getText() == null ||
                  token.getText().isEmpty()) error(root, "Expected \'<font-style>\'");

    !         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,3532 ****
              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();
              String weight = FontWeight.NORMAL.name();

              if ("inherit".equals(ident)) {
                  weight = FontWeight.NORMAL.name();
              } else if ("normal".equals(ident)) {
    --- 3523,3533 ----
              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(Locale.ROOT);
              String weight = FontWeight.NORMAL.name();

              if ("inherit".equals(ident)) {
                  weight = FontWeight.NORMAL.name();
              } else if ("normal".equals(ident)) {
    *** 3570,3580 ****
                  (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());
              if ("inherit".equals(fam)) {
                  return new ParsedValueImpl<String,String>("inherit", StringConverter.getInstance());
              } else if ("serif".equals(fam) ||
                  "sans-serif".equals(fam) ||
                  "cursive".equals(fam) ||
    --- 3571,3581 ----
                  (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(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) ||