Java Code Examples for org.w3c.css.sac.LexicalUnit#SAC_IDENT

The following examples show how to use org.w3c.css.sac.LexicalUnit#SAC_IDENT . 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: ShortHandProcessor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected String getBorderColor( 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 CSSConstants.CSS_BLACK_VALUE;
}
 
Example 2
Source File: FontWeightReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public CSSValue createValue( StyleKey name, LexicalUnit value ) {
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) {
    if ( value.getStringValue().equalsIgnoreCase( "bolder" ) ) {
      return FontWeight.BOLDER;
    }
    if ( value.getStringValue().equalsIgnoreCase( "bold" ) ) {
      return FontWeight.BOLD;
    }
    if ( value.getStringValue().equalsIgnoreCase( "lighter" ) ) {
      return FontWeight.LIGHTER;
    }
    if ( value.getStringValue().equalsIgnoreCase( "normal" ) ) {
      return FontWeight.NORMAL;
    }
  }
  return CSSValueFactory.createNumericValue( value );
}
 
Example 3
Source File: ShortHandProcessor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected String getBorderWidth( String[] values, CSSEngine engine )
{
	for ( int i = 0; i < values.length; i++ )
	{
		LexicalUnit u = getUnit( values[i], engine );
		if ( u != null )
		{
			int type = u.getLexicalUnitType( );
			if ( type >= LexicalUnit.SAC_EM
					&& type <= LexicalUnit.SAC_PERCENTAGE )
			{
				return values[i];
			}
			else if ( type == LexicalUnit.SAC_IDENT )
			{
				if ( CSSConstants.CSS_MEDIUM_VALUE.equals( values[i] )
						|| CSSConstants.CSS_THICK_VALUE.equals( values[i] )
						|| CSSConstants.CSS_THIN_VALUE.equals( values[i] ) )
				{
					return values[i];
				}
			}
		}
	}
	return CSSConstants.CSS_MEDIUM_VALUE;
}
 
Example 4
Source File: SpacingLimitReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private CSSValue parseSingleSpacingValue( final LexicalUnit value ) {
  if ( value == null ) {
    return null;
  }

  if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) {
    if ( value.getStringValue().equalsIgnoreCase( "normal" ) ) {
      return SpacingLimitReadHandler.NORMAL;
    }
    return null;
  }
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE ) {
    return CSSNumericValue.createValue( CSSNumericType.PERCENTAGE,
      value.getFloatValue() );
  }

  return CSSValueFactory.createLengthValue( value );
}
 
Example 5
Source File: CropReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public CSSValue createValue( StyleKey name, LexicalUnit value ) {
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) {
    final String stringValue = value.getStringValue();
    if ( stringValue.equalsIgnoreCase( "auto" ) ||
      stringValue.equalsIgnoreCase( "none" ) ) {
      return CSSAutoValue.getInstance();
    }
  } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_FUNCTION ) {
    if ( value.getFunctionName().equalsIgnoreCase( "inset-rect" ) ) {
      return getRectangle( CSSRectangleType.INSET_RECT, value.getParameters() );
    }
    return null;
  } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_RECT_FUNCTION ) {
    return getRectangle( CSSRectangleType.RECT, value.getParameters() );
  }
  return null;
}
 
Example 6
Source File: BackgroundPositionReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected CSSValue parseSecondPosition( final LexicalUnit value,
                                        final CSSValue firstValue ) {
  if ( value == null ) {
    return CENTER;
  }
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) {
    if ( "left".equalsIgnoreCase( value.getStringValue() ) ) {
      return LEFT;
    } else if ( "center".equalsIgnoreCase( value.getStringValue() ) ) {
      return CENTER;
    } else if ( "right".equalsIgnoreCase( value.getStringValue() ) ) {
      return RIGHT;
    } else if ( "top".equalsIgnoreCase( value.getStringValue() ) ) {
      return TOP;
    } else if ( "bottom".equalsIgnoreCase( value.getStringValue() ) ) {
      return BOTTOM;
    }
    return null; // ignore this rule, it contains errors.
  }
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE ) {
    return CSSNumericValue.createValue( CSSNumericType.PERCENTAGE,
      value.getFloatValue() );
  } else if ( CSSValueFactory.isLengthValue( value ) ) {
    return CSSValueFactory.createLengthValue( value );
  }
  return CENTER;
}
 
Example 7
Source File: FitPositionReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected CSSValue parseSecondPosition( final LexicalUnit value,
                                        final CSSValue firstValue ) {
  if ( value == null ) {
    return CENTER;
  }
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) {
    if ( "left".equalsIgnoreCase( value.getStringValue() ) ) {
      return LEFT;
    } else if ( "center".equalsIgnoreCase( value.getStringValue() ) ) {
      return CENTER;
    } else if ( "right".equalsIgnoreCase( value.getStringValue() ) ) {
      return RIGHT;
    } else if ( "top".equalsIgnoreCase( value.getStringValue() ) ) {
      return TOP;
    } else if ( "bottom".equalsIgnoreCase( value.getStringValue() ) ) {
      return BOTTOM;
    }
    return null; // ignore this rule, it contains errors.
  }
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE ) {
    return CSSNumericValue.createValue( CSSNumericType.PERCENTAGE,
      value.getFloatValue() );
  } else if ( CSSValueFactory.isLengthValue( value ) ) {
    return CSSValueFactory.createLengthValue( value );
  }
  return CENTER;
}
 
Example 8
Source File: PageReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CSSValue createValue( StyleKey name, LexicalUnit value ) {
  if ( value.getLexicalUnitType() != LexicalUnit.SAC_IDENT ) {
    return null;
  }
  String ident = value.getStringValue();
  if ( ident.equalsIgnoreCase( "auto" ) ) {
    return CSSAutoValue.getInstance();
  }

  return new CSSConstant( ident );
}
 
Example 9
Source File: DropInitialSizeReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
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: Measure.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
public String getStringValue() throws DOMException {
	short lexicalUnit = value.getLexicalUnitType();
	if ((lexicalUnit == LexicalUnit.SAC_IDENT) || (lexicalUnit == LexicalUnit.SAC_STRING_VALUE)
			|| (lexicalUnit == LexicalUnit.SAC_URI))
		return value.getStringValue();
	// TODO There are more cases to catch of getLexicalUnitType()
	throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
}
 
Example 11
Source File: MarginManager.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Value createValue(LexicalUnit lu, CSSEngine engine)
		throws DOMException {
	switch (lu.getLexicalUnitType()) {
	case LexicalUnit.SAC_IDENT:
		String s = lu.getStringValue().toLowerCase().intern();
		Object v = values.get(s);
		if (v == null) {
			throw createInvalidIdentifierDOMException(lu.getStringValue());
		}
		return (Value) v;
	}
	return super.createValue(lu, engine);
}
 
Example 12
Source File: ColumnWidthReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CSSValue createValue( StyleKey name, LexicalUnit value ) {
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) {
    if ( value.getStringValue().equalsIgnoreCase( "auto" ) ) {
      return CSSAutoValue.getInstance();
    }
    return null;
  }
  return CSSValueFactory.createLengthValue( value );
}
 
Example 13
Source File: ColumnSpanReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 14
Source File: VerticalAlignManager.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Value createValue(LexicalUnit lu, CSSEngine engine)
		throws DOMException {
	switch (lu.getLexicalUnitType()) {
	case LexicalUnit.SAC_IDENT:
		String s = lu.getStringValue().toLowerCase().intern();
		Object v = values.get(s);
		if (v == null) {
			throw createInvalidIdentifierDOMException(lu.getStringValue());
		}
		return (Value) v;
	}
	return super.createValue(lu, engine);
}
 
Example 15
Source File: ColumnCountReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 16
Source File: TextLineColorReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CSSValue createValue( StyleKey name, LexicalUnit value ) {
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) {
    if ( value.getStringValue().equalsIgnoreCase( "auto" ) ) {
      return CSSAutoValue.getInstance();
    }
  }
  return super.createValue( name, value );
}
 
Example 17
Source File: QuotesReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CSSValue createValue( StyleKey name, LexicalUnit value ) {
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) {
    if ( value.getStringValue().equalsIgnoreCase( "none" ) ) {
      return new CSSConstant( "none" );
    }
    return null;
  }
  return super.createValue( name, value );
}
 
Example 18
Source File: MoveToReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected CSSValue lookupValue( final LexicalUnit value ) {
  CSSValue content = super.lookupValue( value );
  if ( content != null ) {
    return content;
  }

  if ( value.getLexicalUnitType() != LexicalUnit.SAC_IDENT ) {
    return null;
  }
  return new CSSConstant( value.getStringValue() );
}
 
Example 19
Source File: CSSValue.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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 20
Source File: ShortHandProcessor.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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;
				}
			}

		}
	}
}