@@ -35,6 +35,16 @@ private WidgetStyle() {
3535 // prevent instantiation of utility class
3636 }
3737
38+ /**
39+ * Check whether a given widget style contains the target style.
40+ *
41+ * @param widgetStyle
42+ * The style declaration to test, usually a comma-separated
43+ * {@code String}; trailing spaces are ignored.
44+ * @param target
45+ * The style being checked, case-insensitive.
46+ * @return {@code true} if the target style matches.
47+ */
3848 public static boolean isStyle (String widgetStyle , String target ) {
3949 if (widgetStyle == null || target == null )
4050 return widgetStyle == target ;
@@ -44,20 +54,62 @@ public static boolean isStyle(String widgetStyle, String target) {
4454 return false ;
4555 }
4656
57+ /**
58+ * Check whether a given {@link ModuleItem} has the target style.
59+ *
60+ * @param item
61+ * The module item to test.
62+ * @param target
63+ * The style being checked, case-insensitive.
64+ * @return {@code true} if the module item has the target style.
65+ */
4766 public static boolean isStyle (ModuleItem <?> item , String target ) {
4867 return isStyle (item .getWidgetStyle (), target );
4968 }
5069
51- public static String [] getStyleModifiers (String widgetStyle , String target ) {
70+ /**
71+ * Get the modifying value for a given style attribute in a style declaration.
72+ *
73+ * <p>
74+ * For example, for {@code style="format:#0.001"}, this will return
75+ * {@code "#0.001"}.
76+ * </p>
77+ *
78+ * @param widgetStyle
79+ * The style declaration string, e.g. <code>"format:#0.001"</code>.
80+ * @param target
81+ * The target style attribute, e.g. <code>"format"</code>.
82+ * @return The modifier for the given target, e.g. <code>"#0.001"</code>.
83+ */
84+ public static String getStyleModifier (String widgetStyle , String target ) {
5285 if (widgetStyle == null || target == null )
5386 return null ;
5487 String [] styles = widgetStyle .split ("," );
5588 for (String s : styles ) {
5689 if (s .trim ().toLowerCase ().startsWith (target .toLowerCase ())) {
57- String suffix = s .split (":" )[1 ];
58- return suffix .split ("/" );
90+ return s .split (":" )[1 ];
5991 }
6092 }
6193 return null ;
6294 }
95+
96+ /**
97+ * Get an array of all modifying values for a given style attribute.
98+ *
99+ * <p>
100+ * For example, for {@code style="extensions:png/gif/bmp"}, this will return {@code ["png", "gif", "bmp"]}.
101+ * </p>
102+ *
103+ * @param widgetStyle
104+ * The style declaration string, e.g. <code>"extensions:png/gif/bmp"</code>.
105+ * @param target
106+ * The target style attribute, e.g. <code>"extensions"</code>.
107+ * @return An array of modifiers for the given target, e.g. <code>["png", "gif", "bmp"]</code>.
108+ */
109+ public static String [] getStyleModifiers (String widgetStyle , String target ) {
110+ String suffix = getStyleModifier (widgetStyle , target );
111+ if (suffix == null ) return null ;
112+ return suffix .split ("/" );
113+ }
114+
63115}
0 commit comments