public final class CSSColor

  1. Object
  2. CSSColor

Parses the CSS color forms into a packed 0xAARRGGBB integer: #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(...) / rgba(...) with integer or percentage components, and the CSS named-color subset.

This is the single home for CSS color-string parsing in the framework. The runtime CSS gradient parser and the vector map style engine both delegate here so the grammar – and the named-color table – lives in exactly one place.

Methods

public static int parse(String value)Parses a CSS color string into 0xAARRGGBB, throwing IllegalArgumentException when the value is not a recognised color so the caller can choose between a default and a propagated failure.
public static int parse(String value, int defaultColor)Parses a CSS color string into 0xAARRGGBB, returning defaultColor when the value is null or not a recognised color.

Inherited methods

Method details

parse

public static int parse(String value)
Parses a CSS color string into 0xAARRGGBB, throwing IllegalArgumentException when the value is not a recognised color so the caller can choose between a default and a propagated failure.

parse

public static int parse(String value, int defaultColor)
Parses a CSS color string into 0xAARRGGBB, returning defaultColor when the value is null or not a recognised color. The lenient variant for styling input that should degrade gracefully rather than fail.