// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package org.jdeferred.impl; import java.util.Iterator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import org.jdeferred.AlwaysCallback; import org.jdeferred.DoneCallback; import org.jdeferred.DoneFilter; import org.jdeferred.DonePipe; import org.jdeferred.FailCallback; import org.jdeferred.FailFilter; import org.jdeferred.FailPipe; import org.jdeferred.ProgressCallback; import org.jdeferred.ProgressFilter; import org.jdeferred.ProgressPipe; import org.jdeferred.Promise; import org.slf4j.Logger; import org.slf4j.LoggerFactory; // Referenced classes of package org.jdeferred.impl: // FilteredPromise, PipedPromise public abstract class AbstractPromise implements Promise { protected final List alwaysCallbacks = new CopyOnWriteArrayList(); protected final List doneCallbacks = new CopyOnWriteArrayList(); protected final List failCallbacks = new CopyOnWriteArrayList(); protected final Logger log = LoggerFactory.getLogger(org/jdeferred/impl/AbstractPromise); protected final List progressCallbacks = new CopyOnWriteArrayList(); protected Object rejectResult; protected Object resolveResult; protected volatile org.jdeferred.Promise.State state; public AbstractPromise() { state = org.jdeferred.Promise.State.PENDING; } public Promise always(AlwaysCallback alwayscallback) { this; JVM INSTR monitorenter ; alwaysCallbacks.add(alwayscallback); if (!isPending()) { triggerAlways(alwayscallback, state, resolveResult, rejectResult); } this; JVM INSTR monitorexit ; return this; alwayscallback; this; JVM INSTR monitorexit ; throw alwayscallback; } public Promise done(DoneCallback donecallback) { this; JVM INSTR monitorenter ; doneCallbacks.add(donecallback); if (isResolved()) { triggerDone(donecallback, resolveResult); } this; JVM INSTR monitorexit ; return this; donecallback; this; JVM INSTR monitorexit ; throw donecallback; } public Promise fail(FailCallback failcallback) { this; JVM INSTR monitorenter ; failCallbacks.add(failcallback); if (isRejected()) { triggerFail(failcallback, rejectResult); } this; JVM INSTR monitorexit ; return this; failcallback; this; JVM INSTR monitorexit ; throw failcallback; } public boolean isPending() { return state == org.jdeferred.Promise.State.PENDING; } public boolean isRejected() { return state == org.jdeferred.Promise.State.REJECTED; } public boolean isResolved() { return state == org.jdeferred.Promise.State.RESOLVED; } public Promise progress(ProgressCallback progresscallback) { progressCallbacks.add(progresscallback); return this; } public org.jdeferred.Promise.State state() { return state; } public Promise then(DoneCallback donecallback) { return done(donecallback); } public Promise then(DoneCallback donecallback, FailCallback failcallback) { done(donecallback); fail(failcallback); return this; } public Promise then(DoneCallback donecallback, FailCallback failcallback, ProgressCallback progresscallback) { done(donecallback); fail(failcallback); progress(progresscallback); return this; } public Promise then(DoneFilter donefilter) { return new FilteredPromise(this, donefilter, null, null); } public Promise then(DoneFilter donefilter, FailFilter failfilter) { return new FilteredPromise(this, donefilter, failfilter, null); } public Promise then(DoneFilter donefilter, FailFilter failfilter, ProgressFilter progressfilter) { return new FilteredPromise(this, donefilter, failfilter, progressfilter); } public Promise then(DonePipe donepipe) { return new PipedPromise(this, donepipe, null, null); } public Promise then(DonePipe donepipe, FailPipe failpipe) { return new PipedPromise(this, donepipe, failpipe, null); } public Promise then(DonePipe donepipe, FailPipe failpipe, ProgressPipe progresspipe) { return new PipedPromise(this, donepipe, failpipe, progresspipe); } protected void triggerAlways(AlwaysCallback alwayscallback, org.jdeferred.Promise.State state1, Object obj, Object obj1) { alwayscallback.onAlways(state1, obj, obj1); } protected void triggerAlways(org.jdeferred.Promise.State state1, Object obj, Object obj1) { for (Iterator iterator = alwaysCallbacks.iterator(); iterator.hasNext();) { AlwaysCallback alwayscallback = (AlwaysCallback)iterator.next(); try { triggerAlways(alwayscallback, state1, obj, obj1); } catch (Exception exception) { log.error("an uncaught exception occured in a AlwaysCallback", exception); } } this; JVM INSTR monitorenter ; notifyAll(); this; JVM INSTR monitorexit ; return; state1; this; JVM INSTR monitorexit ; throw state1; } protected void triggerDone(Object obj) { for (Iterator iterator = doneCallbacks.iterator(); iterator.hasNext();) { DoneCallback donecallback = (DoneCallback)iterator.next(); try { triggerDone(donecallback, obj); } catch (Exception exception) { log.error("an uncaught exception occured in a DoneCallback", exception); } } } protected void triggerDone(DoneCallback donecallback, Object obj) { donecallback.onDone(obj); } protected void triggerFail(Object obj) { for (Iterator iterator = failCallbacks.iterator(); iterator.hasNext();) { FailCallback failcallback = (FailCallback)iterator.next(); try { triggerFail(failcallback, obj); } catch (Exception exception) { log.error("an uncaught exception occured in a FailCallback", exception); } } } protected void triggerFail(FailCallback failcallback, Object obj) { failcallback.onFail(obj); } protected void triggerProgress(Object obj) { for (Iterator iterator = progressCallbacks.iterator(); iterator.hasNext();) { ProgressCallback progresscallback = (ProgressCallback)iterator.next(); try { triggerProgress(progresscallback, obj); } catch (Exception exception) { log.error("an uncaught exception occured in a ProgressCallback", exception); } } } protected void triggerProgress(ProgressCallback progresscallback, Object obj) { progresscallback.onProgress(obj); } public void waitSafely() throws InterruptedException { waitSafely(-1L); } public void waitSafely(long l) throws InterruptedException { long l1 = System.currentTimeMillis(); this; JVM INSTR monitorenter ; _L2: boolean flag = isPending(); if (!flag) { break MISSING_BLOCK_LABEL_77; } if (l > 0L) { break MISSING_BLOCK_LABEL_48; } wait(); _L4: if (l <= 0L) goto _L2; else goto _L1 _L1: if (System.currentTimeMillis() - l1 < l) goto _L2; else goto _L3 _L3: this; JVM INSTR monitorexit ; return; wait(l - (System.currentTimeMillis() - l1)); goto _L4 Object obj; obj; Thread.currentThread().interrupt(); throw obj; obj; this; JVM INSTR monitorexit ; throw obj; this; JVM INSTR monitorexit ; } }