示例#1
0
 /**
  * check if the value is strictly positive
  *
  * @param ac the validation context
  * @param property the property the value is defined in
  * @throws InvalidParamException
  */
 public void checkStrictPositiveness(ApplContext ac, CssProperty property)
     throws InvalidParamException {
   if (!isStrictlyPositive()) {
     throw new InvalidParamException(
         "strictly-positive", toString(), property.getPropertyName(), ac);
   }
 }
 /**
  * Update the source file and the line. Overrides this method for a macro
  *
  * @param line The line number where this property is defined
  * @param source The source file where this property is defined
  */
 public void setInfo(int line, String source) {
   super.setInfo(line, source);
   if (top != null) {
     top.setInfo(line, source);
   }
   if (right != null) {
     right.setInfo(line, source);
   }
   if (left != null) {
     left.setInfo(line, source);
   }
   if (bottom != null) {
     bottom.setInfo(line, source);
   }
 }
示例#3
0
 /**
  * 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;
 }
 /**
  * Set the context. Overrides this method for a macro
  *
  * @see org.w3c.css.css.CssCascadingOrder#order
  * @see org.w3c.css.css.StyleSheetParser#handleRule
  */
 public void setSelectors(CssSelectors selector) {
   super.setSelectors(selector);
   if (top != null) {
     top.setSelectors(selector);
   }
   if (right != null) {
     right.setSelectors(selector);
   }
   if (bottom != null) {
     bottom.setSelectors(selector);
   }
   if (left != null) {
     left.setSelectors(selector);
   }
 }
示例#5
0
 /**
  * check if the value is positive or null
  *
  * @param ac the validation context
  * @param property the property the value is defined in
  * @throws InvalidParamException
  */
 public void checkPositiveness(ApplContext ac, CssProperty property) throws InvalidParamException {
   if (!isPositive()) {
     throw new InvalidParamException("negative-value", toString(), property.getPropertyName(), ac);
   }
 }