private void error(CSSParseException e, String what, boolean rethrowEOF) { if (! e.isCallerNotified()) { String message = e.getMessage() + " Skipping " + what + "."; _errorHandler.error(_URI, message); } e.setCallerNotified(true); if (e.isEOF() && rethrowEOF) { throw e; } }
protected void checkInheritAllowed(CSSPrimitiveValue value, boolean inheritAllowed) { if (value.getCssValueType() == CSSPrimitiveValue.CSS_INHERIT && ! inheritAllowed) { throw new CSSParseException("Invalid use of inherit", -1); } }
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()); } }
public FSColor darkenColor() { float[] hsb = RGBtoHSB(getRed(), getGreen(), getBlue(), null); float hBase = hsb[0]; float sBase = hsb[1]; float bBase = hsb[2]; float hDarker = hBase; float sDarker = sBase; float bDarker = 0.56f*bBase; int[] rgb = HSBtoRGB(hDarker, sDarker, bDarker); return new FSRGBColor(rgb[0], rgb[1], rgb[2]); }
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 void operator() throws IOException { //System.out.println("operator()"); Token t = la(); switch (t.getType()) { case Token.VIRGULE: case Token.COMMA: next(); skip_whitespace(); break; } }
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 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; }
public String getMessage() { if (_genericMessage != null) { return _genericMessage + " at line " + (_line+1) + "."; } else { String found = _found == null ? "end of file" : _found.getExternalName(); return "Found " + found + " where " + descr(_expected) + " was expected at line " + (_line+1) + "."; } }
private static int [] zzUnpackAttribute() { int [] result = new int[518]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; }
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); } }
private String medium() throws IOException { //System.out.println("medium()"); String result = null; Token t = next(); if (t == Token.TK_IDENT) { result = getTokenValue(t); skip_whitespace(); } else { push(t); throw new CSSParseException(t, Token.TK_IDENT, getCurrentLine()); } return result; }
protected void checkIdentType(CSSName cssName, CSSPrimitiveValue value) { if (value.getPrimitiveType() != CSSPrimitiveValue.CSS_IDENT) { throw new CSSParseException("Value for " + cssName + " must be an identifier", -1); } }
private int unary_operator() throws IOException { //System.out.println("unary_operator()"); Token t = next(); if (! (t == Token.TK_MINUS || t == Token.TK_PLUS)) { push(t); throw new CSSParseException( t, new Token[] { Token.TK_MINUS, Token.TK_PLUS}, getCurrentLine()); } if (t == Token.TK_MINUS) { return -1; } else { /* t == Token.TK_PLUS */ return 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 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 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 checkIdentOrNumberType(CSSName cssName, CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && type != CSSPrimitiveValue.CSS_NUMBER) { throw new CSSParseException("Value for " + cssName + " must be an identifier or a length", -1); } }
protected void checkNumberType(CSSName cssName, CSSPrimitiveValue value) { if (value.getPrimitiveType() != CSSPrimitiveValue.CSS_NUMBER) { throw new CSSParseException("Value for " + cssName + " must be a number", -1); } }
protected void checkStringType(CSSName cssName, CSSPrimitiveValue value) { if (value.getPrimitiveType() != CSSPrimitiveValue.CSS_STRING) { throw new CSSParseException("Value for " + cssName + " must be a string", -1); } }