Example usage for com.google.gwt.core.ext.linker PublicResource getContents

List of usage examples for com.google.gwt.core.ext.linker PublicResource getContents

Introduction

In this page you can find the example usage for com.google.gwt.core.ext.linker PublicResource getContents.

Prototype

public abstract InputStream getContents(TreeLogger logger) throws UnableToCompleteException;

Source Link

Document

Provides access to the contents of the EmittedResource.

Usage

From source file:com.bedatadriven.rebar.appcache.linker.AppCacheIFrameLinker.java

License:Apache License

private StringBuffer readManifestTemplate(TreeLogger logger, PermutationContext context, String suffix)
        throws UnableToCompleteException {
    // first try to find a template provided in the module's public
    // folder//from   w w  w  .j a  v  a  2s .c  o m
    for (PublicResource artifact : context.find(PublicResource.class)) {
        if (artifact.getPartialPath().equals(context.getModuleName() + "." + suffix)) {
            return readAll(logger, artifact.getContents(logger));
        }
    }

    String defaultTemplate = "Default." + suffix;
    InputStream defaultIn = getClass().getResourceAsStream(defaultTemplate);
    if (defaultIn == null) {
        logger.log(TreeLogger.Type.ERROR, "Could not read default '" + defaultTemplate + "'");
        throw new UnableToCompleteException();
    }
    return readAll(logger, defaultIn);
}