Cursor extends AbstractCssProperty<Cursor> implements StateChangeInformer<Bean> { @Override public Cursor setCssValue(final String cssValue) { if (cssValue == null) { throw new NullValueException("the value can not be null"); } final String trimmedCssValue = StringUtil.strip(cssValue); final int cssValueLength = trimmedCssValue.length(); if (cssValueLength > 0 && (trimmedCssValue.charAt(0) == ':' || trimmedCssValue.charAt(cssValueLength - 1) == ';')) { throw new InvalidValueException( "cssValue can not start with : (colon) or end with ; (semicolon)"); } final String[] cssValueParts = StringUtil.splitByComma(trimmedCssValue); final String cursorType = StringUtil .strip(cssValueParts[cssValueParts.length - 1]).toLowerCase(); if (!ALL_CURSORTYPES.contains(StringUtil.strip(cursorType))) { throw new InvalidValueException( "The last cursor should be the inbuild cursor like auto, default etc.."); } if (cssValueParts.length > 1) { final StringBuilder cssValueBuilder = new StringBuilder(); if (urlCss3Values == null) { urlCss3Values = new UrlCss3Value[cssValueParts.length - 1]; for (int i = 0; i < cssValueParts.length - 1; i++) { final UrlCss3Value urlCss3Value = new UrlCss3Value( cssValueParts[i]); urlCss3Value.setAlreadyInUse(true); urlCss3Value.setStateChangeInformer(this); urlCss3Values[i] = urlCss3Value; cssValueBuilder.append(urlCss3Value.getValue()) .append(", "); } } else { UrlCss3Value[] urlCss3ValuesTemp = null; if ((cssValueParts.length - 1) == urlCss3Values.length) { urlCss3ValuesTemp = urlCss3Values; } else { urlCss3ValuesTemp = new UrlCss3Value[cssValueParts.length - 1]; } for (int i = 0; i < cssValueParts.length - 1; i++) { final UrlCss3Value urlCss3Value; if (i < urlCss3Values.length) { urlCss3Value = urlCss3Values[i]; urlCss3Value.setUrlCssValue(cssValueParts[i]); } else { urlCss3Value = new UrlCss3Value(cssValueParts[i]); } urlCss3Value.setAlreadyInUse(true); urlCss3Value.setStateChangeInformer(this); urlCss3ValuesTemp[i] = urlCss3Value; cssValueBuilder.append(urlCss3Value.getValue()) .append(", "); } for (int i = cssValueParts.length - 1; i < urlCss3Values.length; i++) { urlCss3Values[i].setAlreadyInUse(false); } for (final UrlCss3Value urlCss3Value : urlCss3ValuesTemp) { urlCss3Value.setStateChangeInformer(this); urlCss3Value.setAlreadyInUse(true); } urlCss3Values = urlCss3ValuesTemp; } cssValueBuilder.append(cursorType); this.cssValue = cssValueBuilder.toString(); this.cursorType = cursorType; } else { this.cssValue = trimmedCssValue; this.cursorType = cursorType; } if (getStateChangeInformer() != null) { getStateChangeInformer().stateChanged(this); } return this; } Cursor();  Cursor(final String cssValue);  Cursor(final Cursor cursor);  Cursor(final String cursorType, final String... cursorUrls);  Cursor(final String cursorType,
            final UrlCss3Value... urlCss3Values); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); @Override Cursor setCssValue(final String cssValue); void setCursorType(final String cursorType); String getCursorType(); String[] getCursorUrls(); void setCursorUrls(final String cursorType,
            final String... cursorUrls); void setCursorUrls(final String cursorType,
            final UrlCss3Value... urlCss3Values); List<UrlCss3Value> getUrlCss3Values(); static String[] getAllCursorTypes(); @Override void stateChanged(final Bean stateChangedObject); static final String ALIAS; static final String ALL_SCROLL; static final String AUTO; static final String CELL; static final String CONTEXT_MENU; static final String COL_RESIZE; static final String COPY; static final String CROSSHAIR; static final String DEFAULT; static final String E_RESIZE; static final String EW_RESIZE; static final String GRAB; static final String GRABBING; static final String HELP; static final String MOVE; static final String N_RESIZE; static final String NE_RESIZE; static final String NESW_RESIZE; static final String NS_RESIZE; static final String NW_RESIZE; static final String NWSE_RESIZE; static final String NO_DROP; static final String NONE; static final String NOT_ALLOWED; static final String POINTER; static final String PROGRESS; static final String ROW_RESIZE; static final String S_RESIZE; static final String SE_RESIZE; static final String SW_RESIZE; static final String TEXT; static final String VERTICAL_TEXT; static final String W_RESIZE; static final String WAIT; static final String ZOOM_IN; static final String ZOOM_OUT; static final String INITIAL; static final String INHERIT; }
@Test public void testSetCssValue() { Cursor cursor = new Cursor(); String cssValue = "url(\"Test.png\") , url(sample) 7 8 , auto"; cursor.setCssValue(cssValue); assertEquals("cursor: url(\"Test.png\"), url(\"sample\") 7 8, auto", cursor.toString()); assertEquals(Cursor.AUTO, cursor.getCursorType()); List<UrlCss3Value> urlCss3ValuesFirst = cursor.getUrlCss3Values(); assertEquals(2, urlCss3ValuesFirst.size()); assertEquals("Test.png", urlCss3ValuesFirst.get(0).getUrl()); assertEquals("sample", urlCss3ValuesFirst.get(1).getUrl()); assertEquals(7, urlCss3ValuesFirst.get(1).getX()); assertEquals(8, urlCss3ValuesFirst.get(1).getY()); cssValue = "url(\"Another.png\") , url(yes.png) 7 8 , default"; cursor.setCssValue(cssValue); List<UrlCss3Value> urlCss3ValuesSecond = cursor.getUrlCss3Values(); assertFalse(urlCss3ValuesSecond == urlCss3ValuesFirst); cssValue = "url(\"No.png\") 77 98 , default"; cursor.setCssValue(cssValue); List<UrlCss3Value> urlCss3ValuesThird = cursor.getUrlCss3Values(); assertEquals(1, urlCss3ValuesThird.size()); assertEquals("No.png", urlCss3ValuesThird.get(0).getUrl()); assertEquals(77, urlCss3ValuesFirst.get(0).getX()); assertEquals(98, urlCss3ValuesFirst.get(0).getY()); assertFalse(Objects.equals(urlCss3ValuesSecond, urlCss3ValuesThird)); assertEquals(Cursor.DEFAULT, cursor.getCursorType()); }