Search in sources :

Example 16 with LexicalUnit

use of com.gargoylesoftware.css.parser.LexicalUnit in project LoboEvolution by LoboEvolution.

the class CSSValueImpl method getCssText.

/**
 * <p>getCssText.</p>
 *
 * @return the css text
 */
public String getCssText() {
    if (getCssValueType() == CSSValueType.CSS_VALUE_LIST) {
        // Create the string from the LexicalUnits so we include the correct
        // operators in the string
        final StringBuilder sb = new StringBuilder();
        final List<?> list = (List<?>) value_;
        final Iterator<?> it = list.iterator();
        boolean separate = false;
        while (it.hasNext()) {
            final Object o = it.next();
            final CSSValueImpl cssValue = (CSSValueImpl) o;
            if (separate) {
                if (cssValue.value_ instanceof LexicalUnit) {
                    final LexicalUnit lu = (LexicalUnit) cssValue.value_;
                    if (lu.getLexicalUnitType() != LexicalUnitType.OPERATOR_COMMA) {
                        sb.append(" ");
                    }
                } else {
                    sb.append(" ");
                }
            }
            sb.append(o.toString());
            separate = true;
        }
        return sb.toString();
    }
    return value_ != null ? value_.toString() : "";
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) LexicalUnit(com.gargoylesoftware.css.parser.LexicalUnit)

Aggregations

LexicalUnit (com.gargoylesoftware.css.parser.LexicalUnit)16 CSSParseException (com.gargoylesoftware.css.parser.CSSParseException)9 Locator (com.gargoylesoftware.css.parser.Locator)2 ArrayList (java.util.ArrayList)2 CSSValueImpl (com.gargoylesoftware.css.dom.CSSValueImpl)1 Property (com.gargoylesoftware.css.dom.Property)1 LexicalUnitImpl (com.gargoylesoftware.css.parser.LexicalUnitImpl)1 List (java.util.List)1