This method initiates the receiving of a datagram into the given + * buffer. The method behaves in exactly the same manner as the {@link + * #receive(ByteBuffer,Object,CompletionHandler) + * receive(ByteBuffer,Object,CompletionHandler)} method except that instead + * of specifying a completion handler, this method returns a {@code Future} + * representing the pending result. The {@code Future}'s {@link Future#get() + * get} method returns the datagram's source address. * * @param dst * The buffer into which the datagram is to be transferred @@ -419,84 +407,19 @@ public abstract class AsynchronousDatagr * @throws IllegalArgumentException * If the buffer is read-only */ - public final Future
receive(ByteBuffer dst) { - return receive(dst, 0L, TimeUnit.MILLISECONDS, null, null); - } + public abstract Future receive(ByteBuffer dst); /** * Sends a datagram via this channel. * - * This method initiates sending of a datagram, returning a - * {@code Future} representing the pending result of the operation. - * The operation sends the remaining bytes in the given buffer as a single - * datagram to the given target address. The result of the operation, obtained - * by invoking the {@code Future}'s {@link Future#get() get} - * method, is the number of bytes sent. - * - *
The datagram is transferred from the byte buffer as if by a regular - * {@link AsynchronousByteChannel#write write} operation. - * - *
If a timeout is specified and the timeout elapses before the operation - * completes then the operation completes with the exception {@link - * InterruptedByTimeoutException}. When a timeout elapses then the state of - * the {@link ByteBuffer} is not defined. The buffers should be discarded or - * at least care must be taken to ensure that the buffer is not accessed - * while the channel remains open. - * - *
If there is a security manager installed and the channel is not - * connected then this method verifies that the target address and port number - * are permitted by the security manager's {@link SecurityManager#checkConnect - * checkConnect} method. The overhead of this security check can be avoided - * by first connecting the socket via the {@link #connect connect} method. - * - * @param src - * The buffer containing the datagram to be sent - * @param target - * The address to which the datagram is to be sent - * @param timeout - * The timeout, or {@code 0L} for no timeout - * @param unit - * The time unit of the {@code timeout} argument - * @param attachment - * The object to attach to the I/O operation; can be {@code null} - * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return a {@code Future} object representing the pending result - * - * @throws UnresolvedAddressException - * If the given remote address is not fully resolved - * @throws UnsupportedAddressTypeException - * If the type of the given remote address is not supported - * @throws IllegalArgumentException - * If the timeout is negative, or if the channel's socket is - * connected to an address that is not equal to {@code target} - * @throws SecurityException - * If a security manager has been installed and it does not permit - * datagrams to be sent to the given address - * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - public abstract Future
send(ByteBuffer src, - SocketAddress target, - long timeout, - TimeUnit unit, - A attachment, - CompletionHandler handler); - - /** - * Sends a datagram via this channel. - * - * This method initiates sending of a datagram, returning a - * {@code Future} representing the pending result of the operation. - * The operation sends the remaining bytes in the given buffer as a single - * datagram to the given target address. The result of the operation, obtained - * by invoking the {@code Future}'s {@link Future#get() get} - * method, is the number of bytes sent. - * - *
This method is equivalent to invoking {@link - * #send(ByteBuffer,SocketAddress,long,TimeUnit,Object,CompletionHandler)} - * with a timeout of {@code 0L}. + *
This method initiates sending of a datagram from the given buffer to + * the given address. The {@code handler} parameter is a completion handler + * that is invoked when the send completes (or fails). The result passed to + * the completion handler is the number of bytes sent. + * + *
Otherwise this method works in the same manner as the {@link + * AsynchronousByteChannel#write(ByteBuffer,Object,CompletionHandler)} + * method. * * @param src * The buffer containing the datagram to be sent @@ -505,9 +428,7 @@ public abstract class AsynchronousDatagr * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return a {@code Future} object representing the pending result + * The handler for consuming the result * * @throws UnresolvedAddressException * If the given remote address is not fully resolved @@ -520,30 +441,23 @@ public abstract class AsynchronousDatagr * If a security manager has been installed and it does not permit * datagrams to be sent to the given address * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - public final Future
send(ByteBuffer src, - SocketAddress target, - A attachment, - CompletionHandler handler) - { - return send(src, target, 0L, TimeUnit.MILLISECONDS, attachment, handler); - } + * If the channel group has terminated + */ + public abstract void send(ByteBuffer src, + SocketAddress target, + A attachment, + CompletionHandler handler); /** * Sends a datagram via this channel. * - * This method initiates sending of a datagram, returning a - * {@code Future} representing the pending result of the operation. - * The operation sends the remaining bytes in the given buffer as a single - * datagram to the given target address. The result of the operation, obtained - * by invoking the {@code Future}'s {@link Future#get() get} - * method, is the number of bytes sent. - * - *
This method is equivalent to invoking {@link - * #send(ByteBuffer,SocketAddress,long,TimeUnit,Object,CompletionHandler)} - * with a timeout of {@code 0L} and an attachment and completion handler - * of {@code null}. + *
This method initiates sending of a datagram from the given buffer to + * the given address. The method behaves in exactly the same manner as the + * {@link #send(ByteBuffer,SocketAddress,Object,CompletionHandler) + * send(ByteBuffer,SocketAddress,Object,CompletionHandler)} method except + * that instead of specifying a completion handler, this method returns a + * {@code Future} representing the pending result. The {@code Future}'s + * {@link Future#get() get} method returns the number of bytes sent. * * @param src * The buffer containing the datagram to be sent @@ -563,17 +477,15 @@ public abstract class AsynchronousDatagr * If a security manager has been installed and it does not permit * datagrams to be sent to the given address */ - public final Future
send(ByteBuffer src, SocketAddress target) { - return send(src, target, 0L, TimeUnit.MILLISECONDS, null, null); - } + public abstract Future send(ByteBuffer src, SocketAddress target); /** * Receives a datagram via this channel. * - * This method initiates the receiving of a datagram, returning a - * {@code Future} representing the pending result of the operation. - * The {@code Future}'s {@link Future#get() get} method returns - * the number of bytes transferred upon successful completion. + *
This method initiates the receiving of a datagram into the given + * buffer. The {@code handler} parameter is a completion handler that is + * invoked when the receive operation completes (or fails). The result + * passed to the completion handler is number of bytes read. * *
This method may only be invoked if this channel is connected, and it * only accepts datagrams from the peer that the channel is connected too. @@ -599,120 +511,62 @@ public abstract class AsynchronousDatagr * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return a {@code Future} object representing the pending result + * The handler for consuming the result * * @throws IllegalArgumentException * If the timeout is negative or buffer is read-only * @throws NotYetConnectedException * If this channel is not connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - public abstract Future
read(ByteBuffer dst, - long timeout, - TimeUnit unit, - A attachment, - CompletionHandler handler); + * If the channel group has terminated + */ + public abstract void read(ByteBuffer dst, + long timeout, + TimeUnit unit, + A attachment, + CompletionHandler handler); /** * @throws NotYetConnectedException * If this channel is not connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - @Override - public final Future read(ByteBuffer dst, - A attachment, - CompletionHandler handler) + * If the channel group has terminated + */ + @Override + public final void read(ByteBuffer dst, + A attachment, + CompletionHandler handler) { - return read(dst, 0L, TimeUnit.MILLISECONDS, attachment, handler); + read(dst, 0L, TimeUnit.MILLISECONDS, attachment, handler); } /** * @throws NotYetConnectedException * If this channel is not connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - @Override - public final Future read(ByteBuffer dst) { - return read(dst, 0L, TimeUnit.MILLISECONDS, null, null); - } - - /** - * Writes a datagram to this channel. - * - * This method initiates sending of a datagram, returning a - * {@code Future} representing the pending result of the operation. - * The operation sends the remaining bytes in the given buffer as a single - * datagram. The result of the operation, obtained by invoking the - * {@code Future}'s {@link Future#get() get} method, is the - * number of bytes sent. - * - *
The datagram is transferred from the byte buffer as if by a regular - * {@link AsynchronousByteChannel#write write} operation. - * - *
This method may only be invoked if this channel is connected, - * in which case it sends datagrams directly to the socket's peer. Otherwise - * it behaves exactly as specified in the {@link - * AsynchronousByteChannel} interface. - * - *
If a timeout is specified and the timeout elapses before the operation - * completes then the operation completes with the exception {@link - * InterruptedByTimeoutException}. When a timeout elapses then the state of - * the {@link ByteBuffer} is not defined. The buffers should be discarded or - * at least care must be taken to ensure that the buffer is not accessed - * while the channel remains open. - * - * @param src - * The buffer containing the datagram to be sent - * @param timeout - * The timeout, or {@code 0L} for no timeout - * @param unit - * The time unit of the {@code timeout} argument - * @param attachment - * The object to attach to the I/O operation; can be {@code null} - * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return a {@code Future} object representing the pending result - * - * @throws IllegalArgumentException - * If the timeout is negative + * If the channel group has terminated + */ + @Override + public abstract Future
read(ByteBuffer dst); + + /** * @throws NotYetConnectedException * If this channel is not connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - public abstract Future write(ByteBuffer src, - long timeout, - TimeUnit unit, - A attachment, - CompletionHandler handler); + * If the channel group has terminated + */ + @Override + public abstract void write(ByteBuffer src, + A attachment, + CompletionHandler handler); + + /** * @throws NotYetConnectedException * If this channel is not connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - @Override - public final Future write(ByteBuffer src, - A attachment, - CompletionHandler handler) - { - return write(src, 0L, TimeUnit.MILLISECONDS, attachment, handler); - } - - /** - * @throws NotYetConnectedException - * If this channel is not connected - * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - @Override - public final Future write(ByteBuffer src) { - return write(src, 0L, TimeUnit.MILLISECONDS, null, null); - } + * If the channel group has terminated + */ + @Override + public abstract Future write(ByteBuffer src); } --- a/src/share/classes/java/nio/channels/AsynchronousFileChannel.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/channels/AsynchronousFileChannel.java Tue Sep 22 01:20:51 2009 -0700 @@ -48,7 +48,12 @@ import java.util.Collections; * * An asynchronous file channel does not have a current position * within the file. Instead, the file position is specified to each read and - * write operation. + * write methd that initiate asynchronous operations. A {@link CompletionHandler} + * is specified as a parameter and is invoked to consume the result of the I/O + * operation. This class also defines read and write methods that initiate + * asynchronous operations, returning a {@link Future} to represent the pending + * result of the operation. The {@code Future} may be used to check if the + * operation has completed, to wait for its completion. * *
In addition to read and write operations, this class defines the * following operations:
@@ -59,17 +64,10 @@ import java.util.Collections; * out} to the underlying storage device, ensuring that data are not * lost in the event of a system crash.+ * A region of a file may be {@link FileLock locked} - * against access by other programs.
* * - * - * A region of a file may be {@link #lock locked} against + * access by other programs.
The {@link #read read}, {@link #write write}, and {@link #lock lock} - * methods defined by this class are asynchronous and return a {@link Future} - * to represent the pending result of the operation. This may be used to check - * if the operation has completed, to wait for its completion, and to retrieve - * the result. These method may optionally specify a {@link CompletionHandler} - * that is invoked to consume the result of the I/O operation when it completes. * *
An {@code AsynchronousFileChannel} is associated with a thread pool to * which tasks are submitted to handle I/O events and dispatch to completion @@ -123,22 +121,6 @@ public abstract class AsynchronousFileCh } /** - * Closes this channel. - * - *
If this channel is associated with its own thread pool then closing - * the channel causes the thread pool to shutdown after all actively - * executing completion handlers have completed. No attempt is made to stop - * or interrupt actively completion handlers. - * - *
This method otherwise behaves exactly as specified by the {@link - * AsynchronousChannel} interface. - * - * @throws IOException {@inheritDoc} - */ - @Override - public abstract void close() throws IOException; - - /** * Opens or creates a file for reading and/or writing, returning an * asynchronous file channel to access the file. * @@ -215,9 +197,8 @@ public abstract class AsynchronousFileCh * should be taken when configuring the {@code Executor}. Minimally it * should support an unbounded work queue and should not run tasks on the * caller thread of the {@link ExecutorService#execute execute} method. - * {@link #close Closing} the channel results in the orderly {@link - * ExecutorService#shutdown shutdown} of the executor service. Shutting down - * the executor service by other means results in unspecified behavior. + * Shutting down the executor service while the channel is open results in + * unspecified behavior. * *
The {@code attrs} parameter is an optional array of file {@link * FileAttribute file-attributes} to set atomically when creating the file. @@ -276,7 +257,8 @@ public abstract class AsynchronousFileCh *
An invocation of this method behaves in exactly the same way as the * invocation *
- * ch.{@link #open(Path,Set,ExecutorService,FileAttribute[]) open}(file, opts, null, new FileAttribute<?>[0]); + * ch.{@link #open(Path,Set,ExecutorService,FileAttribute[]) + * open}(file, opts, null, new FileAttribute<?>[0]); ** where {@code opts} is a {@code Set} containing the options specified to * this method. @@ -405,10 +387,11 @@ public abstract class AsynchronousFileCh /** * Acquires a lock on the given region of this channel's file. * - *This method initiates an operation to acquire a lock on the given region - * of this channel's file. The method returns a {@code Future} representing - * the pending result of the operation. Its {@link Future#get() get} - * method returns the {@link FileLock} on successful completion. + *
This method initiates an operation to acquire a lock on the given + * region of this channel's file. The {@code handler} parameter is a + * completion handler that is invoked when the lock is acquired (or the + * operation fails). The result passed to the completion handler is the + * resulting {@code FileLock}. * *
The region specified by the {@code position} and {@code size} * parameters need not be contained within, or even overlap, the actual @@ -455,9 +438,7 @@ public abstract class AsynchronousFileCh * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return a {@code Future} object representing the pending result + * The handler for consuming the result * * @throws OverlappingFileLockException * If a lock that overlaps the requested region is already held by @@ -466,26 +447,24 @@ public abstract class AsynchronousFileCh * @throws IllegalArgumentException * If the preconditions on the parameters do not hold * @throws NonReadableChannelException - * If {@code shared} is true this channel but was not opened for reading + * If {@code shared} is true but this channel was not opened for reading * @throws NonWritableChannelException * If {@code shared} is false but this channel was not opened for writing - * @throws ShutdownChannelGroupException - * If a handler is specified, the channel is closed, and the channel - * was originally created with its own thread pool - */ - public abstract Future
lock(long position, - long size, - boolean shared, - A attachment, - CompletionHandler handler); + */ + public abstract void lock(long position, + long size, + boolean shared, + A attachment, + CompletionHandler handler); /** * Acquires an exclusive lock on this channel's file. * - * This method initiates an operation to acquire an exclusive lock on this - * channel's file. The method returns a {@code Future} representing - * the pending result of the operation. Its {@link Future#get() get} - * method returns the {@link FileLock} on successful completion. + *
This method initiates an operation to acquire a lock on the given + * region of this channel's file. The {@code handler} parameter is a + * completion handler that is invoked when the lock is acquired (or the + * operation fails). The result passed to the completion handler is the + * resulting {@code FileLock}. * *
An invocation of this method of the form {@code ch.lock(att,handler)} * behaves in exactly the same way as the invocation @@ -496,40 +475,72 @@ public abstract class AsynchronousFileCh * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return a {@code Future} object representing the pending result + * The handler for consuming the result * * @throws OverlappingFileLockException * If a lock is already held by this Java virtual machine, or there * is already a pending attempt to lock a region * @throws NonWritableChannelException * If this channel was not opened for writing - * @throws ShutdownChannelGroupException - * If a handler is specified, the channel is closed, and the channel - * was originally created with its own thread pool - */ - public final Future
lock(A attachment, - CompletionHandler handler) + */ + public final void lock(A attachment, + CompletionHandler handler) { - return lock(0L, Long.MAX_VALUE, false, attachment, handler); + lock(0L, Long.MAX_VALUE, false, attachment, handler); } + + /** + * Acquires a lock on the given region of this channel's file. + * + * This method initiates an operation to acquire a lock on the given + * region of this channel's file. The method behaves in exactly the same + * manner as the {@link #lock(long, long, boolean, Object, CompletionHandler)} + * method except that instead of specifying a completion handler, this + * method returns a {@code Future} representing the pending result. The + * {@code Future}'s {@link Future#get() get} method returns the {@link + * FileLock} on successful completion. + * + * @param position + * The position at which the locked region is to start; must be + * non-negative + * @param size + * The size of the locked region; must be non-negative, and the sum + * {@code position} + {@code size} must be non-negative + * @param shared + * {@code true} to request a shared lock, in which case this + * channel must be open for reading (and possibly writing); + * {@code false} to request an exclusive lock, in which case this + * channel must be open for writing (and possibly reading) + * + * @return a {@code Future} object representing the pending result + * + * @throws OverlappingFileLockException + * If a lock is already held by this Java virtual machine, or there + * is already a pending attempt to lock a region + * @throws IllegalArgumentException + * If the preconditions on the parameters do not hold + * @throws NonReadableChannelException + * If {@code shared} is true but this channel was not opened for reading + * @throws NonWritableChannelException + * If {@code shared} is false but this channel was not opened for writing + */ + public abstract Future
lock(long position, long size, boolean shared); /** * Acquires an exclusive lock on this channel's file. * * This method initiates an operation to acquire an exclusive lock on this * channel's file. The method returns a {@code Future} representing the - * pending result of the operation. Its {@link Future#get() get} method - * returns the {@link FileLock} on successful completion. + * pending result of the operation. The {@code Future}'s {@link Future#get() + * get} method returns the {@link FileLock} on successful completion. * *
An invocation of this method behaves in exactly the same way as the * invocation *
- * ch.{@link #lock(long,long,boolean,Object,CompletionHandler) lock}(0L, Long.MAX_VALUE, false, null, null) + * ch.{@link #lock(long,long,boolean) lock}(0L, Long.MAX_VALUE, false) ** - * @return A {@code Future} object representing the pending result + * @return a {@code Future} object representing the pending result * * @throws OverlappingFileLockException * If a lock is already held by this Java virtual machine, or there @@ -538,7 +549,7 @@ public abstract class AsynchronousFileCh * If this channel was not opened for writing */ public final Futurelock() { - return lock(0L, Long.MAX_VALUE, false, null, null); + return lock(0L, Long.MAX_VALUE, false); } /** @@ -576,7 +587,7 @@ public abstract class AsynchronousFileCh * blocked in this method and is attempting to lock an overlapping * region of the same file * @throws NonReadableChannelException - * If {@code shared} is true this channel but was not opened for reading + * If {@code shared} is true but this channel was not opened for reading * @throws NonWritableChannelException * If {@code shared} is false but this channel was not opened for writing * @@ -629,11 +640,10 @@ public abstract class AsynchronousFileCh * starting at the given file position. * * This method initiates the reading of a sequence of bytes from this - * channel into the given buffer, starting at the given file position. This - * method returns a {@code Future} representing the pending result of the - * operation. The Future's {@link Future#get() get} method returns the - * number of bytes read or {@code -1} if the given position is greater than - * or equal to the file's size at the time that the read is attempted. + * channel into the given buffer, starting at the given file position. The + * result of the read is the number of bytes read or {@code -1} if the given + * position is greater than or equal to the file's size at the time that the + * read is attempted. * *
This method works in the same manner as the {@link * AsynchronousByteChannel#read(ByteBuffer,Object,CompletionHandler)} @@ -649,22 +659,17 @@ public abstract class AsynchronousFileCh * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return A {@code Future} object representing the pending result + * The handler for consuming the result * * @throws IllegalArgumentException * If the position is negative or the buffer is read-only * @throws NonReadableChannelException * If this channel was not opened for reading - * @throws ShutdownChannelGroupException - * If a handler is specified, the channel is closed, and the channel - * was originally created with its own thread pool - */ - public abstract Future
read(ByteBuffer dst, - long position, - A attachment, - CompletionHandler handler); + */ + public abstract void read(ByteBuffer dst, + long position, + A attachment, + CompletionHandler handler); /** * Reads a sequence of bytes from this channel into the given buffer, @@ -673,13 +678,15 @@ public abstract class AsynchronousFileCh * This method initiates the reading of a sequence of bytes from this * channel into the given buffer, starting at the given file position. This * method returns a {@code Future} representing the pending result of the - * operation. The Future's {@link Future#get() get} method returns the - * number of bytes read or {@code -1} if the given position is greater + * operation. The {@code Future}'s {@link Future#get() get} method returns + * the number of bytes read or {@code -1} if the given position is greater * than or equal to the file's size at the time that the read is attempted. * - *
This method is equivalent to invoking {@link - * #read(ByteBuffer,long,Object,CompletionHandler)} with the {@code attachment} - * and handler parameters set to {@code null}. + *
This method works in the same manner as the {@link + * AsynchronousByteChannel#read(ByteBuffer)} method, except that bytes are + * read starting at the given file position. If the given file position is + * greater than the file's size at the time that the read is attempted then + * no bytes are read. * * @param dst * The buffer into which bytes are to be transferred @@ -694,19 +701,11 @@ public abstract class AsynchronousFileCh * @throws NonReadableChannelException * If this channel was not opened for reading */ - public final Future
read(ByteBuffer dst, long position) { - return read(dst, position, null, null); - } + public abstract Future read(ByteBuffer dst, long position); /** * Writes a sequence of bytes to this channel from the given buffer, starting * at the given file position. - * - * This method initiates the writing of a sequence of bytes to this channel - * from the given buffer, starting at the given file position. The method - * returns a {@code Future} representing the pending result of the write - * operation. The Future's {@link Future#get() get} method returns the - * number of bytes written. * *
This method works in the same manner as the {@link * AsynchronousByteChannel#write(ByteBuffer,Object,CompletionHandler)} @@ -724,36 +723,35 @@ public abstract class AsynchronousFileCh * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return A {@code Future} object representing the pending result + * The handler for consuming the result * * @throws IllegalArgumentException * If the position is negative * @throws NonWritableChannelException * If this channel was not opened for writing - * @throws ShutdownChannelGroupException - * If a handler is specified, the channel is closed, and the channel - * was originally created with its own thread pool - */ - public abstract Future
write(ByteBuffer src, - long position, - A attachment, - CompletionHandler handler); + */ + public abstract void write(ByteBuffer src, + long position, + A attachment, + CompletionHandler handler); /** * Writes a sequence of bytes to this channel from the given buffer, starting * at the given file position. * - * This method initiates the writing of a sequence of bytes to this channel - * from the given buffer, starting at the given file position. The method - * returns a {@code Future} representing the pending result of the write - * operation. The Future's {@link Future#get() get} method returns the - * number of bytes written. - * - *
This method is equivalent to invoking {@link - * #write(ByteBuffer,long,Object,CompletionHandler)} with the {@code attachment} - * and handler parameters set to {@code null}. + *
This method initiates the writing of a sequence of bytes to this + * channel from the given buffer, starting at the given file position. The + * method returns a {@code Future} representing the pending result of the + * write operation. The {@code Future}'s {@link Future#get() get} method + * returns the number of bytes written. + * + *
This method works in the same manner as the {@link + * AsynchronousByteChannel#write(ByteBuffer)} method, except that bytes are + * written starting at the given file position. If the given position is + * greater than the file's size, at the time that the write is attempted, + * then the file will be grown to accommodate the new bytes; the values of + * any bytes between the previous end-of-file and the newly-written bytes + * are unspecified. * * @param src * The buffer from which bytes are to be transferred @@ -768,7 +766,5 @@ public abstract class AsynchronousFileCh * @throws NonWritableChannelException * If this channel was not opened for writing */ - public final Future
write(ByteBuffer src, long position) { - return write(src, position, null, null); - } + public abstract Future write(ByteBuffer src, long position); } --- a/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java Tue Sep 22 01:20:51 2009 -0700 @@ -85,9 +85,6 @@ import java.io.IOException; * public void failed(Throwable exc, Void att) { * ... * } - * public void cancelled(Void att) { - * ... - * } * }); * This method initiates accepting a connection made to this channel's - * socket, returning a {@link Future} representing the pending result - * of the operation. The {@code Future}'s {@link Future#get() get} - * method will return the {@link AsynchronousSocketChannel} for the new - * connection on successful completion. + *
This method initiates an asynchronous operation to accept a + * connection made to this channel's socket. The {@code handler} parameter is + * a completion handler that is invoked when a connection is accepted (or + * the operation fails). The result passed to the completion handler is + * the {@link AsynchronousSocketChannel} to the new connection. * *
When a new connection is accepted then the resulting {@code * AsynchronousSocketChannel} will be bound to the same {@link @@ -269,35 +266,35 @@ public abstract class AsynchronousServer * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return an Future object representing the pending result + * The handler for consuming the result * * @throws AcceptPendingException * If an accept operation is already in progress on this channel * @throws NotYetBoundException * If this channel's socket has not yet been bound * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - public abstract Future
- accept(A attachment, CompletionHandler handler); + * If the channel group has terminated + */ + public abstract void accept(A attachment, + CompletionHandler handler); /** * Accepts a connection. * - * This method is equivalent to invoking {@link - * #accept(Object,CompletionHandler)} with the {@code attachment} - * and {@code handler} parameters set to {@code null}. - * - * @return an Future object representing the pending result + *
This method initiates an asynchronous operation to accept a + * connection made to this channel's socket. The method behaves in exactly + * the same manner as the {@link #accept(Object, CompletionHandler)} method + * except that instead of specifying a completion handler, this method + * returns a {@code Future} representing the pending result. The {@code + * Future}'s {@link Future#get() get} method returns the {@link + * AsynchronousSocketChannel} to the new connection on successful completion. + * + * @return a {@code Future} object representing the pending result * * @throws AcceptPendingException * If an accept operation is already in progress on this channel * @throws NotYetBoundException * If this channel's socket has not yet been bound */ - public final Future
accept() { - return accept(null, null); - } + public abstract Future accept(); } --- a/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java Tue Sep 22 01:20:51 2009 -0700 @@ -274,14 +274,11 @@ public abstract class AsynchronousSocket /** * Connects this channel. * - * This method initiates an operation to connect this channel, returning - * a {@code Future} representing the pending result of the operation. If - * the connection is successfully established then the {@code Future}'s - * {@link Future#get() get} method will return {@code null}. If the - * connection cannot be established then the channel is closed. In that case, - * invoking the {@code get} method throws {@link - * java.util.concurrent.ExecutionException} with an {@code IOException} as - * the cause. + *
This method initiates an operation to connect this channel. The + * {@code handler} parameter is a completion handler that is invoked when + * the connection is successfully established or connection cannot be + * established. If the connection cannot be established then the channel is + * closed. * *
This method performs exactly the same security checks as the {@link * java.net.Socket} class. That is, if a security manager has been @@ -294,9 +291,7 @@ public abstract class AsynchronousSocket * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return A {@code Future} object representing the pending result + * The handler for consuming the result * * @throws UnresolvedAddressException * If the given remote address is not fully resolved @@ -307,23 +302,26 @@ public abstract class AsynchronousSocket * @throws ConnectionPendingException * If a connection operation is already in progress on this channel * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown + * If the channel group has terminated * @throws SecurityException * If a security manager has been installed * and it does not permit access to the given remote endpoint * * @see #getRemoteAddress */ - public abstract Future
connect(SocketAddress remote, - A attachment, - CompletionHandler handler); + public abstract void connect(SocketAddress remote, + A attachment, + CompletionHandler handler); /** * Connects this channel. * - * This method is equivalent to invoking {@link - * #connect(SocketAddress,Object,CompletionHandler)} with the {@code attachment} - * and handler parameters set to {@code null}. + *
This method initiates an operation to connect this channel. This + * method behaves in exactly the same manner as the {@link + * #connect(SocketAddress, Object, CompletionHandler)} method except that + * instead of specifying a completion handler, this method returns a {@code + * Future} representing the pending result. The {@code Future}'s {@link + * Future#get() get} method returns {@code null} on successful completion. * * @param remote * The remote address to which this channel is to be connected @@ -342,18 +340,17 @@ public abstract class AsynchronousSocket * If a security manager has been installed * and it does not permit access to the given remote endpoint */ - public final Future
connect(SocketAddress remote) { - return connect(remote, null, null); - } + public abstract Future connect(SocketAddress remote); /** * Reads a sequence of bytes from this channel into the given buffer. * - * This method initiates the reading of a sequence of bytes from this - * channel into the given buffer, returning a {@code Future} representing - * the pending result of the operation. The {@code Future}'s {@link - * Future#get() get} method returns the number of bytes read or {@code -1} - * if all bytes have been read and channel has reached end-of-stream. + *
This method initiates an asynchronous read operation to read a + * sequence of bytes from this channel into the given buffer. The {@code + * handler} parameter is a completion handler that is invoked when the read + * operation completes (or fails). The result passed to the completion + * handler is the number of bytes read or {@code -1} if no bytes could be + * read because the channel has reached end-of-stream. * *
If a timeout is specified and the timeout elapses before the operation * completes then the operation completes with the exception {@link @@ -376,9 +373,7 @@ public abstract class AsynchronousSocket * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return A {@code Future} object representing the pending result + * The handler for consuming the result * * @throws IllegalArgumentException * If the {@code timeout} parameter is negative or the buffer is @@ -388,13 +383,13 @@ public abstract class AsynchronousSocket * @throws NotYetConnectedException * If this channel is not yet connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - public abstract Future
read(ByteBuffer dst, - long timeout, - TimeUnit unit, - A attachment, - CompletionHandler handler); + * If the channel group has terminated + */ + public abstract void read(ByteBuffer dst, + long timeout, + TimeUnit unit, + A attachment, + CompletionHandler handler); /** * @throws IllegalArgumentException {@inheritDoc} @@ -402,14 +397,14 @@ public abstract class AsynchronousSocket * @throws NotYetConnectedException * If this channel is not yet connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown + * If the channel group has terminated */ @Override - public final Future read(ByteBuffer dst, - A attachment, - CompletionHandler handler) + public final void read(ByteBuffer dst, + A attachment, + CompletionHandler handler) { - return read(dst, 0L, TimeUnit.MILLISECONDS, attachment, handler); + read(dst, 0L, TimeUnit.MILLISECONDS, attachment, handler); } /** @@ -419,16 +414,18 @@ public abstract class AsynchronousSocket * If this channel is not yet connected */ @Override - public final Future read(ByteBuffer dst) { - return read(dst, 0L, TimeUnit.MILLISECONDS, null, null); - } + public abstract Future read(ByteBuffer dst); /** * Reads a sequence of bytes from this channel into a subsequence of the * given buffers. This operation, sometimes called a scattering read, * is often useful when implementing network protocols that group data into * segments consisting of one or more fixed-length headers followed by a - * variable-length body. + * variable-length body. The {@code handler} parameter is a completion + * handler that is invoked when the read operation completes (or fails). The + * result passed to the completion handler is the number of bytes read or + * {@code -1} if no bytes could be read because the channel has reached + * end-of-stream. * * This method initiates a read of up to r bytes from this channel, * where r is the total number of bytes remaining in the specified @@ -455,11 +452,6 @@ public abstract class AsynchronousSocket * number of buffers (with bytes remaining), exceeds this limit, then the * I/O operation is performed with the maximum number of buffers allowed by * the operating system. - * - *
The return value from this method is a {@code Future} representing - * the pending result of the operation. The {@code Future}'s {@link - * Future#get() get} method returns the number of bytes read or {@code -1L} - * if all bytes have been read and the channel has reached end-of-stream. * *
If a timeout is specified and the timeout elapses before the operation * completes then it completes with the exception {@link @@ -485,9 +477,7 @@ public abstract class AsynchronousSocket * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return A {@code Future} object representing the pending result + * The handler for consuming the result * * @throws IndexOutOfBoundsException * If the pre-conditions for the {@code offset} and {@code length} @@ -500,23 +490,24 @@ public abstract class AsynchronousSocket * @throws NotYetConnectedException * If this channel is not yet connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - public abstract Future
read(ByteBuffer[] dsts, - int offset, - int length, - long timeout, - TimeUnit unit, - A attachment, - CompletionHandler handler); + * If the channel group has terminated + */ + public abstract void read(ByteBuffer[] dsts, + int offset, + int length, + long timeout, + TimeUnit unit, + A attachment, + CompletionHandler handler); /** * Writes a sequence of bytes to this channel from the given buffer. * - * This method initiates the writing of a sequence of bytes to this channel - * from the given buffer, returning a {@code Future} representing the - * pending result of the operation. The {@code Future}'s {@link Future#get() - * get} method will return the number of bytes written. + *
This method initiates an asynchronous write operation to write a + * sequence of bytes to this channel from the given buffer. The {@code + * handler} parameter is a completion handler that is invoked when the write + * operation completes (or fails). The result passed to the completion + * handler is the number of bytes written. * *
If a timeout is specified and the timeout elapses before the operation * completes then it completes with the exception {@link @@ -539,9 +530,7 @@ public abstract class AsynchronousSocket * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return A {@code Future} object representing the pending result + * The handler for consuming the result * * @throws IllegalArgumentException * If the {@code timeout} parameter is negative @@ -550,28 +539,28 @@ public abstract class AsynchronousSocket * @throws NotYetConnectedException * If this channel is not yet connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - public abstract Future
write(ByteBuffer src, - long timeout, - TimeUnit unit, - A attachment, - CompletionHandler handler); + * If the channel group has terminated + */ + public abstract void write(ByteBuffer src, + long timeout, + TimeUnit unit, + A attachment, + CompletionHandler handler); /** * @throws WritePendingException {@inheritDoc} * @throws NotYetConnectedException * If this channel is not yet connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown + * If the channel group has terminated */ @Override - public final Future write(ByteBuffer src, - A attachment, - CompletionHandler handler) + public final void write(ByteBuffer src, + A attachment, + CompletionHandler handler) { - return write(src, 0L, TimeUnit.MILLISECONDS, attachment, handler); + write(src, 0L, TimeUnit.MILLISECONDS, attachment, handler); } /** @@ -580,16 +569,16 @@ public abstract class AsynchronousSocket * If this channel is not yet connected */ @Override - public final Future write(ByteBuffer src) { - return write(src, 0L, TimeUnit.MILLISECONDS, null, null); - } + public abstract Future write(ByteBuffer src); /** * Writes a sequence of bytes to this channel from a subsequence of the given * buffers. This operation, sometimes called a gathering write, is * often useful when implementing network protocols that group data into * segments consisting of one or more fixed-length headers followed by a - * variable-length body. + * variable-length body. The {@code handler} parameter is a completion + * handler that is invoked when the write operation completes (or fails). + * The result passed to the completion handler is the number of bytes written. * * This method initiates a write of up to r bytes to this channel, * where r is the total number of bytes remaining in the specified @@ -615,10 +604,6 @@ public abstract class AsynchronousSocket * used in an I/O operation. Where the number of buffers (with bytes * remaining), exceeds this limit, then the I/O operation is performed with * the maximum number of buffers allowed by the operating system. - * - *
The return value from this method is a {@code Future} representing - * the pending result of the operation. The {@code Future}'s {@link - * Future#get() get} method will return the number of bytes written. * *
If a timeout is specified and the timeout elapses before the operation * completes then it completes with the exception {@link @@ -644,9 +629,7 @@ public abstract class AsynchronousSocket * @param attachment * The object to attach to the I/O operation; can be {@code null} * @param handler - * The handler for consuming the result; can be {@code null} - * - * @return A {@code Future} object representing the pending result + * The handler for consuming the result * * @throws IndexOutOfBoundsException * If the pre-conditions for the {@code offset} and {@code length} @@ -658,13 +641,13 @@ public abstract class AsynchronousSocket * @throws NotYetConnectedException * If this channel is not yet connected * @throws ShutdownChannelGroupException - * If a handler is specified, and the channel group is shutdown - */ - public abstract Future
write(ByteBuffer[] srcs, - int offset, - int length, - long timeout, - TimeUnit unit, - A attachment, - CompletionHandler handler); + * If the channel group has terminated + */ + public abstract void write(ByteBuffer[] srcs, + int offset, + int length, + long timeout, + TimeUnit unit, + A attachment, + CompletionHandler handler); } --- a/src/share/classes/java/nio/channels/Channels.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/channels/Channels.java Tue Sep 22 01:20:51 2009 -0700 @@ -182,7 +182,6 @@ public final class Channels { } /** - * {@note new} * Constructs a stream that reads bytes from the given channel. * * The stream will not be buffered, and it will not support the {@link @@ -258,7 +257,6 @@ public final class Channels { } /** - * {@note new} * Constructs a stream that writes bytes to the given channel. * *
The stream will not be buffered. The stream will be safe for access --- a/src/share/classes/java/nio/channels/CompletionHandler.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/channels/CompletionHandler.java Tue Sep 22 01:20:51 2009 -0700 @@ -32,11 +32,9 @@ package java.nio.channels; * handler to be specified to consume the result of an asynchronous operation. * The {@link #completed completed} method is invoked when the I/O operation * completes successfully. The {@link #failed failed} method is invoked if the - * I/O operations fails. The {@link #cancelled cancelled} method is invoked when - * the I/O operation is cancelled by invoking the {@link - * java.util.concurrent.Future#cancel cancel} method. The implementations of - * these methods should complete in a timely manner so as to avoid keeping the - * invoking thread from dispatching to other completion handlers. + * I/O operations fails. The implementations of these methods should complete + * in a timely manner so as to avoid keeping the invoking thread from dispatching + * to other completion handlers. * * @param
The result type of the I/O operation * @param The type of the object attached to the I/O operation @@ -65,13 +63,4 @@ public interface CompletionHandler * The object attached to the I/O operation when it was initiated. */ void failed(Throwable exc, A attachment); - - /** - * Invoked when an operation is cancelled by invoking the {@link - * java.util.concurrent.Future#cancel cancel} method. - * - * @param attachment - * The object attached to the I/O operation when it was initiated. - */ - void cancelled(A attachment); } --- a/src/share/classes/java/nio/channels/FileChannel.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/channels/FileChannel.java Tue Sep 22 01:20:51 2009 -0700 @@ -39,8 +39,7 @@ import java.util.Collections; /** * A channel for reading, writing, mapping, and manipulating a file. * - * {@note revised} - * A file channel is a {@link SeekableByteChannel} that is connected to + *
A file channel is a {@link SeekableByteChannel} that is connected to * a file. It has a current position within its file which can * be both {@link #position() queried} and {@link #position(long) * modified}. The file itself contains a variable-length sequence @@ -151,7 +150,6 @@ import java.util.Collections; * @author Mike McCloskey * @author JSR-51 Expert Group * @since 1.4 - * @updated 1.7 */ public abstract class FileChannel @@ -164,7 +162,6 @@ public abstract class FileChannel protected FileChannel() { } /** - * {@note new} * Opens or creates a file, returning a file channel to access the file. * *
The {@code options} parameter determines how the file is opened. @@ -293,7 +290,6 @@ public abstract class FileChannel private static final FileAttribute>[] NO_ATTRIBUTES = new FileAttribute[0]; /** - * {@note new} * Opens or creates a file, returning a file channel to access the file. * *
An invocation of this method behaves in exactly the same way as the --- a/src/share/classes/java/nio/channels/FileLock.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/channels/FileLock.java Tue Sep 22 01:20:51 2009 -0700 @@ -114,7 +114,6 @@ import java.io.IOException; * @author Mark Reinhold * @author JSR-51 Expert Group * @since 1.4 - * @updated 1.7 */ public abstract class FileLock { @@ -161,7 +160,7 @@ public abstract class FileLock { } /** - * {@note new} Initializes a new instance of this class. + * Initializes a new instance of this class. * * @param channel * The channel upon whose file this lock is held @@ -199,7 +198,6 @@ public abstract class FileLock { } /** - * {@note revised} * Returns the file channel upon whose file this lock was acquired. * *
This method has been superseded by the {@link #acquiredBy acquiredBy} @@ -213,7 +211,6 @@ public abstract class FileLock { } /** - * {@note new} * Returns the channel upon whose file this lock was acquired. * * @return The channel upon whose file this lock was acquired. --- a/src/share/classes/java/nio/channels/exceptions Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/channels/exceptions Tue Sep 22 01:20:51 2009 -0700 @@ -190,5 +190,5 @@ gen ShutdownChannelGroupException " gen ShutdownChannelGroupException " * Unchecked exception thrown when an attempt is made to construct a channel in * a group that is shutdown or the completion handler for an I/O operation - * cannot be invoked because the channel group is shutdown." \ + * cannot be invoked because the channel group has terminated." \ -3903801676350154157L --- a/src/share/classes/java/nio/channels/package-info.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/channels/package-info.java Tue Sep 22 01:20:51 2009 -0700 @@ -285,7 +285,6 @@ * java.lang.NullPointerException NullPointerException} to be thrown. * * @since 1.4 - * @updated 1.7 * @author Mark Reinhold * @author JSR-51 Expert Group */ --- a/src/share/classes/java/nio/file/FileRef.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/file/FileRef.java Tue Sep 22 01:20:51 2009 -0700 @@ -39,8 +39,6 @@ import java.io.IOException; * metadata or file attributes. * * @since 1.7 - * @see java.io.Inputs - * @see java.io.Outputs * @see java.nio.file.attribute.Attributes * @see java.io.File#toPath */ --- a/src/share/classes/java/nio/file/Files.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/file/Files.java Tue Sep 22 01:20:51 2009 -0700 @@ -133,10 +133,11 @@ public final class Files { *
This method walks a file tree rooted at a given starting file. The * file tree traversal is depth-first with the given {@link * FileVisitor} invoked for each file encountered. File tree traversal - * completes when all accessible files in the tree have been visited, a - * visitor returns a result of {@link FileVisitResult#TERMINATE TERMINATE}, - * or the visitor terminates due to an uncaught {@code Error} or {@code - * RuntimeException}. + * completes when all accessible files in the tree have been visited, or a + * visit method returns a result of {@link FileVisitResult#TERMINATE + * TERMINATE}. Where a visit method terminates due an uncaught error or + * runtime exception then the traversal is terminated and the error or + * exception is propagated to the caller of this method. * *
For each file encountered this method attempts to gets its {@link * java.nio.file.attribute.BasicFileAttributes}. If the file is not a --- a/src/share/classes/java/nio/file/SimpleFileVisitor.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/nio/file/SimpleFileVisitor.java Tue Sep 22 01:20:51 2009 -0700 @@ -124,8 +124,8 @@ public class SimpleFileVisitor
implem * cause. * * @throws IOError - * if iteration of the directory completed prematurely due to an - * I/O error + * with the I/O exception thrown when iteration of the directory + * completed prematurely due to an I/O error */ @Override public FileVisitResult postVisitDirectory(T dir, IOException exc) { --- a/src/share/classes/java/util/Properties.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/util/Properties.java Tue Sep 22 01:20:51 2009 -0700 @@ -101,11 +101,11 @@ import java.io.BufferedWriter; * <!ATTLIST entry key CDATA #REQUIRED> * This class is thread-safe: multiple threads can share a single + * Properties object without the need for external synchronization. + * * @see native2ascii tool for Solaris * @see native2ascii tool for Windows - * - *
This class is thread-safe: multiple threads can share a single - * Properties object without the need for external synchronization. * * @author Arthur van Hoff * @author Michael McCloskey --- a/src/share/classes/java/util/Scanner.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/util/Scanner.java Tue Sep 22 01:20:51 2009 -0700 @@ -674,7 +674,6 @@ public final class Scanner implements It } /** - * {@note new} * Constructs a new
Scanner
that produces values scanned * from the specified file. Bytes from the file are converted into * characters using the underlying platform's @@ -694,7 +693,6 @@ public final class Scanner implements It } /** - * {@note new} * Constructs a newScanner
that produces values scanned * from the specified file. Bytes from the file are converted into * characters using the specified charset. --- a/src/share/classes/java/util/SimpleTimeZone.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/util/SimpleTimeZone.java Tue Sep 22 01:20:51 2009 -0700 @@ -1372,7 +1372,7 @@ public class SimpleTimeZone extends Time throw new IllegalArgumentException( "Illegal start month " + startMonth); } - if (startTime < 0 || startTime >= millisPerDay) { + if (startTime < 0 || startTime > millisPerDay) { throw new IllegalArgumentException( "Illegal start time " + startTime); } @@ -1419,7 +1419,7 @@ public class SimpleTimeZone extends Time throw new IllegalArgumentException( "Illegal end month " + endMonth); } - if (endTime < 0 || endTime >= millisPerDay) { + if (endTime < 0 || endTime > millisPerDay) { throw new IllegalArgumentException( "Illegal end time " + endTime); } --- a/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java Tue Sep 22 01:20:51 2009 -0700 @@ -766,19 +766,21 @@ public class LinkedBlockingQueueexte } /** - * Unlike other traversal methods, iterators need to handle: + * Returns the next live successor of p, or null if no such. + * + * Unlike other traversal methods, iterators need to handle both: * - dequeued nodes (p.next == p) - * - interior removed nodes (p.item == null) + * - (possibly multiple) interior removed nodes (p.item == null) */ private Node nextNode(Node p) { - Node s = p.next; - if (p == s) - return head.next; - // Skip over removed nodes. - // May be necessary if multiple interior Nodes are removed. - while (s != null && s.item == null) - s = s.next; - return s; + for (;;) { + Node s = p.next; + if (s == p) + return head.next; + if (s == null || s.item != null) + return s; + p = s; + } } public E next() { --- a/src/share/classes/javax/swing/JEditorPane.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/javax/swing/JEditorPane.java Tue Sep 22 01:20:51 2009 -0700 @@ -23,6 +23,8 @@ * have any questions. */ package javax.swing; + +import sun.swing.SwingUtilities2; import java.awt.*; import java.awt.event.*; @@ -1123,6 +1125,7 @@ public class JEditorPane extends JTextCo * @param content the content to replace the selection with. This * value can be null
*/ + @Override public void replaceSelection(String content) { if (! isEditable()) { UIManager.getLookAndFeel().provideErrorFeedback(JEditorPane.this); @@ -1133,6 +1136,7 @@ public class JEditorPane extends JTextCo try { Document doc = getDocument(); Caret caret = getCaret(); + boolean composedTextSaved = saveComposedText(caret.getDot()); int p0 = Math.min(caret.getDot(), caret.getMark()); int p1 = Math.max(caret.getDot(), caret.getMark()); if (doc instanceof AbstractDocument) { @@ -1147,6 +1151,9 @@ public class JEditorPane extends JTextCo doc.insertString(p0, content, ((StyledEditorKit)kit). getInputAttributes()); } + } + if (composedTextSaved) { + restoreComposedText(); } } catch (BadLocationException e) { UIManager.getLookAndFeel().provideErrorFeedback(JEditorPane.this); @@ -1323,8 +1330,8 @@ public class JEditorPane extends JTextCo */ public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); - if (getParent() instanceof JViewport) { - JViewport port = (JViewport)getParent(); + JViewport port = SwingUtilities2.getViewport(this); + if (port != null) { TextUI ui = getUI(); int prefWidth = d.width; int prefHeight = d.height; @@ -1445,8 +1452,8 @@ public class JEditorPane extends JTextCo * match its own, false otherwise */ public boolean getScrollableTracksViewportWidth() { - if (getParent() instanceof JViewport) { - JViewport port = (JViewport)getParent(); + JViewport port = SwingUtilities2.getViewport(this); + if (port != null) { TextUI ui = getUI(); int w = port.getWidth(); Dimension min = ui.getMinimumSize(this); @@ -1467,8 +1474,8 @@ public class JEditorPane extends JTextCo * false otherwise */ public boolean getScrollableTracksViewportHeight() { - if (getParent() instanceof JViewport) { - JViewport port = (JViewport)getParent(); + JViewport port = SwingUtilities2.getViewport(this); + if (port != null) { TextUI ui = getUI(); int h = port.getHeight(); Dimension min = ui.getMinimumSize(this); --- a/src/share/classes/javax/swing/JLayer.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/javax/swing/JLayer.java Tue Sep 22 01:20:51 2009 -0700 @@ -1,6 +1,26 @@ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. */ package javax.swing; @@ -158,7 +178,7 @@ public final class JLayergetPreferredSize().height); - } return false; } @@ -497,9 +517,6 @@ public final class JLayer getPreferredSize().width); } return false; } @@ -535,20 +552,36 @@ public final class JLayer > layerList = - new ArrayList >(); + private ArrayList layerMaskList = + new ArrayList (); private long currentEventMask; @@ -572,37 +605,24 @@ public final class JLayer layerWeakReference : layerList) { - if (layerWeakReference.get() == l) { - return true; - } - } - return false; - } - - private void updateAWTEventListener(JLayer layer) { - if (!layerListContains(layer) && layer.getLayerEventMask() != 0) { - layerList.add(new WeakReference (layer)); + private void updateAWTEventListener(long oldEventMask, long newEventMask) { + if (oldEventMask != 0) { + layerMaskList.remove(oldEventMask); + } + if (newEventMask != 0) { + layerMaskList.add(newEventMask); } long combinedMask = 0; - Iterator > it = layerList.iterator(); - while (it.hasNext()) { - WeakReference weakRef = it.next(); - JLayer currLayer = weakRef.get(); - if (currLayer == null) { - it.remove(); - } else { - combinedMask |= currLayer.getLayerEventMask(); - } + for (Long mask : layerMaskList) { + combinedMask |= mask; } if (combinedMask == 0) { removeAWTEventListener(); - layerList.clear(); } else if (getCurrentEventMask() != combinedMask) { removeAWTEventListener(); addAWTEventListener(combinedMask); } + currentEventMask = combinedMask; } private long getCurrentEventMask() { @@ -617,7 +637,7 @@ public final class JLayer getPreferredSize().width); + JViewport port = SwingUtilities2.getViewport(this); + if (port != null) { + return port.getWidth() > getPreferredSize().width; } return false; } @@ -2747,8 +2748,9 @@ public class JList extends JComponent im getVisibleRowCount() <= 0) { return true; } - if (getParent() instanceof JViewport) { - return (getParent().getHeight() > getPreferredSize().height); + JViewport port = SwingUtilities2.getViewport(this); + if (port != null) { + return port.getHeight() > getPreferredSize().height; } return false; } --- a/src/share/classes/javax/swing/JTable.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/javax/swing/JTable.java Tue Sep 22 01:20:51 2009 -0700 @@ -718,9 +718,9 @@ public class JTable extends JComponent i * @see #addNotify */ protected void configureEnclosingScrollPane() { - Container p = getParent(); - if (p instanceof JViewport) { - Container gp = p.getParent(); + JViewport port = SwingUtilities2.getViewport(this); + if (port != null) { + Container gp = port.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane)gp; // Make certain we are the viewPort's view and not, for @@ -750,9 +750,9 @@ public class JTable extends JComponent i * from configureEnclosingScrollPane() and updateUI() in a safe manor. */ private void configureEnclosingScrollPaneUI() { - Container p = getParent(); - if (p instanceof JViewport) { - Container gp = p.getParent(); + JViewport port = SwingUtilities2.getViewport(this); + if (port != null) { + Container gp = port.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane)gp; // Make certain we are the viewPort's view and not, for @@ -819,9 +819,9 @@ public class JTable extends JComponent i * @since 1.3 */ protected void unconfigureEnclosingScrollPane() { - Container p = getParent(); - if (p instanceof JViewport) { - Container gp = p.getParent(); + JViewport port = SwingUtilities2.getViewport(this); + if (port != null) { + Container gp = port.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane)gp; // Make certain we are the viewPort's view and not, for @@ -5215,9 +5215,10 @@ public class JTable extends JComponent i * @see #getFillsViewportHeight */ public boolean getScrollableTracksViewportHeight() { + JViewport port = SwingUtilities2.getViewport(this); return getFillsViewportHeight() - && getParent() instanceof JViewport - && (getParent().getHeight() > getPreferredSize().height); + && port != null + && port.getHeight() > getPreferredSize().height; } /** --- a/src/share/classes/javax/swing/JTextField.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/javax/swing/JTextField.java Tue Sep 22 01:20:51 2009 -0700 @@ -23,6 +23,8 @@ * have any questions. */ package javax.swing; + +import sun.swing.SwingUtilities2; import java.awt.*; import java.awt.event.*; @@ -288,11 +290,7 @@ public class JTextField extends JTextCom * @see JComponent#isValidateRoot */ public boolean isValidateRoot() { - Component parent = getParent(); - if (parent instanceof JViewport) { - return false; - } - return true; + return SwingUtilities2.getViewport(this) == null; } --- a/src/share/classes/javax/swing/JTextPane.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/javax/swing/JTextPane.java Tue Sep 22 01:20:51 2009 -0700 @@ -170,6 +170,7 @@ public class JTextPane extends JEditorPa * * @param content the content to replace the selection with */ + @Override public void replaceSelection(String content) { replaceSelection(content, true); } @@ -183,6 +184,7 @@ public class JTextPane extends JEditorPa if (doc != null) { try { Caret caret = getCaret(); + boolean composedTextSaved = saveComposedText(caret.getDot()); int p0 = Math.min(caret.getDot(), caret.getMark()); int p1 = Math.max(caret.getDot(), caret.getMark()); AttributeSet attr = getInputAttributes().copyAttributes(); @@ -196,6 +198,9 @@ public class JTextPane extends JEditorPa if (content != null && content.length() > 0) { doc.insertString(p0, content, attr); } + } + if (composedTextSaved) { + restoreComposedText(); } } catch (BadLocationException e) { UIManager.getLookAndFeel().provideErrorFeedback(JTextPane.this); --- a/src/share/classes/javax/swing/JTree.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/javax/swing/JTree.java Tue Sep 22 01:20:51 2009 -0700 @@ -3498,8 +3498,9 @@ public class JTree extends JComponent im * @see Scrollable#getScrollableTracksViewportWidth */ public boolean getScrollableTracksViewportWidth() { - if (getParent() instanceof JViewport) { - return getParent().getWidth() > getPreferredSize().width; + JViewport port = SwingUtilities2.getViewport(this); + if (port != null) { + return port.getWidth() > getPreferredSize().width; } return false; } @@ -3514,8 +3515,9 @@ public class JTree extends JComponent im * @see Scrollable#getScrollableTracksViewportHeight */ public boolean getScrollableTracksViewportHeight() { - if (getParent() instanceof JViewport) { - return getParent().getHeight() > getPreferredSize().height; + JViewport port = SwingUtilities2.getViewport(this); + if (port != null) { + return port.getHeight() > getPreferredSize().height; } return false; } --- a/src/share/classes/javax/swing/SwingUtilities.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/javax/swing/SwingUtilities.java Tue Sep 22 01:20:51 2009 -0700 @@ -999,24 +999,20 @@ public class SwingUtilities implements S textR.height = (int) v.getPreferredSpan(View.Y_AXIS); } else { textR.width = SwingUtilities2.stringWidth(c, fm, text); - - // Take into account the left and right side bearings. - // This gives more space than it is actually needed, - // but there are two reasons: - // 1. If we set the width to the actual bounds, - // all callers would have to account for the bearings - // themselves. NOTE: all pref size calculations don't do it. - // 2. You can do a drawString at the returned location - // and the text won't be clipped. lsb = SwingUtilities2.getLeftSideBearing(c, fm, text); if (lsb < 0) { + // If lsb is negative, add it to the width and later + // adjust the x location. This gives more space than is + // actually needed. + // This is done like this for two reasons: + // 1. If we set the width to the actual bounds all + // callers would have to account for negative lsb + // (pref size calculations ONLY look at width of + // textR) + // 2. You can do a drawString at the returned location + // and the text won't be clipped. textR.width -= lsb; } - rsb = SwingUtilities2.getRightSideBearing(c, fm, text); - if (rsb > 0) { - textR.width += rsb; - } - if (textR.width > availTextWidth) { text = SwingUtilities2.clipString(c, fm, text, availTextWidth); --- a/src/share/classes/javax/swing/plaf/LayerUI.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/javax/swing/plaf/LayerUI.java Tue Sep 22 01:20:51 2009 -0700 @@ -1,6 +1,26 @@ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. */ package javax.swing.plaf; @@ -202,6 +222,7 @@ public class LayerUI l) { if (l.getView() instanceof Scrollable) { return ((Scrollable)l.getView()).getScrollableTracksViewportHeight(); - } - if (l.getParent() instanceof JViewport) { - return (((JViewport)l.getParent()).getHeight() > l.getPreferredSize().height); } return false; } @@ -294,6 +318,7 @@ public class LayerUI l) { if (l.getView() instanceof Scrollable) { return ((Scrollable)l.getView()).getScrollableTracksViewportWidth(); - } - if (l.getParent() instanceof JViewport) { - return (((JViewport)l.getParent()).getWidth() > l.getPreferredSize().width); } return false; } @@ -318,6 +340,10 @@ public class LayerUI derivedColorsMap = - new HashMap (); - - /** Tempory key used for fetching from the derivedColorsMap */ - private final DerivedColorKey tmpDCKey = new DerivedColorKey(); + private ColorTree colorTree = new ColorTree(); /** Listener for changes to user defaults table */ private DefaultsListener defaultsListener = new DefaultsListener(); @@ -117,14 +110,14 @@ final class ${LAF_NAME}Defaults { void initialize() { // add listener for derived colors UIManager.addPropertyChangeListener(defaultsListener); - UIManager.getDefaults().addPropertyChangeListener(defaultsListener); + UIManager.getDefaults().addPropertyChangeListener(colorTree); } /** Called by UIManager when this look and feel is uninstalled. */ void uninitialize() { // remove listener for derived colors - UIManager.getDefaults().removePropertyChangeListener(defaultsListener); UIManager.removePropertyChangeListener(defaultsListener); + UIManager.getDefaults().removePropertyChangeListener(colorTree); } /** @@ -663,22 +656,23 @@ final class ${LAF_NAME}Defaults { } } - /** - * Get a derived color, derived colors are shared instances and will be - * updated when its parent UIDefault color changes. - * - * @param uiDefaultParentName The parent UIDefault key - * @param hOffset The hue offset - * @param sOffset The saturation offset - * @param bOffset The brightness offset - * @param aOffset The alpha offset - * @return The stored derived color - */ - public DerivedColor getDerivedColor(String uiDefaultParentName, - float hOffset, float sOffset, - float bOffset, int aOffset){ - return getDerivedColor(uiDefaultParentName, hOffset, sOffset, - bOffset, aOffset, true); + private void addColor(UIDefaults d, String uin, int r, int g, int b, int a) { + Color color = new ColorUIResource(new Color(r, g, b, a)); + colorTree.addColor(uin, color); + d.put(uin, color); + } + + private void addColor(UIDefaults d, String uin, String parentUin, + float hOffset, float sOffset, float bOffset, int aOffset) { + addColor(d, uin, parentUin, hOffset, sOffset, bOffset, aOffset, true); + } + + private void addColor(UIDefaults d, String uin, String parentUin, + float hOffset, float sOffset, float bOffset, + int aOffset, boolean uiResource) { + Color color = getDerivedColor(uin, parentUin, + hOffset, sOffset, bOffset, aOffset, uiResource); + d.put(uin, color); } /** @@ -694,89 +688,110 @@ final class ${LAF_NAME}Defaults { * false if it should not be a UIResource * @return The stored derived color */ - public DerivedColor getDerivedColor(String uiDefaultParentName, + public DerivedColor getDerivedColor(String parentUin, float hOffset, float sOffset, float bOffset, int aOffset, boolean uiResource){ - tmpDCKey.set(uiDefaultParentName, hOffset, sOffset, bOffset, aOffset, - uiResource); - DerivedColor color = derivedColorsMap.get(tmpDCKey); - if (color == null){ - if (uiResource) { - color = new DerivedColor.UIResource(uiDefaultParentName, - hOffset, sOffset, bOffset, aOffset); - } else { - color = new DerivedColor(uiDefaultParentName, hOffset, sOffset, - bOffset, aOffset); - } - // calculate the initial value - color.rederiveColor(); - // add the listener so that if the color changes we'll propogate it - color.addPropertyChangeListener(defaultsListener); - // add to the derived colors table - derivedColorsMap.put(new DerivedColorKey(uiDefaultParentName, - hOffset, sOffset, bOffset, aOffset, uiResource),color); - } - return color; - } - - /** - * Key class for derived colors - */ - private class DerivedColorKey { - private String uiDefaultParentName; - private float hOffset, sOffset, bOffset; - private int aOffset; - private boolean uiResource; - - DerivedColorKey(){} - - DerivedColorKey(String uiDefaultParentName, float hOffset, - float sOffset, float bOffset, int aOffset, - boolean uiResource) { - set(uiDefaultParentName, hOffset, sOffset, bOffset, aOffset, uiResource); - } - - void set (String uiDefaultParentName, float hOffset, - float sOffset, float bOffset, int aOffset, - boolean uiResource) { - this.uiDefaultParentName = uiDefaultParentName; - this.hOffset = hOffset; - this.sOffset = sOffset; - this.bOffset = bOffset; - this.aOffset = aOffset; - this.uiResource = uiResource; + return getDerivedColor(null, parentUin, + hOffset, sOffset, bOffset, aOffset, uiResource); + } + + private DerivedColor getDerivedColor(String uin, String parentUin, + float hOffset, float sOffset, + float bOffset, int aOffset, + boolean uiResource) { + DerivedColor color; + if (uiResource) { + color = new DerivedColor.UIResource(parentUin, + hOffset, sOffset, bOffset, aOffset); + } else { + color = new DerivedColor(parentUin, hOffset, sOffset, + bOffset, aOffset); + } + + if (derivedColors.containsKey(color)) { + return derivedColors.get(color); + } else { + derivedColors.put(color, color); + color.rederiveColor(); /// move to ARP.decodeColor() ? + colorTree.addColor(uin, color); + return color; + } + } + + private Map derivedColors = + new HashMap (); + + private class ColorTree implements PropertyChangeListener { + private Node root = new Node(null, null); + private Map nodes = new HashMap (); + + public Color getColor(String uin) { + return nodes.get(uin).color; + } + + public void addColor(String uin, Color color) { + Node parent = getParentNode(color); + Node node = new Node(color, parent); + parent.children.add(node); + if (uin != null) { + nodes.put(uin, node); + } + } + + private Node getParentNode(Color color) { + Node parent = root; + if (color instanceof DerivedColor) { + String parentUin = ((DerivedColor)color).getUiDefaultParentName(); + Node p = nodes.get(parentUin); + if (p != null) { + parent = p; + } + } + return parent; + } + + public void update() { + root.update(); } @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof DerivedColorKey)) return false; - DerivedColorKey that = (DerivedColorKey) o; - if (aOffset != that.aOffset) return false; - if (Float.compare(that.bOffset, bOffset) != 0) return false; - if (Float.compare(that.hOffset, hOffset) != 0) return false; - if (Float.compare(that.sOffset, sOffset) != 0) return false; - if (uiDefaultParentName != null ? - !uiDefaultParentName.equals(that.uiDefaultParentName) : - that.uiDefaultParentName != null) return false; - if (this.uiResource != that.uiResource) return false; - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + uiDefaultParentName.hashCode(); - result = 31 * result + hOffset != +0.0f ? - Float.floatToIntBits(hOffset) : 0; - result = 31 * result + sOffset != +0.0f ? - Float.floatToIntBits(sOffset) : 0; - result = 31 * result + bOffset != +0.0f ? - Float.floatToIntBits(bOffset) : 0; - result = 31 * result + aOffset; - result = 31 * result + (uiResource ? 1 : 0); - return result; + public void propertyChange(PropertyChangeEvent ev) { + String name = ev.getPropertyName(); + Node node = nodes.get(name); + if (node != null) { + // this is a registered color + node.parent.children.remove(node); + Color color = (Color) ev.getNewValue(); + Node parent = getParentNode(color); + node.set(color, parent); + parent.children.add(node); + node.update(); + } + } + + class Node { + Color color; + Node parent; + List children = new LinkedList (); + + Node(Color color, Node parent) { + set(color, parent); + } + + public void set(Color color, Node parent) { + this.color = color; + this.parent = parent; + } + + public void update() { + if (color instanceof DerivedColor) { + ((DerivedColor)color).rederiveColor(); + } + for (Node child: children) { + child.update(); + } + } } } @@ -786,49 +801,12 @@ final class ${LAF_NAME}Defaults { private class DefaultsListener implements PropertyChangeListener { @Override public void propertyChange(PropertyChangeEvent evt) { - Object src = evt.getSource(); - String key = evt.getPropertyName(); - if (key.equals("lookAndFeel")){ + if ("lookAndFeel".equals(evt.getPropertyName())) { // LAF has been installed, this is the first point at which we // can access our defaults table via UIManager so before now // all derived colors will be incorrect. // First we need to update - for (DerivedColor color : derivedColorsMap.values()) { - color.rederiveColor(); - } - } else if (src instanceof DerivedColor && key.equals("rgb")) { - // derived color that is in UIManager defaults has changed - // update all its dependent colors. Don't worry about doing - // this recursively since calling rederiveColor will cause - // another PCE to be fired, ending up here and essentially - // recursing - DerivedColor parentColor = (DerivedColor)src; - String parentKey = null; - Set > entries = - UIManager.getDefaults().entrySet(); - - for (Map.Entry entry : entries) { - Object value = entry.getValue(); - if (value == parentColor) { - parentKey = entry.getKey().toString(); - } - } - - if (parentKey == null) { - //couldn't find the DerivedColor in the UIDefaults map, - //so we just bail. - return; - } - - for (Map.Entry entry : entries) { - Object value = entry.getValue(); - if (value instanceof DerivedColor) { - DerivedColor color = (DerivedColor)entry.getValue(); - if (parentKey.equals(color.getUiDefaultParentName())) { - color.rederiveColor(); - } - } - } + colorTree.update(); } } } @@ -875,4 +853,3 @@ final class ${LAF_NAME}Defaults { } } } - --- a/src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java Tue Sep 22 01:20:51 2009 -0700 @@ -39,8 +39,6 @@ import java.beans.PropertyChangeListener * @author Jasper Potts */ class DerivedColor extends Color { - private final PropertyChangeSupport changeSupport = - new PropertyChangeSupport(this); private final String uiDefaultParentName; private final float hOffset, sOffset, bOffset; private final int aOffset; @@ -79,7 +77,6 @@ class DerivedColor extends Color { * Recalculate the derived color from the UIManager parent color and offsets */ public void rederiveColor() { - int old = argbValue; Color src = UIManager.getColor(uiDefaultParentName); if (src != null) { float[] tmp = Color.RGBtoHSB(src.getRed(), src.getGreen(), src.getBlue(), null); @@ -97,7 +94,6 @@ class DerivedColor extends Color { int alpha = clamp(aOffset); argbValue = (Color.HSBtoRGB(tmp[0], tmp[1], tmp[2]) & 0xFFFFFF) | (alpha << 24); } - changeSupport.firePropertyChange("rgb", old, argbValue); } /** @@ -141,35 +137,6 @@ class DerivedColor extends Color { return result; } - /** - * Add a PropertyChangeListener to the listener list. - * The listener is registered for all properties. - * The same listener object may be added more than once, and will be called - * as many times as it is added. - * If listener
is null, no exception is thrown and no action - * is taken. - * - * @param listener The PropertyChangeListener to be added - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - changeSupport.addPropertyChangeListener(listener); - } - - /** - * Remove a PropertyChangeListener from the listener list. - * This removes a PropertyChangeListener that was registered - * for all properties. - * Iflistener
was added more than once to the same event - * source, it will be notified one less time after being removed. - * Iflistener
is null, or was never added, no exception is - * thrown and no action is taken. - * - * @param listener The PropertyChangeListener to be removed - */ - public void removePropertyChangeListener(PropertyChangeListener listener) { - changeSupport.removePropertyChangeListener(listener); - } - private float clamp(float value) { if (value < 0) { value = 0; @@ -211,5 +178,15 @@ class DerivedColor extends Color { float bOffset, int aOffset) { super(uiDefaultParentName, hOffset, sOffset, bOffset, aOffset); } + + @Override + public boolean equals(Object o) { + return (o instanceof UIResource) && super.equals(o); + } + + @Override + public int hashCode() { + return super.hashCode() + 7; + } } } --- a/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java Tue Sep 15 16:15:36 2009 +0400 +++ b/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java Tue Sep 22 01:20:51 2009 -0700 @@ -40,6 +40,9 @@ import java.awt.Graphics2D; import java.awt.Graphics2D; import java.awt.LayoutManager; import java.awt.image.BufferedImage; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.*; import javax.swing.GrayFilter; import javax.swing.Icon; import javax.swing.JToolBar; @@ -87,6 +90,8 @@ public class NimbusLookAndFeel extends S */ private UIDefaults uiDefaults; + private DefaultsListener defaultsListener = new DefaultsListener(); + /** * Create a new NimbusLookAndFeel. */ @@ -115,8 +120,7 @@ public class NimbusLookAndFeel extends S defaults.uninitialize(); // clear all cached images to free memory ImageCache.getInstance().flush(); - // remove the listeners and things installed by NimbusStyle - NimbusStyle.uninitialize(); + UIManager.getDefaults().removePropertyChangeListener(defaultsListener); } /** @@ -515,4 +519,62 @@ public class NimbusLookAndFeel extends S return obj; } } + + private Map> compiledDefaults = null; + private boolean defaultListenerAdded = false; + + static String parsePrefix(String key) { + if (key == null) { + return null; + } + boolean inquotes = false; + for (int i = 0; i < key.length(); i++) { + char c = key.charAt(i); + if (c == '"') { + inquotes = !inquotes; + } else if ((c == '[' || c == '.') && !inquotes) { + return key.substring(0, i); + } + } + return null; + } + + Map getDefaultsForPrefix(String prefix) { + if (compiledDefaults == null) { + compiledDefaults = new HashMap >(); + for (Map.Entry


I AM GROOT
I AM GROOT
I AM GROOT
Types os events
- inline - the event is writen inside the tag in html (it is a attribute of the tag)
- Traditional - it is defined in JS as a part of the object(see JS)
- W3C - See JS code
inline TAGs
- onclick()- calls the function when the element clicked once
- ondblclick() - calls the function when the element clicked Twice
events os W3C
- click
- dblclick
- mouseover - like :hover
- mouseout - like not :hover
- mousemove - is the mouse moves
- mouseup -
- mousedown -
Click here for JS Code


|
|
New emonbase not picking up nodes |
0 |
1 year 12 weeks ago by joshpond |
n/a |
|
|
Pulses processing in Emoncms |
0 |
1 year 16 weeks ago by pierantonio81 |
n/a |
|
|
Unwanted wi-fi connections to emonpi |
0 |
1 year 16 weeks ago by Jez Wingfield |
n/a |
|
|
Local logging |
0 |
1 year 17 weeks ago by oymyakon |
n/a |
|
|
Emoncms v9 and minus temperatures |
0 |
1 year 17 weeks ago by rmtucker |
n/a |
|
|
wh accumulator 25kw limit |
0 |
1 year 18 weeks ago by tasminracer |
n/a |
|
|
Trouble with rawdata graphs based on local time |
0 |
1 year 18 weeks ago by Aymeric_THIBAUT |
n/a |
|
|
Help - Data Feed Foul Up |
0 |
1 year 18 weeks ago by JBlackham |
n/a |
|
|
Histogram and other Vis Feeds not Showing Up |
0 |
1 year 19 weeks ago by JBlackham |
n/a |
|
|
Why has the local emonCms server (with ready-to-use disk images) guide been removed? |
0 |
1 year 19 weeks ago by Gzero |
n/a |
|
|
emonBase doesn't start until Ethernet plugged in |
0 |
1 year 23 weeks ago by meso |
n/a |
|
|
emoncms server visualalizations show www root |
0 |
1 year 24 weeks ago by chris1howell |
n/a |
|
|
EmonPi Capabilities |
0 |
1 year 25 weeks ago by jtroberts73 |
n/a |
|
|
Feeds show as inactive on local install |
0 |
1 year 26 weeks ago by JumpMaster |
n/a |
|
|
Observation: radio interference on emonTx->emonBase frequency |
0 |
1 year 27 weeks ago by meso |
n/a |
|
|
emonTx V3.4 + pulse sensor + CTs and AC adapter: OK? |
0 |
1 year 27 weeks ago by meso |
n/a |
|
|
New to the forum looking for advice on excess pv |
0 |
1 year 32 weeks ago by glyndwr |
n/a |
|
|
Publish to MQTT with vlow write image? |
0 |
1 year 32 weeks ago by sheppy |
n/a |
|
|
MK2 self consumption |
0 |
1 year 33 weeks ago by Autodidaktos |
n/a |
|
|
Quick way to get a copy of phpfina data for use in other programs? |
0 |
1 year 33 weeks ago by ScooterS |
n/a |
|
|
Emonpi internal data logging |
0 |
1 year 33 weeks ago by fasugba |
n/a |
|
|
Passing data into my own database |
0 |
1 year 34 weeks ago by chuayq |
n/a |
|
|
Bug - APIkey in Feeds API Help - Background boxes for keys not long enough |
0 |
1 year 34 weeks ago by psg |
n/a |
|
|
View data with different users |
0 |
1 year 35 weeks ago by Kevin Copado |
n/a |
|
|
Bug in v8.5 multigraph? |
0 |
1 year 35 weeks ago by rbreuss |
n/a |
|
|
inputs no updating and being created new again |
0 |
1 year 37 weeks ago by Yoyonovich |
n/a |
|
|
Use of a pryanometer |
0 |
1 year 39 weeks ago by Guest |
n/a |
|
|
Calculating Costs |
0 |
1 year 39 weeks ago by northwarks |
n/a |
|
|
Documentation update for com_baud = 57600 ? |
0 |
1 year 40 weeks ago by Ian Davies |
n/a |
|
|
Raspberry Pi Arduino Java Example Event Handler not triggering |
0 |
1 year 43 weeks ago by Guest |
n/a |
|
|
forum security |
0 |
1 year 43 weeks ago by djh |
n/a |
|
|
Rate of Change reacts strangely |
0 |
1 year 43 weeks ago by Bruno |
n/a |
|
|
Feed processes |
0 |
1 year 44 weeks ago by Bruno |
n/a |
|
|
DS18B20 Block Breakout Case |
0 |
1 year 45 weeks ago by viper1bw |
n/a |
|
|
Emoncms Event Module problem [SOLVED] |
0 |
1 year 46 weeks ago by Mandela |
n/a |
|
|
Some EmonGLCD sketches not compiling after udate to Arduino 1.6.0 |
0 |
1 year 50 weeks ago by Lykke |
n/a |
|
|
Switching to full emoncms (master branch) - Local no longer working? |
0 |
2 years 4 days ago by ewiandr |
n/a |
|
|
GLCD digital thermometer |
0 |
2 years 4 weeks ago by bobdylan |
n/a |
|
|
error after a brand new install |
0 |
2 years 7 weeks ago by Guest |
n/a |
|
|
emoncms - calculate & display cost of natural gas |
0 |
2 years 7 weeks ago by ddcarter |
n/a |
|
|
Emoncms Multigraph fill below curve |
0 |
2 years 7 weeks ago by Dunum |
n/a |
|
|
Notice: Undefined index: name in /var/www/emoncms/Modules/input/input_model.php on line 288 |
0 |
2 years 9 weeks ago by nicolas |
n/a |
|
|
kWh to kWhd phptimeseries feeds stopped updating. How do I get them to restart? |
0 |
2 years 13 weeks ago by nrgbod |
n/a |
|
|
How to use emoncms ? Inputs, Feeds, ... |
0 |
2 years 14 weeks ago by Guest |
n/a |
|
|
Beginners question about input processing |
0 |
2 years 14 weeks ago by Guest |
n/a |
|
|
Cross-Origin Request Blocked - Calling get.json on emoncms.org (free account) from outside? |
0 |
2 years 15 weeks ago by gluino |
n/a |
|
|
Adding feed process stops inputs updating |
0 |
2 years 16 weeks ago by ngbod |
n/a |
|
|
add url feed in emoncms weather station |
0 |
2 years 16 weeks ago by calberts |
n/a |
|
|
data being stored but cannot visualize |
0 |
2 years 24 weeks ago by rangua |
n/a |
|
|
ZOOM widget with year 2015 data |
0 |
2 years 25 weeks ago by albertin |
n/a |


Dos - Step 1
For this project, we'll make sure our project file is Dos.csproj
, and modify it the way we did for Uno.
1: 2: 3: 4: 5: 6: 7: |
|
We'll need to add Nancy to paket.dependencies
(nuget Nancy
), and create a paket.references
file for Dos that has the same packages from Uno, plus Nancy. The whole file will look like:
1: 2: 3: |
|
Then, run paket install
to pull in the new dependency and make the necessary modifications to Dos.csproj
.
Nancy strives to provide a Super-Duper-Happy-Path (SDHP), where all you have to do is follow their conventions, and everything will "just work." (You can also configure every aspect of it; it's only opinionated in its defaults.) One of these conventions is that the controllers inherit from NancyModule
, and when they do, no further configuration is required. So, we create the Modules
directory, and add HomeModule.cs
, which looks like this:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: |
|
Since we'll be hosting this with Kestrel (via OWIN), we still need a Startup.cs
, though its Configure()
method looks a bit different:
1: 2: |
|
(We need to add a using statement for Nancy.Owin
so that the UseNancy()
method is visible.)
With the exception of the namespace, the App.cs
file is identical to the one from Uno. dotnet run
, then go to http://localhost:5000 and see your greeting from Nancy!


Material Selector - change texture rendering in canvas layers
Menu Blend - change canvas menu blending by globalCompositeOperation
Color Picker - change alpha 0x88/0xff of canvas menu background color
XeltoSS Script Container - HTML Container with ProtoSS transpiled Class in ES6 Standard
Menu - rounded pattern buttons with blend luminosity ("home" "misc" "game") [autocache in canvas array]
Pages:
home:
rounded pattern button, mouse over activates Keyboard input [draggable]
blue label "Zeta Ret Clockwork" - rounded pattern button will display text
red rectangle
2 animated black rectangles - uses color and geometric transform [uses int colors]
Page Label "Home Page"
border rendering around linear gradient rectangle [uses int colors]
transformed radial gradient rectangle [uses int colors]
shape container - radiant curve 360, pattern round rectangle, radial gradient ellipse, circle and rectangle with border [draggable][mouse wheel][color picker]
transformed ellipse with border and drop shadow [uses int colors]
transformed complex polygon with cubic curves, border and drop shadow [uses int colors]
text label "Hello" [uses int colors]
text label "Stroked" with border
HTMLElement img, uses canvas DisplayObject transform, red shape mimic of HTMLElement is drawn on canvas using ordered css transform of "matrix(1, 0, 0, 1, 730, 120) rotate(30deg) scale(0.8, 1) skew(40deg,0)" with "forceSelfInvalidate" flag of DisplayObject thus imitating perfectly standard css transformations as follows: calculate Math.cos and Math.sin of x and y rotation, transform rotate matrix using scale x and y, calculate Math.tan of x and y skew, and cross transform by multiplication the product of rotation scale matrix, set translation properties without scale
misc:
gallery - 3 gallery items with images using url loader


File Windows.lua
Functions
| Windows:getShellName () | Return OS shell name (e.g. |
| Windows:makeFileLink (linkPath, filePath) | windows implementation of operating-system--make-folder-link. |
| Windows:makeFolderLink (linkPath, folderPath) | windows implementation of operating-system--make-folder-link. |
| Windows:new (t) | Constructor for new instance. |
| Windows:newClass (t) | Constructor for extending class. |
| Windows:openFileInDefaultApp (file) | Opens one file in its O.S.-registered default app. |
| Windows:sendUnmodifiedKeys (keyStr) | Send key string verbatim using AHK compiled script, which just directs parameter string verbatim to Lightroom, and must therefore be in AHK compatible format if it contains any special keystroke modifiers. |
Functions
- Windows:getShellName ()
- Return OS shell name (e.g. Explorer or Finder)
- Windows:makeFileLink (linkPath, filePath)
-
windows implementation of operating-system--make-folder-link.
Parameters:
-
linkPath
: -
filePath
:
-
- Windows:makeFolderLink (linkPath, folderPath)
-
windows implementation of operating-system--make-folder-link.
Parameters:
-
linkPath
: -
folderPath
:
-
- Windows:new (t)
-
Constructor for new instance.
Parameters:
-
t
:
-
- Windows:newClass (t)
-
Constructor for extending class.
Parameters:
-
t
:
-
- Windows:openFileInDefaultApp (file)
-
Opens one file in its O.S.-registered default app.
Parameters:
-
file
:
Usage:
Non-blocking - nothing returned.
Good choice for opening local help files, since lr-http-open-url-in-browser does not work properly on Mac in that case.
Not called directly - see operating system parent class for more info
-
- Windows:sendUnmodifiedKeys (keyStr)
-
Send key string verbatim using AHK compiled script, which just directs parameter string verbatim to Lightroom, and must therefore be in AHK compatible format if it contains any special keystroke modifiers.
Parameters:
-
keyStr
:
Usage:
Ctrl sequence format is: {Ctrl Down}key(s){Ctrl Up}
Not called directly - see operating system parent class for more info
-


This option controls Run | Debugging Actions | Reload Changed Classes action behavior. If it's turned on, the make process is performed before searching and reloading changed classes.


Paxmod error!
Paxmod is unable to access the bundled API experiments. Please verify:
- You have set
extensions.experiments.enabled = true
at about:config
.
- You're running a Firefox version that supports unsigned extensions with API experiments (e.g. Developer or Nightly) and not the standard release.
Check the add-on homepage for more information.