You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/10/31 08:39:17 UTC

svn commit: r590582 - /harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/Buffer.java

Author: pyang
Date: Wed Oct 31 00:39:16 2007
New Revision: 590582

URL: http://svn.apache.org/viewvc?rev=590582&view=rev
Log:
Re-apply the patch for HARMONY-4521([classlib][nio][java6]Add new interfaces in java.nio.Buffer.java), the patch applied last time is recovered by merge operation from Harmony trunk at r588245

Modified:
    harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/Buffer.java

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/Buffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/Buffer.java?rev=590582&r1=590581&r2=590582&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/Buffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/Buffer.java Wed Oct 31 00:39:16 2007
@@ -91,6 +91,53 @@
         this.capacity = this.limit = capacity;
     }
 
+	
+	/**
+	 * Answers the array that backs this buffer.
+	 * 
+	 * It wants to allow array-backed buffers to be passed to native code more
+	 * efficiently. Subclasses provide more concrete return values for this
+	 * method.
+	 * 
+	 * Modifications to this buffer's content will cause the returned array's
+	 * content to be modified, and vice versa.
+	 * 
+	 * Invoking the <code>hasArray</code> method before invoking this method
+	 * can guarantee it to be called safely.
+	 * 
+	 * @return The array that backs this buffer
+	 * 
+	 * @throws ReadOnlyBufferException -
+	 *             If this buffer is backed by an array but is read-only
+	 *         UnsupportedOperationException - If this buffer is not backed
+	 *             by an accessible array
+	 * @since 1.6
+	 * 
+	 */
+	public abstract Object array();
+	
+	/**
+	 * Returns the offset within this buffer's backing array of the first
+	 * element of the buffer (optional operation).
+	 * 
+	 * If this buffer is backed by an array then buffer position p corresponds
+	 * to array index p + arrayOffset().
+	 * 
+	 * Invoke the hasArray method before invoking this method in order to ensure
+	 * that this buffer has an accessible backing array.
+	 * 
+	 * @return The offset within this buffer's array of the first element of the
+	 *         buffer
+	 * 
+	 * @throws ReadOnlyBufferException -
+	 *             If this buffer is backed by an array but is read-only
+	 *         UnsupportedOperationException - If this buffer is not backed
+	 *             by an accessible array
+	 * 
+	 * @since 1.6
+	 */
+	public abstract int arrayOffset();
+
     /**
      * Returns the capacity of this buffer.
      * 
@@ -137,6 +184,21 @@
         return this;
     }
 
+
+	
+	/**
+	 * Answers if this buffer is backed by an available array.
+	 * 
+	 * If it returns true then the <code>array</code> and
+	 * <code>arrayOffset</code> methods can be called safely.
+	 * 
+	 * @return true if and only if this buffer is backed by an array and is
+	 *         not read-only.
+	 *         
+	 * @since 1.6
+	 */
+	public abstract boolean hasArray();
+
     /**
      * Returns true if there are remaining element(s) in this buffer.
      * <p>
@@ -148,6 +210,15 @@
     public final boolean hasRemaining() {
         return position < limit;
     }
+	
+	/**
+	 * Answers if this buffer is direct.
+	 * 
+	 * @return true if and only if this buffer is direct
+	 * 
+	 * @since 1.6
+	 */
+	public abstract boolean isDirect();
 
     /**
      * Returns whether this buffer is readonly or not.