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

The following examples show how to use org.w3c.css.sac.LexicalUnit#SAC_URI . 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: 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 2
Source File: Measure.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
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 3
Source File: Measure.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
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 4
Source File: URIManager.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
 */
public Value createValue( LexicalUnit lu, CSSEngine engine )
		throws DOMException
{
	if ( lu.getLexicalUnitType( ) == LexicalUnit.SAC_URI )
	{
		return new URIValue( lu.getStringValue( ) );
	}
	return createStringValue( lu.getLexicalUnitType( ),
			lu.getStringValue( ), engine );
}
 
Example 5
Source File: ShortHandProcessor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected String getBackgroundImage( String[] values, CSSEngine engine )
{
	for ( int i = 0; i < values.length; i++ )
	{
		LexicalUnit u = getUnit( values[i], engine );
		if ( u != null && u.getLexicalUnitType( ) == LexicalUnit.SAC_URI )
		{
			return values[i];
		}
	}
	return EMPTY_VALUE;
}
 
Example 6
Source File: CSSValueFactory.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 7
Source File: ListStyleImageReadHandler.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 NONE;
    }
    return null;
  }
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_URI ) {
    return CSSValueFactory.createUriValue( value );
  }
  return null;
}
 
Example 8
Source File: TextOverflowEllipsisReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected CSSValue parseValue( final LexicalUnit value ) {
  if ( value.getLexicalUnitType() == LexicalUnit.SAC_URI ) {
    return new CSSStringValue( CSSStringType.URI, value.getStringValue() );
  } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_STRING_VALUE ) {
    return new CSSStringValue( CSSStringType.STRING, value.getStringValue() );
  }
  return null;
}
 
Example 9
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 10
Source File: CSSValueFactory.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static CSSFunctionValue parseFunction( LexicalUnit unit ) {
  if ( isFunctionValue( unit ) == false ) {
    return null;
  }
  LexicalUnit parameters = unit.getParameters();
  String functionName = unit.getFunctionName();
  if ( parameters == null ) {
    // no-parameter function include the date() function...
    return new CSSFunctionValue( functionName, EMPTY_PARAMETERS );
  }
  if ( "attr".equalsIgnoreCase( functionName ) ) {
    return parseComplexAttrFn( unit.getParameters() );
  }
  if ( "color".equalsIgnoreCase( functionName ) ) {
    // for some strange reason, flute translates "rgb" functions into "color" functions which
    // are not even mentioned in the CSS specs. We therefore translate it back into RGB.
    functionName = "rgb";
  }

  final ArrayList contentList = new ArrayList();
  while ( parameters != null ) {
    if ( parameters.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) {
      contentList.add( new CSSConstant( parameters.getStringValue() ) );
    } else if ( parameters.getLexicalUnitType() == LexicalUnit.SAC_STRING_VALUE ) {
      contentList.add( new CSSStringValue( CSSStringType.STRING,
        parameters.getStringValue() ) );
    } else if ( CSSValueFactory.isNumericValue( parameters ) ) {
      final CSSNumericValue numericValue =
        CSSValueFactory.createNumericValue( parameters );
      if ( numericValue == null ) {
        return null;
      }
      contentList.add( numericValue );
    } else if ( CSSValueFactory.isLengthValue( parameters ) ) {
      final CSSNumericValue lengthValue =
        CSSValueFactory.createLengthValue( parameters );
      if ( lengthValue == null ) {
        return null;
      }
      contentList.add( lengthValue );
    } else if ( parameters.getLexicalUnitType() == LexicalUnit.SAC_ATTR ) {
      final CSSAttrFunction attrFn =
        CSSValueFactory.parseAttrFunction( parameters );
      if ( attrFn == null ) {
        return null;
      }
      contentList.add( attrFn );
    } else if ( parameters.getLexicalUnitType() == LexicalUnit.SAC_URI ) {
      final CSSStringValue uriValue = CSSValueFactory.createUriValue(
        parameters );
      if ( uriValue == null ) {
        return null;
      }
      contentList.add( uriValue );
    } else if ( isFunctionValue( parameters ) ) {
      final CSSFunctionValue functionValue = parseFunction( parameters );
      if ( functionValue == null ) {
        return null;
      }
      contentList.add( functionValue );
    } else {
      // parse error: Something we do not understand ...
      return null;
    }
    parameters = CSSValueFactory.parseComma( parameters );
  }
  final CSSValue[] paramVals = (CSSValue[])
    contentList.toArray( new CSSValue[ contentList.size() ] );

  return new CSSFunctionValue( functionName, paramVals );
}