private void checkIdentPosition(CSSName cssName, IdentValue firstIdent, IdentValue secondIdent) { if (firstIdent == IdentValue.TOP || firstIdent == IdentValue.BOTTOM || secondIdent == IdentValue.LEFT || secondIdent == IdentValue.RIGHT) { throw new CSSParseException("Invalid combination of keywords in " + cssName, -1); } }
protected void checkValueCount(CSSName cssName, int min, int max, int found) { if (! (found >= min && found <= max)) { throw new CSSParseException("Found " + found + " value(s) for " + cssName + " when between " + min + " and " + max + " value(s) were expected", -1); } }
protected void checkValidity(CSSName cssName, BitSet validValues, IdentValue value) { if (! validValues.get(value.FS_ID)) { throw new CSSParseException("Ident " + value + " is an invalid or unsupported value for " + cssName, -1); } }
protected void checkLengthType(CSSName cssName, CSSPrimitiveValue value) { if (! isLength(value)) { throw new CSSParseException("Value for " + cssName + " must be a length", -1); } }
protected void checkInheritAllowed(CSSPrimitiveValue value, boolean inheritAllowed) { if (value.getCssValueType() == CSSPrimitiveValue.CSS_INHERIT && ! inheritAllowed) { throw new CSSParseException("Invalid use of inherit", -1); } }
protected void checkIdentType(CSSName cssName, CSSPrimitiveValue value) { if (value.getPrimitiveType() != CSSPrimitiveValue.CSS_IDENT) { throw new CSSParseException("Value for " + cssName + " must be an identifier", -1); } }
protected void checkIdentOrURIType(CSSName cssName, CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && type != CSSPrimitiveValue.CSS_URI) { throw new CSSParseException("Value for " + cssName + " must be an identifier or a URI", -1); } }
protected void checkIdentOrString(CSSName cssName, CSSPrimitiveValue value) { short type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_STRING && type != CSSPrimitiveValue.CSS_IDENT) { throw new CSSParseException("Value for " + cssName + " must be an identifier or string", -1); } }
protected void checkIdentOrColorType(CSSName cssName, CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && type != CSSPrimitiveValue.CSS_RGBCOLOR) { throw new CSSParseException("Value for " + cssName + " must be an identifier or a color", -1); } }
private FSCMYKColor createCMYKColorFromFunction(List params) { if (params.size() != 4) { throw new CSSParseException( "The cmyk() function must have exactly four parameters", getCurrentLine()); } float[] colorComponents = new float[4]; for (int i = 0; i < params.size(); i++) { colorComponents[i] = parseCMYKColorComponent((PropertyValue)params.get(i), (i+1)); //Warning on the truncation? } return new FSCMYKColor(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]); }
protected void checkIdentLengthOrPercentType(CSSName cssName, CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && ! isLength(value) && type != CSSPrimitiveValue.CSS_PERCENTAGE) { throw new CSSParseException("Value for " + cssName + " must be an identifier, length, or percentage", -1); } }
protected void checkLengthOrPercentType(CSSName cssName, CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (! isLength(value) && type != CSSPrimitiveValue.CSS_PERCENTAGE) { throw new CSSParseException("Value for " + cssName + " must be a length or percentage", -1); } }
protected void checkIdentOrLengthType(CSSName cssName, CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && ! isLength(value)) { throw new CSSParseException("Value for " + cssName + " must be an identifier or a length", -1); } }
protected void checkIdentLengthNumberOrPercentType(CSSName cssName, CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && ! isLength(value) && type != CSSPrimitiveValue.CSS_PERCENTAGE && type != CSSPrimitiveValue.CSS_NUMBER) { throw new CSSParseException("Value for " + cssName + " must be an identifier, length, or percentage", -1); } }
protected void checkInteger(CSSName cssName, CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_NUMBER || (type == CSSPrimitiveValue.CSS_NUMBER && (int)value.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) != Math.round(value.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)))) { throw new CSSParseException("Value for " + cssName + " must be an integer", -1); } }
protected void checkIdentOrIntegerType(CSSName cssName, CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if ((type != CSSPrimitiveValue.CSS_IDENT && type != CSSPrimitiveValue.CSS_NUMBER) || (type == CSSPrimitiveValue.CSS_NUMBER && (int)value.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) != Math.round(value.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)))) { throw new CSSParseException("Value for " + cssName + " must be an identifier or an integer", -1); } }
private void addPseudoElement(Token t, Selector selector) { String value = getTokenValue(t); if (SUPPORTED_PSEUDO_ELEMENTS.contains(value)) { selector.setPseudoElement(value); } else { throw new CSSParseException(value + " is not a recognized psuedo-element", getCurrentLine()); } }
protected void checkAngleType(CSSName cssName, CSSPrimitiveValue value) { if (value.getPrimitiveType() != CSSPrimitiveValue.CSS_DEG && value.getPrimitiveType() != CSSPrimitiveValue.CSS_RAD && value.getPrimitiveType() != CSSPrimitiveValue.CSS_GRAD) { throw new CSSParseException("Value for " + cssName + "must be an angle (degrees, radians or grads)", -1); } }
protected IdentValue checkIdent(CSSName cssName, CSSPrimitiveValue value) { IdentValue result = IdentValue.valueOf(value.getStringValue()); if (result == null) { throw new CSSParseException("Value " + value.getStringValue() + " is not a recognized identifier", -1); } ((PropertyValue)value).setIdentValue(result); return result; }
private void prio() throws IOException { //System.out.println("prio()"); Token t = next(); if (t == Token.TK_IMPORTANT_SYM) { skip_whitespace(); } else { push(t); throw new CSSParseException(t, Token.TK_IMPORTANT_SYM, getCurrentLine()); } }