@Override
    public ListStyle setCssValue(final String cssValue) {
        // NB: cssValue can contain upper case so it should not be converted to
        // lower case.
        final String trimmedCssValue;
        if (cssValue == null) {
            throw new NullValueException(
                    "null is an invalid value. The value format should be as for example cjk-ideographic inside url(\"Sqpurple.gif\"). Or, initial/inherit.");
        } else if ((trimmedCssValue = StringUtil.strip(cssValue)).isEmpty()) {
            throw new NullValueException(cssValue
                    + " is an invalid value. The value format should be as for example cjk-ideographic inside url(\"Sqpurple.gif\"). Or, initial/inherit.");
        }

        final String[] cssValueParts = StringUtil.splitBySpace(trimmedCssValue);

        if (cssValueParts.length > 1) {
            if (trimmedCssValue.contains(ListStyleImage.INITIAL)) {
                throw new InvalidValueException(
                        "The string 'initial' makes the given cssValue invalid, please remove 'initial' from it and try.");
            }
            if (trimmedCssValue.contains(ListStyleImage.INHERIT)) {
                throw new InvalidValueException(
                        "The string 'inherit' makes the given cssValue invalid, please remove 'inherit' from it and try.");
            }
        } else {
            if (PREDEFINED_CONSTANTS.contains(trimmedCssValue)) {
                listStyleType = null;
                listStylePosition = null;
                if (listStyleImage != null) {
                    listStyleImage.setAlreadyInUse(false);
                    listStyleImage = null;
                }

                this.cssValue = trimmedCssValue;
                if (getStateChangeInformer() != null) {
                    getStateChangeInformer().stateChanged(this);
                }
                return this;
            }
        }

        ListStyleType listStyleType = null;
        ListStylePosition listStylePosition = null;
        ListStyleImage listStyleImage = null;

        for (final String eachPart : cssValueParts) {
            if (listStyleType == null && ListStyleType.isValid(eachPart)) {
                listStyleType = ListStyleType.getThis(eachPart);
            } else if (listStylePosition == null
                    && ListStylePosition.isValid(eachPart)) {
                listStylePosition = ListStylePosition.getThis(eachPart);
            } else if (listStyleImage == null
                    && ListStyleImage.isValid(eachPart)) {
                if (this.listStyleImage == null) {
                    listStyleImage = new ListStyleImage(eachPart);
                    listStyleImage.setStateChangeInformer(this);
                    listStyleImage.setAlreadyInUse(true);
                } else {
                    this.listStyleImage.setCssValue(eachPart);
                    listStyleImage = this.listStyleImage;
                }
            } else {
                throw new InvalidValueException(cssValue
                        + " is an invalid value. The value format should be as for example cjk-ideographic inside url(\"Sqpurple.gif\"). Or, initial/inherit.");
            }
        }

        final StringBuilder cssValueBuilder = new StringBuilder();
        boolean invalid = true;
        if (listStyleType != null) {
            cssValueBuilder.append(listStyleType.getCssValue()).append(' ');
            invalid = false;
        }
        if (listStylePosition != null) {
            cssValueBuilder.append(listStylePosition.getCssValue()).append(' ');
            invalid = false;
        }
        if (listStyleImage != null) {
            cssValueBuilder.append(listStyleImage.getCssValue()).append(' ');
            invalid = false;
        }
        if (invalid) {
            throw new InvalidValueException(cssValue
                    + " is an invalid value. The value format should be as for example cjk-ideographic inside url(\"Sqpurple.gif\"). Or, initial/inherit.");
        }
        this.cssValue = StringBuilderUtil.getTrimmedString(cssValueBuilder);
        this.listStyleType = listStyleType;
        this.listStylePosition = listStylePosition;
        this.listStyleImage = listStyleImage;

        if (getStateChangeInformer() != null) {
            getStateChangeInformer().stateChanged(this);
        }

        return this;
    }
@ Override public ListStyle setCssValue ( final String cssValue ) { final String trimmedCssValue ; if ( cssValue == null ) { throw new NullValueException ( "null is an invalid value. The value format should be as for example cjk-ideographic inside url(\"Sqpurple.gif\"). Or, initial/inherit." ) ; } else if ( ( trimmedCssValue = StringUtil . strip ( cssValue ) ) . isEmpty ( ) ) { throw new NullValueException ( cssValue + " is an invalid value. The value format should be as for example cjk-ideographic inside url(\"Sqpurple.gif\"). Or, initial/inherit." ) ; } final String [ ] cssValueParts = StringUtil . splitBySpace ( trimmedCssValue ) ; if ( cssValueParts . length > 1 ) { if ( trimmedCssValue . contains ( ListStyleImage . INITIAL ) ) { throw new InvalidValueException ( "The string 'initial' makes the given cssValue invalid, please remove 'initial' from it and try." ) ; } if ( trimmedCssValue . contains ( ListStyleImage . INHERIT ) ) { throw new InvalidValueException ( "The string 'inherit' makes the given cssValue invalid, please remove 'inherit' from it and try." ) ; } } else { if ( PREDEFINED_CONSTANTS . contains ( trimmedCssValue ) ) { listStyleType = null ; listStylePosition = null ; if ( listStyleImage != null ) { listStyleImage . setAlreadyInUse ( false ) ; listStyleImage = null ; } this . cssValue = trimmedCssValue ; if ( getStateChangeInformer ( ) != null ) { getStateChangeInformer ( ) . stateChanged ( this ) ; } return this ; } } ListStyleType listStyleType = null ; ListStylePosition listStylePosition = null ; ListStyleImage listStyleImage = null ; for ( final String eachPart : cssValueParts ) { if ( listStyleType == null && ListStyleType . isValid ( eachPart ) ) { listStyleType = ListStyleType . getThis ( eachPart ) ; } else if ( listStylePosition == null && ListStylePosition . isValid ( eachPart ) ) { listStylePosition = ListStylePosition . getThis ( eachPart ) ; } else if ( listStyleImage == null && ListStyleImage . isValid ( eachPart ) ) { if ( this . listStyleImage == null ) { listStyleImage = new ListStyleImage ( eachPart ) ; listStyleImage . setStateChangeInformer ( this ) ; listStyleImage . setAlreadyInUse ( true ) ; } else { this . listStyleImage . setCssValue ( eachPart ) ; listStyleImage = this . listStyleImage ; } } else { throw new InvalidValueException ( cssValue + " is an invalid value. The value format should be as for example cjk-ideographic inside url(\"Sqpurple.gif\"). Or, initial/inherit." ) ; } } final StringBuilder cssValueBuilder = new StringBuilder ( ) ; boolean invalid = true ; if ( listStyleType != null ) { cssValueBuilder . append ( listStyleType . getCssValue ( ) ) . append ( ' ' ) ; invalid = false ; } if ( listStylePosition != null ) { cssValueBuilder . append ( listStylePosition . getCssValue ( ) ) . append ( ' ' ) ; invalid = false ; } if ( listStyleImage != null ) { cssValueBuilder . append ( listStyleImage . getCssValue ( ) ) . append ( ' ' ) ; invalid = false ; } if ( invalid ) { throw new InvalidValueException ( cssValue + " is an invalid value. The value format should be as for example cjk-ideographic inside url(\"Sqpurple.gif\"). Or, initial/inherit." ) ; } this . cssValue = StringBuilderUtil . getTrimmedString ( cssValueBuilder ) ; this . listStyleType = listStyleType ; this . listStylePosition = listStylePosition ; this . listStyleImage = listStyleImage ; if ( getStateChangeInformer ( ) != null ) { getStateChangeInformer ( ) . stateChanged ( this ) ; } return this ; }
@param cssValue
the value should be in the format of
<code>55px</code> or <code>95%</code>. {@code null}
is considered as an invalid value and it will throw
{@code NullValueException}.
@since 1.0.0
@author WFF