break; case 1: val = cpv.getCssText(); break; case 2: if (ValueConstants.isNumber(cpv.getPrimitiveType())) { val = new Float(cpv.getFloatValue(cpv.getPrimitiveType())); } else { val = "";//actual.cssValue().getCssText();
protected void checkInheritAllowed(CSSPrimitiveValue value, boolean inheritAllowed) { if (value.getCssValueType() == CSSPrimitiveValue.CSS_INHERIT && ! inheritAllowed) { throw new CSSParseException("Invalid use of inherit", -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; }
protected boolean isLength(CSSPrimitiveValue value) { int unit = value.getPrimitiveType(); return unit == CSSPrimitiveValue.CSS_EMS || unit == CSSPrimitiveValue.CSS_EXS || unit == CSSPrimitiveValue.CSS_PX || unit == CSSPrimitiveValue.CSS_IN || unit == CSSPrimitiveValue.CSS_CM || unit == CSSPrimitiveValue.CSS_MM || unit == CSSPrimitiveValue.CSS_PT || unit == CSSPrimitiveValue.CSS_PC || (unit == CSSPrimitiveValue.CSS_NUMBER && value.getFloatValue(CSSPrimitiveValue.CSS_IN) == 0.0f); }
private boolean isBorderStyle(CSSPrimitiveValue value) { if (value.getPrimitiveType() != CSSPrimitiveValue.CSS_IDENT) { return false; } IdentValue ident = IdentValue.valueOf(value.getCssText()); if (ident == null) { return false; } return PrimitivePropertyBuilders.BORDER_STYLES.get(ident.FS_ID); }
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentOrURIType(cssName, value); if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { IdentValue ident = checkIdent(cssName, value); checkValidity(cssName, ALLOWED, ident); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentOrString(cssName, value); if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { // Convert to string return Collections.singletonList( new PropertyDeclaration( cssName, new PropertyValue( CSSPrimitiveValue.CSS_STRING, value.getStringValue(), value.getCssText()), important, origin)); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
private CSSPrimitiveValue convertToBorderColor(CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && type != CSSPrimitiveValue.CSS_RGBCOLOR) { return null; } if (type == CSSPrimitiveValue.CSS_RGBCOLOR) { return value; } else { FSRGBColor color = Conversions.getColor(value.getStringValue()); if (color != null) { return new PropertyValue(color); } IdentValue ident = IdentValue.valueOf(value.getCssText()); if (ident == null || ident != IdentValue.TRANSPARENT) { return null; } return value; } } }
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentType(cssName, value); if (! value.getStringValue().equals("auto")) { // Treat as string since it won't be a proper IdentValue value = new PropertyValue( CSSPrimitiveValue.CSS_STRING, value.getStringValue(), value.getCssText()); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
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); } }
@Override public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentOrIntegerType(cssName, value); if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { IdentValue ident = checkIdent(cssName, value); checkValidity(cssName, ALLOWED, ident); } else if (value.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) < 1) { throw new CSSParseException("column-count must be one or greater", -1); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentOrColorType(cssName, value); if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { FSRGBColor color = Conversions.getColor(value.getStringValue()); if (color != null) { return Collections.singletonList( new PropertyDeclaration( cssName, new PropertyValue(color), important, origin)); } IdentValue ident = checkIdent(cssName, value); checkValidity(cssName, ALLOWED, ident); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
private CSSPrimitiveValue convertToBorderWidth(CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && ! isLength(value)) { return null; } if (isLength(value)) { return value; } else { IdentValue ident = IdentValue.valueOf(value.getStringValue()); if (ident == null) { return null; } if (PrimitivePropertyBuilders.BORDER_WIDTHS.get(ident.FS_ID)) { return Conversions.getBorderWidth(ident.toString()); } else { return null; } } }
((CSSPrimitiveValue)values.get(0)).getCssValueType() == CSSPrimitiveValue.CSS_INHERIT) { CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); addAll(result, props[0], value, origin, important); throw new CSSParseException(value.getCssText() + " is not a border width, style, or color", -1);
public String getDeclarationStandardText() { return cssName + ": " + cssPrimitiveValue.getCssText() + ";"; }
private void checkNumberIsInteger(CSSName cssName, CSSPrimitiveValue value) { if ((int)value.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) != Math.round(value.getFloatValue(CSSPrimitiveValue.CSS_NUMBER))) { throw new CSSParseException("The value " + value.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) + " in " + cssName + " must be an integer", -1); } }
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentOrIntegerType(cssName, value); if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { IdentValue ident = checkIdent(cssName, value); checkValidity(cssName, ALLOWED, ident); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
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); } }
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); } }
/** * Description of the Method * * @return Returns */ public IdentValue asIdentValue() { if (!identIsSet) { _identVal = IdentValue.getByIdentString(cssPrimitiveValue.getCssText()); identIsSet = true; } return _identVal; }