svn commit: r161025 [12/13] - in incubator/beehive/trunk: ./ external/beehive-antext/ netui/ant/ netui/external/xdoclet/ netui/src/bootstrap/ netui/src/compiler-core/ netui/src/compiler-core/org/apache/beehive/netui/compiler/ netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/ netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ netui/src/compiler-core/org/apache/beehive/netui/compiler/model/ netui/src/compiler-core/org/apache/beehive/netui/compiler/model/validation/ netui/src/compiler-core/org/apache/beehive/netui/compiler/processor/ netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/declaration/ netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/type/ netui/src/compiler-core/schema/processed-annotations/ netui/src/compiler-xdoclet/ netui/src/compiler-xdoclet/org/apache/beehive/netui/compiler/xdoclet/tools/ netui/src/compiler-xdoclet/org/apache/beehive/netui/compiler/xdoclet/typesystem/impl/ netui/src/compiler-xdoclet/org/apache/beehive/netui/compiler/xdoclet/typesystem/impl/declaration/ netui/src/compiler-xdoclet/org/apache/beehive/netui/compiler/xdoclet/typesystem/impl/env/ netui/src/compiler-xdoclet/org/apache/beehive/netui/compiler/xdoclet/typesystem/impl/type/ netui/src/compiler-xdoclet/org/apache/beehive/netui/tasks/ netui/src/compiler-xdoclet/org/apache/beehive/netui/xdoclet/ netui/src/compiler/ netui/src/compiler/org/apache/beehive/netui/compiler/apt/ netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/ netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/declaration/ netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/type/ netui/src/pageflow-jdk14/ netui/src/pageflow-jdk14/org/ netui/src/pageflow-jdk14/org/apache/ netui/src/pageflow-jdk14/org/apache/beehive/ netui/src/pageflow-jdk14/org/apache/beehive/netui/ netui/src/pageflow-jdk14/org/apache/beehive/netui/pageflow/ netui/src/pageflow-jdk14/org/apache/beehive/netui/pageflow/internal/ netui/src/pageflow/ netui/src/pageflow/org/apache/beehive/netui/pageflow/ netui/src/pageflow/org/apache/beehive/netui/pageflow/config/ netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/ netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ netui/src/pageflow/org/apache/beehive/netui/pageflow/interceptor/ netui/src/pageflow/org/apache/beehive/netui/pageflow/interceptor/action/ netui/src/pageflow/org/apache/beehive/netui/pageflow/interceptor/action/internal/ netui/src/pageflow/org/apache/beehive/netui/pageflow/interceptor/request/ netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/ netui/src/pageflow/org/apache/beehive/netui/pageflow/util/ netui/src/pageflow/org/apache/beehive/netui/pageflow/xmlhttprequest/ netui/src/pageflow/org/apache/beehive/netui/script/common/ netui/src/pageflow/org/apache/beehive/netui/script/el/ netui/src/pageflow/org/apache/beehive/netui/script/el/util/ netui/src/scoping/ netui/src/tags-databinding/ netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/ netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/ netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/ netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/ netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/ netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/ netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/rendering/cell/ netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/rendering/pager/ netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/sql/ netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/util/ netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/base/style/ netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/cellrepeater/ netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/ netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/invoke/ netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/pageinput/ netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/repeater/ netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/repeater/pad/ netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/ netui/src/tags-html/ netui/src/tags-html/org/apache/beehive/netui/tags/ netui/src/tags-html/org/apache/beehive/netui/tags/html/ netui/src/tags-html/org/apache/beehive/netui/tags/internal/ netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ netui/src/tags-html/org/apache/beehive/netui/tags/rendering/ netui/src/tags-html/org/apache/beehive/netui/tags/tree/ netui/src/tags-template/ netui/src/tags-template/org/apache/beehive/netui/tags/template/ netui/src/testRecorder/ netui/src/tomcat-webapp/5x/org/apache/beehive/netui/tomcat/ netui/src/util/ netui/src/util/org/apache/beehive/netui/core/urls/ netui/src/util/org/apache/beehive/netui/core/urltemplates/ netui/src/util/org/apache/beehive/netui/util/ netui/src/util/org/apache/beehive/netui/util/cache/ netui/src/util/org/apache/beehive/netui/util/classloader/ netui/src/util/org/apache/beehive/netui/util/config/ netui/src/util/org/apache/beehive/netui/util/internal/ netui/src/util/org/apache/beehive/netui/util/internal/concurrent/ netui/src/util/org/apache/beehive/netui/util/type/ netui/test/src/junitTests/ netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/ netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/ netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/ netui/test/src/junitTests/org/apache/beehive/netui/test/servlet/ netui/test/src/junitTests/org/apache/beehive/netui/test/util/iterator/ netui/test/src/testRecorderQA/ netui/test/webapps/drt/ netui/test/webapps/drt/coreWeb/WEB-INF/src/miniTests/actionInterceptors/ netui/test/webapps/drt/coreWeb/miniTests/actionInterceptors/interruptChain/ netui/test/webapps/drt/coreWeb/miniTests/exceptionMessages/ netui/test/webapps/drt/coreWeb/miniTests/handlePageException/ netui/test/webapps/drt/coreWeb/miniTests/handlers/ netui/test/webapps/drt/coreWeb/miniTests/pageFlowUtils/ netui/test/webapps/drt/coreWeb/miniTests/preventDoubleSubmit/ netui/test/webapps/drt/coreWeb/miniTests/tiles/ netui/test/webapps/drt/coreWeb/miniTests/updateFormFromNested/ netui/test/webapps/drt/coreWeb/pageFlowCore/inheritance/super1/ netui/test/webapps/drt/coreWeb/pageFlowCore/pfPageInput/ netui/test/webapps/drt/coreWeb/tags/encoding/ netui/test/webapps/drt/coreWeb/template/xhtml/ netui/test/webapps/drt/coreWeb/tiles/pf/ netui/test/webapps/drt/coreWeb/tiles/pf/nested/ netui/test/webapps/drt/coreWeb/validation/addExpressionMessages/ netui/test/webapps/drt/coreWeb/validation/argExpressions/ netui/test/webapps/drt/coreWeb/validation/custom/ netui/test/webapps/drt/coreWeb/validation/declarativeValidation/

12 Apr 2005 07:10:32 -0000

Added: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/ReentrantLock.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/ReentrantLock.java?view=auto&rev=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/ReentrantLock.java
 (added)
+++ 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/ReentrantLock.java
 Mon Apr 11 23:42:11 2005
@@ -0,0 +1,871 @@
+/*
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/licenses/publicdomain
+ */
+
+package org.apache.beehive.netui.util.internal.concurrent;
+
+import java.util.*;
+
+/**
+ * A reentrant mutual exclusion [EMAIL PROTECTED] Lock} with the same basic
+ * behavior and semantics as the implicit monitor lock accessed using
+ * <tt>synchronized</tt> methods and statements, but with extended
+ * capabilities.
+ *
+ * <p> A <tt>ReentrantLock</tt> is <em>owned</em> by the thread last
+ * successfully locking, but not yet unlocking it. A thread invoking
+ * <tt>lock</tt> will return, successfully acquiring the lock, when
+ * the lock is not owned by another thread. The method will return
+ * immediately if the current thread already owns the lock. This can
+ * be checked using methods [EMAIL PROTECTED] #isHeldByCurrentThread}, and 
[EMAIL PROTECTED]
+ * #getHoldCount}.
+ *
+ * <p> The constructor for this class accepts an optional
+ * <em>fairness</em> parameter.  When set <tt>true</tt>, under
+ * contention, locks favor granting access to the longest-waiting
+ * thread.  Otherwise this lock does not guarantee any particular
+ * access order.  Programs using fair locks accessed by many threads
+ * may display lower overall throughput (i.e., are slower; often much
+ * slower) than those using the default setting, but have smaller
+ * variances in times to obtain locks and guarantee lack of
+ * starvation. Note however, that fairness of locks does not guarantee
+ * fairness of thread scheduling. Thus, one of many threads using a
+ * fair lock may obtain it multiple times in succession while other
+ * active threads are not progressing and not currently holding the
+ * lock.
+ * Also note that the untimed [EMAIL PROTECTED] #tryLock() tryLock} method 
does not
+ * honor the fairness setting. It will succeed if the lock
+ * is available even if other threads are waiting.
+ *
+ * <p> It is recommended practice to <em>always</em> immediately
+ * follow a call to <tt>lock</tt> with a <tt>try</tt> block, most
+ * typically in a before/after construction such as:
+ *
+ * <pre>
+ * class X {
+ *   private final ReentrantLock lock = new ReentrantLock();
+ *   // ...
+ *
+ *   public void m() {
+ *     lock.lock();  // block until condition holds
+ *     try {
+ *       // ... method body
+ *     } finally {
+ *       lock.unlock()
+ *     }
+ *   }
+ * }
+ * </pre>
+ *
+ * <p>In addition to implementing the [EMAIL PROTECTED] Lock} interface, this
+ * class defines methods <tt>isLocked</tt> and
+ * <tt>getLockQueueLength</tt>, as well as some associated
+ * <tt>protected</tt> access methods that may be useful for
+ * instrumentation and monitoring.
+ *
+ * <p> Serialization of this class behaves in the same way as built-in
+ * locks: a deserialized lock is in the unlocked state, regardless of
+ * its state when serialized.
+ *
+ * <p> This lock supports a maximum of 2147483648 recursive locks by
+ * the same thread.
+ *
+ * @since 1.5
+ * @author Doug Lea
+ * @author Dawid Kurzyniec
+ */
+class ReentrantLock implements Lock, java.io.Serializable,
+                                      CondVar.LockInfo {
+    private static final long serialVersionUID = 7373984872572414699L;
+
+    private final Impl impl;
+
+    static abstract class Impl {
+        protected Thread owner_ = null;
+        protected int holds_ = 0;
+
+        protected Impl() {}
+
+        public abstract void lockInterruptibly() throws InterruptedException;
+
+        public boolean tryLock() {
+            Thread caller = Thread.currentThread();
+            synchronized (this) {
+                if (owner_ == null) {
+                    owner_ = caller;
+                    holds_ = 1;
+                    return true;
+                }
+                else if (caller == owner_) {
+                    ++holds_;
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        public abstract boolean tryLock(long nanos) throws 
InterruptedException;
+
+        public abstract void unlock();
+
+        public synchronized int getHoldCount() {
+            return isHeldByCurrentThread() ? holds_ : 0;
+        }
+
+        public synchronized boolean isHeldByCurrentThread() {
+            return Thread.currentThread() == owner_;
+        }
+
+        public synchronized boolean isLocked() {
+            return owner_ != null;
+        }
+
+        public abstract boolean isFair();
+
+        protected synchronized Thread getOwner() {
+            return owner_;
+        }
+
+        public boolean hasQueuedThreads() {
+            throw new UnsupportedOperationException("Use FAIR version");
+        }
+
+        public int getQueueLength() {
+            throw new UnsupportedOperationException("Use FAIR version");
+        }
+
+        public Collection getQueuedThreads() {
+            throw new UnsupportedOperationException("Use FAIR version");
+        }
+
+        public boolean isQueued(Thread thread) {
+            throw new UnsupportedOperationException("Use FAIR version");
+        }
+    }
+
+    final static class NonfairImpl extends Impl implements 
java.io.Serializable {
+
+        NonfairImpl() {}
+
+        public void lockInterruptibly() throws InterruptedException {
+            if (Thread.interrupted()) throw new InterruptedException();
+            Thread caller = Thread.currentThread();
+            synchronized (this) {
+                if (owner_ == null) {
+                    owner_ = caller;
+                    holds_ = 1;
+                    return;
+                }
+                else if (caller == owner_) {
+                    ++holds_;
+                    return;
+                }
+                else {
+                    try {
+                        do { wait(); } while (owner_ != null);
+                        owner_ = caller;
+                        holds_ = 1;
+                        return;
+                    }
+                    catch (InterruptedException ex) {
+                        notify();
+                        throw ex;
+                    }
+                }
+            }
+        }
+
+        public boolean tryLock(long nanos) throws InterruptedException {
+            if (Thread.interrupted()) throw new InterruptedException();
+            Thread caller = Thread.currentThread();
+
+            synchronized (this) {
+                if (owner_ == null) {
+                    owner_ = caller;
+                    holds_ = 1;
+                    return true;
+                }
+                else if (caller == owner_) {
+                    ++holds_;
+                    return true;
+                }
+                else if (nanos <= 0)
+                    return false;
+                else {
+                    long deadline = Utils.nanoTime() + nanos;
+                    try {
+                        for (; ; ) {
+                            TimeUnit.NANOSECONDS.timedWait(this, nanos);
+                            if (caller == owner_) {
+                                ++holds_;
+                                return true;
+                            }
+                            else if (owner_ == null) {
+                                owner_ = caller;
+                                holds_ = 1;
+                                return true;
+                            }
+                            else {
+                                nanos = deadline - Utils.nanoTime();
+                                if (nanos <= 0)
+                                    return false;
+                            }
+                        }
+                    }
+                    catch (InterruptedException ex) {
+                        notify();
+                        throw ex;
+                    }
+                }
+            }
+        }
+
+        public synchronized void unlock() {
+            if (Thread.currentThread() != owner_)
+                throw new IllegalMonitorStateException("Not owner");
+
+            if (--holds_ == 0) {
+                owner_ = null;
+                notify();
+            }
+        }
+
+        public final boolean isFair() {
+            return false;
+        }
+    }
+
+    final static class FairImpl extends Impl implements WaitQueue.QueuedSync,
+                                                        java.io.Serializable  {
+
+        private final WaitQueue wq_ = new FIFOWaitQueue();
+
+        FairImpl() {}
+
+        public synchronized boolean recheck(WaitQueue.WaitNode node) {
+            Thread caller = Thread.currentThread();
+            if (owner_ == null) {
+                owner_ = caller;
+                holds_ = 1;
+                return true;
+            }
+            else if (caller == owner_) {
+                ++holds_;
+                return true;
+            }
+            wq_.insert(node);
+            return false;
+        }
+
+        public synchronized void takeOver(WaitQueue.WaitNode node) {
+            // assert (holds_ == 1 && owner_ == Thread.currentThread()
+            owner_ = node.getOwner();
+        }
+
+        public void lockInterruptibly() throws InterruptedException {
+            if (Thread.interrupted()) throw new InterruptedException();
+            Thread caller = Thread.currentThread();
+            synchronized (this) {
+                if (owner_ == null) {
+                    owner_ = caller;
+                    holds_ = 1;
+                    return;
+                }
+                else if (caller == owner_) {
+                    ++holds_;
+                    return;
+                }
+            }
+            WaitQueue.WaitNode n = new WaitQueue.WaitNode();
+            n.doWait(this);
+        }
+
+        public boolean tryLock(long nanos) throws InterruptedException {
+            if (Thread.interrupted()) throw new InterruptedException();
+            Thread caller = Thread.currentThread();
+            synchronized (this) {
+                if (owner_ == null) {
+                    owner_ = caller;
+                    holds_ = 1;
+                    return true;
+                }
+                else if (caller == owner_) {
+                    ++holds_;
+                    return true;
+                }
+            }
+            WaitQueue.WaitNode n = new WaitQueue.WaitNode();
+            return n.doTimedWait(this, nanos);
+        }
+
+        protected synchronized WaitQueue.WaitNode getSignallee(Thread caller) {
+            if (caller != owner_)
+                throw new IllegalMonitorStateException("Not owner");
+            // assert (holds_ > 0)
+            if (holds_ >= 2) { // current thread will keep the lock
+                --holds_;
+                return null;
+            }
+            // assert (holds_ == 1)
+            WaitQueue.WaitNode w = wq_.extract();
+            if (w == null) { // if none, clear for new arrivals
+                owner_ = null;
+                holds_ = 0;
+            }
+            return w;
+        }
+
+        public void unlock() {
+            Thread caller = Thread.currentThread();
+            for (;;) {
+                WaitQueue.WaitNode w = getSignallee(caller);
+                if (w == null) return;  // no one to signal
+                if (w.signal(this)) return; // notify if still waiting, else 
skip
+            }
+        }
+
+        public final boolean isFair() {
+            return true;
+        }
+
+        public synchronized boolean hasQueuedThreads() {
+            return wq_.hasNodes();
+        }
+
+        public synchronized int getQueueLength() {
+            return wq_.getLength();
+        }
+
+        public synchronized Collection getQueuedThreads() {
+            return wq_.getWaitingThreads();
+        }
+
+        public synchronized boolean isQueued(Thread thread) {
+            return wq_.isWaiting(thread);
+        }
+    }
+
+    /**
+     * Creates an instance of <tt>ReentrantLock</tt>.
+     * This is equivalent to using <tt>ReentrantLock(false)</tt>.
+     */
+    public ReentrantLock() {
+        impl = new NonfairImpl();
+    }
+
+    /**
+     * Creates an instance of <tt>ReentrantLock</tt> with the
+     * given fairness policy.
+     * @param fair true if this lock will be fair; else false
+     */
+    public ReentrantLock(boolean fair) {
+        impl = (fair)? (Impl)new FairImpl() : new NonfairImpl();
+    }
+
+
+    /**
+     * Acquires the lock.
+     *
+     * <p>Acquires the lock if it is not held by another thread and returns
+     * immediately, setting the lock hold count to one.
+     *
+     * <p>If the current thread
+     * already holds the lock then the hold count is incremented by one and
+     * the method returns immediately.
+     *
+     * <p>If the lock is held by another thread then the
+     * current thread becomes disabled for thread scheduling
+     * purposes and lies dormant until the lock has been acquired,
+     * at which time the lock hold count is set to one.
+     */
+    public void lock() {
+        boolean wasInterrupted = false;
+        while (true) {
+            try {
+                impl.lockInterruptibly();
+                if (wasInterrupted) {
+                    Thread.currentThread().interrupt();
+                }
+                return;
+            }
+            catch (InterruptedException e) {
+                wasInterrupted = true;
+            }
+        }
+    }
+
+    /**
+     * Acquires the lock unless the current thread is
+     * [EMAIL PROTECTED] Thread#interrupt interrupted}.
+     *
+     * <p>Acquires the lock if it is not held by another thread and returns
+     * immediately, setting the lock hold count to one.
+     *
+     * <p>If the current thread already holds this lock then the hold count
+     * is incremented by one and the method returns immediately.
+     *
+     * <p>If the lock is held by another thread then the
+     * current thread becomes disabled for thread scheduling
+     * purposes and lies dormant until one of two things happens:
+     *
+     * <ul>
+     *
+     * <li>The lock is acquired by the current thread; or
+     *
+     * <li>Some other thread [EMAIL PROTECTED] Thread#interrupt interrupts} 
the current
+     * thread.
+     *
+     * </ul>
+     *
+     * <p>If the lock is acquired by the current thread then the lock hold
+     * count is set to one.
+     *
+     * <p>If the current thread:
+     *
+     * <ul>
+     *
+     * <li>has its interrupted status set on entry to this method; or
+     *
+     * <li>is [EMAIL PROTECTED] Thread#interrupt interrupted} while acquiring
+     * the lock,
+     *
+     * </ul>
+     *
+     * then [EMAIL PROTECTED] InterruptedException} is thrown and the current 
thread's
+     * interrupted status is cleared.
+     *
+     * <p>In this implementation, as this method is an explicit interruption
+     * point, preference is
+     * given to responding to the interrupt over normal or reentrant
+     * acquisition of the lock.
+     *
+     * @throws InterruptedException if the current thread is interrupted
+     */
+    public void lockInterruptibly() throws InterruptedException {
+        impl.lockInterruptibly();
+    }
+
+    /**
+     * Acquires the lock only if it is not held by another thread at the time
+     * of invocation.
+     *
+     * <p>Acquires the lock if it is not held by another thread and
+     * returns immediately with the value <tt>true</tt>, setting the
+     * lock hold count to one. Even when this lock has been set to use a
+     * fair ordering policy, a call to <tt>tryLock()</tt> <em>will</em>
+     * immediately acquire the lock if it is available, whether or not
+     * other threads are currently waiting for the lock.
+     * This &quot;barging&quot; behavior can be useful in certain
+     * circumstances, even though it breaks fairness. If you want to honor
+     * the fairness setting for this lock, then use
+     * [EMAIL PROTECTED] #tryLock(long, TimeUnit) tryLock(0, TimeUnit.SECONDS) 
}
+     * which is almost equivalent (it also detects interruption).
+     *
+     * <p> If the current thread
+     * already holds this lock then the hold count is incremented by one and
+     * the method returns <tt>true</tt>.
+     *
+     * <p>If the lock is held by another thread then this method will return
+     * immediately with the value <tt>false</tt>.
+     *
+     * @return <tt>true</tt> if the lock was free and was acquired by the
+     * current thread, or the lock was already held by the current thread; and
+     * <tt>false</tt> otherwise.
+     */
+    public boolean tryLock() {
+        return impl.tryLock();
+    }
+
+    /**
+     * Acquires the lock if it is not held by another thread within the given
+     * waiting time and the current thread has not been
+     * [EMAIL PROTECTED] Thread#interrupt interrupted}.
+     *
+     * <p>Acquires the lock if it is not held by another thread and returns
+     * immediately with the value <tt>true</tt>, setting the lock hold count
+     * to one. If this lock has been set to use a fair ordering policy then
+     * an available lock <em>will not</em> be acquired if any other threads
+     * are waiting for the lock. This is in contrast to the [EMAIL PROTECTED] 
#tryLock()}
+     * method. If you want a timed <tt>tryLock</tt> that does permit barging on
+     * a fair lock then combine the timed and un-timed forms together:
+     *
+     * <pre>if (lock.tryLock() || lock.tryLock(timeout, unit) ) { ... }
+     * </pre>
+     *
+     * <p>If the current thread
+     * already holds this lock then the hold count is incremented by one and
+     * the method returns <tt>true</tt>.
+     *
+     * <p>If the lock is held by another thread then the
+     * current thread becomes disabled for thread scheduling
+     * purposes and lies dormant until one of three things happens:
+     *
+     * <ul>
+     *
+     * <li>The lock is acquired by the current thread; or
+     *
+     * <li>Some other thread [EMAIL PROTECTED] Thread#interrupt interrupts} 
the current
+     * thread; or
+     *
+     * <li>The specified waiting time elapses
+     *
+     * </ul>
+     *
+     * <p>If the lock is acquired then the value <tt>true</tt> is returned and
+     * the lock hold count is set to one.
+     *
+     * <p>If the current thread:
+     *
+     * <ul>
+     *
+     * <li>has its interrupted status set on entry to this method; or
+     *
+     * <li>is [EMAIL PROTECTED] Thread#interrupt interrupted} while acquiring
+     * the lock,
+     *
+     * </ul>
+     * then [EMAIL PROTECTED] InterruptedException} is thrown and the current 
thread's
+     * interrupted status is cleared.
+     *
+     * <p>If the specified waiting time elapses then the value <tt>false</tt>
+     * is returned.
+     * If the time is
+     * less than or equal to zero, the method will not wait at all.
+     *
+     * <p>In this implementation, as this method is an explicit interruption
+     * point, preference is
+     * given to responding to the interrupt over normal or reentrant
+     * acquisition of the lock, and over reporting the elapse of the waiting
+     * time.
+     *
+     * @param timeout the time to wait for the lock
+     * @param unit the time unit of the timeout argument
+     *
+     * @return <tt>true</tt> if the lock was free and was acquired by the
+     * current thread, or the lock was already held by the current thread; and
+     * <tt>false</tt> if the waiting time elapsed before the lock could be
+     * acquired.
+     *
+     * @throws InterruptedException if the current thread is interrupted
+     * @throws NullPointerException if unit is null
+     *
+     */
+    public boolean tryLock(long timeout, TimeUnit unit) throws 
InterruptedException {
+        return impl.tryLock(unit.toNanos(timeout));
+    }
+
+    /**
+     * Attempts to release this lock.
+     *
+     * <p>If the current thread is the
+     * holder of this lock then the hold count is decremented. If the
+     * hold count is now zero then the lock is released.  If the
+     * current thread is not the holder of this lock then [EMAIL PROTECTED]
+     * IllegalMonitorStateException} is thrown.
+     * @throws IllegalMonitorStateException if the current thread does not
+     * hold this lock.
+     */
+    public void unlock() {
+        impl.unlock();
+    }
+
+    /**
+     * Returns a [EMAIL PROTECTED] Condition} instance for use with this
+     * [EMAIL PROTECTED] Lock} instance.
+     *
+     * <p>The returned [EMAIL PROTECTED] Condition} instance supports the same
+     * usages as do the [EMAIL PROTECTED] Object} monitor methods ([EMAIL 
PROTECTED]
+     * Object#wait() wait}, [EMAIL PROTECTED] Object#notify notify}, and 
[EMAIL PROTECTED]
+     * Object#notifyAll notifyAll}) when used with the built-in
+     * monitor lock.
+     *
+     * <ul>
+     *
+     * <li>If this lock is not held when any of the [EMAIL PROTECTED] 
Condition}
+     * [EMAIL PROTECTED] Condition#await() waiting} or [EMAIL PROTECTED] 
Condition#signal
+     * signalling} methods are called, then an [EMAIL PROTECTED]
+     * IllegalMonitorStateException} is thrown.
+     *
+     * <li>When the condition [EMAIL PROTECTED] Condition#await() waiting}
+     * methods are called the lock is released and, before they
+     * return, the lock is reacquired and the lock hold count restored
+     * to what it was when the method was called.
+     *
+     * <li>If a thread is [EMAIL PROTECTED] Thread#interrupt interrupted} while
+     * waiting then the wait will terminate, an [EMAIL PROTECTED]
+     * InterruptedException} will be thrown, and the thread's
+     * interrupted status will be cleared.
+     *
+     * <li> Waiting threads are signalled in FIFO order
+     *
+     * <li>The ordering of lock reacquisition for threads returning
+     * from waiting methods is the same as for threads initially
+     * acquiring the lock, which is in the default case not specified,
+     * but for <em>fair</em> locks favors those threads that have been
+     * waiting the longest.
+     *
+     * </ul>
+     *
+     * @return the Condition object
+     */
+    public Condition newCondition() {
+        return new CondVar(this);
+    }
+
+    /**
+     * Queries the number of holds on this lock by the current thread.
+     *
+     * <p>A thread has a hold on a lock for each lock action that is not
+     * matched by an unlock action.
+     *
+     * <p>The hold count information is typically only used for testing and
+     * debugging purposes. For example, if a certain section of code should
+     * not be entered with the lock already held then we can assert that
+     * fact:
+     *
+     * <pre>
+     * class X {
+     *   ReentrantLock lock = new ReentrantLock();
+     *   // ...
+     *   public void m() {
+     *     assert lock.getHoldCount() == 0;
+     *     lock.lock();
+     *     try {
+     *       // ... method body
+     *     } finally {
+     *       lock.unlock();
+     *     }
+     *   }
+     * }
+     * </pre>
+     *
+     * @return the number of holds on this lock by the current thread,
+     * or zero if this lock is not held by the current thread.
+     */
+    public int getHoldCount() {
+        return impl.getHoldCount();
+    }
+
+    /**
+     * Queries if this lock is held by the current thread.
+     *
+     * <p>Analogous to the [EMAIL PROTECTED] Thread#holdsLock} method for 
built-in
+     * monitor locks, this method is typically used for debugging and
+     * testing. For example, a method that should only be called while
+     * a lock is held can assert that this is the case:
+     *
+     * <pre>
+     * class X {
+     *   ReentrantLock lock = new ReentrantLock();
+     *   // ...
+     *
+     *   public void m() {
+     *       assert lock.isHeldByCurrentThread();
+     *       // ... method body
+     *   }
+     * }
+     * </pre>
+     *
+     * <p>It can also be used to ensure that a reentrant lock is used
+     * in a non-reentrant manner, for example:
+     *
+     * <pre>
+     * class X {
+     *   ReentrantLock lock = new ReentrantLock();
+     *   // ...
+     *
+     *   public void m() {
+     *       assert !lock.isHeldByCurrentThread();
+     *       lock.lock();
+     *       try {
+     *           // ... method body
+     *       } finally {
+     *           lock.unlock();
+     *       }
+     *   }
+     * }
+     * </pre>
+     * @return <tt>true</tt> if current thread holds this lock and
+     * <tt>false</tt> otherwise.
+     */
+    public boolean isHeldByCurrentThread() {
+        return impl.isHeldByCurrentThread();
+    }
+
+    /**
+     * Queries if this lock is held by any thread. This method is
+     * designed for use in monitoring of the system state,
+     * not for synchronization control.
+     * @return <tt>true</tt> if any thread holds this lock and
+     * <tt>false</tt> otherwise.
+     */
+    public boolean isLocked() {
+        return impl.isLocked();
+    }
+
+    /**
+     * Returns true if this lock has fairness set true.
+     * @return true if this lock has fairness set true.
+     */
+    public final boolean isFair() {
+        return impl.isFair();
+    }
+
+    /**
+     * Returns the thread that currently owns this lock, or
+     * <tt>null</tt> if not owned. Note that the owner may be
+     * momentarily <tt>null</tt> even if there are threads trying to
+     * acquire the lock but have not yet done so.  This method is
+     * designed to facilitate construction of subclasses that provide
+     * more extensive lock monitoring facilities.
+     * @return the owner, or <tt>null</tt> if not owned.
+     */
+    protected Thread getOwner() {
+        return impl.getOwner();
+    }
+
+    /**
+     * Queries whether any threads are waiting to acquire this lock. Note that
+     * because cancellations may occur at any time, a <tt>true</tt>
+     * return does not guarantee that any other thread will ever
+     * acquire this lock.  This method is designed primarily for use in
+     * monitoring of the system state.
+     *
+     * @return true if there may be other threads waiting to acquire
+     * the lock.
+     */
+    public final boolean hasQueuedThreads() {
+        return impl.hasQueuedThreads();
+    }
+
+
+    /**
+     * Queries whether the given thread is waiting to acquire this
+     * lock. Note that because cancellations may occur at any time, a
+     * <tt>true</tt> return does not guarantee that this thread
+     * will ever acquire this lock.  This method is designed primarily for use
+     * in monitoring of the system state.
+     *
+     * @param thread the thread
+     * @return true if the given thread is queued waiting for this lock.
+     * @throws NullPointerException if thread is null
+     */
+    public final boolean hasQueuedThread(Thread thread) {
+        return impl.isQueued(thread);
+    }
+
+
+    /**
+     * Returns an estimate of the number of threads waiting to
+     * acquire this lock.  The value is only an estimate because the number of
+     * threads may change dynamically while this method traverses
+     * internal data structures.  This method is designed for use in
+     * monitoring of the system state, not for synchronization
+     * control.
+     * @return the estimated number of threads waiting for this lock
+     */
+    public final int getQueueLength() {
+        return impl.getQueueLength();
+    }
+
+    /**
+     * Returns a collection containing threads that may be waiting to
+     * acquire this lock.  Because the actual set of threads may change
+     * dynamically while constructing this result, the returned
+     * collection is only a best-effort estimate.  The elements of the
+     * returned collection are in no particular order.  This method is
+     * designed to facilitate construction of subclasses that provide
+     * more extensive monitoring facilities.
+     * @return the collection of threads
+     */
+    protected Collection getQueuedThreads() {
+        return impl.getQueuedThreads();
+    }
+
+//    /**
+//     * Queries whether any threads are waiting on the given condition
+//     * associated with this lock. Note that because timeouts and
+//     * interrupts may occur at any time, a <tt>true</tt> return does
+//     * not guarantee that a future <tt>signal</tt> will awaken any
+//     * threads.  This method is designed primarily for use in
+//     * monitoring of the system state.
+//     * @param condition the condition
+//     * @return <tt>true</tt> if there are any waiting threads.
+//     * @throws IllegalMonitorStateException if this lock
+//     * is not held
+//     * @throws IllegalArgumentException if the given condition is
+//     * not associated with this lock
+//     * @throws NullPointerException if condition null
+//     */
+//    public boolean hasWaiters(Condition condition) {
+//        if (condition == null)
+//            throw new NullPointerException();
+//        if (!(condition instanceof 
AbstractQueuedSynchronizer.ConditionObject))
+//            throw new IllegalArgumentException("not owner");
+//        return 
sync.hasWaiters((AbstractQueuedSynchronizer.ConditionObject)condition);
+//    }
+
+//    /**
+//     * Returns an estimate of the number of threads waiting on the
+//     * given condition associated with this lock. Note that because
+//     * timeouts and interrupts may occur at any time, the estimate
+//     * serves only as an upper bound on the actual number of waiters.
+//     * This method is designed for use in monitoring of the system
+//     * state, not for synchronization control.
+//     * @param condition the condition
+//     * @return the estimated number of waiting threads.
+//     * @throws IllegalMonitorStateException if this lock
+//     * is not held
+//     * @throws IllegalArgumentException if the given condition is
+//     * not associated with this lock
+//     * @throws NullPointerException if condition null
+//     */
+//    public int getWaitQueueLength(Condition condition) {
+//        if (condition == null)
+//            throw new NullPointerException();
+//        if (!(condition instanceof 
AbstractQueuedSynchronizer.ConditionObject))
+//            throw new IllegalArgumentException("not owner");
+//        return 
sync.getWaitQueueLength((AbstractQueuedSynchronizer.ConditionObject)condition);
+//    }
+
+//    /**
+//     * Returns a collection containing those threads that may be
+//     * waiting on the given condition associated with this lock.
+//     * Because the actual set of threads may change dynamically while
+//     * constructing this result, the returned collection is only a
+//     * best-effort estimate. The elements of the returned collection
+//     * are in no particular order.  This method is designed to
+//     * facilitate construction of subclasses that provide more
+//     * extensive condition monitoring facilities.
+//     * @param condition the condition
+//     * @return the collection of threads
+//     * @throws IllegalMonitorStateException if this lock
+//     * is not held
+//     * @throws IllegalArgumentException if the given condition is
+//     * not associated with this lock
+//     * @throws NullPointerException if condition null
+//     */
+//    protected Collection getWaitingThreads(Condition condition) {
+//        if (condition == null)
+//            throw new NullPointerException();
+//        if (!(condition instanceof 
AbstractQueuedSynchronizer.ConditionObject))
+//            throw new IllegalArgumentException("not owner");
+//        return 
sync.getWaitingThreads((AbstractQueuedSynchronizer.ConditionObject)condition);
+//    }
+
+    /**
+     * Returns a string identifying this lock, as well as its lock
+     * state.  The state, in brackets, includes either the String
+     * &quot;Unlocked&quot; or the String &quot;Locked by&quot;
+     * followed by the [EMAIL PROTECTED] Thread#getName} of the owning thread.
+     * @return a string identifying this lock, as well as its lock state.
+     */
+    public String toString() {
+        Thread owner = getOwner();
+        return super.toString() + ((owner == null) ?
+                                   "[Unlocked]" :
+                                   "[Locked by thread " + owner.getName() + 
"]");
+    }
+}

Propchange: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/ReentrantLock.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/TimeUnit.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/TimeUnit.java?view=auto&rev=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/TimeUnit.java
 (added)
+++ 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/TimeUnit.java
 Mon Apr 11 23:42:11 2005
@@ -0,0 +1,328 @@
+/*
+  * Written by Doug Lea with assistance from members of JCP JSR-166
+  * Expert Group and released to the public domain, as explained at
+  * http://creativecommons.org/licenses/publicdomain
+  */
+
+package org.apache.beehive.netui.util.internal.concurrent;
+
+/**
+  * A <tt>TimeUnit</tt> represents time durations at a given unit of
+  * granularity and provides utility methods to convert across units,
+  * and to perform timing and delay operations in these units.  A
+  * <tt>TimeUnit</tt> does not maintain time information, but only
+  * helps organize and use time representations that may be maintained
+  * separately across various contexts.  A nanosecond is defined as one
+  * thousandth of a microsecond, a microsecond as one thousandth of a
+  * millisecond, a millisecond as one thousandth of a second, a minute
+  * as sixty seconds, an hour as sixty minutes, and a day as twenty four
+  * hours.
+  *
+  * <p>A <tt>TimeUnit</tt> is mainly used to inform time-based methods
+  * how a given timing parameter should be interpreted. For example,
+  * the following code will timeout in 50 milliseconds if the [EMAIL PROTECTED]
+  * org.apache.beehive.netui.util.concurrent.locks.Lock lock} is not available:
+  *
+  * <pre>  Lock lock = ...;
+  *  if ( lock.tryLock(50L, TimeUnit.MILLISECONDS) ) ...
+  * </pre>
+  * while this code will timeout in 50 seconds:
+  * <pre>
+  *  Lock lock = ...;
+  *  if ( lock.tryLock(50L, TimeUnit.SECONDS) ) ...
+  * </pre>
+  *
+  * Note however, that there is no guarantee that a particular timeout
+  * implementation will be able to notice the passage of time at the
+  * same granularity as the given <tt>TimeUnit</tt>.
+  *
+  * @since 1.5
+  * @author Doug Lea
+  */
+abstract class TimeUnit implements java.io.Serializable {
+
+     public static final TimeUnit NANOSECONDS = new TimeUnit(0, "NANOSECONDS") 
{
+         public long toNanos(long d)   { return d; }
+         public long toMicros(long d)  { return d/(C1/C0); }
+         public long toMillis(long d)  { return d/(C2/C0); }
+         public long toSeconds(long d) { return d/(C3/C0); }
+         public long toMinutes(long d) { return d/(C4/C0); }
+         public long toHours(long d)   { return d/(C5/C0); }
+         public long toDays(long d)    { return d/(C6/C0); }
+         public long convert(long d, TimeUnit u) { return u.toNanos(d); }
+         int excessNanos(long d, long m) { return (int)(d - (m*C2)); }
+     };
+     public static final TimeUnit MICROSECONDS = new TimeUnit(1, 
"MICROSECONDS") {
+         public long toNanos(long d)   { return x(d, C1/C0, MAX/(C1/C0)); }
+         public long toMicros(long d)  { return d; }
+         public long toMillis(long d)  { return d/(C2/C1); }
+         public long toSeconds(long d) { return d/(C3/C1); }
+         public long toMinutes(long d) { return d/(C4/C1); }
+         public long toHours(long d)   { return d/(C5/C1); }
+         public long toDays(long d)    { return d/(C6/C1); }
+         public long convert(long d, TimeUnit u) { return u.toMicros(d); }
+         int excessNanos(long d, long m) { return (int)((d*C1) - (m*C2)); }
+     };
+     public static final TimeUnit MILLISECONDS = new TimeUnit(2, 
"MILLISECONDS") {
+         public long toNanos(long d)   { return x(d, C2/C0, MAX/(C2/C0)); }
+         public long toMicros(long d)  { return x(d, C2/C1, MAX/(C2/C1)); }
+         public long toMillis(long d)  { return d; }
+         public long toSeconds(long d) { return d/(C3/C2); }
+         public long toMinutes(long d) { return d/(C4/C2); }
+         public long toHours(long d)   { return d/(C5/C2); }
+         public long toDays(long d)    { return d/(C6/C2); }
+         public long convert(long d, TimeUnit u) { return u.toMillis(d); }
+         int excessNanos(long d, long m) { return 0; }
+     };
+     public static final TimeUnit SECONDS = new TimeUnit(3, "SECONDS") {
+         public long toNanos(long d)   { return x(d, C3/C0, MAX/(C3/C0)); }
+         public long toMicros(long d)  { return x(d, C3/C1, MAX/(C3/C1)); }
+         public long toMillis(long d)  { return x(d, C3/C2, MAX/(C3/C2)); }
+         public long toSeconds(long d) { return d; }
+         public long toMinutes(long d) { return d/(C4/C3); }
+         public long toHours(long d)   { return d/(C5/C3); }
+         public long toDays(long d)    { return d/(C6/C3); }
+         public long convert(long d, TimeUnit u) { return u.toSeconds(d); }
+         int excessNanos(long d, long m) { return 0; }
+     };
+     public static final TimeUnit MINUTES = new TimeUnit(4, "MINUTES") {
+         public long toNanos(long d)   { return x(d, C4/C0, MAX/(C4/C0)); }
+         public long toMicros(long d)  { return x(d, C4/C1, MAX/(C4/C1)); }
+         public long toMillis(long d)  { return x(d, C4/C2, MAX/(C4/C2)); }
+         public long toSeconds(long d) { return x(d, C4/C3, MAX/(C4/C3)); }
+         public long toMinutes(long d) { return d; }
+         public long toHours(long d)   { return d/(C5/C4); }
+         public long toDays(long d)    { return d/(C6/C4); }
+         public long convert(long d, TimeUnit u) { return u.toMinutes(d); }
+         int excessNanos(long d, long m) { return 0; }
+     };
+     public static final TimeUnit HOURS = new TimeUnit(5, "HOURS") {
+         public long toNanos(long d)   { return x(d, C5/C0, MAX/(C5/C0)); }
+         public long toMicros(long d)  { return x(d, C5/C1, MAX/(C5/C1)); }
+         public long toMillis(long d)  { return x(d, C5/C2, MAX/(C5/C2)); }
+         public long toSeconds(long d) { return x(d, C5/C3, MAX/(C5/C3)); }
+         public long toMinutes(long d) { return x(d, C5/C4, MAX/(C5/C4)); }
+         public long toHours(long d)   { return d; }
+         public long toDays(long d)    { return d/(C6/C5); }
+         public long convert(long d, TimeUnit u) { return u.toHours(d); }
+         int excessNanos(long d, long m) { return 0; }
+     };
+     public static final TimeUnit DAYS = new TimeUnit(6, "DAYS") {
+         public long toNanos(long d)   { return x(d, C6/C0, MAX/(C6/C0)); }
+         public long toMicros(long d)  { return x(d, C6/C1, MAX/(C6/C1)); }
+         public long toMillis(long d)  { return x(d, C6/C2, MAX/(C6/C2)); }
+         public long toSeconds(long d) { return x(d, C6/C3, MAX/(C6/C3)); }
+         public long toMinutes(long d) { return x(d, C6/C4, MAX/(C6/C4)); }
+         public long toHours(long d)   { return x(d, C6/C5, MAX/(C6/C5)); }
+         public long toDays(long d)    { return d; }
+         public long convert(long d, TimeUnit u) { return u.toDays(d); }
+         int excessNanos(long d, long m) { return 0; }
+     };
+
+     private static final TimeUnit[] values = new TimeUnit[]
+         { NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, 
DAYS };
+
+     public static TimeUnit[] values() {
+         return (TimeUnit[])values.clone();
+     }
+
+     /**
+      * The index of this unit. This value is no longer used in this
+      * version of this class, but is retained for serialization
+      * compatibility with previous version.
+      */
+     private final int index;
+
+     /** name of this unit */
+     private final String name;
+
+     /** Internal constructor */
+     TimeUnit(int index, String name) {
+         this.index = index;
+         this.name = name;
+     }
+
+     // Handy constants for conversion methods
+     static final long C0 = 1;
+     static final long C1 = C0 * 1000;
+     static final long C2 = C1 * 1000;
+     static final long C3 = C2 * 1000;
+     static final long C4 = C3 * 60;
+     static final long C5 = C4 * 60;
+     static final long C6 = C5 * 24;
+
+     static final long MAX = Long.MAX_VALUE;
+
+     /**
+      * Scale d by m, checking for overflow.
+      * This has a short name to make above code more readable.
+      */
+     static long x(long d, long m, long over) {
+         if (d >  over) return Long.MAX_VALUE;
+         if (d < -over) return Long.MIN_VALUE;
+         return d * m;
+     }
+
+     /**
+      * Convert the given time duration in the given unit to this
+      * unit.  Conversions from finer to coarser granularities
+      * truncate, so lose precision. For example converting
+      * <tt>999</tt> milliseconds to seconds results in
+      * <tt>0</tt>. Conversions from coarser to finer granularities
+      * with arguments that would numerically overflow saturate to
+      * <tt>Long.MIN_VALUE</tt> if negative or <tt>Long.MAX_VALUE</tt>
+      * if positive.
+      *
+      * @param duration the time duration in the given <tt>unit</tt>
+      * @param unit the unit of the <tt>duration</tt> argument
+      * @return the converted duration in this unit,
+      * or <tt>Long.MIN_VALUE</tt> if conversion would negatively
+      * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
+      */
+     public abstract long convert(long duration, TimeUnit unit);
+
+     /**
+      * Equivalent to <tt>NANOSECONDS.convert(duration, this)</tt>.
+      * @param duration the duration
+      * @return the converted duration,
+      * or <tt>Long.MIN_VALUE</tt> if conversion would negatively
+      * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
+      * @see #convert
+      */
+     public abstract long toNanos(long duration);
+
+     /**
+      * Equivalent to <tt>MICROSECONDS.convert(duration, this)</tt>.
+      * @param duration the duration
+      * @return the converted duration,
+      * or <tt>Long.MIN_VALUE</tt> if conversion would negatively
+      * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
+      * @see #convert
+      */
+     public abstract long toMicros(long duration);
+
+     /**
+      * Equivalent to <tt>MILLISECONDS.convert(duration, this)</tt>.
+      * @param duration the duration
+      * @return the converted duration,
+      * or <tt>Long.MIN_VALUE</tt> if conversion would negatively
+      * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
+      * @see #convert
+      */
+     public abstract long toMillis(long duration);
+
+     /**
+      * Equivalent to <tt>SECONDS.convert(duration, this)</tt>.
+      * @param duration the duration
+      * @return the converted duration,
+      * or <tt>Long.MIN_VALUE</tt> if conversion would negatively
+      * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
+      * @see #convert
+      */
+     public abstract long toSeconds(long duration);
+
+     /**
+      * Equivalent to <tt>MINUTES.convert(duration, this)</tt>.
+      * @param duration the duration
+      * @return the converted duration,
+      * or <tt>Long.MIN_VALUE</tt> if conversion would negatively
+      * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
+      * @see #convert
+      */
+     public abstract long toMinutes(long duration);
+
+     /**
+      * Equivalent to <tt>HOURS.convert(duration, this)</tt>.
+      * @param duration the duration
+      * @return the converted duration,
+      * or <tt>Long.MIN_VALUE</tt> if conversion would negatively
+      * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
+      * @see #convert
+      */
+     public abstract long toHours(long duration);
+
+     /**
+      * Equivalent to <tt>DAYS.convert(duration, this)</tt>.
+      * @param duration the duration
+      * @return the converted duration
+      * @see #convert
+      */
+     public abstract long toDays(long duration);
+
+     /**
+      * Utility to compute the excess-nanosecond argument to wait,
+      * sleep, join.
+      * @param d the duration
+      * @param m the number of millisecondss
+      * @return the number of nanoseconds
+      */
+     abstract int excessNanos(long d, long m);
+
+     /**
+      * Perform a timed <tt>Object.wait</tt> using this time unit.
+      * This is a convenience method that converts timeout arguments
+      * into the form required by the <tt>Object.wait</tt> method.
+      *
+      * <p>For example, you could implement a blocking <tt>poll</tt>
+      * method (see [EMAIL PROTECTED] BlockingQueue#poll BlockingQueue.poll})
+      * using:
+      *
+      * <pre>  public synchronized  Object poll(long timeout, TimeUnit unit) 
throws InterruptedException {
+      *    while (empty) {
+      *      unit.timedWait(this, timeout);
+      *      ...
+      *    }
+      *  }</pre>
+      *
+      * @param obj the object to wait on
+      * @param timeout the maximum time to wait.
+      * @throws InterruptedException if interrupted while waiting.
+      * @see java.lang.Object#wait(long, int)
+      */
+     public void timedWait(Object obj, long timeout)
+         throws InterruptedException {
+         if (timeout > 0) {
+             long ms = toMillis(timeout);
+             int ns = excessNanos(timeout, ms);
+             obj.wait(ms, ns);
+         }
+     }
+
+     /**
+      * Perform a timed <tt>Thread.join</tt> using this time unit.
+      * This is a convenience method that converts time arguments into the
+      * form required by the <tt>Thread.join</tt> method.
+      * @param thread the thread to wait for
+      * @param timeout the maximum time to wait
+      * @throws InterruptedException if interrupted while waiting.
+      * @see java.lang.Thread#join(long, int)
+      */
+     public void timedJoin(Thread thread, long timeout)
+         throws InterruptedException {
+         if (timeout > 0) {
+             long ms = toMillis(timeout);
+             int ns = excessNanos(timeout, ms);
+             thread.join(ms, ns);
+         }
+     }
+
+     /**
+      * Perform a <tt>Thread.sleep</tt> using this unit.
+      * This is a convenience method that converts time arguments into the
+      * form required by the <tt>Thread.sleep</tt> method.
+      * @param timeout the minimum time to sleep
+      * @throws InterruptedException if interrupted while sleeping.
+      * @see java.lang.Thread#sleep
+      */
+     public void sleep(long timeout) throws InterruptedException {
+         if (timeout > 0) {
+             long ms = toMillis(timeout);
+             int ns = excessNanos(timeout, ms);
+             Thread.sleep(ms, ns);
+         }
+     }
+
+     public String toString() {
+         return name;
+     }
+}

Propchange: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/TimeUnit.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/Utils.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/Utils.java?view=auto&rev=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/Utils.java
 (added)
+++ 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/Utils.java
 Mon Apr 11 23:42:11 2005
@@ -0,0 +1,266 @@
+/*
+ * Written by Dawid Kurzyniec, based on code written by Doug Lea with 
assistance
+ * from members of JCP JSR-166 Expert Group. Released to the public domain,
+ * as explained at http://creativecommons.org/licenses/publicdomain.
+ *
+ * Thanks to Craig Mattocks for suggesting to use <code>sun.misc.Perf</code>.
+ */
+
+package org.apache.beehive.netui.util.internal.concurrent;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * <p>
+ * This class groups together the functionality of java.util.concurrent that
+ * cannot be fully and reliably implemented in backport, but for which some
+ * form of emulation is possible.
+ * <p>
+ * Currently, this class contains methods related to nanosecond-precision
+ * timing, particularly via the [EMAIL PROTECTED] #nanoTime} method. To 
measure time
+ * accurately, this method by default uses <code>java.sun.Perf</code> on
+ * JDK1.4.2 and it falls back to <code>System.currentTimeMillis</code>
+ * on earlier JDKs.
+ *
+ * @author Dawid Kurzyniec
+ * @version 1.0
+ */
+final class Utils {
+
+    private final static NanoTimer nanoTimer;
+    private final static String providerProp =
+        "org.apache.beehive.netui.util.concurrent.NanoTimerProvider";
+
+    static {
+        NanoTimer timer = null;
+        try {
+            String nanoTimerClassName = (String)
+                AccessController.doPrivileged(new PrivilegedAction() {
+                    public Object run() {
+                        return System.getProperty(providerProp);
+                    }
+                });
+            if (nanoTimerClassName != null) {
+                Class cls = Class.forName(nanoTimerClassName);
+                timer = (NanoTimer) cls.newInstance();
+            }
+        }
+        catch (Exception e) {
+            System.err.println("WARNING: unable to load Perf provider; " +
+                               "switching to a default");
+            e.printStackTrace();
+        }
+
+        if (timer == null) {
+            try {
+                timer = new SunPerfProvider();
+            }
+            catch (Throwable e) {}
+        }
+
+        if (timer == null) {
+            timer = new MillisProvider();
+        }
+
+        nanoTimer = timer;
+    }
+
+    private Utils() {}
+
+    /**
+     * Returns the current value of the most precise available system timer,
+     * in nanoseconds. This method can only be used to measure elapsed time and
+     * is not related to any other notion of system or wall-clock time. The
+     * value returned represents nanoseconds since some fixed but arbitrary
+     * time (perhaps in the future, so values may be negative). This method
+     * provides nanosecond precision, but not necessarily nanosecond accuracy.
+     * No guarantees are made about how frequently values change. Differences
+     * in successive calls that span greater than approximately 292 years
+     * (263 nanoseconds) will not accurately compute elapsed time due to
+     * numerical overflow.
+     * <p>
+     * <em>Implementation note:</em>By default, this method uses
+     * <code>sun.misc.Perf</code> on Java 1.4.2, and falls back to
+     * System.currentTimeMillis() emulation on earlier JDKs. Custom
+     * timer can be provided via the system property
+     * <code>org.apache.beehive.netui.util.concurrent.NanoTimerProvider</code>.
+     * The value of the property should name a class implementing
+     * [EMAIL PROTECTED] NanoTimer} interface.
+     * <p>
+     * Note: on JDK 1.4.2, <code>sun.misc.Perf</code> timer seems to have
+     * resolution of the order of 1 microsecond, measured on Linux.
+     *
+     * @return The current value of the system timer, in nanoseconds.
+     */
+    public static long nanoTime() {
+        return nanoTimer.nanoTime();
+    }
+
+    /**
+     * Causes the current thread to wait until it is signalled or interrupted,
+     * or the specified waiting time elapses. This method originally appears
+     * in the [EMAIL PROTECTED] Condition} interface, but it was moved to here 
since it
+     * can only be emulated, with very little accuracy guarantees: the
+     * efficient implementation requires accurate nanosecond timer and native
+     * support for nanosecond-precision wait queues, which are not usually
+     * present in JVMs prior to 1.5. Loss of precision may cause total waiting
+     * times to be systematically shorter than specified when re-waits occur.
+     *
+     * <p>The lock associated with this condition is atomically
+     * released and the current thread becomes disabled for thread scheduling
+     * purposes and lies dormant until <em>one</em> of five things happens:
+     * <ul>
+     * <li>Some other thread invokes the [EMAIL PROTECTED]
+     * org.apache.beehive.netui.util.concurrent.locks.Condition#signal}
+     * method for this
+     * <tt>Condition</tt> and the current thread happens to be chosen as the
+     * thread to be awakened; or
+     * <li>Some other thread invokes the [EMAIL PROTECTED]
+     * org.apache.beehive.netui.util.concurrent.locks.Condition#signalAll}
+     * method for this
+     * <tt>Condition</tt>; or
+     * <li>Some other thread [EMAIL PROTECTED] Thread#interrupt interrupts} 
the current
+     * thread, and interruption of thread suspension is supported; or
+     * <li>The specified waiting time elapses; or
+     * <li>A &quot;<em>spurious wakeup</em>&quot; occurs.
+     * </ul>
+     *
+     * <p>In all cases, before this method can return the current thread must
+     * re-acquire the lock associated with this condition. When the
+     * thread returns it is <em>guaranteed</em> to hold this lock.
+     *
+     * <p>If the current thread:
+     * <ul>
+     * <li>has its interrupted status set on entry to this method; or
+     * <li>is [EMAIL PROTECTED] Thread#interrupt interrupted} while waiting
+     * and interruption of thread suspension is supported,
+     * </ul>
+     * then [EMAIL PROTECTED] InterruptedException} is thrown and the current 
thread's
+     * interrupted status is cleared. It is not specified, in the first
+     * case, whether or not the test for interruption occurs before the lock
+     * is released.
+     *
+     * <p>The method returns an estimate of the number of nanoseconds
+     * remaining to wait given the supplied <tt>nanosTimeout</tt>
+     * value upon return, or a value less than or equal to zero if it
+     * timed out. Accuracy of this estimate is directly dependent on the
+     * accuracy of [EMAIL PROTECTED] #nanoTime}. This value can be used to 
determine
+     * whether and how long to re-wait in cases where the wait returns but an
+     * awaited condition still does not hold. Typical uses of this method take
+     * the following form:
+     *
+     * <pre>
+     * synchronized boolean aMethod(long timeout, TimeUnit unit) {
+     *   long nanosTimeout = unit.toNanos(timeout);
+     *   while (!conditionBeingWaitedFor) {
+     *     if (nanosTimeout &gt; 0)
+     *         nanosTimeout = theCondition.awaitNanos(nanosTimeout);
+     *      else
+     *        return false;
+     *   }
+     *   // ...
+     * }
+     * </pre>
+     *
+     * <p><b>Implementation Considerations</b>
+     * <p>The current thread is assumed to hold the lock associated with this
+     * <tt>Condition</tt> when this method is called.
+     * It is up to the implementation to determine if this is
+     * the case and if not, how to respond. Typically, an exception will be
+     * thrown (such as [EMAIL PROTECTED] IllegalMonitorStateException}) and the
+     * implementation must document that fact.
+     *
+     * <p>A condition implementation can favor responding to an interrupt over
+     * normal method return in response to a signal, or over indicating the
+     * elapse of the specified waiting time. In either case the implementation
+     * must ensure that the signal is redirected to another waiting thread, if
+     * there is one.
+     *
+     * @param cond the condition to wait for
+     * @param nanosTimeout the maximum time to wait, in nanoseconds
+     * @return A value less than or equal to zero if the wait has
+     * timed out; otherwise an estimate, that
+     * is strictly less than the <tt>nanosTimeout</tt> argument,
+     * of the time still remaining when this method returned.
+     *
+     * @throws InterruptedException if the current thread is interrupted (and
+     * interruption of thread suspension is supported).
+     */
+    public static long awaitNanos(Condition cond, long nanosTimeout)
+        throws InterruptedException
+    {
+        if (nanosTimeout <= 0) return nanosTimeout;
+        long now = nanoTime();
+        cond.await(nanosTimeout, TimeUnit.NANOSECONDS);
+        return nanosTimeout - (nanoTime() - now);
+    }
+
+    private static final class SunPerfProvider implements NanoTimer {
+        final sun.misc.Perf perf;
+        final long multiplier, divisor;
+        SunPerfProvider() {
+            perf = (sun.misc.Perf)
+                AccessController.doPrivileged(new PrivilegedAction() {
+                    public Object run() {
+                        return sun.misc.Perf.getPerf();
+                    }
+                });
+            // trying to avoid BOTH overflow and rounding errors
+            long numerator = 1000000000;
+            long denominator = perf.highResFrequency();
+            long gcd = gcd(numerator, denominator);
+            this.multiplier = numerator / gcd;
+            this.divisor = denominator / gcd;
+        }
+        public long nanoTime() {
+            long ctr = perf.highResCounter();
+
+            // anything less sophisticated suffers either from rounding errors
+            // (FP arithmetics, backport v1.0) or overflow, when gcd is small
+            // (a bug in backport v1.0_01 reported by Ramesh Nethi)
+
+            return ((ctr / divisor) * multiplier) +
+                    (ctr % divisor) * multiplier / divisor;
+
+            // even the above can theoretically cause problems if your JVM is
+            // running for sufficiently long time, but "sufficiently" means 292
+            // years (worst case), or 30,000 years (common case).
+
+            // Details: when the ticks ctr overflows, there is no way to avoid
+            // discontinuity in computed nanos, even in infinite arithmetics,
+            // unless we count number of overflows that the ctr went through
+            // since the JVM started. This follows from the fact that
+            // (2^64*multiplier/divisor) mod (2^64) > 0 in general case.
+            // Theoretically we could find out the number of overflows by
+            // checking System.currentTimeMillis(), but this is unreliable
+            // since the system time can unpredictably change during the JVM
+            // lifetime.
+            // The time to overflow is 2^63 / ticks frequency. With current
+            // ticks frequencies of several MHz, it gives about 30,000 years
+            // before the problem happens. If ticks frequency reaches 1 GHz, 
the
+            // time to overflow is 292 years. It is unlikely that the frequency
+            // ever exceeds 1 GHz. We could double the time to overflow
+            // (to 2^64 / frequency) by using unsigned arithmetics, e.g. by
+            // adding the following correction whenever the ticks is negative:
+            //      -2*((Long.MIN_VALUE / divisor) * multiplier +
+            //          (Long.MIN_VALUE % divisor) * multiplier / divisor)
+            // But, with the worst case of as much as 292 years, it does not
+            // seem justified.
+        }
+    }
+
+    private static final class MillisProvider implements NanoTimer {
+        MillisProvider() {}
+        public long nanoTime() {
+            return System.currentTimeMillis() * 1000000;
+        }
+    }
+
+    private static long gcd(long a, long b) {
+        long r;
+        while (b>0) { r = a % b; a = b; b = r; }
+        return a;
+    }
+
+}

Propchange: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/Utils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/WaitQueue.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/WaitQueue.java?view=auto&rev=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/WaitQueue.java
 (added)
+++ 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/WaitQueue.java
 Mon Apr 11 23:42:11 2005
@@ -0,0 +1,124 @@
+/*
+  based on file: QueuedSemaphore.java
+  Originally written by Doug Lea and released into the public domain.
+  This may be used for any purposes whatsoever without acknowledgment.
+  Thanks for the assistance and support of Sun Microsystems Labs,
+  and everyone contributing, testing, and using this code.
+  History:
+  Date       Who                What
+  11Jun1998  dl               Create public version
+   5Aug1998  dl               replaced int counters with longs
+  24Aug1999  dl               release(n): screen arguments
+ */
+
+package org.apache.beehive.netui.util.internal.concurrent;
+
+import java.util.*;
+
+/**
+ * Base class for internal queue classes for semaphores, etc.
+ * Relies on subclasses to actually implement queue mechanics.
+ * NOTE: this class is NOT present in java.util.concurrent.
+ **/
+
+abstract class WaitQueue {
+
+    public abstract void insert(WaitNode w); // assumed not to block
+    public abstract WaitNode extract(); // should return null if empty
+
+    public abstract boolean hasNodes();
+    public abstract int getLength();
+    public abstract Collection getWaitingThreads();
+    public abstract boolean isWaiting(Thread thread);
+
+    static interface QueuedSync {
+        // invoked with sync on wait node, (atomically) just before enqueuing
+        boolean recheck(WaitNode node);
+        // invoked with sync on wait node, (atomically) just before signalling
+        void takeOver(WaitNode node);
+    }
+
+    static class WaitNode {
+        boolean waiting = true;
+        WaitNode next = null;
+        final Thread owner;
+
+        public WaitNode() {
+            this.owner = Thread.currentThread();
+        }
+
+        public Thread getOwner() {
+            return owner;
+        }
+
+        public synchronized boolean signal(QueuedSync sync) {
+            boolean signalled = waiting;
+            if (signalled) {
+                waiting = false;
+                notify();
+                sync.takeOver(this);
+            }
+            return signalled;
+        }
+
+        public synchronized boolean doTimedWait(QueuedSync sync, long nanos)
+            throws InterruptedException
+        {
+            if (sync.recheck(this) || !waiting)
+                return true;
+            else if (nanos <= 0) {
+                waiting = false;
+                return false;
+            }
+            else {
+                long deadline = Utils.nanoTime() + nanos;
+                try {
+                    for (; ; ) {
+                        TimeUnit.NANOSECONDS.timedWait(this, nanos);
+                        if (!waiting) // definitely signalled
+                            return true;
+                        else {
+                            nanos = deadline - Utils.nanoTime();
+                            if (nanos <= 0) { //  timed out
+                                waiting = false;
+                                return false;
+                            }
+                        }
+                    }
+                }
+                catch (InterruptedException ex) {
+                    if (waiting) { // no notification
+                        waiting = false; // invalidate for the signaller
+                        throw ex;
+                    }
+                    else { // thread was interrupted after it was notified
+                        Thread.currentThread().interrupt();
+                        return true;
+                    }
+                }
+            }
+        }
+
+        public synchronized void doWait(QueuedSync sync)
+            throws InterruptedException
+        {
+            if (!sync.recheck(this)) {
+                try {
+                    while (waiting) wait();
+                }
+                catch (InterruptedException ex) {
+                    if (waiting) { // no notification
+                        waiting = false; // invalidate for the signaller
+                        throw ex;
+                    }
+                    else { // thread was interrupted after it was notified
+                        Thread.currentThread().interrupt();
+                        return;
+                    }
+                }
+            }
+        }
+    }
+
+}
+

Propchange: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/internal/concurrent/WaitQueue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/type/TypeUtils.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/type/TypeUtils.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/type/TypeUtils.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/type/TypeUtils.java
 Mon Apr 11 23:42:11 2005
@@ -45,14 +45,14 @@
     private static final Logger LOGGER = Logger.getInstance(TypeUtils.class);
     private static final String TYPE_CONVERTER_PROPERTIES = 
"/properties/netui-typeconverter.properties";
     private static final String EMPTY_STRING = "";
-    private static final HashMap<Class, BaseTypeConverter> TYPE_CONVERTERS = 
new HashMap<Class, BaseTypeConverter>();
+    private static final HashMap/*<Class, BaseTypeConverter>*/ TYPE_CONVERTERS 
= new HashMap/*<Class, BaseTypeConverter>*/();
     private static String TO_STRING = null;
 
     static {
         // initialize the default type converters
         initialize();
 
-        Map<String, String> map = readFromConfig();
+        Map/*<String, String>*/ map = readFromConfig();
         if(map != null) {
             load(map);
             map.clear();
@@ -194,7 +194,7 @@
         if(TO_STRING != null)
             return TO_STRING;
 
-        StringBuilder sb = new StringBuilder(256);
+        StringBuffer sb = new StringBuffer(256);
         sb.append(TypeUtils.class.getName() + " regestered converters (class 
name, TypeConverter implementation):\n");
         sb.append(":::::\n");
         Iterator iterator = TYPE_CONVERTERS.keySet().iterator();
@@ -213,7 +213,7 @@
         return TO_STRING;
     }
 
-    private static Map<String, String> readFromProperties() {
+    private static Map/*<String, String>*/ readFromProperties() {
         Properties props = null;
         InputStream is = null;
         try {
@@ -237,7 +237,7 @@
             }
         }
 
-        LinkedHashMap<String, String> map = new LinkedHashMap<String, 
String>();
+        LinkedHashMap/*<String, String>*/ map = new LinkedHashMap/*<String, 
String>*/();
         Enumeration e = props.propertyNames();
         while(e.hasMoreElements()) {
             String key = (String)e.nextElement();
@@ -247,7 +247,7 @@
         return map;
     }
 
-    private static final Map<String, String> readFromConfig() {
+    private static final Map/*<String, String>*/ readFromConfig() {
         NetuiConfig config = ConfigUtil.getConfig();
         if(config == null)
             return null;
@@ -261,7 +261,7 @@
         if(converterArray == null)
             return null;
 
-        LinkedHashMap<String, String> map = new LinkedHashMap<String, 
String>();
+        LinkedHashMap/*<String, String>*/ map = new LinkedHashMap/*<String, 
String>*/();
         for(int i = 0; i < converterArray.length; i++) {
             map.put(converterArray[i].getType(), 
converterArray[i].getConverterClass());
         }
@@ -269,10 +269,12 @@
         return map;
     }
 
-    private static void load(Map<String, String> map) {
+    private static void load(Map/*<String, String>*/ map) {
         // load the properties and continue to populate the map
-        for(String key : map.keySet()) {
-            String className = map.get(key);
+        for ( Iterator i = map.keySet().iterator(); i.hasNext(); )
+        {
+            String key = (String) i.next();
+            String className = (String) map.get(key);
 
             if((key == null || key.equals(EMPTY_STRING)) || (className == null 
|| className.equals(EMPTY_STRING))) {
                 String msg = "Could not create a TypeConverter for type \"" + 
key + "\" and TypeConverter \"" + className + "\"";

Modified: incubator/beehive/trunk/netui/test/src/junitTests/build.xml
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/build.xml?view=diff&r1=161024&r2=161025
==============================================================================
--- incubator/beehive/trunk/netui/test/src/junitTests/build.xml (original)
+++ incubator/beehive/trunk/netui/test/src/junitTests/build.xml Mon Apr 11 
23:42:11 2005
@@ -28,7 +28,7 @@
                debug="${compile.debug}"
                deprecation="${compile.deprecation}"
                optimize="${compile.optimize}"
-               source="${compile.source}">
+               source="1.4">
             <include name="**/*.java"/>
         </javac>
 

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/MutableURITest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/MutableURITest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/MutableURITest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/MutableURITest.java
 Mon Apr 11 23:42:11 2005
@@ -281,7 +281,7 @@
 
         // add a parameter with a null value (just a name)
         uri.addParameter( name, null, true );
-        List< String > values = uri.getParameters( name );
+        List/*< String >*/ values = uri.getParameters( name );
         assertEquals( values.size(), 1 );
         assertEquals( values.get( 0 ), null );
 
@@ -305,8 +305,9 @@
         assertEquals( uri.getParameters().size(), 1 );
         i = 0;
 
-        for ( String v : values )
+        for ( java.util.Iterator ii = values.iterator(); ii.hasNext(); )  
         {
+            String v = ( String ) ii.next();
             assertEquals( v, initValues[i++] );
         }
 
@@ -332,13 +333,15 @@
         uri.addParameters( map, true );
         assertEquals( uri.getParameters( initParams[0][0] ).size(), 1 );
         assertEquals( uri.getParameters().size(), initParams.length );
-        Map< String, List< String > > params = uri.getParameters();
+        Map/*< String, List< String > >*/ params = uri.getParameters();
         i = 0;
 
-        for ( String n : params.keySet() )
+        for ( java.util.Iterator j = params.keySet().iterator(); j.hasNext(); 
)  
         {
-            for ( String v : params.get( n ) )
+            String n = ( String ) j.next();
+            for ( java.util.Iterator k = ( ( List ) params.get( n ) 
).iterator(); k.hasNext(); )  
             {
+                String v = ( String ) k.next();
                 assertTrue( map.containsKey( n ) );
                 assertEquals( v, map.get( n ) );
             }

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplateTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplateTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplateTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplateTest.java
 Mon Apr 11 23:42:11 2005
@@ -34,12 +34,12 @@
 public class URLTemplateTest extends TestCase
 {
 
-    private static final List<String> KNOWN_TEMPLATE_TOKENS =
-            Arrays.asList( URLTemplateDescriptor.SCHEME_TOKEN, 
URLTemplateDescriptor.DOMAIN_TOKEN,
-                    URLTemplateDescriptor.PORT_TOKEN );
+    private static final List/*<String>*/ KNOWN_TEMPLATE_TOKENS =
+            Arrays.asList( new String[]{ URLTemplateDescriptor.SCHEME_TOKEN, 
URLTemplateDescriptor.DOMAIN_TOKEN,
+                    URLTemplateDescriptor.PORT_TOKEN } );
 
-    private static final List<String> REQUIRED_TEMPLATE_TOKENS =
-            Arrays.asList( URLTemplateDescriptor.PATH_TOKEN, 
URLTemplateDescriptor.QUERY_STRING_TOKEN );
+    private static final List/*<String>*/ REQUIRED_TEMPLATE_TOKENS =
+            Arrays.asList( new String[]{ URLTemplateDescriptor.PATH_TOKEN, 
URLTemplateDescriptor.QUERY_STRING_TOKEN } );
 
     public URLTemplateTest( String name )
     {
@@ -130,7 +130,7 @@
         urlTemplate.verify();
         urlTemplate.substitute( "{url:domain}", "myhost.com" );
         urlTemplate.substitute( "{url:port}", 8443 );
-        HashMap< String, String > tokensAndValues = new HashMap< String, 
String >();
+        HashMap/*< String, String >*/ tokensAndValues = new HashMap/*< String, 
String >*/();
         tokensAndValues.put( "{url:scheme}", "https" );
         tokensAndValues.put( "{url:path}", "/my/path" );
         tokensAndValues.put( "{url:queryString}", "param1=true&amp;foo" );

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplatesTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplatesTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplatesTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplatesTest.java
 Mon Apr 11 23:42:11 2005
@@ -63,12 +63,12 @@
         { "wsrp-url-templates", "wsrp-action", "wsrp-secure-action", 
"wsrp-resource", "wsrp-secure-resource" }
     };
 
-    private static final List<String> KNOWN_TEMPLATE_TOKENS =
-            Arrays.asList( URLTemplateDescriptor.SCHEME_TOKEN, 
URLTemplateDescriptor.DOMAIN_TOKEN,
-                    URLTemplateDescriptor.PORT_TOKEN );
+    private static final List/*<String>*/ KNOWN_TEMPLATE_TOKENS =
+            Arrays.asList( new String[]{ URLTemplateDescriptor.SCHEME_TOKEN, 
URLTemplateDescriptor.DOMAIN_TOKEN,
+                    URLTemplateDescriptor.PORT_TOKEN } );
 
-    private static final List<String> REQUIRED_TEMPLATE_TOKENS =
-            Arrays.asList( URLTemplateDescriptor.PATH_TOKEN, 
URLTemplateDescriptor.QUERY_STRING_TOKEN );
+    private static final List/*<String>*/ REQUIRED_TEMPLATE_TOKENS =
+            Arrays.asList( new String[]{ URLTemplateDescriptor.PATH_TOKEN, 
URLTemplateDescriptor.QUERY_STRING_TOKEN } );
 
     private URLTemplates _urlTemplates = new URLTemplates();
 
@@ -161,7 +161,7 @@
         for (int i = 0; i < _refGroups.length; i++)
         {
             String name = _refGroups[i][0];
-            HashMap< String, String > refGroup = new HashMap< String, String 
>();
+            HashMap/*< String, String >*/ refGroup = new HashMap/*< String, 
String >*/();
             refGroup.put( URLTemplateDescriptor.ACTION_TEMPLATE, 
_refGroups[i][1] );
             refGroup.put( URLTemplateDescriptor.SECURE_ACTION_TEMPLATE, 
_refGroups[i][2] );
             refGroup.put( URLTemplateDescriptor.RESOURCE_TEMPLATE, 
_refGroups[i][3] );
@@ -201,7 +201,7 @@
 
     public void testAddBadTemplateRefGroup()
     {
-        HashMap< String, String > refGroup = new HashMap< String, String >();
+        HashMap/*< String, String >*/ refGroup = new HashMap/*< String, String 
>*/();
 
         // null ref group
         boolean threw = false;

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DataGridTestUtil.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DataGridTestUtil.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DataGridTestUtil.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DataGridTestUtil.java
 Mon Apr 11 23:42:11 2005
@@ -76,7 +76,7 @@
     }
 
     static final PagedDataSet getPagedDataSet() {
-        ArrayList<String> list = new ArrayList<String>();
+        ArrayList/*<String>*/ list = new ArrayList/*<String>*/();
         list.add("abc");
         list.add("def");
         list.add("ghi");

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DefaultSortTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DefaultSortTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DefaultSortTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DefaultSortTest.java
 Mon Apr 11 23:42:11 2005
@@ -69,4 +69,4 @@
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterCodecTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterCodecTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterCodecTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterCodecTest.java
 Mon Apr 11 23:42:11 2005
@@ -150,4 +150,4 @@
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterModelTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterModelTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterModelTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterModelTest.java
 Mon Apr 11 23:42:11 2005
@@ -25,6 +25,7 @@
 
 import org.apache.beehive.netui.test.servlet.ServletFactory;
 import org.apache.beehive.netui.databinding.datagrid.api.filter.FilterModel;
+import org.apache.beehive.netui.databinding.datagrid.api.filter.Filter;
 import 
org.apache.beehive.netui.databinding.datagrid.api.filter.FilterOperationHint;
 import org.apache.beehive.netui.databinding.datagrid.api.DataGridState;
 
@@ -46,14 +47,14 @@
         assertNotNull(fm);
         assertNotNull(fm.getFilters("CUSTOMERNAME"));
         assertTrue(fm.isFiltered("CUSTOMERNAME"));
-        assertEquals(FilterOperationHint.EQUAL, 
fm.getFilters("CUSTOMERNAME").get(0).getOperation().getOperationHint());
+        assertEquals(FilterOperationHint.EQUAL, 
((Filter)fm.getFilters("CUSTOMERNAME").get(0)).getOperation().getOperationHint());
 
         state = DataGridTestUtil.createDataGridState(_request, "products");
         fm = state.getFilterModel();
         assertNotNull(fm);
         assertNotNull(fm.getFilters("ID"));
         assertTrue(fm.isFiltered("ID"));
-        assertEquals(FilterOperationHint.NOT_EQUAL, 
fm.getFilters("ID").get(0).getOperation().getOperationHint());
+        assertEquals(FilterOperationHint.NOT_EQUAL, 
((Filter)fm.getFilters("ID").get(0)).getOperation().getOperationHint());
     }
 
     protected void setUp() {
@@ -75,4 +76,4 @@
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterURLTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterURLTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterURLTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterURLTest.java
 Mon Apr 11 23:42:11 2005
@@ -73,4 +73,4 @@
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerCodecTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerCodecTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerCodecTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerCodecTest.java
 Mon Apr 11 23:42:11 2005
@@ -67,4 +67,4 @@
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerModelTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerModelTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerModelTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerModelTest.java
 Mon Apr 11 23:42:11 2005
@@ -257,4 +257,4 @@
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerRendererTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerRendererTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerRendererTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PagerRendererTest.java
 Mon Apr 11 23:42:11 2005
@@ -99,4 +99,4 @@
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SQLSupportTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SQLSupportTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SQLSupportTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SQLSupportTest.java
 Mon Apr 11 23:42:11 2005
@@ -103,4 +103,4 @@
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}

Modified: 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SortCodecTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SortCodecTest.java?view=diff&r1=161024&r2=161025
==============================================================================
--- 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SortCodecTest.java
 (original)
+++ 
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SortCodecTest.java
 Mon Apr 11 23:42:11 2005
@@ -69,7 +69,7 @@
             "netui_sort=" + _namespace + ";CUSTOMERNAME,-UNITPRICE" +
             "&netui_sort=productGrid;QUANTITY");
         SortCodec codec = new SortCodec();
-        Map<String, List<Sort>> allSorts = 
codec.decode(_request.getParameterMap());
+        Map<String, List<Sort>/> allSorts = 
codec.decode(_request.getParameterMap());
         List<Sort> sorts = allSorts.get(_namespace);
 
         assert sorts != null;
@@ -132,4 +132,4 @@
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}


Reply via email to