com.vaadin.sass.internal.parser
Class SassExpression

java.lang.Object
  extended by com.vaadin.sass.internal.parser.SassExpression
All Implemented Interfaces:
SassListItem, Serializable

public class SassExpression
extends Object
implements SassListItem, Serializable

SassExpressions are used for representing and evaluating arithmetic expressions.

Author:
Vaadin
See Also:
Serialized Form

Constructor Summary
  SassExpression(LexicalUnitImpl chain)
           
protected SassExpression(List<SassListItem> items)
           
 
Method Summary
 String buildString(Node.BuildStringStrategy strategy)
          Return a string representation of this item using the given strategy of converting items to strings.
 boolean containsArithmeticalOperator()
          Checks whether the item contains an arithmetic expression.
 SassListItem evaluateArithmeticExpressions()
          Evaluates the arithmetic expressions of this item without modifying this item.
 int getColumnNumber()
           
 LexicalUnitImpl getContainedValue()
           
 int getLineNumber()
           
 String printState()
          Returns a string representation of this item.
 SassListItem replaceChains()
          Returns an object that is otherwise similar to this but chains of LexicalUnitImpl objects have been replaced with SassExpressions representing the same expressions.
 SassExpression replaceFunctions()
          Returns a new item that is the result of evaluating all functions in this item.
 SassExpression 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SassExpression

public SassExpression(LexicalUnitImpl chain)

SassExpression

protected SassExpression(List<SassListItem> items)
Method Detail

getLineNumber

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

getColumnNumber

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

containsArithmeticalOperator

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

Specified by:
containsArithmeticalOperator in interface SassListItem

evaluateArithmeticExpressions

public SassListItem evaluateArithmeticExpressions()
Description copied from interface: SassListItem
Evaluates the arithmetic expressions of this item without modifying this item.

Specified by:
evaluateArithmeticExpressions in interface SassListItem
Returns:
For single values, the result of the arithmetic expression. For a list, a copy of the list where the arithmetic expressions have been replaced with their evaluated values.

replaceFunctions

public SassExpression replaceFunctions()
Description copied from interface: SassListItem
Returns a new item that is the result of evaluating all functions in this item. Does not modify this item. If the item does not change as a result of evaluating functions, an implementation can return the item itself. Otherwise a new item should be returned. For a list with both changed and unchanged items, the unchanged items can be references to the same objects as in the original list.

Specified by:
replaceFunctions in interface SassListItem

replaceVariables

public SassExpression 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.

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.

printState

public String printState()
Description copied from interface: SassListItem
Returns a string representation of this item. See LexicalUnitImpl.printState(). For a list, the string representation contains the list items separated with the separator character of the list. No parentheses appear in the string representation of a list, for valid CSS output.

Specified by:
printState in interface SassListItem
Returns:
A string representation of this item.

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.

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.

getContainedValue

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

replaceChains

public SassListItem replaceChains()
Description copied from interface: SassListItem
Returns an object that is otherwise similar to this but chains of LexicalUnitImpl objects have been replaced with SassExpressions representing the same expressions.

Specified by:
replaceChains in interface SassListItem
Returns:
An object equivalent to this but with chains of LexicalUnitImpl objects replaced with corresponding SassExpressions.


Copyright © 2013–2014 Vaadin. All rights reserved.