com.vaadin.sass.internal
Class ScssStylesheet

java.lang.Object
  extended by com.vaadin.sass.internal.tree.Node
      extended by com.vaadin.sass.internal.ScssStylesheet
All Implemented Interfaces:
Serializable

public class ScssStylesheet
extends Node

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.sass.internal.tree.Node
Node.BuildStringStrategy, Node.PrintStrategy, Node.ToStringStrategy
 
Field Summary
 
Fields inherited from class com.vaadin.sass.internal.tree.Node
PRINT_STRATEGY, TO_STRING_STRATEGY
 
Constructor Summary
ScssStylesheet()
          Read in a file SCSS and parse it into a ScssStylesheet
 
Method Summary
 void addResolver(ScssStylesheetResolver resolver)
          Adds the given resolver to the resolver list
 void addSourceUris(Collection<String> uris)
           
 void compile()
          Applies all the visitors and compiles SCSS into Css.
 void compile(ScssContext.UrlMode urlMode)
          Applies all the visitors and compiles SCSS into Css.
 Node copy()
          Copy a node (deep copy including children).
static ScssStylesheet get(String identifier)
          Main entry point for the SASS compiler.
static ScssStylesheet get(String identifier, ScssStylesheet parentStylesheet)
          Main entry point for the SASS compiler.
static ScssStylesheet get(String identifier, ScssStylesheet parentStylesheet, SCSSDocumentHandler documentHandler, SCSSErrorHandler errorHandler)
          Main entry point for the SASS compiler.
 String getCharset()
           
 String getDirectory()
          Returns the directory containing this style sheet
 String getFileName()
          Returns the full file name for this style sheet
 String getPrefix()
           
 List<ScssStylesheetResolver> getResolvers()
          Retrieves a list of resolvers to use when resolving imports
 List<String> getSourceUris()
           
 String printState()
          Prints out the current state of the node tree.
 org.w3c.css.sac.InputSource resolveStylesheet(String identifier, ScssStylesheet parentStylesheet)
           
 void setCharset(String charset)
           
 void setFile(File file)
           
 void setPrefix(String prefix)
           
 void setResolvers(List<ScssStylesheetResolver> resolvers)
          Sets the list of resolvers to use when resolving imports
 String toString()
           
 Collection<Node> traverse(ScssContext context)
          Traverses a node and its children recursively, calling all the appropriate handlers via Node#traverse().
static void warning(String msg)
           
 void write(Writer writer)
           
 void write(Writer writer, boolean minify)
           
 
Methods inherited from class com.vaadin.sass.internal.tree.Node
appendChild, copyChildren, getChildren, getNormalParentNode, getParentNode, replaceNode, replaceNodeAt, setChildren, traverseChildren, traverseChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScssStylesheet

public ScssStylesheet()
Read in a file SCSS and parse it into a ScssStylesheet

Parameters:
file -
Throws:
IOException
Method Detail

get

public static ScssStylesheet get(String identifier)
                          throws org.w3c.css.sac.CSSException,
                                 IOException
Main entry point for the SASS compiler. Takes in a file and builds up a ScssStylesheet tree out of it. Calling compile() on it will transform SASS into CSS. Calling printState() will print out the SCSS/CSS.

Parameters:
identifier - The file path. If null then null is returned.
Returns:
Throws:
org.w3c.css.sac.CSSException
IOException

get

public static ScssStylesheet get(String identifier,
                                 ScssStylesheet parentStylesheet)
                          throws org.w3c.css.sac.CSSException,
                                 IOException
Main entry point for the SASS compiler. Takes in a file and an optional parent style sheet, then builds up a ScssStylesheet tree out of it. Calling compile() on it will transform SASS into CSS. Calling printState() will print out the SCSS/CSS.

Parameters:
identifier - The file path. If null then null is returned.
parentStylesheet - Style sheet from which to inherit resolvers and encoding. May be null.
Returns:
Throws:
org.w3c.css.sac.CSSException
IOException

get

public static ScssStylesheet get(String identifier,
                                 ScssStylesheet parentStylesheet,
                                 SCSSDocumentHandler documentHandler,
                                 SCSSErrorHandler errorHandler)
                          throws org.w3c.css.sac.CSSException,
                                 IOException
Main entry point for the SASS compiler. Takes in a file, an optional parent stylesheet, and document and error handlers. Then builds up a ScssStylesheet tree out of it. Calling compile() on it will transform SASS into CSS. Calling printState() will print out the SCSS/CSS.

Parameters:
identifier - The file path. If null then null is returned.
parentStylesheet - Style sheet from which to inherit resolvers and encoding. May be null.
documentHandler - Instance of document handler. May not be null.
errorHandler - Instance of error handler. May not be null.
Returns:
Throws:
org.w3c.css.sac.CSSException
IOException

resolveStylesheet

public org.w3c.css.sac.InputSource resolveStylesheet(String identifier,
                                                     ScssStylesheet parentStylesheet)

getResolvers

public List<ScssStylesheetResolver> getResolvers()
Retrieves a list of resolvers to use when resolving imports

Returns:
the resolvers used to resolving imports

setResolvers

public void setResolvers(List<ScssStylesheetResolver> resolvers)
Sets the list of resolvers to use when resolving imports

Parameters:
resolvers - the resolvers to set

addResolver

public void addResolver(ScssStylesheetResolver resolver)
Adds the given resolver to the resolver list

Parameters:
resolver - The resolver to add

getSourceUris

public List<String> getSourceUris()

addSourceUris

public void addSourceUris(Collection<String> uris)

compile

public void compile()
             throws Exception
Applies all the visitors and compiles SCSS into Css.

Throws:
Exception

compile

public void compile(ScssContext.UrlMode urlMode)
             throws Exception
Applies all the visitors and compiles SCSS into Css.

Parameters:
urlMode - Specifies whether urls appearing in an scss style sheet are taken to be absolute or relative. It is also possible to use old Vaadin style urls (ScssContext.UrlMode.MIXED), where urls are relative only when they appear in simple properties such as "background-image:url(image.png)". Absolute url mode means that urls appear in the output css in the same form as they are in the source scss files. Relative urls take into account the locations of imported scss files. For instance, if a style sheets imports foo/bar.scss and bar.scss contains url(baz.png), it will be output as url(foo/baz.png) in relative mode and as url(baz.png) in absolute mode.
Throws:
Exception

printState

public String printState()
Prints out the current state of the node tree. Will return SCSS before compile and CSS after. For now this is an own method with it's own implementation that most node types will implement themselves.

Overrides:
printState in class Node
Returns:
State as a string

toString

public String toString()
Overrides:
toString in class Object

traverse

public Collection<Node> traverse(ScssContext context)
Traverses a node and its children recursively, calling all the appropriate handlers via Node#traverse(). The node itself may be removed during the traversal and replaced with other nodes at the same position or later on the child list of its parent.

Specified by:
traverse in class Node
Parameters:
context - current compilation context
Returns:
nodes replacing the current node

setFile

public void setFile(File file)

getDirectory

public String getDirectory()
Returns the directory containing this style sheet

Returns:
The directory containing this style sheet

getFileName

public String getFileName()
Returns the full file name for this style sheet

Returns:
The full file name for this style sheet

warning

public static final void warning(String msg)

getCharset

public String getCharset()

setCharset

public void setCharset(String charset)

getPrefix

public String getPrefix()

setPrefix

public void setPrefix(String prefix)

copy

public Node copy()
Description copied from class: Node
Copy a node (deep copy including children). The copy is detached from the original tree, with null as parent, and data that is not relevant to handling of function or mixin expansion is not copied.

Specified by:
copy in class Node
Returns:
copy of the node

write

public void write(Writer writer)
           throws IOException
Throws:
IOException

write

public void write(Writer writer,
                  boolean minify)
           throws IOException
Throws:
IOException


Copyright © 2013–2015 Vaadin. All rights reserved.