Example usage for javax.imageio.stream ImageInputStream getClass

List of usage examples for javax.imageio.stream ImageInputStream getClass

Introduction

In this page you can find the example usage for javax.imageio.stream ImageInputStream getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.apache.xmlgraphics.image.loader.util.ImageUtil.java

/**
 * Decorates an ImageInputStream so the flush*() methods are ignored and have no effect.
 * The decoration is implemented using a dynamic proxy.
 * @param in the ImageInputStream//from   w ww .j  a v a2  s  . c  om
 * @return the decorated ImageInputStream
 */
public static ImageInputStream ignoreFlushing(final ImageInputStream in) {
    return (ImageInputStream) Proxy.newProxyInstance(in.getClass().getClassLoader(),
            new Class[] { ImageInputStream.class }, new InvocationHandler() {
                public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                    String methodName = method.getName();
                    //Ignore calls to flush*()
                    if (!methodName.startsWith("flush")) {
                        try {
                            return method.invoke(in, args);
                        } catch (InvocationTargetException ite) {
                            throw ite.getCause();
                        }
                    } else {
                        return null;
                    }
                }
            });
}