/** * Creates a new Widths * * @param expression the unicode em * @exception InvalidParamException values are incorrect */ public Widths(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { CssValue val; char op; int i = 0; setByUser(); do { val = expression.getValue(); op = expression.getOperator(); if (val instanceof CssUnicodeRange) { values.addElement(val); if (op != SPACE) { throw new InvalidParamException("operator", new Character(op), getPropertyName(), ac); } if (expression.end()) { throw new InvalidParamException("few-value", getPropertyName(), ac); } expression.next(); } do { op = expression.getOperator(); val = expression.getValue(); if (val instanceof CssNumber) { values.addElement(" "); values.addElement(val); } else { throw new InvalidParamException("value", val, getPropertyName(), ac); } expression.next(); } while ((op == SPACE) && !expression.end()); values.addElement(", "); } while (op == CssOperator.COMMA); }
/** * Creates a new CssFontFamily * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontFamily(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { ArrayList<CssValue> values = new ArrayList<CssValue>(); while (!expression.end()) { char op = expression.getOperator(); CssValue val = expression.getValue(); switch (val.getType()) { case CssTypes.CSS_STRING: // check it's not a quoted reserved keyword String s = val.toString(); if (s.length() > 2) { // we remove quotes and check it's not reserved. CssIdent id = new CssIdent(s.substring(1, s.length() - 1)); if (getGenericFontName(id) != null) { ac.getFrame().addWarning("generic-family.quote", 2); } } values.add(val); break; case CssTypes.CSS_IDENT: ArrayList<CssIdent> idval = new ArrayList<CssIdent>(); idval.add((CssIdent) val); // we add idents if separated by spaces... while (op == SPACE && expression.getRemainingCount() > 1) { expression.next(); op = expression.getOperator(); val = expression.getValue(); if (val.getType() == CssTypes.CSS_IDENT) { idval.add((CssIdent) val); } else { throw new InvalidParamException("value", val, getPropertyName(), ac); } } checkExpression(ac, values, idval, check); break; default: throw new InvalidParamException("value", val, getPropertyName(), ac); } expression.next(); if (!expression.end() && (op != COMMA)) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } } checkValues(ac, values); value = (values.size() > 1) ? new CssLayerList(values) : values.get(0); }
/** * Creates a new CssSpeakNumeral * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssSpeakNumeral(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; char op; val = expression.getValue(); op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { CssIdent id = (CssIdent) val; if (inherit.equals(id)) { value = inherit; } else { value = getAllowedIdent(id); if (value == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } expression.next(); }
/** * Creates a new CssPitch * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssPitch(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; char op; val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_FREQUENCY: value = val; break; case CssTypes.CSS_IDENT: CssIdent id = (CssIdent) val; if (inherit.equals(id)) { value = inherit; break; } value = getAllowedIdent(id); if (value != null) { break; } default: throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } expression.next(); }
/** * Creates a new CssEnableBackground * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssEnableBackground(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val; char op; int nbCoord = 0; boolean got_new = false; ArrayList<CssValue> values = new ArrayList<>(); while (!expression.end()) { val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_NUMBER: nbCoord++; if (!got_new || nbCoord > 4) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } // <x> <y> <width> <height> where <width> and <height> >= 0 if (nbCoord > 2) { val.getCheckableValue().checkPositiveness(ac, this); } values.add(val); break; case CssTypes.CSS_IDENT: if (inherit.equals(val)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } value = inherit; break; } if (accumulate.equals(val)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } value = accumulate; break; } if (id_new.equals(val) && !got_new) { values.add(id_new); got_new = true; break; } default: throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } // both space and commas can happen... if (op != CssOperator.SPACE && op != CssOperator.COMMA) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } expression.next(); } if (!values.isEmpty()) { value = (values.size() == 1) ? values.get(0) : new CssValueList(values); } }
/** * Create a new Cursor * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public CssCursorCSS21(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { CssValue val = expression.getValue(); char op = expression.getOperator(); setByUser(); if (val.equals(inherit)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } setInheritedValue(true); expression.next(); return; } while ((op == COMMA) && (val instanceof CssURL)) { if (val != null && val.equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } getUris().addElement(val); expression.next(); val = expression.getValue(); op = expression.getOperator(); } if (val instanceof CssURL) { throw new InvalidParamException("comma", val.toString(), getPropertyName(), ac); } if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < CURSOR.length; i++) { if (hash_values[i] == hash) { setValue(i); expression.next(); if (check && !expression.end()) { throw new InvalidParamException("unrecognize", ac); } return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); }
/** * Creates a new CssCueAfter * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssCueAfter(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; char op; val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_URL: value = val; // now let's check for a volume... if (expression.getRemainingCount() > 1) { CssValue vnext = expression.getNextValue(); if (vnext.getType() == CssTypes.CSS_VOLUME) { // we got a volume, so let's do extra checks, then // construct the value... if (op != SPACE) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } expression.next(); ArrayList<CssValue> values = new ArrayList<CssValue>(2); values.add(val); values.add(vnext); value = new CssValueList(values); } else if (check) { throw new InvalidParamException("value", vnext, getPropertyName(), ac); } } break; case CssTypes.CSS_IDENT: if (inherit.equals(val)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", inherit, getPropertyName(), ac); } value = inherit; break; } if (none.equals(val)) { if (check && expression.getCount() > 1) { throw new InvalidParamException("value", inherit, getPropertyName(), ac); } value = none; break; } default: throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } expression.next(); }
/** * Create a new CssBackgroundClip * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Incorrect value */ public CssBackgroundOrigin(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { ArrayList<CssValue> values = new ArrayList<CssValue>(); CssValue val = expression.getValue(); char op; while (!expression.end()) { val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: if (inherit.equals(val)) { // if we got inherit after other values, fail // if we got more than one value... fail if ((values.size() > 0) || (expression.getCount() > 1)) { throw new InvalidParamException("value", val, getPropertyName(), ac); } values.add(inherit); break; } else if (border_box.equals(val)) { values.add(border_box); break; } else if (content_box.equals(val)) { values.add(content_box); break; } else if (padding_box.equals(val)) { values.add(padding_box); break; } default: throw new InvalidParamException("value", val, getPropertyName(), ac); } expression.next(); if (!expression.end() && (op != COMMA)) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } } if (values.size() == 1) { value = values.get(0); } else { value = new CssLayerList(values); } }
/** * Creates a new CssTransitionProperty * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTransitionProperty(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val; char op; ArrayList<CssValue> values = new ArrayList<CssValue>(); boolean singleVal = false; CssValue sValue = null; while (!expression.end()) { val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: if (inherit.equals(val)) { singleVal = true; sValue = inherit; values.add(inherit); } else { CssIdent ident = getAllowedIdent(ac, (CssIdent) val); if (ident == none) { singleVal = true; sValue = none; } values.add(ident); } break; default: throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } expression.next(); if (!expression.end() && (op != COMMA)) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } } if (singleVal && values.size() > 1) { throw new InvalidParamException("value", sValue.toString(), getPropertyName(), ac); } value = (values.size() == 1) ? values.get(0) : new CssLayerList(values); }
/** * Creates a new CssOutline * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssOutline(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 3) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; char op; _color = new CssOutlineColor(); _style = new CssOutlineStyle(); _width = new CssOutlineWidth(); while (!expression.end()) { val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_NUMBER: case CssTypes.CSS_LENGTH: if (_width.value == null) { CssExpression ex = new CssExpression(); ex.addValue(val); _width = new CssOutlineWidth(ac, ex, check); break; } // else, we already got one... throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); case CssTypes.CSS_HASH_IDENT: case CssTypes.CSS_COLOR: if (_color.value == null) { CssExpression ex = new CssExpression(); ex.addValue(val); _color = new CssOutlineColor(ac, ex, check); break; } // else, we already got one... throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); case CssTypes.CSS_IDENT: if (inherit.equals(val)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } value = inherit; break; } CssIdent ident = (CssIdent) val; // let's try to find which ident we have... if (_style.value == null) { CssIdent match = CssBorderStyle.getMatchingIdent(ident); if (match != null) { _style.value = match; break; } } if (_width.value == null) { CssIdent match = CssBorderWidth.getMatchingIdent(ident); if (match != null) { _width.value = match; break; } } if (_color.value == null) { CssIdent match = CssOutlineColor.getMatchingIdent(ident); if (match != null) { _color.value = match; break; } else { CssExpression ex = new CssExpression(); ex.addValue(val); _color = new CssOutlineColor(ac, ex, check); break; } } // unrecognized... fail default: throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } expression.next(); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); } } if (expression.getCount() == 1) { if (_width.value != null) { value = _width.value; } else if (_style.value != null) { value = _style.value; } else { value = _color.value; } } else { ArrayList<CssValue> values = new ArrayList<CssValue>(4); if (_width.value != null) { values.add(_width.value); } if (_style.value != null) { values.add(_style.value); } if (_color.value != null) { values.add(_color.value); } value = new CssValueList(values); } }
/** * Creates a new CssTextAlign * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextAlign(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val; char op; if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } CssString stringValue = null; CssIdent identValue = null; CssIdent endValue = null; while (!expression.end()) { val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_STRING: if (stringValue != null || endValue != null) { throw new InvalidParamException("value", val, getPropertyName(), ac); } stringValue = (CssString) val; if (stringValue.toString().length() != 3) { // TODO specific error (string length) throw new InvalidParamException("value", stringValue, getPropertyName(), ac); } break; case CssTypes.CSS_IDENT: CssIdent ident = (CssIdent) val; // ident, so inherit, or allowed value if (inherit.equals(val)) { value = inherit; if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } break; } if (stringValue != null) { identValue = getNonUniqueIdent(ident); // we got string, we can only get // non-unique values if (identValue != null) { break; } } else { // ok, so here we can have either values // and if we get two values, we need to // have start and end. if (identValue != null) { if (start.equals(identValue) && end.equals(ident)) { endValue = end; break; } // we have two ident values, let it fail // (through the default: in the case } else { identValue = getNonUniqueIdent(ident); if (identValue == null) { identValue = getUniqueIdent(ident); } if (identValue != null) { break; } } // unknown value, let it fail } default: throw new InvalidParamException("value", val, getPropertyName(), ac); } if (op != CssOperator.SPACE) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } expression.next(); } // now reconstruct the value if (value != inherit) { if (expression.getCount() == 1) { if (identValue != null) { value = identValue; } else if (stringValue != null) { value = stringValue; } // other case (endValue alone non-null) // can't happen } else { // sanity check... if (stringValue != null && identValue != null) { if (getUniqueIdent(identValue) != null) { // TODO specific error msg throw new InvalidParamException("value", identValue, getPropertyName(), ac); } } ArrayList<CssValue> v = new ArrayList<CssValue>(4); if (identValue != null) { v.add(identValue); } if (endValue != null) { v.add(endValue); } if (stringValue != null) { v.add(stringValue); } value = new CssValueList(v); } } }
/** * Create a new OutlineATSC * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public OutlineATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 3) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); char op = SPACE; boolean find = true; int max_values = 3; ac.getFrame().addWarning("atsc", val.toString()); if (val.equals(inherit)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } this.same = true; color = new OutlineColorATSC(ac, expression); width = new OutlineWidthATSC(); width.value = inherit; style = new OutlineStyleATSC(); style.value = OutlineStyleATSC.BORDERSTYLE.length - 1; return; } while (find && max_values-- > 0) { find = false; val = expression.getValue(); op = expression.getOperator(); if (val != null && val.equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } if (val == null) { break; } if (op != SPACE) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } if (style == null) { try { style = new OutlineStyleATSC(ac, expression); find = true; } catch (InvalidParamException e) { } } if (!find && color == null) { try { color = new OutlineColorATSC(ac, expression); find = true; } catch (InvalidParamException e) { } } if (!find && width == null) { width = new OutlineWidthATSC(ac, expression); find = true; } if (val != null && !find) { throw new InvalidParamException("unrecognize", ac); } } if (max_values >= 2) { throw new InvalidParamException("few-value", getPropertyName(), ac); } /* if (color == null) { color = new OutlineColorATSC(); } if (width == null) { width = new OutlineWidthATSC(); } if (style == null) { style = new OutlineStyleATSC(); } */ }
/** * Set the value of the property * * @param expression The expression for this property * @param check set it to true to check the number of values * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBorderWidth(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 4) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; char op; ArrayList<CssValue> res = new ArrayList<CssValue>(); while (res.size() < 4 && !expression.end()) { val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_NUMBER: val = ((CssNumber) val).getLength(); case CssTypes.CSS_LENGTH: CssLength length = (CssLength) val; if (!length.isPositive()) { throw new InvalidParamException( "negative-value", expression.getValue(), getPropertyName(), ac); } res.add(length); break; case CssTypes.CSS_IDENT: if (inherit.equals(val)) { res.add(inherit); break; } CssIdent match = getMatchingIdent((CssIdent) val); if (match == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } res.add(match); break; default: throw new InvalidParamException("unrecognize", ac); } expression.next(); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); } } // check that inherit is alone if (res.size() > 1 && res.contains(inherit)) { throw new InvalidParamException("unrecognize", ac); } value = (res.size() == 1) ? res.get(0) : new CssValueList(res); // now assign the computed values... top = new CssBorderTopWidth(); right = new CssBorderRightWidth(); bottom = new CssBorderBottomWidth(); left = new CssBorderLeftWidth(); switch (res.size()) { case 1: top.value = left.value = right.value = bottom.value = res.get(0); break; case 2: top.value = bottom.value = res.get(0); right.value = left.value = res.get(1); break; case 3: top.value = res.get(0); right.value = left.value = res.get(1); bottom.value = res.get(2); break; case 4: top.value = res.get(0); right.value = res.get(1); bottom.value = res.get(2); left.value = res.get(3); break; default: // can't happen throw new InvalidParamException("unrecognize", ac); } }
/** * Creates a new CssFontVariantNumeric * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontVariantNumeric(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 5) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; char op; CssIdent fraValue = null; CssIdent figValue = null; CssIdent spaValue = null; CssIdent zerValue = null; CssIdent ordValue = null; boolean match; while (!expression.end()) { val = expression.getValue(); op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { CssIdent ident = (CssIdent) val; if (inherit.equals(ident)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } value = inherit; } else if (normal.equals(ident)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } value = normal; } else { // no inherit, nor normal, test the up-to-three values match = false; if (figValue == null) { figValue = getNumericFigValues(ident); match = (figValue != null); } if (!match && fraValue == null) { fraValue = getNumericFraValues(ident); match = (fraValue != null); } if (!match && spaValue == null) { spaValue = getNumericSpaValues(ident); match = (spaValue != null); } if (!match && zerValue == null) { match = slashedZero.equals(ident); if (match) { zerValue = slashedZero; } } if (!match && ordValue == null) { match = ordinal.equals(ident); if (match) { ordValue = ordinal; } } if (!match) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } if (op != CssOperator.SPACE) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } expression.next(); } // now set the right value if (expression.getCount() == 1) { // the last test is here in case value is already set // (normal or inherit) if (figValue != null) { value = figValue; } else if (fraValue != null) { value = fraValue; } else if (spaValue != null) { value = spaValue; } else if (zerValue != null) { value = zerValue; } else if (ordValue != null) { value = ordValue; } } else { // do this to keep the same order for comparisons ArrayList<CssValue> v = new ArrayList<CssValue>(); if (figValue != null) { v.add(figValue); } if (fraValue != null) { v.add(fraValue); } if (spaValue != null) { v.add(spaValue); } if (zerValue != null) { v.add(zerValue); } if (ordValue != null) { v.add(ordValue); } value = new CssValueList(v); } }
/** * Creates a new CssTextDecoration * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextDecoration(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 4) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; char op; CssIdent undValue = null; CssIdent oveValue = null; CssIdent linValue = null; CssIdent bliValue = null; val = expression.getValue(); op = expression.getOperator(); if (val.getType() != CssTypes.CSS_IDENT) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } CssIdent ident = (CssIdent) val; if (none.equals(ident)) { value = none; if (check && expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } else { int nbgot = 0; do { if (undValue == null && underline.equals(ident)) { undValue = underline; } else if (oveValue == null && overline.equals(ident)) { oveValue = overline; } else if (linValue == null && line_through.equals(ident)) { linValue = line_through; } else if (bliValue == null && blink.equals(ident)) { bliValue = blink; } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } nbgot++; if (expression.getRemainingCount() == 1 || (!check && nbgot == 4)) { // if we have both, exit // (needed only if check == false... break; } if (op != CssOperator.SPACE) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } expression.next(); val = expression.getValue(); op = expression.getOperator(); if (val.getType() != CssTypes.CSS_IDENT) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } ident = (CssIdent) val; } while (!expression.end()); // now construct the value ArrayList<CssValue> v = new ArrayList<CssValue>(nbgot); if (undValue != null) { v.add(undValue); } if (oveValue != null) { v.add(oveValue); } if (linValue != null) { v.add(linValue); } if (bliValue != null) { v.add(bliValue); } value = (nbgot > 1) ? new CssValueList(v) : v.get(0); } expression.next(); }
/** * Creates a new CssVoiceVolume * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssVoiceVolume(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; char op; CssValue dbValue = null; CssValue ideValue = null; while (!expression.end()) { val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_VOLUME: if (dbValue != null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } dbValue = val; break; case CssTypes.CSS_IDENT: CssIdent id = (CssIdent) val; if (inherit.equals(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", inherit, getPropertyName(), ac); } value = inherit; break; } else if (silent.equals(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", silent, getPropertyName(), ac); } value = silent; break; } else { if (ideValue == null) { ideValue = getAllowedIdent(id); if (ideValue != null) { break; } } } default: throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } if (op != SPACE) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } expression.next(); } // now check what we have... if (value != inherit && value != silent) { ArrayList<CssValue> v = new ArrayList<CssValue>(2); if (ideValue != null) { v.add(ideValue); } if (dbValue != null) { v.add(dbValue); } value = (v.size() == 1) ? v.get(0) : new CssValueList(v); } }
/** * Create a new CssBorderATSC * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public CssBorderColorATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); switch (expression.getCount()) { case 1: /* CssValue val = expression.floatValue(); if (val.equals(transparent)) { top = new CssBorderTopColorATSC(); top.face.face = transparent; expression.next(); } else if (val.equals(inherit)) { top = new CssBorderTopColorATSC(); top.face.face = inherit; expression.next(); } else{*/ top = new CssBorderTopColorATSC(ac, expression); /*bottom = new CssBorderBottomColorATSC((CssBorderFaceColorATSC) top.get()); right = new CssBorderRightColorATSC((CssBorderFaceColorATSC) top.get()); left = new CssBorderLeftColorATSC((CssBorderFaceColorATSC) top.get());*/ break; case 2: if (expression.getOperator() != SPACE) throw new InvalidParamException( "operator", ((new Character(expression.getOperator())).toString()), ac); if (expression.getValue().equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } top = new CssBorderTopColorATSC(ac, expression); if (expression.getValue().equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } right = new CssBorderRightColorATSC(ac, expression); /*bottom = new CssBorderBottomColorATSC((CssBorderFaceColorATSC) top.get()); left = new CssBorderLeftColorATSC((CssBorderFaceColorATSC) right.get());*/ break; case 3: if (expression.getOperator() != SPACE) throw new InvalidParamException( "operator", ((new Character(expression.getOperator())).toString()), ac); if (expression.getValue().equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } top = new CssBorderTopColorATSC(ac, expression); if (expression.getOperator() != SPACE) throw new InvalidParamException( "operator", ((new Character(expression.getOperator())).toString()), ac); if (expression.getValue().equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } right = new CssBorderRightColorATSC(ac, expression); if (expression.getValue().equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } bottom = new CssBorderBottomColorATSC(ac, expression); // left = new CssBorderLeftColorATSC((CssBorderFaceColorATSC) right.get()); break; case 4: if (expression.getOperator() != SPACE) throw new InvalidParamException( "operator", ((new Character(expression.getOperator())).toString()), ac); if (expression.getValue().equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } top = new CssBorderTopColorATSC(ac, expression); if (expression.getOperator() != SPACE) throw new InvalidParamException( "operator", ((new Character(expression.getOperator())).toString()), ac); if (expression.getValue().equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } right = new CssBorderRightColorATSC(ac, expression); if (expression.getOperator() != SPACE) throw new InvalidParamException( "operator", ((new Character(expression.getOperator())).toString()), ac); if (expression.getValue().equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } bottom = new CssBorderBottomColorATSC(ac, expression); if (expression.getValue().equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } left = new CssBorderLeftColorATSC(ac, expression); break; default: if (check) { throw new InvalidParamException("unrecognize", ac); } } }