CssUtils { public static BlendMode parseBlendMode(String cssValue) { if (cssValue == null) { return BlendMode.NORMAL; } switch (cssValue) { case CommonCssConstants.MULTIPLY: return BlendMode.MULTIPLY; case CommonCssConstants.SCREEN: return BlendMode.SCREEN; case CommonCssConstants.OVERLAY: return BlendMode.OVERLAY; case CommonCssConstants.DARKEN: return BlendMode.DARKEN; case CommonCssConstants.LIGHTEN: return BlendMode.LIGHTEN; case CommonCssConstants.COLOR_DODGE: return BlendMode.COLOR_DODGE; case CommonCssConstants.COLOR_BURN: return BlendMode.COLOR_BURN; case CommonCssConstants.HARD_LIGHT: return BlendMode.HARD_LIGHT; case CommonCssConstants.SOFT_LIGHT: return BlendMode.SOFT_LIGHT; case CommonCssConstants.DIFFERENCE: return BlendMode.DIFFERENCE; case CommonCssConstants.EXCLUSION: return BlendMode.EXCLUSION; case CommonCssConstants.HUE: return BlendMode.HUE; case CommonCssConstants.SATURATION: return BlendMode.SATURATION; case CommonCssConstants.COLOR: return BlendMode.COLOR; case CommonCssConstants.LUMINOSITY: return BlendMode.LUMINOSITY; case CommonCssConstants.NORMAL: default: return BlendMode.NORMAL; } } private  CssUtils(); static List<String> splitStringWithComma(final String value); static BlendMode parseBlendMode(String cssValue); static List<List<String>> extractShorthandProperties(String str); static String normalizeCssProperty(String str); static String removeDoubleSpacesAndTrim(String str); static Integer parseInteger(String str); static Float parseFloat(String str); static Double parseDouble(String str); static float parseAngle(String angle, String defaultMetric); static float parseAngle(String angle); static int[] parseAspectRatio(String str); static float parseAbsoluteLength(String length, String defaultMetric); static float parseAbsoluteLength(String length); static float parseRelativeValue(final String relativeValue, final float baseValue); static UnitValue parseLengthValueToPt(final String value, final float emValue, final float remValue); static boolean isValidNumericValue(final String value); static float parseAbsoluteFontSize(String fontSizeValue, String defaultMetric); static float parseAbsoluteFontSize(String fontSizeValue); static float parseRelativeFontSize(final String relativeFontSizeValue, final float baseValue); static UnitValue[] parseSpecificCornerBorderRadius(String specificBorderRadius, final float emValue, final float remValue); static float parseResolution(String resolutionStr); static int determinePositionBetweenValueAndUnit(String string); static boolean isMetricValue(final String value); static boolean isAngleValue(final String value); static boolean isRelativeValue(final String value); static boolean isFontRelativeValue(final String value); static boolean isPercentageValue(final String value); static boolean isRemValue(final String value); static boolean isEmValue(final String value); static boolean isExValue(final String value); static boolean isNumericValue(final String value); static String extractUrl(final String url); static boolean isBase64Data(String data); static int findNextUnescapedChar(String source, char ch, int startIndex); static boolean isColorProperty(String value); static boolean compareFloats(double d1, double d2); static boolean compareFloats(float f1, float f2); static float[] parseRgbaColor(String colorValue); static Range parseUnicodeRange(String unicodeRange); static float convertPtsToPx(float pts); static double convertPtsToPx(double pts); static float convertPxToPts(float px); static double convertPxToPts(double px); static boolean isStyleSheetLink(IElementNode headChildElement); static boolean isInitialOrInheritOrUnset(String value);  }
@Test public void parseBlendModeTest() { Assert.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode(null)); Assert.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode(CommonCssConstants.NORMAL)); Assert.assertEquals(BlendMode.MULTIPLY, CssUtils.parseBlendMode(CommonCssConstants.MULTIPLY)); Assert.assertEquals(BlendMode.SCREEN, CssUtils.parseBlendMode(CommonCssConstants.SCREEN)); Assert.assertEquals(BlendMode.OVERLAY, CssUtils.parseBlendMode(CommonCssConstants.OVERLAY)); Assert.assertEquals(BlendMode.DARKEN, CssUtils.parseBlendMode(CommonCssConstants.DARKEN)); Assert.assertEquals(BlendMode.LIGHTEN, CssUtils.parseBlendMode(CommonCssConstants.LIGHTEN)); Assert.assertEquals(BlendMode.COLOR_DODGE, CssUtils.parseBlendMode(CommonCssConstants.COLOR_DODGE)); Assert.assertEquals(BlendMode.COLOR_BURN, CssUtils.parseBlendMode(CommonCssConstants.COLOR_BURN)); Assert.assertEquals(BlendMode.HARD_LIGHT, CssUtils.parseBlendMode(CommonCssConstants.HARD_LIGHT)); Assert.assertEquals(BlendMode.SOFT_LIGHT, CssUtils.parseBlendMode(CommonCssConstants.SOFT_LIGHT)); Assert.assertEquals(BlendMode.DIFFERENCE, CssUtils.parseBlendMode(CommonCssConstants.DIFFERENCE)); Assert.assertEquals(BlendMode.EXCLUSION, CssUtils.parseBlendMode(CommonCssConstants.EXCLUSION)); Assert.assertEquals(BlendMode.HUE, CssUtils.parseBlendMode(CommonCssConstants.HUE)); Assert.assertEquals(BlendMode.SATURATION, CssUtils.parseBlendMode(CommonCssConstants.SATURATION)); Assert.assertEquals(BlendMode.COLOR, CssUtils.parseBlendMode(CommonCssConstants.COLOR)); Assert.assertEquals(BlendMode.LUMINOSITY, CssUtils.parseBlendMode(CommonCssConstants.LUMINOSITY)); Assert.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode("invalid")); Assert.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode("SCREEN")); }