/** * Converts the current lexical unit to a dimension. */ protected LexicalUnit dimension(boolean positive, LexicalUnit prev) { try { float sgn = (positive) ? 1 : -1; String val = scanner.getStringValue(); int i; loop: for (i = 0; i < val.length(); i++) { switch (val.charAt(i)) { default: break loop; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': } } nextIgnoreSpaces(); return CSSLexicalUnit.createDimension (sgn * Float.parseFloat(val.substring(0, i)), val.substring(i), prev); } catch (NumberFormatException e) { throw createCSSParseException("number.format"); } }
/** * Converts the current lexical unit to a dimension. */ protected LexicalUnit dimension(boolean positive, LexicalUnit prev) { try { float sgn = (positive) ? 1 : -1; String val = scanner.getStringValue(); int i; loop: for (i = 0; i < val.length(); i++) { switch (val.charAt(i)) { default: break loop; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': } } nextIgnoreSpaces(); return CSSLexicalUnit.createDimension (sgn * Float.parseFloat(val.substring(0, i)), val.substring(i), prev); } catch (NumberFormatException e) { throw createCSSParseException("number.format"); } }
/** * Converts the current lexical unit to a dimension. */ protected LexicalUnit dimension(boolean positive, LexicalUnit prev) { try { float sgn = (positive) ? 1 : -1; String val = scanner.getStringValue(); int i; loop: for (i = 0; i < val.length(); i++) { switch (val.charAt(i)) { default: break loop; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': } } nextIgnoreSpaces(); return CSSLexicalUnit.createDimension (sgn * Float.parseFloat(val.substring(0, i)), val.substring(i), prev); } catch (NumberFormatException e) { throw createCSSParseException("number.format"); } }