Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package pl.matisoft.soy.compile;
  
 
 import  javax.annotation.Nullable;
 import java.net.URL;
 import java.util.List;
 import java.util.Map;

Created with IntelliJ IDEA. User: mszczap Date: 20.06.13 Time: 17:40
 
 public class DefaultTofuCompiler implements TofuCompiler {
 
     private static final Logger logger = LoggerFactory.getLogger(DefaultTofuCompiler.class);
 
 
 
 
     private SoyJsSrcOptions soyJsSrcOptions = new SoyJsSrcOptions();
 
 
     @Override
     public SoyTofu compile(@Nullable final Collection<URLurlsthrows IOException {
         Preconditions.checkNotNull("compileTimeGlobalModelResolver");
 
         if (urls == null || urls.isEmpty()) {
             throw new IOException("Unable to compile, no urls found");
         }
 
         .debug("SoyTofu compilation of templates:" + urls.size());
         final long time1 = System.currentTimeMillis();
 
         final SoyFileSet.Builder sfsBuilder = new SoyFileSet.Builder();
 
         for (final URL url : urls) {
             sfsBuilder.add(url);
         }
 
         addCompileTimeGlobalModel(sfsBuilder);
 
         final SoyFileSet soyFileSet = sfsBuilder.build();
 
         final SoyTofuOptions soyTofuOptions = createSoyTofuOptions();
         final SoyTofu soyTofu = soyFileSet.compileToTofu(soyTofuOptions);
 
         final long time2 = System.currentTimeMillis();
 
         .debug("SoyTofu compilation complete." + (time2 - time1) + " ms");
 
         return soyTofu;
     }
 
     private void addCompileTimeGlobalModel(final SoyFileSet.Builder sfsBuilder) {
         final Optional<SoyMapDatasoyMapData = .resolveData();
         if (soyMapData.isPresent()) {
             final Map<String, ?> mapData = soyMapData.get().asMap();
             if (mapData.size() > 0) {
                 .debug("Setting compile time globals, entries number:" + mapData.size());
                 sfsBuilder.setCompileTimeGlobals(mapData);
             }
         }
     }
 
     private SoyTofuOptions createSoyTofuOptions() {
         final SoyTofuOptions soyTofuOptions = new SoyTofuOptions();
         soyTofuOptions.setUseCaching(isHotReloadModeOff());
 
         return soyTofuOptions;
     }
 
     @Override
     public final Optional<StringcompileToJsSrc(@Nullable final URL url, @Nullable final SoyMsgBundle soyMsgBundle) {
         if (url == null) {
             return Optional.absent();
         }
 
         final Collection<StringcompiledTemplates = compileToJsSrc(Lists.newArrayList(url), soyMsgBundle);
        if (compiledTemplates.isEmpty()) {
            return Optional.absent();
        }
        return Optional.fromNullable(compiledTemplates.iterator().next());
    }
    @Override
    public Collection<StringcompileToJsSrc(Collection<URLtemplates, @Nullable SoyMsgBundle soyMsgBundle) {
        Preconditions.checkNotNull("soyJsSrcOptions");
        .debug("SoyJavaScript compilation of template:" + templates);
        final long time1 = System.currentTimeMillis();
        final SoyFileSet soyFileSet = buildSoyFileSetFrom(templates);
        final List<Stringret = soyFileSet.compileToJsSrc(soyMsgBundle);
        final long time2 = System.currentTimeMillis();
        .debug("SoyJavaScript compilation complete." + (time2 - time1) + " ms");
        return ret;
    }
    private SoyFileSet buildSoyFileSetFrom(final Collection<URLurls) {
        final SoyFileSet.Builder builder = new SoyFileSet.Builder();
        for (final URL url : urls) {
            builder.setAllowExternalCalls(true);
            builder.add(url);
        }
        addCompileTimeGlobalModel(builder);
        return builder.build();
    }
    public void setHotReloadMode(final boolean hotReloadMode) {
        this. = hotReloadMode;
    }
    public void setCompileTimeGlobalModelResolver(final CompileTimeGlobalModelResolver compileTimeGlobalModelResolver) {
        this. = compileTimeGlobalModelResolver;
    }
    public void setSoyJsSrcOptions(final SoyJsSrcOptions soyJsSrcOptions) {
        this. = soyJsSrcOptions;
    }
    public boolean isHotReloadMode() {
        return ;
    }
    public boolean isHotReloadModeOff() {
        return !;
    }
        return ;
    }
    public SoyTofuOptions getSoyTofuOptions() {
        return ;
    }
    public void setSoyTofuOptions(SoyTofuOptions soyTofuOptions) {
        this. = soyTofuOptions;
    }
New to GrepCode? Check out our FAQ X