Java Code Examples for org.w3c.css.sac.LexicalUnit#SAC_INTEGER
The following examples show how to use
org.w3c.css.sac.LexicalUnit#SAC_INTEGER .
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: AbstractColorManager.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates a color component from a lexical unit. */ protected Value createColorComponent( LexicalUnit lu ) throws DOMException { switch ( lu.getLexicalUnitType( ) ) { case LexicalUnit.SAC_INTEGER : return new FloatValue( CSSPrimitiveValue.CSS_NUMBER, lu .getIntegerValue( ) ); case LexicalUnit.SAC_REAL : return new FloatValue( CSSPrimitiveValue.CSS_NUMBER, lu .getFloatValue( ) ); case LexicalUnit.SAC_PERCENTAGE : return new FloatValue( CSSPrimitiveValue.CSS_PERCENTAGE, lu .getFloatValue( ) ); } throw createInvalidRGBComponentUnitDOMException( lu .getLexicalUnitType( ) ); }
Example 2
Source File: CSSValueFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static CSSNumericValue createNumericValue( LexicalUnit value ) { final short lexicalUnitType = value.getLexicalUnitType(); if ( lexicalUnitType == LexicalUnit.SAC_INTEGER ) { return CSSNumericValue.createValue( CSSNumericType.NUMBER, value.getIntegerValue() ); } if ( lexicalUnitType == LexicalUnit.SAC_REAL ) { return CSSNumericValue.createValue( CSSNumericType.NUMBER, value.getFloatValue() ); } return null; }
Example 3
Source File: XColSpanReadHandler.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_INTEGER ) { return CSSNumericValue.createValue( CSSNumericType.NUMBER, value.getIntegerValue() ); } return null; }
Example 4
Source File: XRowSpanReadHandler.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_INTEGER ) { return CSSNumericValue.createValue( CSSNumericType.NUMBER, value.getIntegerValue() ); } return null; }
Example 5
Source File: CounterModificationReadHandler.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 ) { return null; } final String mayBeNone = value.getStringValue(); if ( "none".equalsIgnoreCase( mayBeNone ) ) { return new CSSConstant( "none" ); } final ArrayList counterSpecs = new ArrayList(); while ( value != null ) { if ( value.getLexicalUnitType() != LexicalUnit.SAC_IDENT ) { return null; } final String identifier = value.getStringValue(); value = value.getNextLexicalUnit(); CSSValue counterValue = ZERO; if ( value != null ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_INTEGER ) { counterValue = CSSNumericValue.createValue ( CSSNumericType.NUMBER, value.getIntegerValue() ); value = value.getNextLexicalUnit(); } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_ATTR ) { counterValue = CSSValueFactory.parseAttrFunction( value ); value = value.getNextLexicalUnit(); } else if ( CSSValueFactory.isFunctionValue( value ) ) { counterValue = CSSValueFactory.parseFunction( value ); value = value.getNextLexicalUnit(); } } counterSpecs.add( new CSSValuePair ( new CSSConstant( identifier ), counterValue ) ); } return new CSSValueList( counterSpecs ); }
Example 6
Source File: ColumnSpanReadHandler.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" ); } if ( value.getStringValue().equalsIgnoreCase( "all" ) ) { return new CSSConstant( "all" ); } return null; } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_INTEGER ) { return CSSNumericValue.createValue( CSSNumericType.NUMBER, value.getIntegerValue() ); } return null; }
Example 7
Source File: ColumnCountReadHandler.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; } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_INTEGER ) { return CSSNumericValue.createValue( CSSNumericType.NUMBER, value.getIntegerValue() ); } return null; }
Example 8
Source File: DropInitialValueReadHandler.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 9
Source File: DropInitialSizeReadHandler.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() ); } if ( value.getLexicalUnitType() == LexicalUnit.SAC_INTEGER ) { return CSSNumericValue.createValue( CSSNumericType.NUMBER, value.getIntegerValue() ); } return CSSValueFactory.createLengthValue( value ); }
Example 10
Source File: OrphanAndWidowReadHandler.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_INTEGER ) { return CSSNumericValue.createValue( CSSNumericType.NUMBER, value.getIntegerValue() ); } return null; }
Example 11
Source File: CSSValueFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static CSSNumericValue createLengthValue( LexicalUnit value ) { final short lexicalUnitType = value.getLexicalUnitType(); if ( lexicalUnitType == LexicalUnit.SAC_INTEGER ) { if ( value.getFloatValue() != 0 ) { return null; } return CSSNumericValue.createValue( CSSNumericType.PT, 0 ); } if ( lexicalUnitType == LexicalUnit.SAC_EM ) { return CSSNumericValue.createValue( CSSNumericType.EM, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_EX ) { return CSSNumericValue.createValue( CSSNumericType.EX, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_PIXEL ) { return CSSNumericValue.createValue( CSSNumericType.PX, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_INCH ) { return CSSNumericValue.createValue( CSSNumericType.INCH, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_CENTIMETER ) { return CSSNumericValue.createValue( CSSNumericType.CM, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_MILLIMETER ) { return CSSNumericValue.createValue( CSSNumericType.MM, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_PICA ) { return CSSNumericValue.createValue( CSSNumericType.PC, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_POINT ) { return CSSNumericValue.createValue( CSSNumericType.PT, value.getFloatValue() ); } return null; }
Example 12
Source File: Measure.java From tm4e with Eclipse Public License 1.0 | 5 votes |
/** * Return a float representation of the receiver's value. * * @param valueType * a short representing the value type, see * {@link CSSValue#getCssValueType()} */ public float getFloatValue(short valueType) throws DOMException { // If it's actually a SAC_INTEGER return the integer value, callers tend // to expect and cast // There is no getIntegerFloat(short) // TODO Not sure the purpose of arg valyeType, its not referenced in // this method if (value.getLexicalUnitType() == LexicalUnit.SAC_INTEGER) return value.getIntegerValue(); // TODO not sure what to do if it's not one of the lexical unit types // that are specified in LexicalUnit#getFloatValue() // ie. SAC_DEGREE, SAC_GRADIAN, SAC_RADIAN, SAC_MILLISECOND, SAC_SECOND, // SAC_HERTZ or SAC_KILOHERTZ return value.getFloatValue(); }
Example 13
Source File: CSSValueFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static boolean isNumericValue( LexicalUnit value ) { final short lexicalUnitType = value.getLexicalUnitType(); if ( lexicalUnitType == LexicalUnit.SAC_INTEGER ) { return true; } else if ( lexicalUnitType == LexicalUnit.SAC_REAL ) { return true; } return false; }
Example 14
Source File: IntegerManager.java From birt with Eclipse Public License 1.0 | 5 votes |
public Value createValue(LexicalUnit lu, CSSEngine engine) throws DOMException { switch( lu.getLexicalUnitType()) { case LexicalUnit.SAC_INHERIT: return CSSValueConstants.INHERIT_VALUE; case LexicalUnit.SAC_INTEGER: return new FloatValue( CSSPrimitiveValue.CSS_NUMBER, lu.getIntegerValue()); default: throw createInvalidLexicalUnitDOMException(lu.getLexicalUnitType()); } }
Example 15
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 16
Source File: Measure.java From tm4e with Eclipse Public License 1.0 | 5 votes |
public String getCssText() { // TODO: All LexicalUnit.SAC_OPERATOR_* except for COMMA left undone for // now as it's not even clear whether they should be treated as measures // see bug #278139 switch (value.getLexicalUnitType()) { case LexicalUnit.SAC_INTEGER: return String.valueOf(value.getIntegerValue()); case LexicalUnit.SAC_REAL: return String.valueOf(value.getFloatValue()); case LexicalUnit.SAC_PERCENTAGE: case LexicalUnit.SAC_PIXEL: case LexicalUnit.SAC_CENTIMETER: case LexicalUnit.SAC_EM: case LexicalUnit.SAC_EX: case LexicalUnit.SAC_PICA: case LexicalUnit.SAC_POINT: case LexicalUnit.SAC_INCH: case LexicalUnit.SAC_DEGREE: return String.valueOf(value.getFloatValue()) + value.getDimensionUnitText(); case LexicalUnit.SAC_URI: return "url(" + value.getStringValue() + ")"; case LexicalUnit.SAC_OPERATOR_COMMA: return ","; case LexicalUnit.SAC_INHERIT: return "inherit"; } return value.getStringValue(); }
Example 17
Source File: Measure.java From tm4e with Eclipse Public License 1.0 | 5 votes |
public short getPrimitiveType() { switch (value.getLexicalUnitType()) { case LexicalUnit.SAC_IDENT: return CSS_IDENT; case LexicalUnit.SAC_INTEGER: case LexicalUnit.SAC_REAL: return CSS_NUMBER; case LexicalUnit.SAC_URI: return CSS_URI; case LexicalUnit.SAC_PERCENTAGE: return CSS_PERCENTAGE; case LexicalUnit.SAC_PIXEL: return CSS_PX; case LexicalUnit.SAC_CENTIMETER: return CSS_CM; case LexicalUnit.SAC_EM: return CSS_EMS; case LexicalUnit.SAC_EX: return CSS_EXS; case LexicalUnit.SAC_INCH: return CSS_IN; case LexicalUnit.SAC_STRING_VALUE: return CSS_STRING; case LexicalUnit.SAC_DIMENSION: return CSS_DIMENSION; case LexicalUnit.SAC_OPERATOR_COMMA: return CSS_CUSTOM; // TODO don't think this is right, see bug // #278139 case LexicalUnit.SAC_INHERIT: return CSS_INHERIT; } // TODO Auto-generated method stub throw new UnsupportedOperationException( "NOT YET IMPLEMENTED - LexicalUnit type: " + value.getLexicalUnitType()); }
Example 18
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 19
Source File: ShortHandProcessor.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void buildFontStyle( StringBuffer buffer, String[] vs, CSSEngine engine ) { for ( int i = 0; i < vs.length; i++ ) { LexicalUnit u = getUnit( vs[i], engine ); if ( u != null ) { if ( u.getLexicalUnitType( ) == LexicalUnit.SAC_IDENT ) { if ( isIdentifier( vs[i], IStyle.STYLE_FONT_STYLE, engine ) ) { appendStyle( buffer, CSSConstants.CSS_FONT_STYLE_PROPERTY, vs[i] ); continue; } if ( isIdentifier( vs[i], IStyle.STYLE_FONT_WEIGHT, engine ) ) { appendStyle( buffer, CSSConstants.CSS_FONT_WEIGHT_PROPERTY, vs[i] ); continue; } } else if ( u.getLexicalUnitType( ) == LexicalUnit.SAC_INTEGER ) { if ( CSSConstants.CSS_100_VALUE.equals( vs[i] ) || CSSConstants.CSS_200_VALUE.equals( vs[i] ) || CSSConstants.CSS_300_VALUE.equals( vs[i] ) || CSSConstants.CSS_400_VALUE.equals( vs[i] ) || CSSConstants.CSS_500_VALUE.equals( vs[i] ) || CSSConstants.CSS_600_VALUE.equals( vs[i] ) || CSSConstants.CSS_700_VALUE.equals( vs[i] ) || CSSConstants.CSS_800_VALUE.equals( vs[i] ) || CSSConstants.CSS_900_VALUE.equals( vs[i] ) ) { appendStyle( buffer, CSSConstants.CSS_FONT_WEIGHT_PROPERTY, vs[i] ); continue; } } } } }
Example 20
Source File: AbstractLengthManager.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}. */ public Value createValue( LexicalUnit lu, CSSEngine engine ) throws DOMException { switch ( lu.getLexicalUnitType( ) ) { case LexicalUnit.SAC_EM : return new FloatValue( CSSPrimitiveValue.CSS_EMS, lu .getFloatValue( ) ); case LexicalUnit.SAC_EX : return new FloatValue( CSSPrimitiveValue.CSS_EXS, lu .getFloatValue( ) ); case LexicalUnit.SAC_PIXEL : return new FloatValue( CSSPrimitiveValue.CSS_PX, lu .getFloatValue( ) ); case LexicalUnit.SAC_CENTIMETER : return new FloatValue( CSSPrimitiveValue.CSS_CM, lu .getFloatValue( ) ); case LexicalUnit.SAC_MILLIMETER : return new FloatValue( CSSPrimitiveValue.CSS_MM, lu .getFloatValue( ) ); case LexicalUnit.SAC_INCH : return new FloatValue( CSSPrimitiveValue.CSS_IN, lu .getFloatValue( ) ); case LexicalUnit.SAC_POINT : return new FloatValue( CSSPrimitiveValue.CSS_PT, lu .getFloatValue( ) ); case LexicalUnit.SAC_PICA : return new FloatValue( CSSPrimitiveValue.CSS_PC, lu .getFloatValue( ) ); case LexicalUnit.SAC_INTEGER : return new FloatValue( CSSPrimitiveValue.CSS_NUMBER, lu .getIntegerValue( ) ); case LexicalUnit.SAC_REAL : return new FloatValue( CSSPrimitiveValue.CSS_NUMBER, lu .getFloatValue( ) ); case LexicalUnit.SAC_PERCENTAGE : return new FloatValue( CSSPrimitiveValue.CSS_PERCENTAGE, lu .getFloatValue( ) ); } throw createInvalidLexicalUnitDOMException( lu.getLexicalUnitType( ) ); }