com.vaadin.sass.internal.resolver
Class AbstractResolver

java.lang.Object
  extended by com.vaadin.sass.internal.resolver.AbstractResolver
All Implemented Interfaces:
ScssStylesheetResolver, Serializable
Direct Known Subclasses:
ClassloaderResolver, FilesystemResolver

public abstract class AbstractResolver
extends Object
implements ScssStylesheetResolver, Serializable

Base class for resolvers. Implements functionality for locating paths which an import can be relative to and helpers for extracting path information from the identifier.

Author:
Vaadin Ltd
See Also:
Serialized Form

Constructor Summary
AbstractResolver()
           
 
Method Summary
protected  String extractFullPath(String path, String identifier)
          Extracts the full path from the path combined with the identifier
protected  List<String> getPotentialParentPaths(ScssStylesheet parentStylesheet, String identifier)
          Retrieves the parent paths which should be used while resolving relative identifiers.
protected  String normalize(String path)
          Normalizes "." and ".." from the path string where parent path segments can be removed.
protected  org.w3c.css.sac.InputSource normalizeAndResolve(String identifier)
          Resolves the normalized version of the given identifier
 org.w3c.css.sac.InputSource resolve(ScssStylesheet parentStylesheet, String identifier)
          Called with the "identifier" of a stylesheet that the resolver should try to find.
protected abstract  org.w3c.css.sac.InputSource resolveNormalized(String identifier)
          Resolves the identifier after it has been normalized using normalize(String).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractResolver

public AbstractResolver()
Method Detail

resolve

public org.w3c.css.sac.InputSource resolve(ScssStylesheet parentStylesheet,
                                           String identifier)
Description copied from interface: ScssStylesheetResolver
Called with the "identifier" of a stylesheet that the resolver should try to find. The identifier is basically a filename, like "runo.scss" or "addon/styles.scss", but might exclude ".scss". The resolver must InputSource.setURI(String) to the final location where the stylesheet was found, e.g "runo.scss" might result in a URI like "VAADIN/themes/runo/runo.scss".

Specified by:
resolve in interface ScssStylesheetResolver
Parameters:
parentStylesheet - The parent style sheet
identifier - used fo find stylesheet
Returns:
InputSource for stylesheet (with URI set) or null if not found

getPotentialParentPaths

protected List<String> getPotentialParentPaths(ScssStylesheet parentStylesheet,
                                               String identifier)
Retrieves the parent paths which should be used while resolving relative identifiers. By default uses the parent stylesheet location and a possible absolute path in the identifier.

Parameters:
parentStylesheet - The parent stylesheet or null if there is no parent
identifier - The identifier to be resolved
Returns:
a list of paths in which to look for the relative import

extractFullPath

protected String extractFullPath(String path,
                                 String identifier)
Extracts the full path from the path combined with the identifier

Parameters:
path - The base path
identifier - The identifier which may contain a path part, separated by "/" from the real identifier
Returns:
a normalized version of the path where identifier does not contain any directory information

normalizeAndResolve

protected org.w3c.css.sac.InputSource normalizeAndResolve(String identifier)
Resolves the normalized version of the given identifier

Parameters:
identifier - The identifier to resolve
Returns:
An input source if the resolver found one or null otherwise

resolveNormalized

protected abstract org.w3c.css.sac.InputSource resolveNormalized(String identifier)
Resolves the identifier after it has been normalized using normalize(String).

Parameters:
identifier - The normalized identifier
Returns:
an InputSource if the resolver found a source or null otherwise

normalize

protected String normalize(String path)
Normalizes "." and ".." from the path string where parent path segments can be removed. Preserve leading "..". Also ensure / is used instead of \ in all places.

Parameters:
path - A relative or absolute file path
Returns:
The normalized path


Copyright © 2013–2014 Vaadin. All rights reserved.