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

com.googlecode.gwt.test.internal.patchers.SafeHtmlUtilsPatcher Maven / Gradle / Ivy

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

import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.googlecode.gwt.test.exceptions.GwtTestPatchException;
import com.googlecode.gwt.test.patchers.PatchClass;
import com.googlecode.gwt.test.patchers.PatchMethod;
import com.googlecode.gwt.test.utils.GwtReflectionUtils;

import java.lang.reflect.Constructor;

@PatchClass(SafeHtmlUtils.class)
public class SafeHtmlUtilsPatcher {

    @PatchMethod
    public static SafeHtml fromSafeConstant(String s) {
        // PatchMethod to avoid gwt-dev dependency.. See SafeHtmlHostedModeUtils
        Class clazz;
        try {
            clazz = Class.forName("com.google.gwt.safehtml.shared.SafeHtmlString");
            Constructor cons = clazz.getDeclaredConstructor(String.class);
            return (SafeHtml) GwtReflectionUtils.instantiateClass(cons, s);
        } catch (Exception e) {
            throw new GwtTestPatchException("Error while instanciate a SafeHtmlString instance", e);
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy