com.vaadin.sass.internal.parser
Class SassList

java.lang.Object
  extended by com.vaadin.sass.internal.parser.SassList
All Implemented Interfaces:
SassListItem, Serializable, Iterable<SassListItem>
Direct Known Subclasses:
ArgumentList

public class SassList
extends Object
implements SassListItem, Iterable<SassListItem>, Serializable

SassList is a list that has a specified separator character (comma or space) and data items. The data items can be lists.

See Also:
Serialized Form

Nested Class Summary
static class SassList.Separator
           
 
Constructor Summary
SassList()
           
SassList(SassList.Separator sep, List<SassListItem> items)
           
SassList(SassList.Separator sep, SassListItem... items)
           
SassList(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.
 boolean equals(Object o)
           
 SassList evaluateFunctionsAndExpressions(boolean evaluateArithmetics)
          Evaluates the arithmetic expressions and functions of this item without modifying this item.
 SassListItem flatten()
          Returns a SassListItem whose textual (CSS) representation is the same as that of this list.
 SassListItem get(int index)
           
 int getColumnNumber()
           
 LexicalUnitImpl getContainedValue()
          Returns the only LexicalUnitImpl contained in this list.
protected  List<SassListItem> getItems()
           
 int getLineNumber()
           
 SassList.Separator getSeparator()
           
 String getStringWithNesting()
          Returns a string representation of the list where nesting is indicated using parentheses.
 int hashCode()
           
 Iterator<SassListItem> iterator()
           
 String printState()
          Returns a string representation of this item.
 SassList 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.
 void setSeparator(SassList.Separator separator)
           
 void setSourcePosition(int line, int column)
           
 int size()
           
 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
 

Constructor Detail

SassList

public SassList()

SassList

public SassList(SassListItem... items)

SassList

public SassList(SassList.Separator sep,
                SassListItem... items)

SassList

public SassList(SassList.Separator sep,
                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

setSourcePosition

public void setSourcePosition(int line,
                              int column)

getSeparator

public SassList.Separator getSeparator()

setSeparator

public void setSeparator(SassList.Separator separator)

getContainedValue

public LexicalUnitImpl getContainedValue()
Returns the only LexicalUnitImpl contained in this list.

Specified by:
getContainedValue in interface SassListItem
Throws:
ParseException - if this.size() != 1 or if the type of this.get(0) is not LexicalUnitImpl.

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.

flatten

public SassListItem flatten()
Returns a SassListItem whose textual (CSS) representation is the same as that of this list. Any extra nesting is recursively removed. Nesting is extra if a list contains only one element. A list with extra nesting is replaced by its contents (a SassList or a SassListItem). The flattened representation of an empty list is the item itself. For a non-empty list the definition of flatten is recursive. The flattened representation of a list containing a single value is the flattened representation of the value. For a list containing multiple values, the flattened representation is obtained by replacing all elements of the list by their flattened representations. Examples of flattened representations: a) (1) -> 1 b) (1 (2) ((3)) ) -> (1 2 3) c) (1, (2, 3), 4) -> (1, (2, 3), 4) (i.e., no change). Note that the flattened representation of a list can be a single value instead of a list, as in the example (a) above. This method should only be called by the parser.

Returns:
A flattened representation of this item.

containsArithmeticalOperator

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

Specified by:
containsArithmeticalOperator in interface SassListItem

evaluateFunctionsAndExpressions

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

replaceVariables

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

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.

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.

toString

public String toString()
Overrides:
toString in class Object

getStringWithNesting

public String getStringWithNesting()
Returns a string representation of the list where nesting is indicated using parentheses. Such a representation is mainly useful for debugging.


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

size

public int size()

get

public SassListItem get(int index)

iterator

public Iterator<SassListItem> iterator()
Specified by:
iterator in interface Iterable<SassListItem>

getItems

protected List<SassListItem> getItems()


Copyright © 2013–2014 Vaadin. All rights reserved.