Java Code Examples for org.w3c.css.sac.LexicalUnit#getLexicalUnitType()
The following examples show how to use
org.w3c.css.sac.LexicalUnit#getLexicalUnitType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextIndentReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public CSSValue createValue( StyleKey name, LexicalUnit value ) { CSSValue cssvalue = null; if ( value.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE ) { cssvalue = CSSNumericValue.createValue( CSSNumericType.PERCENTAGE, value.getFloatValue() ); } else { cssvalue = CSSValueFactory.createLengthValue( value ); } value = value.getNextLexicalUnit(); if ( value != null ) { if ( value.getLexicalUnitType() != LexicalUnit.SAC_IDENT ) { return null; } if ( value.getStringValue().equalsIgnoreCase( "hanging" ) ) { return new CSSValueList( new CSSValue[] { cssvalue, new CSSConstant( "hanging" ) } ); } else { return null; } } return new CSSValueList( new CSSValue[] { cssvalue } ); }
Example 2
Source File: DisplayReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Parses the LexicalUnit and returns a map of (StyleKey, CSSValue) pairs. * * @param unit * @return */ public Map createValues( LexicalUnit unit ) { if ( unit.getLexicalUnitType() != LexicalUnit.SAC_IDENT ) { return null; } final Map map = new HashMap(); final String key = unit.getStringValue().toLowerCase(); if ( key.equals( "none" ) ) { map.put( BoxStyleKeys.DISPLAY_ROLE, DisplayRole.NONE ); return map; } final DisplayMapEntry entry = (DisplayMapEntry) values.get( key ); if ( entry == null ) { return null; } map.put( BoxStyleKeys.DISPLAY_ROLE, entry.getRole() ); map.put( BoxStyleKeys.DISPLAY_MODEL, entry.getModel() ); return map; }
Example 3
Source File: ShortHandProcessor.java From birt with Eclipse Public License 1.0 | 6 votes |
protected String getBackgroundColor( String[] values, CSSEngine engine ) { for ( int i = 0; i < values.length; i++ ) { LexicalUnit u = getUnit( values[i], engine ); if ( u != null ) { if ( u.getLexicalUnitType( ) == LexicalUnit.SAC_RGBCOLOR ) { return values[i]; } else if ( u.getLexicalUnitType( ) == LexicalUnit.SAC_IDENT ) { if ( isIdentifier( values[i], IStyle.STYLE_COLOR, engine ) ) { return values[i]; } } } } return null; }
Example 4
Source File: CSSValueFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static CSSStringValue createUriValue( LexicalUnit value ) { if ( value.getLexicalUnitType() != LexicalUnit.SAC_URI ) { return null; } final String uri = value.getStringValue(); return new CSSStringValue( CSSStringType.URI, uri ); }
Example 5
Source File: ImageOrientationReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public CSSValue createValue( StyleKey name, LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) { String ident = value.getStringValue(); if ( ident.equalsIgnoreCase( "auto" ) ) { return CSSAutoValue.getInstance(); } return null; } if ( value.getLexicalUnitType() != LexicalUnit.SAC_DEGREE ) { return null; } return CSSNumericValue.createValue( CSSNumericType.DEG, value.getFloatValue() ); }
Example 6
Source File: BoxShadowReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public CSSValue createValue( StyleKey name, LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) { if ( value.getStringValue().equalsIgnoreCase( "none" ) ) { return new CSSConstant( "none" ); } return null; } // todo // box-shadows are not yet implemented. Hey, they are not // part of CSS2.1 so people *can* wait for that feature. return null; }
Example 7
Source File: PseudoclassReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected CSSValue parseValue( final LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_STRING_VALUE || value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) { return new CSSStringValue( CSSStringType.STRING, value.getStringValue() ); } return null; }
Example 8
Source File: DropInitialAfterAdjustReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected CSSValue lookupValue( final LexicalUnit value ) { CSSValue constant = super.lookupValue( value ); if ( constant != null ) { return constant; } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE ) { return CSSNumericValue.createValue( CSSNumericType.PERCENTAGE, value.getFloatValue() ); } return CSSValueFactory.createLengthValue( value ); }
Example 9
Source File: BorderWidthReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected CSSValue parseWidth( final LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) { if ( value.getStringValue().equalsIgnoreCase( "thin" ) ) { return BorderWidth.THIN; } if ( value.getStringValue().equalsIgnoreCase( "medium" ) ) { return BorderWidth.MEDIUM; } if ( value.getStringValue().equalsIgnoreCase( "thick" ) ) { return BorderWidth.THICK; } } return super.parseWidth( value ); }
Example 10
Source File: DropInitialBeforeAdjustReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected CSSValue lookupValue( final LexicalUnit value ) { CSSValue constant = super.lookupValue( value ); if ( constant != null ) { return constant; } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE ) { return CSSNumericValue.createValue( CSSNumericType.PERCENTAGE, value.getFloatValue() ); } return CSSValueFactory.createLengthValue( value ); }
Example 11
Source File: TextAlignReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected CSSValue lookupValue( final LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_STRING_VALUE ) { return new CSSStringValue( CSSStringType.STRING, value.getStringValue() ); } return super.lookupValue( value ); }
Example 12
Source File: ColumnGapReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public CSSValue createValue( StyleKey name, LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) { if ( value.getStringValue().equalsIgnoreCase( "auto" ) ) { return CSSAutoValue.getInstance(); } return null; } if ( value.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE ) { return CSSNumericValue.createValue( CSSNumericType.PERCENTAGE, value.getFloatValue() ); } return CSSValueFactory.createLengthValue( value ); }
Example 13
Source File: FontWeightManager.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}. */ public Value createValue(LexicalUnit lu, CSSEngine engine) throws DOMException { if (lu.getLexicalUnitType() == LexicalUnit.SAC_INTEGER) { int i = lu.getIntegerValue(); switch (i) { case 100: return CSSValueConstants.NUMBER_100; case 200: return CSSValueConstants.NUMBER_200; case 300: return CSSValueConstants.NUMBER_300; case 400: return CSSValueConstants.NUMBER_400; case 500: return CSSValueConstants.NUMBER_500; case 600: return CSSValueConstants.NUMBER_600; case 700: return CSSValueConstants.NUMBER_700; case 800: return CSSValueConstants.NUMBER_800; case 900: return CSSValueConstants.NUMBER_900; } throw createInvalidFloatValueDOMException(i); } return super.createValue(lu, engine); }
Example 14
Source File: BaselineShiftReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected CSSValue lookupValue( final LexicalUnit value ) { CSSValue constant = super.lookupValue( value ); if ( constant != null ) { return constant; } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE ) { return CSSNumericValue.createValue( CSSNumericType.PERCENTAGE, value.getFloatValue() ); } return CSSValueFactory.createLengthValue( value ); }
Example 15
Source File: TextKashidaSpaceReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public CSSValue createValue( StyleKey name, LexicalUnit value ) { if ( value.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE ) { return null; } return CSSNumericValue.createValue ( CSSNumericType.PERCENTAGE, value.getFloatValue() ); }
Example 16
Source File: InlineBoxAlignReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected CSSValue lookupValue( final LexicalUnit value ) { CSSValue constant = super.lookupValue( value ); if ( constant != null ) { return constant; } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_INTEGER ) { return CSSNumericValue.createValue( CSSNumericType.NUMBER, value.getIntegerValue() ); } return null; }
Example 17
Source File: CSSValue.java From birt with Eclipse Public License 1.0 | 4 votes |
public short getPrimitiveType( ) { if ( value instanceof LexicalUnit ) { LexicalUnit lu = (LexicalUnit) value; switch ( lu.getLexicalUnitType( ) ) { case LexicalUnit.SAC_INHERIT : return CSS_IDENT; case LexicalUnit.SAC_INTEGER : case LexicalUnit.SAC_REAL : return CSS_NUMBER; case LexicalUnit.SAC_EM : return CSS_EMS; case LexicalUnit.SAC_EX : return CSS_EXS; case LexicalUnit.SAC_PIXEL : return CSS_PX; case LexicalUnit.SAC_INCH : return CSS_IN; case LexicalUnit.SAC_CENTIMETER : return CSS_CM; case LexicalUnit.SAC_MILLIMETER : return CSS_MM; case LexicalUnit.SAC_POINT : return CSS_PT; case LexicalUnit.SAC_PICA : return CSS_PC; case LexicalUnit.SAC_PERCENTAGE : return CSS_PERCENTAGE; case LexicalUnit.SAC_URI : return CSS_URI; case LexicalUnit.SAC_DEGREE : return CSS_DEG; case LexicalUnit.SAC_GRADIAN : return CSS_GRAD; case LexicalUnit.SAC_RADIAN : return CSS_RAD; case LexicalUnit.SAC_MILLISECOND : return CSS_MS; case LexicalUnit.SAC_SECOND : return CSS_S; case LexicalUnit.SAC_HERTZ : return CSS_KHZ; case LexicalUnit.SAC_KILOHERTZ : return CSS_HZ; case LexicalUnit.SAC_IDENT : return CSS_IDENT; case LexicalUnit.SAC_STRING_VALUE : return CSS_STRING; case LexicalUnit.SAC_ATTR : return CSS_ATTR; case LexicalUnit.SAC_UNICODERANGE : case LexicalUnit.SAC_SUB_EXPRESSION : case LexicalUnit.SAC_FUNCTION : return CSS_STRING; case LexicalUnit.SAC_DIMENSION : return CSS_DIMENSION; } } return CSS_UNKNOWN; }
Example 18
Source File: TargetNameReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected CSSValue lookupValue( final LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_STRING_VALUE ) { return new CSSStringValue( CSSStringType.STRING, value.getStringValue() ); } return super.lookupValue( value ); }
Example 19
Source File: FontReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * Parses the LexicalUnit and returns a map of (StyleKey, CSSValue) pairs. * * @param unit * @return */ public Map createValues( LexicalUnit unit ) { // todo we ignore the font-family system font styles for now. CSSValue fontStyle = styleReadHandler.createValue( null, unit ); if ( fontStyle != null ) { unit = unit.getNextLexicalUnit(); if ( unit == null ) { return null; } } CSSValue fontVariant = variantReadHandler.createValue( null, unit ); if ( fontVariant != null ) { unit = unit.getNextLexicalUnit(); if ( unit == null ) { return null; } } CSSValue fontWeight = weightReadHandler.createValue( null, unit ); if ( fontWeight != null ) { unit = unit.getNextLexicalUnit(); if ( unit == null ) { return null; } } CSSValue fontSize = sizeReadHandler.createValue( null, unit ); if ( fontSize == null ) { return null; // required value is missing } unit = unit.getNextLexicalUnit(); if ( unit == null ) { return null; // font family missing } CSSValue lineHeight = null; if ( unit.getLexicalUnitType() == LexicalUnit.SAC_OPERATOR_SLASH ) { unit = unit.getNextLexicalUnit(); if ( unit == null ) { return null; } lineHeight = lineHeightReadHandler.createValue( null, unit ); if ( lineHeight == null ) { return null; // required sequence missing } unit = unit.getNextLexicalUnit(); if ( unit == null ) { return null; } } CSSValue fontFamily = fontFamilyReadHandler.createValue( null, unit ); if ( fontFamily == null ) { return null; // font family is required! } Map map = new HashMap(); map.put( FontStyleKeys.FONT_FAMILY, fontFamily ); map.put( FontStyleKeys.FONT_SIZE, fontSize ); if ( lineHeight != null ) { map.put( LineStyleKeys.LINE_HEIGHT, lineHeight ); } if ( fontWeight != null ) { map.put( FontStyleKeys.FONT_WEIGHT, fontWeight ); } if ( fontVariant != null ) { map.put( FontStyleKeys.FONT_VARIANT, fontVariant ); } if ( fontStyle != null ) { map.put( FontStyleKeys.FONT_STYLE, fontStyle ); } return map; }
Example 20
Source File: BackgroundRepeatReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public CSSValue createValue( StyleKey name, LexicalUnit value ) { ArrayList values = new ArrayList(); while ( value != null ) { if ( value.getLexicalUnitType() != LexicalUnit.SAC_IDENT ) { return null; } final CSSConstant horizontal; final CSSConstant vertical; final String horizontalString = value.getStringValue(); if ( horizontalString.equalsIgnoreCase( "repeat-x" ) ) { horizontal = BackgroundRepeat.REPEAT; vertical = BackgroundRepeat.NOREPEAT; } else if ( value.getStringValue().equalsIgnoreCase( "repeat-y" ) ) { horizontal = BackgroundRepeat.NOREPEAT; vertical = BackgroundRepeat.REPEAT; } else { horizontal = translateRepeat( horizontalString ); if ( horizontal == null ) { return null; } value = value.getNextLexicalUnit(); if ( value == null ) { vertical = horizontal; } else if ( value.getLexicalUnitType() != LexicalUnit.SAC_IDENT ) { return null; } else { vertical = translateRepeat( value.getStringValue() ); if ( vertical == null ) { return null; } } } values.add( new CSSValuePair( horizontal, vertical ) ); value = CSSValueFactory.parseComma( value ); } return new CSSValueList( values ); }