com.vaadin.sass.internal.parser
Class LexicalUnitImpl

java.lang.Object
  extended by com.vaadin.sass.internal.parser.LexicalUnitImpl
All Implemented Interfaces:
SassListItem, SCSSLexicalUnit, Serializable, org.w3c.css.sac.LexicalUnit

public class LexicalUnitImpl
extends Object
implements org.w3c.css.sac.LexicalUnit, SCSSLexicalUnit, SassListItem, Serializable

Version:
$Revision: 1.3 $
Author:
Philippe Le Hegaret
See Also:
Serialized Form

Field Summary
static long PRECISION
           
 
Fields inherited from interface com.vaadin.sass.internal.parser.SCSSLexicalUnit
SAC_LEM, SAC_REM, SCSS_NULL, SCSS_OPERATOR_AND, SCSS_OPERATOR_EQUALS, SCSS_OPERATOR_LEFT_PAREN, SCSS_OPERATOR_NOT, SCSS_OPERATOR_NOT_EQUAL, SCSS_OPERATOR_OR, SCSS_OPERATOR_RIGHT_PAREN, SCSS_VARIABLE
 
Fields inherited from interface org.w3c.css.sac.LexicalUnit
SAC_ATTR, SAC_CENTIMETER, SAC_COUNTER_FUNCTION, SAC_COUNTERS_FUNCTION, SAC_DEGREE, SAC_DIMENSION, SAC_EM, SAC_EX, SAC_FUNCTION, SAC_GRADIAN, SAC_HERTZ, SAC_IDENT, SAC_INCH, SAC_INHERIT, SAC_INTEGER, SAC_KILOHERTZ, SAC_MILLIMETER, SAC_MILLISECOND, SAC_OPERATOR_COMMA, SAC_OPERATOR_EXP, SAC_OPERATOR_GE, SAC_OPERATOR_GT, SAC_OPERATOR_LE, SAC_OPERATOR_LT, SAC_OPERATOR_MINUS, SAC_OPERATOR_MOD, SAC_OPERATOR_MULTIPLY, SAC_OPERATOR_PLUS, SAC_OPERATOR_SLASH, SAC_OPERATOR_TILDE, SAC_PERCENTAGE, SAC_PICA, SAC_PIXEL, SAC_POINT, SAC_RADIAN, SAC_REAL, SAC_RECT_FUNCTION, SAC_RGBCOLOR, SAC_SECOND, SAC_STRING_VALUE, SAC_SUB_EXPRESSION, SAC_UNICODERANGE, SAC_URI
 
Method Summary
 LexicalUnitImpl add(LexicalUnitImpl another)
           
 String buildString(Node.BuildStringStrategy strategy)
          Return a string representation of this item using the given strategy of converting items to strings.
protected  short checkAndGetUnit(LexicalUnitImpl another)
           
static boolean checkLexicalUnitType(SassListItem item, short... lexicalUnitTypes)
           
 boolean containsArithmeticalOperator()
          Checks whether the item contains an arithmetic expression.
 LexicalUnitImpl copy()
          Returns a shallow copy of the LexicalUnitImpl with null as next lexical unit pointer.
 LexicalUnitImpl copyWithValue(float value)
           
static LexicalUnitImpl createAdd(int line, int column)
           
static LexicalUnitImpl createAnd(int line, int column)
           
static LexicalUnitImpl createAttr(int line, int column, String s)
           
static LexicalUnitImpl createCM(int line, int column, float v)
           
static LexicalUnitImpl createComma(int line, int column)
           
static LexicalUnitImpl createEquals(int line, int column)
           
static LexicalUnitImpl createFunction(int line, int column, String fname, ActualArgumentList params)
           
static LexicalUnitImpl createGreaterThan(int line, int column)
           
static LexicalUnitImpl createGreaterThanOrEqualTo(int line, int column)
           
static LexicalUnitImpl createIdent(int line, int column, String s)
           
static LexicalUnitImpl createIdent(String s)
           
static LexicalUnitImpl createInteger(int line, int column, int i)
           
static LexicalUnitImpl createLeftParenthesis(int line, int column)
           
static LexicalUnitImpl createLessThan(int line, int column)
           
static LexicalUnitImpl createLessThanOrEqualTo(int line, int column)
           
static LexicalUnitImpl createMinus(int line, int column)
           
static LexicalUnitImpl createModulo(int line, int column)
           
static LexicalUnitImpl createMultiply(int line, int column)
           
static LexicalUnitImpl createNotEqual(int line, int column)
           
static LexicalUnitImpl createNull(int line, int column)
           
static LexicalUnitImpl createNumber(int line, int column, float v)
           
static LexicalUnitImpl createOr(int line, int column)
           
static LexicalUnitImpl createPercentage(int line, int column, float v)
           
static LexicalUnitImpl createPX(int line, int column, float v)
           
static LexicalUnitImpl createRawIdent(int line, int column, String s)
           
static LexicalUnitImpl createRect(int line, int column, ActualArgumentList params)
           
static LexicalUnitImpl createRGBColor(int line, int column, ActualArgumentList params)
           
static LexicalUnitImpl createRightParenthesis(int line, int column)
           
static LexicalUnitImpl createSlash(int line, int column)
           
static LexicalUnitImpl createSpace(int line, int column)
           
static LexicalUnitImpl createString(String s)
           
static LexicalUnitImpl createUnicodeRange(int line, int column, SassList params)
           
static LexicalUnitImpl createVariable(int line, int column, String name)
           
 LexicalUnitImpl divide(LexicalUnitImpl denominator)
           
 boolean equals(Object o)
           
 SassListItem evaluateFunctionsAndExpressions(boolean evaluateArithmetics)
          Evaluates the arithmetic expressions and functions of this item without modifying this item.
 int getColumnNumber()
           
 LexicalUnitImpl getContainedValue()
           
 short getDimension()
           
 String getDimensionUnitText()
           
 String getFloatOrInteger()
          Returns the float value as a string unless the value is an integer.
 float getFloatValue()
           
 String getFunctionName()
           
 int getIntegerValue()
           
 short getLexicalUnitType()
           
 int getLineNumber()
           
 LexicalUnitImpl getNextLexicalUnit()
          Deprecated. 
 ActualArgumentList getParameterList()
           
 LexicalUnitImpl getParameters()
           
 LexicalUnitImpl getPreviousLexicalUnit()
          Deprecated. 
 String getSdimension()
           
 String getStringValue()
           
 LexicalUnitImpl getSubValues()
           
 int hashCode()
           
 boolean isNumber()
           
 LexicalUnitImpl minus(LexicalUnitImpl another)
           
 LexicalUnitImpl modulo(LexicalUnitImpl another)
           
 LexicalUnitImpl multiply(LexicalUnitImpl another)
           
 String printState()
          Prints out the current state of the node tree.
 SassListItem replaceVariables(Collection<VariableNode> variables)
          Returns a new item that is otherwise equal to this one but all occurrences of the given variables have been replaced by the values given in the VariableNodes.
 String toString()
           
 String unquotedString()
          Returns a string representation of this item with surrounding quotation marks of the same type (" or ') removed.
 void updateUrl(String prefix)
          Updates all url's of this item by, e.g., adding the prefix to an url not starting with slash "/" and not containing the symbol ":".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PRECISION

public static final long PRECISION
See Also:
Constant Field Values
Method Detail

getLineNumber

public int getLineNumber()
Specified by:
getLineNumber in interface SassListItem

getColumnNumber

public int getColumnNumber()
Specified by:
getColumnNumber in interface SassListItem

getLexicalUnitType

public short getLexicalUnitType()
Specified by:
getLexicalUnitType in interface org.w3c.css.sac.LexicalUnit

getNextLexicalUnit

@Deprecated
public LexicalUnitImpl getNextLexicalUnit()
Deprecated. 

Specified by:
getNextLexicalUnit in interface org.w3c.css.sac.LexicalUnit

getPreviousLexicalUnit

@Deprecated
public LexicalUnitImpl getPreviousLexicalUnit()
Deprecated. 

Specified by:
getPreviousLexicalUnit in interface org.w3c.css.sac.LexicalUnit

isNumber

public boolean isNumber()

getIntegerValue

public int getIntegerValue()
Specified by:
getIntegerValue in interface org.w3c.css.sac.LexicalUnit

getFloatValue

public float getFloatValue()
Specified by:
getFloatValue in interface org.w3c.css.sac.LexicalUnit

getFloatOrInteger

public String getFloatOrInteger()
Returns the float value as a string unless the value is an integer. In that case returns the integer value as a string.

Returns:
a string representing the value, either with or without decimals

getDimensionUnitText

public String getDimensionUnitText()
Specified by:
getDimensionUnitText in interface org.w3c.css.sac.LexicalUnit

getStringValue

public String getStringValue()
Specified by:
getStringValue in interface org.w3c.css.sac.LexicalUnit

getFunctionName

public String getFunctionName()
Specified by:
getFunctionName in interface org.w3c.css.sac.LexicalUnit

getParameters

public LexicalUnitImpl getParameters()
Specified by:
getParameters in interface org.w3c.css.sac.LexicalUnit

getParameterList

public ActualArgumentList getParameterList()

getSubValues

public LexicalUnitImpl getSubValues()
Specified by:
getSubValues in interface org.w3c.css.sac.LexicalUnit

printState

public String printState()
Prints out the current state of the node tree. Will return SCSS before compile and CSS after. Result value could be null.

Specified by:
printState in interface SassListItem
Returns:
State as a string

toString

public String toString()
Overrides:
toString in class Object

unquotedString

public String unquotedString()
Description copied from interface: SassListItem
Returns a string representation of this item with surrounding quotation marks of the same type (" or ') removed. Quotation marks are only removed from a single item or a list containing a single element and only one pair of quotation marks is removed.

Specified by:
unquotedString in interface SassListItem
Returns:
An unquoted string representation of this item.

divide

public LexicalUnitImpl divide(LexicalUnitImpl denominator)

add

public LexicalUnitImpl add(LexicalUnitImpl another)

minus

public LexicalUnitImpl minus(LexicalUnitImpl another)

multiply

public LexicalUnitImpl multiply(LexicalUnitImpl another)

checkAndGetUnit

protected short checkAndGetUnit(LexicalUnitImpl another)

modulo

public LexicalUnitImpl modulo(LexicalUnitImpl another)

copy

public LexicalUnitImpl copy()
Returns a shallow copy of the LexicalUnitImpl with null as next lexical unit pointer. Parameters are not copied but a reference to the same parameter list is used.

Returns:
copy of this without next

copyWithValue

public LexicalUnitImpl copyWithValue(float value)

getDimension

public short getDimension()

getSdimension

public String getSdimension()

createVariable

public static LexicalUnitImpl createVariable(int line,
                                             int column,
                                             String name)

createNull

public static LexicalUnitImpl createNull(int line,
                                         int column)

createNumber

public static LexicalUnitImpl createNumber(int line,
                                           int column,
                                           float v)

createInteger

public static LexicalUnitImpl createInteger(int line,
                                            int column,
                                            int i)

createPercentage

public static LexicalUnitImpl createPercentage(int line,
                                               int column,
                                               float v)

createPX

public static LexicalUnitImpl createPX(int line,
                                       int column,
                                       float v)

createCM

public static LexicalUnitImpl createCM(int line,
                                       int column,
                                       float v)

createRawIdent

public static LexicalUnitImpl createRawIdent(int line,
                                             int column,
                                             String s)

createIdent

public static LexicalUnitImpl createIdent(int line,
                                          int column,
                                          String s)

createString

public static LexicalUnitImpl createString(String s)

createAttr

public static LexicalUnitImpl createAttr(int line,
                                         int column,
                                         String s)

createRGBColor

public static LexicalUnitImpl createRGBColor(int line,
                                             int column,
                                             ActualArgumentList params)

createRect

public static LexicalUnitImpl createRect(int line,
                                         int column,
                                         ActualArgumentList params)

createFunction

public static LexicalUnitImpl createFunction(int line,
                                             int column,
                                             String fname,
                                             ActualArgumentList params)

checkLexicalUnitType

public static boolean checkLexicalUnitType(SassListItem item,
                                           short... lexicalUnitTypes)

createUnicodeRange

public static LexicalUnitImpl createUnicodeRange(int line,
                                                 int column,
                                                 SassList params)

createComma

public static LexicalUnitImpl createComma(int line,
                                          int column)

createSpace

public static LexicalUnitImpl createSpace(int line,
                                          int column)

createSlash

public static LexicalUnitImpl createSlash(int line,
                                          int column)

createAdd

public static LexicalUnitImpl createAdd(int line,
                                        int column)

createMinus

public static LexicalUnitImpl createMinus(int line,
                                          int column)

createMultiply

public static LexicalUnitImpl createMultiply(int line,
                                             int column)

createModulo

public static LexicalUnitImpl createModulo(int line,
                                           int column)

createLeftParenthesis

public static LexicalUnitImpl createLeftParenthesis(int line,
                                                    int column)

createRightParenthesis

public static LexicalUnitImpl createRightParenthesis(int line,
                                                     int column)

createIdent

public static LexicalUnitImpl createIdent(String s)

createEquals

public static LexicalUnitImpl createEquals(int line,
                                           int column)

createNotEqual

public static LexicalUnitImpl createNotEqual(int line,
                                             int column)

createGreaterThan

public static LexicalUnitImpl createGreaterThan(int line,
                                                int column)

createGreaterThanOrEqualTo

public static LexicalUnitImpl createGreaterThanOrEqualTo(int line,
                                                         int column)

createLessThan

public static LexicalUnitImpl createLessThan(int line,
                                             int column)

createLessThanOrEqualTo

public static LexicalUnitImpl createLessThanOrEqualTo(int line,
                                                      int column)

createAnd

public static LexicalUnitImpl createAnd(int line,
                                        int column)

createOr

public static LexicalUnitImpl createOr(int line,
                                       int column)

replaceVariables

public SassListItem replaceVariables(Collection<VariableNode> variables)
Description copied from interface: SassListItem
Returns a new item that is otherwise equal to this one but all occurrences of the given variables have been replaced by the values given in the VariableNodes. Does not modify this item.

Specified by:
replaceVariables in interface SassListItem
Returns:
A SassListItem where all occurrences of variables have been replaced by their values.

evaluateFunctionsAndExpressions

public SassListItem evaluateFunctionsAndExpressions(boolean evaluateArithmetics)
Description copied from interface: SassListItem
Evaluates the arithmetic expressions and functions of this item without modifying this item.

Specified by:
evaluateFunctionsAndExpressions in interface SassListItem
Parameters:
evaluateArithmetics - True indicates that the arithmetic expressions in this item should be evaluated. This parameter is used to handle the case where the operator '/' should not be interpreted as an arithmetic operation. The arithmetic expressions occurring in the parameter lists of functions will be evaluated even if evaluateArithmetics is false.
Returns:
For single values, the result of the arithmetic expression or function. For a list, a copy of the list where the arithmetic expressions and functions have been replaced with their evaluated values.

buildString

public String buildString(Node.BuildStringStrategy strategy)
Description copied from interface: SassListItem
Return a string representation of this item using the given strategy of converting items to strings. See LexicalUnitImpl#buildString(BuildStringStrategy).

Specified by:
buildString in interface SassListItem
Parameters:
strategy - Specifies how an item is converted to a string. The strategy may use the toString- and printState-methods.
Returns:
A string representation of this string.

containsArithmeticalOperator

public boolean containsArithmeticalOperator()
Description copied from interface: SassListItem
Checks whether the item contains an arithmetic expression.

Specified by:
containsArithmeticalOperator in interface SassListItem

updateUrl

public void updateUrl(String prefix)
Description copied from interface: SassListItem
Updates all url's of this item by, e.g., adding the prefix to an url not starting with slash "/" and not containing the symbol ":". This is a mutating method, i.e. it modifies the contents of the current object.

Specified by:
updateUrl in interface SassListItem
Parameters:
prefix - The prefix to be added.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getContainedValue

public LexicalUnitImpl getContainedValue()
Specified by:
getContainedValue in interface SassListItem


Copyright © 2013–2014 Vaadin. All rights reserved.