diff options
author | Artur Signell <artur@vaadin.com> | 2012-09-07 16:43:01 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-09-07 16:43:01 +0300 |
commit | 544152d1adc3a098445f7b11b4651fcc3c2f13bc (patch) | |
tree | 755041e36ad5f39ddc4d72db0f977ef68da7e047 /theme-compiler/src/com/vaadin/sass/resolver/ClassloaderResolver.java | |
parent | 733a7fd89068939b44f357e9eb88e197427097da (diff) | |
download | vaadin-framework-544152d1adc3a098445f7b11b4651fcc3c2f13bc.tar.gz vaadin-framework-544152d1adc3a098445f7b11b4651fcc3c2f13bc.zip |
Renamed sass -> theme-compiler for consistency (#9299)
Diffstat (limited to 'theme-compiler/src/com/vaadin/sass/resolver/ClassloaderResolver.java')
-rw-r--r-- | theme-compiler/src/com/vaadin/sass/resolver/ClassloaderResolver.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/resolver/ClassloaderResolver.java b/theme-compiler/src/com/vaadin/sass/resolver/ClassloaderResolver.java new file mode 100644 index 0000000000..84ac6dc530 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/resolver/ClassloaderResolver.java @@ -0,0 +1,39 @@ +package com.vaadin.sass.resolver; + +import java.io.InputStream; + +import org.w3c.css.sac.InputSource; + +public class ClassloaderResolver implements ScssStylesheetResolver { + + @Override + public InputSource resolve(String identifier) { + // identifier should not have .scss, fileName should + String ext = ".scss"; + if (identifier.endsWith(".css")) { + ext = ".css"; + } + String fileName = identifier; + if (identifier.endsWith(ext)) { + identifier = identifier.substring(0, + identifier.length() - ext.length()); + } else { + fileName = fileName + ext; + } + + // Can the classloader find it? + InputStream is = getClass().getClassLoader().getResourceAsStream( + fileName); + if (is != null) { + InputSource source = new InputSource(); + source.setByteStream(is); + source.setURI(fileName); + return source; + + } else { + return null; + } + + } + +} |