All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.gwt.test.internal.resources.TextResourceCallback Maven / Gradle / Ivy

There is a newer version: 0.63
Show newest version
package com.googlecode.gwt.test.internal.resources;

import com.google.gwt.resources.client.TextResource;

import java.lang.reflect.Method;
import java.net.URL;
import java.util.List;

/**
 * Callback interface where {@link TextResource } methods calls are redirected. For internal
 * use only.
 *
 * @author Gael Lazzari
 */
class TextResourceCallback implements ResourcePrototypeCallback {

    private static interface TextReader {

        String readText() throws Exception;
    }

    private final TextReader textReader;

    TextResourceCallback(final List resourceURLs) {
        textReader = new TextReader() {

            public String readText() throws Exception {
                return TextResourceReader.get().readFiles(resourceURLs);
            }

        };
    }

    TextResourceCallback(final String text) {
        textReader = new TextReader() {

            public String readText() throws Exception {
                return text;
            }

        };
    }

    public Object call(Method method, Object[] args) throws Exception {
        if (method.getName().equals("getText")) {
            return textReader.readText();
        }

        return null;

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy