LayerAdapterFactory.java 3.85 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Properties
 *  org.apache.felix.scr.annotations.Property
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.api.adapter.Adaptable
 *  org.apache.sling.api.adapter.AdapterFactory
 */
package com.day.image.internal;

import com.day.image.Layer;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.adapter.Adaptable;
import org.apache.sling.api.adapter.AdapterFactory;

import javax.imageio.IIOException;
import java.io.IOException;
import java.io.InputStream;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
@Component
@Service
@Properties(value={@Property(name="adaptables", value={"org.apache.sling.api.adapter.Adaptable"}), @Property(name="adapters", value={"com.day.image.Layer"}), @Property(name="adapter.condition", value={"If the adaptable can be adapted to an InputStream."})})
public class LayerAdapterFactory
implements AdapterFactory {
    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Loose catch block
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     * Lifted jumps to return sites
     */
    public <AdapterType> AdapterType getAdapter(Object object, Class<AdapterType> type) {
        if (type != Layer.class) return null;
        if (!(object instanceof Adaptable)) return null;
        Adaptable source = (Adaptable)object;
        InputStream ins = (InputStream)source.adaptTo(InputStream.class);
        if (ins == null) return null;
        Layer layer = new Layer(ins);
        if (ins == null) return (AdapterType)layer;
        try {
            ins.close();
            return (AdapterType)layer;
        }
        catch (IOException ioe) {
            // empty catch block
        }
        return (AdapterType)layer;
        catch (IIOException iioe) {
            if (ins == null) return null;
            try {
                ins.close();
                return null;
            }
            catch (IOException ioe) {
                return null;
            }
            catch (IOException ioe) {
                if (ins == null) return null;
                try {
                    ins.close();
                    return null;
                }
                catch (IOException ioe) {
                    return null;
                }
                catch (OutOfMemoryError oome) {
                    if (ins == null) return null;
                    try {
                        ins.close();
                        return null;
                    }
                    catch (IOException ioe) {
                        return null;
                    }
                    catch (Throwable t) {
                        if (ins == null) return null;
                        try {
                            ins.close();
                            return null;
                        }
                        catch (IOException ioe) {
                            return null;
                        }
                        catch (Throwable throwable) {
                            if (ins == null) throw throwable;
                            try {
                                ins.close();
                                throw throwable;
                            }
                            catch (IOException ioe) {
                                // empty catch block
                            }
                            throw throwable;
                        }
                    }
                }
            }
        }
    }
}