/** * Create a new CssMaxWidthATSC * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public CssMaxWidthATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val.equals(inherit)) { value = inherit; } else if (val instanceof CssLength || val instanceof CssPercentage) { float f = ((Float) val.get()).floatValue(); if (f < 0) { throw new InvalidParamException("negative-value", val.toString(), ac); } value = val; } else if (val.equals(none)) { value = none; } else if (val instanceof CssNumber) { value = ((CssNumber) val).getLength(); } else { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } expression.next(); }
/** * Create a new CssVerticalAlignTV * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public CssVerticalAlignTV(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); int hash = val.hashCode(); setByUser(); if (val instanceof CssIdent) { for (int i = 0; i < VERTICALALIGNTV.length; i++) if (hash_values[i] == hash) { value = VERTICALALIGNTV[i]; expression.next(); return; } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } else if (val instanceof CssPercentage) { value = val; expression.next(); } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } }
/** * 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(); }
/** * Create a new Value * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public StrokeWidth(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { this.ac = ac; setByUser(); // tell this property is set by the user CssValue val = expression.getValue(); boolean correct = false; if (val.equals(inherit)) { value = inherit; expression.next(); correct = true; } else { try { CssWidth width = new CssWidth(ac, expression); value = val; expression.next(); correct = true; } catch (InvalidParamException e) { correct = false; } } if (!correct) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } }
/** * 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(); }
/** * Create a new MediaColorIndex. * * @param expression The expression for this media feature * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public MediaColorIndex(ApplContext ac, String modifier, CssExpression expression, boolean check) throws InvalidParamException { if (expression != null) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); // it must be a >=0 integer only if (val.getType() == CssTypes.CSS_NUMBER) { CssNumber valnum = (CssNumber) val; if (!valnum.isInteger()) { throw new InvalidParamException("integer", val.toString(), ac); } if (!valnum.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), ac); } value = valnum; } else { throw new InvalidParamException("unrecognize", ac); } setModifier(ac, modifier); } else { if (modifier != null) { throw new InvalidParamException("nomodifiershortmedia", getFeatureName(), ac); } } }
/** * Creates a new CssBaselineShift * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBaselineShift(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; val = expression.getValue(); switch (val.getType()) { case CssTypes.CSS_NUMBER: // zero is a valid length. otherwise it will fail. val.getCheckableValue().checkEqualsZero(ac, this); case CssTypes.CSS_LENGTH: case CssTypes.CSS_PERCENTAGE: 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; } // unrecognized ident -> fail. default: throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } }
/** * 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 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 CssBoxHeight * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public CssBoxHeight(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val = expression.getValue(); if (val.equals(auto)) { boxheight = auto; expression.next(); } else if (val.equals(inherit)) { boxheight = inherit; expression.next(); } else if (val.equals(initial)) { boxheight = initial; expression.next(); } else if (val instanceof CssLength) { boxheight = val; expression.next(); } else if (val instanceof CssPercentage) { boxheight = val; expression.next(); } else { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } }
/** * Create a new CssLineStackingStrategy * * @param expression The expression for this property * @exception InvalidParamException Incorrect value */ public CssLineStackingStrategy(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val = expression.getValue(); int i = 0; for (; i < values.length; i++) { if (val.toString().equals(values[i])) { strategy = val; expression.next(); break; } } if (i == values.length) { throw new InvalidParamException("value", val, getPropertyName(), ac); } }
/** * Create a new CssBorderTopStyle * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public CssBorderTopStyle(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } setByUser(); face = new CssBorderFaceStyle(ac, expression); }
/** * Create a new CssMarqueeRepetition * * @param expression The expression for this property * @exception InvalidParamException Incorrect values */ public CssMarqueeRepetition(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val = expression.getValue(); if (val.equals(infinite)) { mrep = infinite; expression.next(); } else if (val.equals(inherit)) { mrep = inherit; expression.next(); } else if (val instanceof CssNumber && ((CssNumber) val).isInteger()) { mrep = val; expression.next(); } else { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } }
/** * 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 CssFontStretch * * @param expression the font stretch * @exception InvalidParamException Values are incorrect */ public CssFontStretchCSS1(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } setByUser(); if (expression.getValue() instanceof CssIdent) { int hash = expression.getValue().hashCode(); for (int i = 0; i < hash_values.length; i++) if (hash_values[i] == hash) { value = i; expression.next(); return; } } throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); }
/** * 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 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 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); } }
/** * Check the border-*-width and returns a value. It makes sense to do it only once for all the * sides, so by having the code here. */ protected static CssValue checkBorderSideWidth( ApplContext ac, CssProperty caller, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue retval = null; CssValue val = expression.getValue(); 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(), caller.getPropertyName(), ac); } retval = length; break; case CssTypes.CSS_IDENT: if (inherit.equals(val)) { retval = inherit; } else { retval = getMatchingIdent((CssIdent) val); } if (retval == null) { throw new InvalidParamException( "value", expression.getValue(), caller.getPropertyName(), ac); } break; default: throw new InvalidParamException("unrecognize", ac); } expression.next(); return retval; }
/** * Create a new CssDirection * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssDirection(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); if (val.getType() != CssTypes.CSS_IDENT) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } if (val.equals(inherit)) { value = inherit; } else if (val.equals(ltr)) { value = ltr; } else if (val.equals(rtl)) { value = rtl; } else { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } expression.next(); }
/** * 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 CssVerticalAlign(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val = expression.getValue(); if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } switch (val.getType()) { case CssTypes.CSS_PERCENTAGE: value = val; break; case CssTypes.CSS_IDENT: val = getMatchingIdent((CssIdent) val); if (val != null) { value = val; break; } default: throw new InvalidParamException("value", val, getPropertyName(), ac); } expression.next(); }
/** * Create a new CssBorderTopRightFitLength * * @param expression The expression for this property * @exception InvalidParamException Incorrect value */ public CssBorderTopRightFitLength(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val = expression.getValue(); int i = 0; if (val instanceof CssIdent) { for (; i < values.length; i++) { if (val.toString().equals(values[i])) { value = val.toString(); expression.next(); break; } } if (i == values.length) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } } else { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } val = expression.getValue(); i = 0; if (val != null) { if (val instanceof CssIdent) { for (; i < values.length; i++) { if (val.toString().equals(values[i])) { value += " " + val.toString(); expression.next(); break; } } if (i == values.length) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } } else { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } } }
/** * 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); } }
/** * Create a new CssRubyPosition * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public CssRubyPosition(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val = expression.getValue(); if (val.equals(before)) { pos = before; expression.next(); } else if (val.equals(after)) { pos = after; expression.next(); } else if (val.equals(right)) { pos = right; expression.next(); } else if (val.equals(inline)) { pos = inline; expression.next(); } else if (val.equals(inherit)) { pos = inherit; expression.next(); } else { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } }
/** * 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 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 CssImeMode * * @param expression The expression for this property * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssImeMode(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { throw new InvalidParamException( "value", expression.getValue().toString(), getPropertyName(), ac); }
/** * 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); } }
/** * 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); } } }