aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/util
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2013-10-17 21:06:56 -0700
committerHarvey Harrison <[email protected]>2013-10-17 21:06:56 -0700
commit791a2749886f02ec7b8db25bf8862e8269b96da5 (patch)
treec9be31d0bbbe8033b4a6a0cfad91a22b6575ced1 /src/java/com/jogamp/common/util
parent5b77e15500b7b19d35976603dd71e8b997b2d8ea (diff)
gluegen: remove trailing whitespace
Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src/java/com/jogamp/common/util')
-rw-r--r--src/java/com/jogamp/common/util/ArrayHashSet.java14
-rw-r--r--src/java/com/jogamp/common/util/FloatStack.java60
-rw-r--r--src/java/com/jogamp/common/util/Function.java12
-rw-r--r--src/java/com/jogamp/common/util/FunctionTask.java28
-rw-r--r--src/java/com/jogamp/common/util/HashUtil.java20
-rw-r--r--src/java/com/jogamp/common/util/IOUtil.java346
-rw-r--r--src/java/com/jogamp/common/util/IntBitfield.java42
-rw-r--r--src/java/com/jogamp/common/util/IntIntHashMap.java90
-rw-r--r--src/java/com/jogamp/common/util/JarUtil.java178
-rw-r--r--src/java/com/jogamp/common/util/JogampVersion.java18
-rw-r--r--src/java/com/jogamp/common/util/LFRingbuffer.java100
-rw-r--r--src/java/com/jogamp/common/util/PrimitiveStack.java28
-rw-r--r--src/java/com/jogamp/common/util/PropertyAccess.java46
-rw-r--r--src/java/com/jogamp/common/util/ReflectionUtil.java54
-rw-r--r--src/java/com/jogamp/common/util/Ringbuffer.java58
-rw-r--r--src/java/com/jogamp/common/util/RunnableExecutor.java22
-rw-r--r--src/java/com/jogamp/common/util/RunnableTask.java30
-rw-r--r--src/java/com/jogamp/common/util/SecurityUtil.java44
-rw-r--r--src/java/com/jogamp/common/util/SyncedRingbuffer.java94
-rw-r--r--src/java/com/jogamp/common/util/TaskBase.java50
-rw-r--r--src/java/com/jogamp/common/util/ValueConv.java36
-rw-r--r--src/java/com/jogamp/common/util/VersionNumber.java76
-rw-r--r--src/java/com/jogamp/common/util/VersionNumberString.java20
-rw-r--r--src/java/com/jogamp/common/util/VersionUtil.java18
-rw-r--r--src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java20
-rw-r--r--src/java/com/jogamp/common/util/cache/TempFileCache.java54
-rw-r--r--src/java/com/jogamp/common/util/cache/TempJarCache.java144
-rw-r--r--src/java/com/jogamp/common/util/locks/Lock.java6
-rw-r--r--src/java/com/jogamp/common/util/locks/LockFactory.java14
-rw-r--r--src/java/com/jogamp/common/util/locks/RecursiveLock.java2
-rw-r--r--src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java66
-rw-r--r--src/java/com/jogamp/common/util/locks/SingletonInstance.java20
-rw-r--r--src/java/com/jogamp/common/util/locks/ThreadLock.java14
33 files changed, 912 insertions, 912 deletions
diff --git a/src/java/com/jogamp/common/util/ArrayHashSet.java b/src/java/com/jogamp/common/util/ArrayHashSet.java
index ed3590a..a125580 100644
--- a/src/java/com/jogamp/common/util/ArrayHashSet.java
+++ b/src/java/com/jogamp/common/util/ArrayHashSet.java
@@ -35,7 +35,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
-/**
+/**
* Hashed ArrayList implementation of the List and Collection interface.
*
* Implementation properties are:
@@ -80,12 +80,12 @@ public class ArrayHashSet<E>
map = new HashMap<E,E>(initialCapacity);
data = new ArrayList<E>(initialCapacity);
}
-
+
public ArrayHashSet(int initialCapacity, float loadFactor) {
map = new HashMap<E,E>(initialCapacity, loadFactor);
data = new ArrayList<E>(initialCapacity);
}
-
+
//
// Cloneable
//
@@ -102,15 +102,15 @@ public class ArrayHashSet<E>
return newObj;
}
-
+
/** Returns this object ordered ArrayList. Use w/ care, it's not a copy. */
public final ArrayList<E> getData() { return data; }
/** Returns this object hash map. Use w/ care, it's not a copy. */
public final HashMap<E,E> getMap() { return map; }
-
+
@Override
public final String toString() { return data.toString(); }
-
+
//
// Collection
//
@@ -408,7 +408,7 @@ public class ArrayHashSet<E>
* Identity method allowing to get the identical object, using the internal hash map.
* <br>
* This is an O(1) operation.
- *
+ *
* @param key hash source to find the identical Object within this list
* @return object from this list, identical to the given <code>key</code> hash code,
* or null if not contained
diff --git a/src/java/com/jogamp/common/util/FloatStack.java b/src/java/com/jogamp/common/util/FloatStack.java
index 2addd76..725491c 100644
--- a/src/java/com/jogamp/common/util/FloatStack.java
+++ b/src/java/com/jogamp/common/util/FloatStack.java
@@ -44,69 +44,69 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack {
private int position;
private /*value*/float/*value*/[] buffer;
private int growSize;
-
+
/**
* @param initialSize initial size, must be &gt; zero
* @param growSize grow size if {@link #position()} is reached, maybe <code>0</code>
- * in which case an {@link IndexOutOfBoundsException} is thrown.
+ * in which case an {@link IndexOutOfBoundsException} is thrown.
*/
public /*name*/FloatStack/*name*/(int initialSize, int growSize) {
this.position = 0;
this.growSize = growSize;
this.buffer = new /*value*/float/*value*/[initialSize];
}
-
+
@Override
public final int capacity() { return buffer.length; }
-
+
@Override
public final int position() { return position; }
-
+
@Override
public final void position(int newPosition) throws IndexOutOfBoundsException {
if( 0 > position || position >= buffer.length ) {
throw new IndexOutOfBoundsException("Invalid new position "+newPosition+", "+this.toString());
}
- position = newPosition;
+ position = newPosition;
}
-
+
@Override
public final int remaining() { return buffer.length - position; }
-
+
@Override
public final int getGrowSize() { return growSize; }
-
+
@Override
public final void setGrowSize(int newGrowSize) { growSize = newGrowSize; }
-
+
public final String toString() {
return "FloatStack[0..(pos "+position+").."+buffer.length+", remaining "+remaining()+"]";
}
-
+
public final /*value*/float/*value*/[] buffer() { return buffer; }
-
+
private final void growIfNecessary(int length) throws IndexOutOfBoundsException {
if( position + length > buffer.length ) {
if( 0 >= growSize ) {
throw new IndexOutOfBoundsException("Out of fixed stack size: "+this);
}
- /*value*/float/*value*/[] newBuffer =
+ /*value*/float/*value*/[] newBuffer =
new /*value*/float/*value*/[buffer.length + growSize];
System.arraycopy(buffer, 0, newBuffer, 0, position);
buffer = newBuffer;
- }
+ }
}
/**
* FILO put operation
- *
+ *
* @param src source buffer
- * @param srcOffset offset of src
- * @param length number of float elements to put from <code>src</code> on-top this stack
+ * @param srcOffset offset of src
+ * @param length number of float elements to put from <code>src</code> on-top this stack
* @return the src float[]
* @throws IndexOutOfBoundsException if stack cannot grow due to zero grow-size or offset+length exceeds src.
*/
- public final /*value*/float/*value*/[]
+ public final /*value*/float/*value*/[]
putOnTop(/*value*/float/*value*/[] src, int srcOffset, int length) throws IndexOutOfBoundsException {
growIfNecessary(length);
System.arraycopy(src, srcOffset, buffer, position, length);
@@ -116,47 +116,47 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack {
/**
* FILO put operation
- *
+ *
* @param src source buffer, it's position is incremented by <code>length</code>
- * @param length number of float elements to put from <code>src</code> on-top this stack
+ * @param length number of float elements to put from <code>src</code> on-top this stack
* @return the src FloatBuffer
* @throws IndexOutOfBoundsException if stack cannot grow due to zero grow-size
* @throws BufferUnderflowException if <code>src</code> FloatBuffer has less remaining elements than <code>length</code>.
*/
- public final /*value2*/FloatBuffer/*value2*/
+ public final /*value2*/FloatBuffer/*value2*/
putOnTop(/*value2*/FloatBuffer/*value2*/ src, int length) throws IndexOutOfBoundsException, BufferUnderflowException {
- growIfNecessary(length);
+ growIfNecessary(length);
src.get(buffer, position, length);
position += length;
return src;
}
-
+
/**
* FILO get operation
- *
+ *
* @param dest destination buffer
- * @param destOffset offset of dest
- * @param length number of float elements to get from-top this stack to <code>dest</code>.
+ * @param destOffset offset of dest
+ * @param length number of float elements to get from-top this stack to <code>dest</code>.
* @return the dest float[]
* @throws IndexOutOfBoundsException if stack or <code>dest</code> has less elements than <code>length</code>.
*/
- public final /*value*/float/*value*/[]
+ public final /*value*/float/*value*/[]
getFromTop(/*value*/float/*value*/[] dest, int destOffset, int length) throws IndexOutOfBoundsException {
System.arraycopy(buffer, position-length, dest, destOffset, length);
position -= length;
return dest;
}
-
+
/**
* FILO get operation
- *
+ *
* @param dest destination buffer, it's position is incremented by <code>length</code>.
* @param length number of float elements to get from-top this stack to <code>dest</code>.
* @return the dest FloatBuffer
* @throws IndexOutOfBoundsException if stack has less elements than length
* @throws BufferOverflowException if <code>src</code> FloatBuffer has less remaining elements than <code>length</code>.
*/
- public final /*value2*/FloatBuffer/*value2*/
+ public final /*value2*/FloatBuffer/*value2*/
getFromTop(/*value2*/FloatBuffer/*value2*/ dest, int length) throws IndexOutOfBoundsException, BufferOverflowException {
dest.put(buffer, position-length, length);
position -= length;
diff --git a/src/java/com/jogamp/common/util/Function.java b/src/java/com/jogamp/common/util/Function.java
index 8bec99c..9b03ce6 100644
--- a/src/java/com/jogamp/common/util/Function.java
+++ b/src/java/com/jogamp/common/util/Function.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -41,9 +41,9 @@ public interface Function<R,A> {
/**
* Implementation may compute variable <code>args</code> list
* and returns a result.
- *
+ *
* @param args variable argument list, <code>A[]</code>, maybe null
* @return the result.
*/
R eval(A... args);
-}
+}
diff --git a/src/java/com/jogamp/common/util/FunctionTask.java b/src/java/com/jogamp/common/util/FunctionTask.java
index 01f85b1..b742d73 100644
--- a/src/java/com/jogamp/common/util/FunctionTask.java
+++ b/src/java/com/jogamp/common/util/FunctionTask.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.common.util;
import java.io.PrintStream;
@@ -41,7 +41,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> {
/**
* Invokes <code>func</code>.
- * @param waitUntilDone if <code>true</code>, waits until <code>func</code> execution is completed, otherwise returns immediately.
+ * @param waitUntilDone if <code>true</code>, waits until <code>func</code> execution is completed, otherwise returns immediately.
* @param func the {@link Function} to execute.
* @param args the {@link Function} arguments
* @return the {@link Function} return value
@@ -69,14 +69,14 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> {
}
return res;
}
-
+
/**
* Create a RunnableTask object w/ synchronization,
- * ie. suitable for <code>invokeAndWait()</code>.
- *
+ * ie. suitable for <code>invokeAndWait()</code>.
+ *
* @param runnable the user action
* @param syncObject the synchronization object the caller shall wait until <code>runnable</code> execution is completed,
- * or <code>null</code> if waiting is not desired.
+ * or <code>null</code> if waiting is not desired.
* @param catchExceptions Influence an occurring exception during <code>runnable</code> execution.
* If <code>true</code>, the exception is silenced and can be retrieved via {@link #getThrowable()},
* otherwise the exception is thrown.
@@ -96,12 +96,12 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> {
/**
* Sets the arguments for {@link #run()}.
- * They will be cleared after calling {@link #run()} or {@link #eval(Object...)}.
+ * They will be cleared after calling {@link #run()} or {@link #eval(Object...)}.
*/
public final void setArgs(A... args) {
this.args = args;
}
-
+
/**
* Retrieves the cached result of {@link #run()}
* and is cleared within this method.
@@ -111,7 +111,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> {
result = null;
return res;
}
-
+
/**
* {@inheritDoc}
* <p>
@@ -170,7 +170,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> {
@Override
public final R eval(A... args) {
this.args = args;
- run();
+ run();
final R res = result;
result = null;
return res;
diff --git a/src/java/com/jogamp/common/util/HashUtil.java b/src/java/com/jogamp/common/util/HashUtil.java
index c5a3bff..5ce2332 100644
--- a/src/java/com/jogamp/common/util/HashUtil.java
+++ b/src/java/com/jogamp/common/util/HashUtil.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -29,7 +29,7 @@ package com.jogamp.common.util;
public class HashUtil {
/**
- * Generates a 32bit equally distributed identity hash value
+ * Generates a 32bit equally distributed identity hash value
* from <code>addr</code> avoiding XOR collision.
*/
public static int getAddrHash32_EqualDist(long addr) {
@@ -38,9 +38,9 @@ public class HashUtil {
int hash = 31 + (int) addr ; // lo addr
return ((hash << 5) - hash) + (int) ( addr >>> 32 ) ; // hi addr
}
-
+
/**
- * Generates a 32bit equally distributed identity hash value
+ * Generates a 32bit equally distributed identity hash value
* from <code>addr</code> and <code>size</code> avoiding XOR collision.
*/
public static int getAddrSizeHash32_EqualDist(long addr, long size) {
@@ -51,9 +51,9 @@ public class HashUtil {
hash = ((hash << 5) - hash) + (int) size ; // lo size
return ((hash << 5) - hash) + (int) ( size >>> 32 ) ; // hi size
}
-
+
/**
- * Generates a 64bit equally distributed hash value
+ * Generates a 64bit equally distributed hash value
* from <code>addr</code> and <code>size</code> avoiding XOR collisions.
*/
public static long getHash64(long addr, long size) {
@@ -62,5 +62,5 @@ public class HashUtil {
return ((hash << 5) - hash) + size;
}
-
+
}
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java
index 242f300..16f191b 100644
--- a/src/java/com/jogamp/common/util/IOUtil.java
+++ b/src/java/com/jogamp/common/util/IOUtil.java
@@ -56,7 +56,7 @@ import com.jogamp.common.os.Platform;
public class IOUtil {
public static final boolean DEBUG = Debug.debug("IOUtil");
-
+
/** {@value} */
public static final String SCHEME_SEPARATOR = ":";
/** {@value} */
@@ -69,28 +69,28 @@ public class IOUtil {
public static final String JAR_SCHEME = "jar";
/** A JAR subprotocol is separeted from the JAR entry w/ this separator {@value}. Even if no class is specified '!/' must follow!. */
public static final String JAR_SCHEME_SEPARATOR = "!";
-
+
/** Std. temporary directory property key <code>java.io.tmpdir</code>. */
- private static final String java_io_tmpdir_propkey = "java.io.tmpdir";
+ private static final String java_io_tmpdir_propkey = "java.io.tmpdir";
private static final String user_home_propkey = "user.home";
private static final String XDG_CACHE_HOME_envkey = "XDG_CACHE_HOME";
- /** Subdirectory within platform's temporary root directory where all JogAmp related temp files are being stored: {@code jogamp} */
+ /** Subdirectory within platform's temporary root directory where all JogAmp related temp files are being stored: {@code jogamp} */
public static final String tmpSubDir = "jogamp";
-
+
private IOUtil() {}
-
- /**
+
+ /**
* Since usage of {@link java.io.FileOutputStream} is considered security critical,
* we need to check it's availability for each use.
* <p>
* In case a SecurityManager is installed, privileged access is required.
* </p>
- *
- * @return the constructor of {@link java.io.FileOutputStream} if available and
- * no SecurityManager is installed or privileged access is granted.
+ *
+ * @return the constructor of {@link java.io.FileOutputStream} if available and
+ * no SecurityManager is installed or privileged access is granted.
* Otherwise null.
- *
+ *
*/
private static final Constructor<?> getFOSCtor() {
Constructor<?> _fosCtor;
@@ -102,7 +102,7 @@ public class IOUtil {
_fosCtor = null;
_t = t;
}
- if(DEBUG) {
+ if(DEBUG) {
System.err.println("IOUtil: java.io.FileOutputStream available: "+(null != _fosCtor));
if(null!=_t) {
_t.printStackTrace();
@@ -110,24 +110,24 @@ public class IOUtil {
}
return _fosCtor;
}
-
+
/***
- *
+ *
* STREAM COPY STUFF
- *
+ *
*/
-
+
/**
* Copy the specified URL resource to the specified output file. The total
* number of bytes written is returned. Both streams are closed upon completion.
- *
- * @param conn the open URLConnection
+ *
+ * @param conn the open URLConnection
* @param outFile the destination
* @return
* @throws IOException
*/
public static int copyURLConn2File(URLConnection conn, File outFile) throws IOException {
- conn.connect(); // redundant
+ conn.connect(); // redundant
int totalNumBytes = 0;
InputStream in = new BufferedInputStream(conn.getInputStream());
@@ -142,10 +142,10 @@ public class IOUtil {
/**
* Copy the specified input stream to the specified output file. The total
* number of bytes written is returned. Both streams are closed upon completion.
- *
- * @param in the source
+ *
+ * @param in the source
* @param outFile the destination
- * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown
+ * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown
* @return
* @throws IOException
*/
@@ -162,10 +162,10 @@ public class IOUtil {
/**
* Copy the specified input stream to the specified output stream. The total
* number of bytes written is returned.
- *
- * @param in the source
+ *
+ * @param in the source
* @param out the destination
- * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown
+ * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown
* @return
* @throws IOException
*/
@@ -176,11 +176,11 @@ public class IOUtil {
/**
* Copy the specified input stream to the specified output stream. The total
* number of bytes written is returned.
- *
+ *
* @param bufferSize the intermediate buffer size, should be {@link MachineDescription#pageSizeInBytes()} for best performance.
- * @param in the source
+ * @param in the source
* @param out the destination
- * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown
+ * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown
* @return
* @throws IOException
*/
@@ -197,7 +197,7 @@ public class IOUtil {
}
return numBytes;
}
-
+
/**
* Copy the specified input stream to a byte array, which is being returned.
*/
@@ -235,17 +235,17 @@ public class IOUtil {
/**
* Copy the specified input stream to a NIO ByteBuffer w/ native byte order, which is being returned.
* <p>The implementation creates the ByteBuffer w/ {@link #copyStream2ByteArray(InputStream)}'s returned byte array.</p>
- *
+ *
* @param stream input stream, which will be wrapped into a BufferedInputStream, if not already done.
*/
public static ByteBuffer copyStream2ByteBuffer(InputStream stream) throws IOException {
- return copyStream2ByteBuffer(stream, -1);
+ return copyStream2ByteBuffer(stream, -1);
}
-
+
/**
* Copy the specified input stream to a NIO ByteBuffer w/ native byte order, which is being returned.
* <p>The implementation creates the ByteBuffer w/ {@link #copyStream2ByteArray(InputStream)}'s returned byte array.</p>
- *
+ *
* @param stream input stream, which will be wrapped into a BufferedInputStream, if not already done.
* @param initialCapacity initial buffer capacity in bytes, if &gt; available bytes
*/
@@ -257,7 +257,7 @@ public class IOUtil {
if( initialCapacity < avail ) {
initialCapacity = avail;
}
- final MachineDescription machine = Platform.getMachineDescription();
+ final MachineDescription machine = Platform.getMachineDescription();
ByteBuffer data = Buffers.newDirectByteBuffer( machine.pageAlignedSize( initialCapacity ) );
byte[] chunk = new byte[machine.pageSizeInBytes()];
int chunk2Read = Math.min(machine.pageSizeInBytes(), avail);
@@ -269,13 +269,13 @@ public class IOUtil {
newData.put(data);
data = newData;
}
-
+
numRead = stream.read(chunk, 0, chunk2Read);
if (numRead > 0) {
data.put(chunk, 0, numRead);
}
avail = stream.available();
- chunk2Read = Math.min(machine.pageSizeInBytes(), avail);
+ chunk2Read = Math.min(machine.pageSizeInBytes(), avail);
} while ( numRead > 0 ); // EOS: -1 == numRead, EOF maybe reached earlier w/ 0 == numRead
data.flip();
@@ -283,13 +283,13 @@ public class IOUtil {
}
/***
- *
+ *
* RESOURCE / FILE NAME STUFF
- *
+ *
*/
-
+
/**
- *
+ *
* @param path
* @param startWithSlash
* @param endWithSlash
@@ -297,7 +297,7 @@ public class IOUtil {
* @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
*/
public static String slashify(String path, boolean startWithSlash, boolean endWithSlash) throws URISyntaxException {
- String p = path.replace('\\', '/'); // unify file separator
+ String p = path.replace('\\', '/'); // unify file separator
if (startWithSlash && !p.startsWith("/")) {
p = "/" + p;
}
@@ -306,23 +306,23 @@ public class IOUtil {
}
return cleanPathString(p);
}
-
- /**
- * Using the simple conversion via File -> URI, assuming proper characters.
+
+ /**
+ * Using the simple conversion via File -> URI, assuming proper characters.
* @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
- * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI
+ * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI
*/
public static URI toURISimple(File file) throws URISyntaxException {
- return new URI(FILE_SCHEME, null, encodeToURI(slashify(file.getAbsolutePath(), true, file.isDirectory())), null);
+ return new URI(FILE_SCHEME, null, encodeToURI(slashify(file.getAbsolutePath(), true, file.isDirectory())), null);
}
-
- /**
- * Using the simple conversion via File -> URI, assuming proper characters.
+
+ /**
+ * Using the simple conversion via File -> URI, assuming proper characters.
* @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
- * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI
+ * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI
*/
public static URI toURISimple(String protocol, String file, boolean isDirectory) throws URISyntaxException {
- return new URI(protocol, null, encodeToURI(slashify(file, true, isDirectory)), null);
+ return new URI(protocol, null, encodeToURI(slashify(file, true, isDirectory)), null);
}
/**
@@ -364,14 +364,14 @@ public class IOUtil {
return arg.toLowerCase();
}
-
+
/***
* @param file
* @param allowOverwrite
* @return outputStream The resulting output stream
- * @throws IOException if the file already exists and <code>allowOverwrite</code> is false,
+ * @throws IOException if the file already exists and <code>allowOverwrite</code> is false,
* the class {@link java.io.FileOutputStream} is not accessible or
- * the user does not have sufficient rights to access the local filesystem.
+ * the user does not have sufficient rights to access the local filesystem.
*/
public static FileOutputStream getFileOutputStream(File file, boolean allowOverwrite) throws IOException {
final Constructor<?> fosCtor = getFOSCtor();
@@ -387,14 +387,14 @@ public class IOUtil {
throw new IOException("error opening " + file + " for write. ", e);
}
}
-
+
public static String getClassFileName(String clazzBinName) {
- // or return clazzBinName.replace('.', File.separatorChar) + ".class"; ?
- return clazzBinName.replace('.', '/') + ".class";
+ // or return clazzBinName.replace('.', File.separatorChar) + ".class"; ?
+ return clazzBinName.replace('.', '/') + ".class";
}
-
+
/**
- * @param clazzBinName com.jogamp.common.util.cache.TempJarCache
+ * @param clazzBinName com.jogamp.common.util.cache.TempJarCache
* @param cl ClassLoader to locate the JarFile
* @return jar:file:/usr/local/projects/JOGL/gluegen/build-x86_64/gluegen-rt.jar!/com/jogamp/common/util/cache/TempJarCache.class
* @throws IOException if the jar file could not been found by the ClassLoader
@@ -406,7 +406,7 @@ public class IOUtil {
}
return url;
}
-
+
/**
* Returns the basename of the given fname w/o directory part
* @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
@@ -419,7 +419,7 @@ public class IOUtil {
}
return fname;
}
-
+
/**
* Returns unified '/' dirname including the last '/'
* @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
@@ -432,22 +432,22 @@ public class IOUtil {
}
return fname;
}
-
+
/**
* The URI's <code><i>protocol</i>:/some/path/gluegen-rt.jar</code>
* parent dirname URI <code><i>protocol</i>:/some/path/</code> will be returned.
* <p>
* <i>protocol</i> may be "file", "http", etc..
* </p>
- *
+ *
* @param uri "<i>protocol</i>:/some/path/gluegen-rt.jar"
* @return "<i>protocol</i>:/some/path/"
* @throws IllegalArgumentException if the URI doesn't match the expected formatting, or is null
- * @throws URISyntaxException
+ * @throws URISyntaxException
*/
public static URI getURIDirname(URI uri) throws IllegalArgumentException, URISyntaxException {
if(null == uri) {
- throw new IllegalArgumentException("URI is null");
+ throw new IllegalArgumentException("URI is null");
}
String uriS = uri.toString();
if( DEBUG ) {
@@ -455,24 +455,24 @@ public class IOUtil {
}
return new URI( getURIDirname(uriS) );
}
-
+
/**
* The URI's <code><i>protocol</i>:/some/path/gluegen-rt.jar</code>
* parent dirname URI <code><i>protocol</i>:/some/path/</code> will be returned.
* <p>
* <i>protocol</i> may be "file", "http", etc..
* </p>
- *
+ *
* @param uri "<i>protocol</i>:/some/path/gluegen-rt.jar" (URI encoded)
* @return "<i>protocol</i>:/some/path/"
* @throws IllegalArgumentException if the URI doesn't match the expected formatting, or is null
- * @throws URISyntaxException
+ * @throws URISyntaxException
*/
public static String getURIDirname(String uriS) throws IllegalArgumentException, URISyntaxException {
if(null == uriS) {
- throw new IllegalArgumentException("uriS is null");
+ throw new IllegalArgumentException("uriS is null");
}
- // from
+ // from
// file:/some/path/gluegen-rt.jar _or_ rsrc:gluegen-rt.jar
// to
// file:/some/path/ _or_ rsrc:
@@ -484,15 +484,15 @@ public class IOUtil {
throw new IllegalArgumentException("URI does not contain protocol terminator ':', in <"+uriS+">");
}
}
- uriS = uriS.substring(0, idx+1); // exclude jar name, include terminal '/' or ':'
-
+ uriS = uriS.substring(0, idx+1); // exclude jar name, include terminal '/' or ':'
+
if( DEBUG ) {
System.out.println("getJarURIDirname res: "+uriS);
- }
+ }
return uriS;
}
-
- /**
+
+ /**
* Converts an {@link URI} to an {@link URL} while using a non encoded path
* for <i>file scheme</i>, i.e. <code>file:/</code>.
* Otherwise the default {@link URL} translation {@link URI#toURL()} is being used.
@@ -551,18 +551,18 @@ public class IOUtil {
}
return url;
}
-
+
/***
- *
+ *
* RESOURCE LOCATION STUFF
- *
+ *
*/
-
+
/**
* Locating a resource using {@link #getResource(String, ClassLoader)}:
* <ul>
- * <li><i>relative</i>: <code>context</code>'s package name-path plus <code>resourcePath</code> via <code>context</code>'s ClassLoader.
- * This allows locations relative to JAR- and other URLs.
+ * <li><i>relative</i>: <code>context</code>'s package name-path plus <code>resourcePath</code> via <code>context</code>'s ClassLoader.
+ * This allows locations relative to JAR- and other URLs.
* The <code>resourcePath</code> may start with <code>../</code> to navigate to parent folder.</li>
* <li><i>absolute</i>: <code>context</code>'s ClassLoader and the <code>resourcePath</code> as is (filesystem)</li>
* </ul>
@@ -570,7 +570,7 @@ public class IOUtil {
* <p>
* Returns the resolved and open URLConnection or null if not found.
* </p>
- *
+ *
* @see #getResource(String, ClassLoader)
* @see ClassLoader#getResource(String)
* @see ClassLoader#getSystemResource(String)
@@ -578,11 +578,11 @@ public class IOUtil {
public static URLConnection getResource(Class<?> context, String resourcePath) {
if(null == resourcePath) {
return null;
- }
+ }
ClassLoader contextCL = (null!=context)?context.getClassLoader():IOUtil.class.getClassLoader();
URLConnection conn = null;
if(null != context) {
- // scoping the path within the class's package
+ // scoping the path within the class's package
final String className = context.getName().replace('.', '/');
final int lastSlash = className.lastIndexOf('/');
if (lastSlash >= 0) {
@@ -647,7 +647,7 @@ public class IOUtil {
/**
* Generates a path for the 'relativeFile' relative to the 'baseLocation'.
- *
+ *
* @param baseLocation denotes a directory
* @param relativeFile denotes a relative file to the baseLocation
* @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
@@ -656,7 +656,7 @@ public class IOUtil {
if(null == relativeFile) {
return null;
}
-
+
if (baseLocation != null) {
final File file = new File(baseLocation, relativeFile);
// Handle things on Windows
@@ -668,14 +668,14 @@ public class IOUtil {
/**
* @param path assuming a slashified path beginning with "/" as it's root directory, either denotes a file or directory.
* @return parent of path
- * @throws URISyntaxException if path is empty or has no parent directory available
+ * @throws URISyntaxException if path is empty or has no parent directory available
*/
public static String getParentOf(String path) throws URISyntaxException {
final int pl = null!=path ? path.length() : 0;
if(pl == 0) {
throw new IllegalArgumentException("path is empty <"+path+">");
}
-
+
final int e = path.lastIndexOf("/");
if( e < 0 ) {
throw new URISyntaxException(path, "path contains no '/'");
@@ -688,7 +688,7 @@ public class IOUtil {
// path is file, return it's parent directory
return path.substring(0, e+1);
}
- final int j = path.lastIndexOf("!") + 1; // '!' Separates JARFile entry -> local start of path
+ final int j = path.lastIndexOf("!") + 1; // '!' Separates JARFile entry -> local start of path
// path is a directory ..
final int p = path.lastIndexOf("/", e-1);
if( p >= j) {
@@ -696,10 +696,10 @@ public class IOUtil {
}
throw new URISyntaxException(path, "parent of path contains no '/'");
}
-
+
/**
* @param path assuming a slashified path beginning with "/" as it's root directory, either denotes a file or directory.
- * @return clean path string where <code>../</code> and <code>./</code> is resolved.
+ * @return clean path string where <code>../</code> and <code>./</code> is resolved.
* @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
*/
public static String cleanPathString(String path) throws URISyntaxException {
@@ -712,47 +712,47 @@ public class IOUtil {
}
return path;
}
-
+
/**
* Generates a URI for the <i>relativePath</i> relative to the <i>baseURI</i>,
* hence the result is a absolute location.
* <p>
- * Impl. operates on the <i>scheme-specific-part</i>, and hence is sub-protocol savvy.
+ * Impl. operates on the <i>scheme-specific-part</i>, and hence is sub-protocol savvy.
* </p>
* <p>
- * In case <i>baseURI</i> is not a path ending w/ '/', it's a assumed to be a file and it's parent is being used.
+ * In case <i>baseURI</i> is not a path ending w/ '/', it's a assumed to be a file and it's parent is being used.
* </p>
- *
+ *
* @param baseURI denotes a URI to a directory ending w/ '/', or a file. In the latter case the file's directory is being used.
* @param relativePath denotes a relative file to the baseLocation's parent directory
* @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
*/
- public static URI getRelativeOf(URI baseURI, String relativePath) throws URISyntaxException {
+ public static URI getRelativeOf(URI baseURI, String relativePath) throws URISyntaxException {
return compose(baseURI.getScheme(), baseURI.getSchemeSpecificPart(), encodeToURI(relativePath), baseURI.getFragment());
}
-
+
/**
* Wraps {@link #getRelativeOf(URI, String)} for convenience.
* @throws IOException
*/
- public static URL getRelativeOf(URL baseURL, String relativePath) throws IOException {
+ public static URL getRelativeOf(URL baseURL, String relativePath) throws IOException {
try {
return getRelativeOf(baseURL.toURI(), relativePath).toURL();
} catch (URISyntaxException e) {
throw new IOException(e);
}
}
-
+
/**
* Generates a URI for the <i>relativePath</i> relative to the <i>schemeSpecificPart</i>,
* hence the result is a absolute location.
* <p>
- * <i>schemeSpecificPart</i>'s query, if exist is split to <i>path</i> and <i>query</i>.
+ * <i>schemeSpecificPart</i>'s query, if exist is split to <i>path</i> and <i>query</i>.
* </p>
* <p>
- * In case <i>path</i> is not a path ending w/ '/', it's a assumed to be a file and it's parent is being used.
+ * In case <i>path</i> is not a path ending w/ '/', it's a assumed to be a file and it's parent is being used.
* </p>
- *
+ *
* @param scheme scheme of the resulting URI
* @param schemeSpecificPart may include a query, which is separated while processing (URI encoded)
* @param relativePath denotes a relative file to the baseLocation's parent directory (URI encoded)
@@ -778,12 +778,12 @@ public class IOUtil {
}
schemeSpecificPart = cleanPathString( schemeSpecificPart );
return new URI(scheme, null == query ? schemeSpecificPart : schemeSpecificPart + "?" + query, fragment);
- }
-
+ }
+
private static final Pattern patternSpaceRaw = Pattern.compile(" ");
private static final Pattern patternSpaceEnc = Pattern.compile("%20");
-
- /**
+
+ /**
* Escapes characters not complying w/ RFC 2396 and the {@link URI#URI(String)} ctor.
* <ul>
* <li>SPACE -> %20</li>
@@ -792,21 +792,21 @@ public class IOUtil {
public static String encodeToURI(String s) {
return patternSpaceRaw.matcher(s).replaceAll("%20");
}
-
- /**
+
+ /**
* Reverses escaping of characters as performed via {@link #encodeToURI(String)}.
*/
public static String decodeFromURI(String s) {
return patternSpaceEnc.matcher(s).replaceAll(" ");
}
-
+
/**
* Returns the connected URLConnection, or null if not url is not available
*/
public static URLConnection openURL(URL url) {
return openURL(url, ".");
}
-
+
/**
* Returns the connected URLConnection, or null if not url is not available
*/
@@ -819,19 +819,19 @@ public class IOUtil {
System.err.println("IOUtil: urlExists("+url+") ["+dbgmsg+"] - true");
}
return c;
- } catch (IOException ioe) {
+ } catch (IOException ioe) {
if(DEBUG) {
System.err.println("IOUtil: urlExists("+url+") ["+dbgmsg+"] - false - "+ioe.getClass().getSimpleName()+": "+ioe.getMessage());
ioe.printStackTrace();
- }
+ }
}
} else if(DEBUG) {
System.err.println("IOUtil: no url - urlExists(null) ["+dbgmsg+"]");
- }
-
+ }
+
return null;
}
-
+
private static String getShellSuffix() {
switch(PlatformPropsImpl.OS_TYPE) {
case WINDOWS:
@@ -840,18 +840,18 @@ public class IOUtil {
return ".sh";
}
}
-
+
private static boolean getOSHasNoexecFS() {
switch(PlatformPropsImpl.OS_TYPE) {
case WINDOWS:
case OPENKODE:
return false;
-
+
default:
return true;
}
}
-
+
/**
* @see <a href="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">Free-Desktop - XDG Base Directory Specification</a>
*/
@@ -862,26 +862,26 @@ public class IOUtil {
case WINDOWS:
case OPENKODE:
return false;
-
+
default:
return true;
}
}
-
+
/**
* Test whether {@code file} exists and matches the given requirements
- *
+ *
* @param file
* @param shallBeDir
* @param shallBeWritable
* @return
*/
- public static boolean testFile(File file, boolean shallBeDir, boolean shallBeWritable) {
+ public static boolean testFile(File file, boolean shallBeDir, boolean shallBeWritable) {
if (!file.exists()) {
if(DEBUG) {
System.err.println("IOUtil.testFile: <"+file.getAbsolutePath()+">: does not exist");
}
- return false;
+ return false;
}
if (shallBeDir && !file.isDirectory()) {
if(DEBUG) {
@@ -893,7 +893,7 @@ public class IOUtil {
if(DEBUG) {
System.err.println("IOUtil.testFile: <"+file.getAbsolutePath()+">: is not writable");
}
- return false;
+ return false;
}
return true;
}
@@ -904,9 +904,9 @@ public class IOUtil {
* <li>exists, and</li>
* <li>is a directory, and</li>
* <li>is writeable, and</li>
- * <li>files can be executed from the directory</li>
+ * <li>files can be executed from the directory</li>
* </ol>
- *
+ *
* @throws SecurityException if file creation and process execution is not allowed within the current security context
* @param dir
*/
@@ -914,12 +914,12 @@ public class IOUtil {
throws SecurityException
{
if (!testFile(dir, true, true)) {
- return false;
+ return false;
}
if(!getOSHasNoexecFS()) {
return true;
}
-
+
File exetst;
try {
exetst = File.createTempFile("jogamp_exe_tst", getShellSuffix(), dir);
@@ -951,31 +951,31 @@ public class IOUtil {
return 0 == ok;
}
- private static File testDirImpl(File dir, boolean create, boolean executable)
+ private static File testDirImpl(File dir, boolean create, boolean executable)
throws SecurityException
{
if (create && !dir.exists()) {
- dir.mkdirs();
+ dir.mkdirs();
}
if( executable ) {
if(testDirExec(dir)) {
return dir;
}
} else if(testFile(dir, true, true)) {
- return dir;
+ return dir;
}
return null;
}
-
+
/**
* Returns the directory {@code dir}, which is processed and tested as described below.
* <ol>
* <li>If {@code create} is {@code true} and the directory does not exist yet, it is created incl. all sub-directories.</li>
* <li>If {@code dirName} exists, but is not a directory, {@code null} is being returned.</li>
* <li>If the directory does not exist or is not writeable, {@code null} is being returned.</li>
- * <li>If {@code executable} is {@code true} and files cannot be executed from the directory, {@code null} is being returned.</li>
+ * <li>If {@code executable} is {@code true} and files cannot be executed from the directory, {@code null} is being returned.</li>
* </ol>
- *
+ *
* @param dir the directory to process
* @param create true if the directory shall be created if not existing
* @param executable true if the user intents to launch executables from the temporary directory, otherwise false.
@@ -985,14 +985,14 @@ public class IOUtil {
throws SecurityException
{
return testDirImpl(dir, create, executable);
- }
-
- private static boolean isStringSet(String s) { return null != s && 0 < s.length(); }
-
+ }
+
+ private static boolean isStringSet(String s) { return null != s && 0 < s.length(); }
+
/**
* This methods finds [and creates] an available temporary sub-directory:
* <pre>
- File tmpBaseDir = null;
+ File tmpBaseDir = null;
if(null != testDir(tmpRoot, true, executable)) { // check tmpRoot first
for(int i = 0; null == tmpBaseDir && i<=9999; i++) {
final String tmpDirSuffix = String.format("_%04d", i); // 4 digits for iteration
@@ -1015,7 +1015,7 @@ public class IOUtil {
private static File getSubTempDir(File tmpRoot, String tmpSubDirPrefix, boolean executable)
throws SecurityException
{
- File tmpBaseDir = null;
+ File tmpBaseDir = null;
if(null != testDirImpl(tmpRoot, true /* create */, executable)) { // check tmpRoot first
for(int i = 0; null == tmpBaseDir && i<=9999; i++) {
final String tmpDirSuffix = String.format("_%04d", i); // 4 digits for iteration
@@ -1024,16 +1024,16 @@ public class IOUtil {
}
return tmpBaseDir;
}
-
+
/**
* Returns a platform independent writable directory for temporary files
- * consisting of the platform's {@code temp-root} + {@link #tmpSubDir},
- * e.g. {@code /tmp/jogamp_0000/}.
+ * consisting of the platform's {@code temp-root} + {@link #tmpSubDir},
+ * e.g. {@code /tmp/jogamp_0000/}.
* <p>
* On standard Java the {@code temp-root} folder is specified by <code>java.io.tempdir</code>.
- * </p>
+ * </p>
* <p>
- * On Android the {@code temp-root} folder is relative to the applications local folder
+ * On Android the {@code temp-root} folder is relative to the applications local folder
* (see {@link Context#getDir(String, int)}) is returned, if
* the Android application/activity has registered it's Application Context
* via {@link jogamp.common.os.android.StaticContext.StaticContext#init(Context, ClassLoader) StaticContext.init(..)}.
@@ -1042,12 +1042,12 @@ public class IOUtil {
* </p>
* <p>
* In case {@code temp-root} is the users home folder,
- * a dot is being prepended to {@link #tmpSubDir}, i.e.: {@code /home/user/.jogamp_0000/}.
+ * a dot is being prepended to {@link #tmpSubDir}, i.e.: {@code /home/user/.jogamp_0000/}.
* </p>
* @param executable true if the user intents to launch executables from the temporary directory, otherwise false.
* @throws RuntimeException if no temporary directory could be determined
* @throws SecurityException if access to <code>java.io.tmpdir</code> is not allowed within the current security context
- *
+ *
* @see PropertyAccess#getProperty(String, boolean)
* @see Context#getDir(String, int)
*/
@@ -1066,40 +1066,40 @@ public class IOUtil {
return tempRootExec;
}
}
-
+
final String java_io_tmpdir = PropertyAccess.getProperty(java_io_tmpdir_propkey, false);
final String user_home = PropertyAccess.getProperty(user_home_propkey, false);
-
+
final String xdg_cache_home;
{
String _xdg_cache_home;
- if( getOSHasFreeDesktopXDG() ) {
+ if( getOSHasFreeDesktopXDG() ) {
_xdg_cache_home = System.getenv(XDG_CACHE_HOME_envkey);
if( !isStringSet(_xdg_cache_home) && isStringSet(user_home) ) {
_xdg_cache_home = user_home + File.separator + ".cache" ; // default
- }
+ }
} else {
_xdg_cache_home = null;
}
xdg_cache_home = _xdg_cache_home;
}
-
+
// 1) java.io.tmpdir/jogamp
if( null == tempRootExec && isStringSet(java_io_tmpdir) ) {
tempRootExec = getSubTempDir(new File(java_io_tmpdir), tmpSubDir, true /* executable */);
}
-
+
// 2) $XDG_CACHE_HOME/jogamp
if(null == tempRootExec && isStringSet(xdg_cache_home)) {
- tempRootExec = getSubTempDir(new File(xdg_cache_home), tmpSubDir, true /* executable */);
+ tempRootExec = getSubTempDir(new File(xdg_cache_home), tmpSubDir, true /* executable */);
}
-
+
// 3) $HOME/.jogamp
- if(null == tempRootExec && isStringSet(user_home)) {
+ if(null == tempRootExec && isStringSet(user_home)) {
tempRootExec = getSubTempDir(new File(user_home), "." + tmpSubDir, true /* executable */);
- }
-
-
+ }
+
+
if(null != tempRootExec) {
tempRootNoexec = tempRootExec;
} else {
@@ -1107,18 +1107,18 @@ public class IOUtil {
if( null == tempRootNoexec && isStringSet(java_io_tmpdir) ) {
tempRootNoexec = getSubTempDir(new File(java_io_tmpdir), tmpSubDir, false /* executable */);
}
-
+
// 2) $XDG_CACHE_HOME/jogamp
if(null == tempRootNoexec && isStringSet(xdg_cache_home)) {
- tempRootNoexec = getSubTempDir(new File(xdg_cache_home), tmpSubDir, false /* executable */);
+ tempRootNoexec = getSubTempDir(new File(xdg_cache_home), tmpSubDir, false /* executable */);
}
-
+
// 3) $HOME/.jogamp
- if(null == tempRootNoexec && isStringSet(user_home)) {
+ if(null == tempRootNoexec && isStringSet(user_home)) {
tempRootNoexec = getSubTempDir(new File(user_home), "." + tmpSubDir, false /* executable */);
- }
+ }
}
-
+
if(DEBUG) {
System.err.println("IOUtil.getTempRoot(): temp dirs: exec: "+tempRootExec.getAbsolutePath()+", noexec: "+tempRootNoexec.getAbsolutePath());
}
@@ -1136,16 +1136,16 @@ public class IOUtil {
private static File tempRootExec = null; // writeable and executable
private static File tempRootNoexec = null; // writeable, maybe executable
private static volatile boolean tempRootSet = false;
-
+
/**
* Utilizing {@link File#createTempFile(String, String, File)} using
- * {@link #getTempDir(boolean)} as the directory parameter, ie. location
+ * {@link #getTempDir(boolean)} as the directory parameter, ie. location
* of the root temp folder.
- *
+ *
* @see File#createTempFile(String, String)
* @see File#createTempFile(String, String, File)
* @see #getTempDir(boolean)
- *
+ *
* @param prefix
* @param suffix
* @param executable true if the temporary root folder needs to hold executable files, otherwise false.
@@ -1154,9 +1154,9 @@ public class IOUtil {
* @throws IOException
* @throws SecurityException
*/
- public static File createTempFile(String prefix, String suffix, boolean executable)
- throws IllegalArgumentException, IOException, SecurityException
- {
+ public static File createTempFile(String prefix, String suffix, boolean executable)
+ throws IllegalArgumentException, IOException, SecurityException
+ {
return File.createTempFile( prefix, suffix, getTempDir(executable) );
}
@@ -1172,6 +1172,6 @@ public class IOUtil {
e.printStackTrace();
}
}
- }
+ }
}
}
diff --git a/src/java/com/jogamp/common/util/IntBitfield.java b/src/java/com/jogamp/common/util/IntBitfield.java
index ad27dff..07b24dc 100644
--- a/src/java/com/jogamp/common/util/IntBitfield.java
+++ b/src/java/com/jogamp/common/util/IntBitfield.java
@@ -29,24 +29,24 @@ package com.jogamp.common.util;
/**
* Simple bitfield holder class using an int[] storage.
- * <p>
+ * <p>
* IntBitfield allows convenient access of a wide field of transient bits using efficient storage in O(1).
* </p>
* <p>
* It can be used e.g. to map key-codes to pressed-state etc.
- * </p>
+ * </p>
*/
public class IntBitfield {
/** Unit size in bits, here 32 bits for one int unit. */
public static final int UNIT_SIZE = 32;
-
+
private static final long UNIT_SHIFT_L = 5L;
private static final int UNIT_SHIFT_I = 5;
-
+
private final int[] storage;
private final long bitsCountL;
private final int bitsCountI;
-
+
/**
* @param bitCount
*/
@@ -54,9 +54,9 @@ public class IntBitfield {
final int units = (int) ( ( bitCount + 7L ) >> UNIT_SHIFT_L );
this.storage = new int[units];
this.bitsCountL = (long)units << UNIT_SHIFT_L ;
- this.bitsCountI = bitsCountL > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)bitsCountL;
+ this.bitsCountI = bitsCountL > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)bitsCountL;
}
-
+
/**
* @param bitCount
*/
@@ -66,7 +66,7 @@ public class IntBitfield {
this.bitsCountI = units << UNIT_SHIFT_I;
this.bitsCountL = bitsCountI;
}
-
+
private final void check(long bitnum) {
if( 0 > bitnum || bitnum >= bitsCountL ) {
throw new ArrayIndexOutOfBoundsException("Bitnum should be within [0.."+(bitsCountL-1)+"], but is "+bitnum);
@@ -77,10 +77,10 @@ public class IntBitfield {
throw new ArrayIndexOutOfBoundsException("Bitnum should be within [0.."+(bitsCountI-1)+"], but is "+bitnum);
}
}
-
+
/** Return the capacity of this bit field, i.e. the number of bits stored int this field. */
public final long capacity() { return bitsCountL; }
-
+
/** Return <code>true</code> if the bit at position <code>bitnum</code> is set, otherwise <code>false</code>. */
public final boolean get(long bitnum) {
check(bitnum);
@@ -88,7 +88,7 @@ public class IntBitfield {
final int b = (int) ( bitnum - ( (long)u << UNIT_SHIFT_L ) );
return 0 != ( storage[u] & ( 1 << b ) ) ;
}
-
+
/** Return <code>true</code> if the bit at position <code>bitnum</code> is set, otherwise <code>false</code>. */
public final boolean get(int bitnum) {
check(bitnum);
@@ -96,12 +96,12 @@ public class IntBitfield {
final int b = bitnum - ( u << UNIT_SHIFT_I );
return 0 != ( storage[u] & ( 1 << b ) ) ;
}
-
- /**
+
+ /**
* Set or clear the bit at position <code>bitnum</code> according to <code>bit</code>
- * and return the previous value.
+ * and return the previous value.
*/
- public final boolean put(long bitnum, boolean bit) {
+ public final boolean put(long bitnum, boolean bit) {
check(bitnum);
final int u = (int) ( bitnum >> UNIT_SHIFT_L );
final int b = (int) ( bitnum - ( (long)u << UNIT_SHIFT_L ) );
@@ -116,12 +116,12 @@ public class IntBitfield {
}
return prev;
}
-
- /**
+
+ /**
* Set or clear the bit at position <code>bitnum</code> according to <code>bit</code>
- * and return the previous value.
+ * and return the previous value.
*/
- public final boolean put(int bitnum, boolean bit) {
+ public final boolean put(int bitnum, boolean bit) {
check(bitnum);
final int u = bitnum >> UNIT_SHIFT_I;
final int b = bitnum - ( u << UNIT_SHIFT_I );
@@ -151,8 +151,8 @@ public class IntBitfield {
c -= (n >> 2) & 011111111111;
return ( (c + ( c >> 3 ) ) & 030707070707 ) % 63;
}
-
- /**
+
+ /**
* Returns the number of set bits within this bitfield.
*/
public long getBitCount() {
diff --git a/src/java/com/jogamp/common/util/IntIntHashMap.java b/src/java/com/jogamp/common/util/IntIntHashMap.java
index 7909478..06b9a3f 100644
--- a/src/java/com/jogamp/common/util/IntIntHashMap.java
+++ b/src/java/com/jogamp/common/util/IntIntHashMap.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
/**
* Created on Sunday, March 28 2010 21:01
*/
@@ -52,14 +52,14 @@ import java.util.Iterator;
* @author Michael Bien
* @author Simon Goller
* @author Sven Gothel
- *
+ *
* @see IntObjectHashMap
* @see IntLongHashMap
* @see LongObjectHashMap
* @see LongLongHashMap
* @see LongIntHashMap
*/
-public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
+public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
Iterable< /*name*/IntIntHashMap/*name*/.Entry > {
private final float loadFactor;
@@ -70,34 +70,34 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
private int capacity;
private int threshold;
private /*value*/int/*value*/ keyNotFoundValue = /*null*/-1/*null*/;
-
+
private static final boolean isPrimitive;
private static final Constructor</*name*/IntIntHashMap/*name*/.Entry> entryConstructor;
private static final Method equalsMethod;
-
+
static class EntryCM { EntryCM() { c = null; m1 = null; } Constructor<Entry> c; Method m1; };
-
+
static {
final Class<?> valueClazz = /*value*/int/*value*/.class;
final Class<?> keyClazz = /*key*/int/*key*/.class;
-
+
isPrimitive = valueClazz.isPrimitive();
-
+
if(!isPrimitive) {
final EntryCM cm = AccessController.doPrivileged(new PrivilegedAction<EntryCM>() {
@SuppressWarnings("unchecked")
public EntryCM run() {
EntryCM r = new EntryCM();
- r.c = (Constructor<Entry>)
- ReflectionUtil.getConstructor(Entry.class,
+ r.c = (Constructor<Entry>)
+ ReflectionUtil.getConstructor(Entry.class,
new Class[] { keyClazz, valueClazz, Entry.class } );
try {
r.m1 = valueClazz.getDeclaredMethod("equals", Object.class);
- } catch (NoSuchMethodException ex) {
+ } catch (NoSuchMethodException ex) {
throw new JogampRuntimeException("Class "+valueClazz+" doesn't support equals(Object)");
}
- return r;
- } } );
+ return r;
+ } } );
entryConstructor = cm.c;
equalsMethod = cm.m1;
} else {
@@ -105,7 +105,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
equalsMethod = null;
}
}
-
+
public /*name*/IntIntHashMap/*name*/() {
this(16, 0.75f);
}
@@ -135,32 +135,32 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
}
private /*name*/IntIntHashMap/*name*/(float loadFactor, int table_size, int size,
- int mask, int capacity, int threshold,
+ int mask, int capacity, int threshold,
/*value*/int/*value*/ keyNotFoundValue) {
this.loadFactor = loadFactor;
this.table = new Entry[table_size];
this.size = size;
-
+
this.mask = mask;
this.capacity = capacity;
this.threshold = threshold;
-
- this.keyNotFoundValue = keyNotFoundValue;
+
+ this.keyNotFoundValue = keyNotFoundValue;
}
-
+
/**
* Disclaimer: If the value type doesn't implement {@link Object#clone() clone()}, only the reference is copied.
* Note: Due to private fields we cannot implement a copy constructor, sorry.
- *
+ *
* @param source the primitive hash map to copy
*/
@Override
public Object clone() {
- /*name*/IntIntHashMap/*name*/ n =
- new /*name*/IntIntHashMap/*name*/(loadFactor, table.length, size,
- mask, capacity, threshold,
+ /*name*/IntIntHashMap/*name*/ n =
+ new /*name*/IntIntHashMap/*name*/(loadFactor, table.length, size,
+ mask, capacity, threshold,
keyNotFoundValue);
-
+
for(int i=table.length-1; i>=0; i--) {
// single linked list -> ArrayList
final ArrayList<Entry> entries = new ArrayList<Entry>();
@@ -182,10 +182,10 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
}
// 1st elem of linked list is table entry
n.table[i] = de_next;
- }
+ }
return n;
}
-
+
public boolean containsValue(/*value*/int/*value*/ value) {
Entry[] t = this.table;
for (int i = t.length; i-- > 0;) {
@@ -196,9 +196,9 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
}
} else {
final Boolean b = (Boolean) ReflectionUtil.callMethod(value, equalsMethod, e.value);
- if(b.booleanValue()) {
+ if(b.booleanValue()) {
return true;
- }
+ }
}
}
}
@@ -299,7 +299,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
final int index = /*keyHash*/key/*keyHash*/ & mask;
Entry prev = t[index];
Entry e = prev;
-
+
while (e != null) {
Entry next = e.next;
if (e.key == key) {
@@ -355,7 +355,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
*
* @return the previous key not found value
* @see #get
- * @see #put
+ * @see #put
*/
public /*value*/int/*value*/ setKeyNotFoundValue(/*value*/int/*value*/ newKeyNotFoundValue) {
/*value*/int/*value*/ t = keyNotFoundValue;
@@ -391,19 +391,19 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
sb.append("}");
return sb;
}
-
+
@Override
public String toString() {
return toString(null).toString();
}
-
+
private final static class EntryIterator implements Iterator<Entry> {
private final Entry[] entries;
-
+
private int index;
private Entry next;
-
+
private EntryIterator(Entry[] entries){
this.entries = entries;
// load next
@@ -439,9 +439,9 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
-
+
}
-
+
/**
* An entry mapping a key to a value.
*/
@@ -449,7 +449,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
public final /*key*/int/*key*/ key;
public /*value*/int/*value*/ value;
-
+
private Entry next;
Entry(/*key*/int/*key*/ k, /*value*/int/*value*/ v, Entry n) {
@@ -457,7 +457,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
value = v;
next = n;
}
-
+
/**
* Returns the key of this entry.
*/
@@ -490,21 +490,21 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
sb.append("[").append(key).append(":").append(value).append("]");
return sb;
}
-
+
@Override
public String toString() {
return toString(null).toString();
}
}
-
+
private static Method getCloneMethod(Object obj) {
final Class<?> clazz = obj.getClass();
return AccessController.doPrivileged(new PrivilegedAction<Method>() {
public Method run() {
try {
return clazz.getDeclaredMethod("clone");
- } catch (NoSuchMethodException ex) {
+ } catch (NoSuchMethodException ex) {
throw new JogampRuntimeException("Class "+clazz+" doesn't support clone()", ex);
}
} } );
diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java
index 29e7dc7..1689d54 100644
--- a/src/java/com/jogamp/common/util/JarUtil.java
+++ b/src/java/com/jogamp/common/util/JarUtil.java
@@ -54,17 +54,17 @@ public class JarUtil {
private static final boolean DEBUG = Debug.debug("JarUtil");
private static final int BUFFER_SIZE = 4096;
-
+
/**
* Interface allowing users to provide an URL resolver that will convert custom classloader
* URLs like Eclipse/OSGi <i>bundleresource:</i> URLs to normal <i>jar:</i> URLs.
- * <p>
+ * <p>
* This might be required for custom classloader where the URI protocol is unknown
- * to the standard runtime environment.
+ * to the standard runtime environment.
* </p>
* <p>
* Note: The provided resolver is only utilized if a given URI's protocol could not be resolved.
- * I.e. it will not be invoked for known protocols like <i>http</i>, <i>https</i>, <i>jar</i> or <i>file</i>.
+ * I.e. it will not be invoked for known protocols like <i>http</i>, <i>https</i>, <i>jar</i> or <i>file</i>.
* </p>
*/
public interface Resolver {
@@ -72,15 +72,15 @@ public class JarUtil {
}
private static Resolver resolver;
-
+
/**
* Setting a custom {@link Resolver} instance.
- *
+ *
* @param r {@link Resolver} to use after querying class file URLs from the classloader.
* @throws IllegalArgumentException if the passed resolver is <code>null</code>
* @throws IllegalStateException if the resolver has already been set.
* @throws SecurityException if the security manager doesn't have the setFactory
- * permission
+ * permission
*/
public static void setResolver(Resolver r) throws IllegalArgumentException, IllegalStateException, SecurityException {
if(r == null) {
@@ -101,13 +101,13 @@ public class JarUtil {
/**
* Returns <code>true</code> if the Class's <code>"com.jogamp.common.GlueGenVersion"</code>
- * is loaded from a JarFile and hence has a Jar URI like
+ * is loaded from a JarFile and hence has a Jar URI like
* URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"</code>.
* <p>
* <i>sub_protocol</i> may be "file", "http", etc..
* </p>
- *
- * @param clazzBinName "com.jogamp.common.GlueGenVersion"
+ *
+ * @param clazzBinName "com.jogamp.common.GlueGenVersion"
* @param cl
* @return true if the class is loaded from a Jar file, otherwise false.
* @see {@link #getJarURI(String, ClassLoader)}
@@ -118,20 +118,20 @@ public class JarUtil {
} catch (Exception e) { /* ignore */ }
return false;
}
-
+
/**
- * The Class's <code>"com.jogamp.common.GlueGenVersion"</code>
+ * The Class's <code>"com.jogamp.common.GlueGenVersion"</code>
* URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"</code>
* will be returned.
* <p>
* <i>sub_protocol</i> may be "file", "http", etc..
* </p>
- *
- * @param clazzBinName "com.jogamp.common.GlueGenVersion"
+ *
+ * @param clazzBinName "com.jogamp.common.GlueGenVersion"
* @param cl ClassLoader to locate the JarFile
* @return "jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"
* @throws IllegalArgumentException if the URI doesn't match the expected formatting or null arguments
- * @throws IOException if the class's Jar file could not been found by the ClassLoader
+ * @throws IOException if the class's Jar file could not been found by the ClassLoader
* @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI
* @see {@link IOUtil#getClassURL(String, ClassLoader)}
*/
@@ -148,7 +148,7 @@ public class JarUtil {
!scheme.equals( IOUtil.JAR_SCHEME ) &&
!scheme.equals( IOUtil.FILE_SCHEME ) &&
!scheme.equals( IOUtil.HTTP_SCHEME ) &&
- !scheme.equals( IOUtil.HTTPS_SCHEME ) )
+ !scheme.equals( IOUtil.HTTPS_SCHEME ) )
{
final URL _url = resolver.resolve( url );
uri = _url.toURI();
@@ -171,19 +171,19 @@ public class JarUtil {
}
return uri;
}
-
-
+
+
/**
* The Class's Jar URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code>
* Jar basename <code>gluegen-rt.jar</code> will be returned.
* <p>
* <i>sub_protocol</i> may be "file", "http", etc..
* </p>
- *
- * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()},
+ *
+ * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()},
* i.e. <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code>
* @return <code>gluegen-rt.jar</code>
- * @throws IllegalArgumentException if the URI doesn't match the expected formatting or is null
+ * @throws IllegalArgumentException if the URI doesn't match the expected formatting or is null
* @see {@link IOUtil#getClassURL(String, ClassLoader)}
*/
public static String getJarBasename(URI classJarURI) throws IllegalArgumentException {
@@ -194,19 +194,19 @@ public class JarUtil {
throw new IllegalArgumentException("URI is not using scheme "+IOUtil.JAR_SCHEME+": <"+classJarURI+">");
}
String uriS = classJarURI.getSchemeSpecificPart();
-
- // from
+
+ // from
// file:/some/path/gluegen-rt.jar!/com/jogamp/common/util/cache/TempJarCache.class
// to
// file:/some/path/gluegen-rt.jar
int idx = uriS.lastIndexOf('!');
if (0 <= idx) {
- uriS = uriS.substring(0, idx); // exclude '!/'
+ uriS = uriS.substring(0, idx); // exclude '!/'
} else {
throw new IllegalArgumentException("JAR URI does not contain jar uri terminator '!', in <"+classJarURI+">");
}
-
- // from
+
+ // from
// file:/some/path/gluegen-rt.jar
// to
// gluegen-rt.jar
@@ -219,10 +219,10 @@ public class JarUtil {
}
}
uriS = uriS.substring(idx+1); // just the jar name
-
+
if(0 >= uriS.lastIndexOf(".jar")) {
throw new IllegalArgumentException("No Jar name in <"+classJarURI+">");
- }
+ }
if(DEBUG) {
System.out.println("getJarName res: "+uriS);
}
@@ -230,17 +230,17 @@ public class JarUtil {
}
/**
- * The Class's <code>com.jogamp.common.GlueGenVersion</code>
+ * The Class's <code>com.jogamp.common.GlueGenVersion</code>
* URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code>
* Jar basename <code>gluegen-rt.jar</code> will be returned.
* <p>
* <i>sub_protocol</i> may be "file", "http", etc..
* </p>
- *
+ *
* @param clazzBinName <code>com.jogamp.common.GlueGenVersion</code>
* @param cl
* @return <code>gluegen-rt.jar</code>
- * @throws IllegalArgumentException if the URI doesn't match the expected formatting
+ * @throws IllegalArgumentException if the URI doesn't match the expected formatting
* @throws IOException if the class's Jar file could not been found by the ClassLoader.
* @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI
* @see {@link IOUtil#getClassURL(String, ClassLoader)}
@@ -248,34 +248,34 @@ public class JarUtil {
public static String getJarBasename(String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException {
return getJarBasename( getJarURI(clazzBinName, cl) );
}
-
+
/**
* The Class's Jar URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code>
* Jar file's sub URI <code><i>sub_protocol</i>:/some/path/gluegen-rt.jar</code> will be returned.
* <p>
* <i>sub_protocol</i> may be "file", "http", etc..
* </p>
- *
- * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()},
+ *
+ * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()},
* i.e. <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code>
* @return <code><i>sub_protocol</i>:/some/path/gluegen-rt.jar</code>
- * @throws IllegalArgumentException if the URI doesn't match the expected formatting or is null
+ * @throws IllegalArgumentException if the URI doesn't match the expected formatting or is null
* @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI
* @see {@link IOUtil#getClassURL(String, ClassLoader)}
*/
public static URI getJarSubURI(URI classJarURI) throws IllegalArgumentException, URISyntaxException {
if(null == classJarURI) {
- throw new IllegalArgumentException("URI is null");
+ throw new IllegalArgumentException("URI is null");
}
if( !classJarURI.getScheme().equals(IOUtil.JAR_SCHEME) ) {
throw new IllegalArgumentException("URI is not a using scheme "+IOUtil.JAR_SCHEME+": <"+classJarURI+">");
}
-
- // from
+
+ // from
// file:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
// to
// file:/some/path/gluegen-rt.jar
- final String uriS0 = classJarURI.getSchemeSpecificPart();
+ final String uriS0 = classJarURI.getSchemeSpecificPart();
int idx = uriS0.lastIndexOf('!');
final String uriS1;
if (0 <= idx) {
@@ -292,26 +292,26 @@ public class JarUtil {
}
return new URI(uriS2);
}
-
+
/**
* The Class's Jar URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code>
* Jar file's entry <code>/com/jogamp/common/GlueGenVersion.class</code> will be returned.
- *
- * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()},
+ *
+ * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()},
* i.e. <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code>
* @return <code>/com/jogamp/common/GlueGenVersion.class</code>
* @see {@link IOUtil#getClassURL(String, ClassLoader)}
*/
public static String getJarEntry(URI classJarURI) {
if(null == classJarURI) {
- throw new IllegalArgumentException("URI is null");
+ throw new IllegalArgumentException("URI is null");
}
if( !classJarURI.getScheme().equals(IOUtil.JAR_SCHEME) ) {
throw new IllegalArgumentException("URI is not a using scheme "+IOUtil.JAR_SCHEME+": <"+classJarURI+">");
}
String uriS = classJarURI.getSchemeSpecificPart();
-
- // from
+
+ // from
// file:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
// to
// file:/some/path/gluegen-rt.jar
@@ -324,18 +324,18 @@ public class JarUtil {
}
/**
- * The Class's <code>com.jogamp.common.GlueGenVersion</code>
+ * The Class's <code>com.jogamp.common.GlueGenVersion</code>
* URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code>
* Jar file's sub URI <code><i>sub_protocol</i>:/some/path/gluegen-rt.jar</code> will be returned.
* <p>
* <i>sub_protocol</i> may be "file", "http", etc..
* </p>
- *
+ *
* @param clazzBinName <code>com.jogamp.common.GlueGenVersion</code>
* @param cl
* @return <code><i>sub_protocol</i>:/some/path/gluegen-rt.jar</code>
- * @throws IllegalArgumentException if the URI doesn't match the expected formatting
- * @throws IOException if the class's Jar file could not been found by the ClassLoader
+ * @throws IllegalArgumentException if the URI doesn't match the expected formatting
+ * @throws IOException if the class's Jar file could not been found by the ClassLoader
* @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI
* @see {@link IOUtil#getClassURL(String, ClassLoader)}
*/
@@ -344,18 +344,18 @@ public class JarUtil {
}
/**
- * The Class's <code>"com.jogamp.common.GlueGenVersion"</code>
+ * The Class's <code>"com.jogamp.common.GlueGenVersion"</code>
* URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"</code>
* Jar file URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/</code> will be returned.
* <p>
* <i>sub_protocol</i> may be "file", "http", etc..
* </p>
- *
- * @param clazzBinName "com.jogamp.common.GlueGenVersion"
+ *
+ * @param clazzBinName "com.jogamp.common.GlueGenVersion"
* @param cl
* @return "jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/"
- * @throws IllegalArgumentException if the URI doesn't match the expected formatting or null arguments
- * @throws IOException if the class's Jar file could not been found by the ClassLoader
+ * @throws IllegalArgumentException if the URI doesn't match the expected formatting or null arguments
+ * @throws IOException if the class's Jar file could not been found by the ClassLoader
* @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI
* @see {@link IOUtil#getClassURL(String, ClassLoader)}
*/
@@ -374,7 +374,7 @@ public class JarUtil {
* @param baseUri file:/some/path/
* @param jarFileName gluegen-rt.jar
* @return jar:file:/some/path/gluegen-rt.jar!/
- * @throws URISyntaxException
+ * @throws URISyntaxException
* @throws IllegalArgumentException null arguments
*/
public static URI getJarFileURI(URI baseUri, String jarFileName) throws IllegalArgumentException, URISyntaxException {
@@ -383,12 +383,12 @@ public class JarUtil {
}
return new URI(IOUtil.JAR_SCHEME, baseUri.toString()+jarFileName+"!/", null);
}
-
+
/**
* @param jarSubUri file:/some/path/gluegen-rt.jar
* @return jar:file:/some/path/gluegen-rt.jar!/
* @throws IllegalArgumentException null arguments
- * @throws URISyntaxException
+ * @throws URISyntaxException
*/
public static URI getJarFileURI(URI jarSubUri) throws IllegalArgumentException, URISyntaxException {
if(null == jarSubUri) {
@@ -396,12 +396,12 @@ public class JarUtil {
}
return new URI(IOUtil.JAR_SCHEME, jarSubUri.toString()+"!/", null);
}
-
+
/**
* @param jarSubUriS file:/some/path/gluegen-rt.jar
* @return jar:file:/some/path/gluegen-rt.jar!/
* @throws IllegalArgumentException null arguments
- * @throws URISyntaxException
+ * @throws URISyntaxException
*/
public static URI getJarFileURI(String jarSubUriS) throws IllegalArgumentException, URISyntaxException {
if(null == jarSubUriS) {
@@ -409,13 +409,13 @@ public class JarUtil {
}
return new URI(IOUtil.JAR_SCHEME, jarSubUriS+"!/", null);
}
-
+
/**
* @param jarFileURI jar:file:/some/path/gluegen-rt.jar!/
* @param jarEntry com/jogamp/common/GlueGenVersion.class
* @return jar:file:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
* @throws IllegalArgumentException null arguments
- * @throws URISyntaxException
+ * @throws URISyntaxException
*/
public static URI getJarEntryURI(URI jarFileURI, String jarEntry) throws IllegalArgumentException, URISyntaxException {
if(null == jarEntry) {
@@ -423,12 +423,12 @@ public class JarUtil {
}
return new URI(jarFileURI.toString()+jarEntry);
}
-
+
/**
- * @param clazzBinName com.jogamp.common.util.cache.TempJarCache
- * @param cl domain
+ * @param clazzBinName com.jogamp.common.util.cache.TempJarCache
+ * @param cl domain
* @return JarFile containing the named class within the given ClassLoader
- * @throws IOException if the class's Jar file could not been found by the ClassLoader
+ * @throws IOException if the class's Jar file could not been found by the ClassLoader
* @throws IllegalArgumentException null arguments
* @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI
* @see {@link #getJarFileURI(String, ClassLoader)}
@@ -441,8 +441,8 @@ public class JarUtil {
* @param jarFileURI jar:file:/some/path/gluegen-rt.jar!/
* @return JarFile as named by URI within the given ClassLoader
* @throws IllegalArgumentException null arguments
- * @throws IOException if the Jar file could not been found
- * @throws URISyntaxException
+ * @throws IOException if the Jar file could not been found
+ * @throws URISyntaxException
*/
public static JarFile getJarFile(URI jarFileURI) throws IOException, IllegalArgumentException, URISyntaxException {
if(null == jarFileURI) {
@@ -452,22 +452,22 @@ public class JarUtil {
System.out.println("getJarFile: "+jarFileURI.toString());
}
final URL jarFileURL = IOUtil.toURL(jarFileURI);
- // final URL jarFileURL = jarFileURI.toURL(); // doesn't work due to encoded path even w/ file schema!
+ // final URL jarFileURL = jarFileURI.toURL(); // doesn't work due to encoded path even w/ file schema!
final URLConnection urlc = jarFileURL.openConnection();
if(urlc instanceof JarURLConnection) {
JarURLConnection jarConnection = (JarURLConnection)jarFileURL.openConnection();
JarFile jarFile = jarConnection.getJarFile();
if(DEBUG) {
System.out.println("getJarFile res: "+jarFile.getName());
- }
+ }
return jarFile;
}
if(DEBUG) {
System.out.println("getJarFile res: NULL");
- }
+ }
return null;
}
-
+
/**
* Return a map from native-lib-base-name to entry-name.
*/
@@ -478,12 +478,12 @@ public class JarUtil {
final Map<String,String> nameMap = new HashMap<String, String>();
final Enumeration<JarEntry> entries = jarFile.entries();
-
+
while (entries.hasMoreElements()) {
final JarEntry entry = entries.nextElement();
final String entryName = entry.getName();
final String baseName = NativeLibrary.isValidNativeLibraryName(entryName, false);
-
+
if(null != baseName) {
nameMap.put(baseName, entryName);
}
@@ -503,7 +503,7 @@ public class JarUtil {
* Root entries are favored over non root entries in case of naming collisions.<br>
* Example on a Unix like machine:<br>
* <pre>
- * mylib.jar!/sub1/libsour.so -> sour (mapped, unique name)
+ * mylib.jar!/sub1/libsour.so -> sour (mapped, unique name)
* mylib.jar!/sub1/libsweet.so (dropped, root entry favored)
* mylib.jar!/libsweet.so -> sweet (mapped, root entry favored)
* mylib.jar!/sweet.dll -> (dropped, not a unix library name)
@@ -515,11 +515,11 @@ public class JarUtil {
* In this case, set all flags to true <code>extractNativeLibraries </code>.
* <code>extractClassFiles</code>, <code>extractOtherFiles</code>.
* </p>
- *
+ *
* @param dest
* @param nativeLibMap
* @param jarFile
- * @param nativeLibraryPath if not null, only extracts native libraries within this path.
+ * @param nativeLibraryPath if not null, only extracts native libraries within this path.
* @param extractNativeLibraries
* @param extractClassFiles
* @param extractOtherFiles
@@ -527,7 +527,7 @@ public class JarUtil {
* @return
* @throws IOException
*/
- public static final int extract(File dest, Map<String, String> nativeLibMap,
+ public static final int extract(File dest, Map<String, String> nativeLibMap,
JarFile jarFile,
String nativeLibraryPath,
boolean extractNativeLibraries,
@@ -573,7 +573,7 @@ public class JarUtil {
}
}
}
-
+
final boolean isClassFile = entryName.endsWith(".class");
if(isClassFile && !extractClassFiles) {
if (DEBUG) {
@@ -581,7 +581,7 @@ public class JarUtil {
}
continue;
}
-
+
if(!isNativeLib && !isClassFile && !extractOtherFiles) {
if (DEBUG) {
System.err.println("JarUtil: JarEntry : " + entryName + " other-file skipped");
@@ -590,16 +590,16 @@ public class JarUtil {
}
final boolean isDir = entryName.endsWith("/");
-
- final boolean isRootEntry = entryName.indexOf('/') == -1 &&
+
+ final boolean isRootEntry = entryName.indexOf('/') == -1 &&
entryName.indexOf(File.separatorChar) == -1;
-
+
if (DEBUG) {
- System.err.println("JarUtil: JarEntry : isNativeLib " + isNativeLib +
+ System.err.println("JarUtil: JarEntry : isNativeLib " + isNativeLib +
", isClassFile " + isClassFile + ", isDir " + isDir +
", isRootEntry " + isRootEntry );
}
-
+
final File destFile = new File(dest, entryName);
if(isDir) {
if (DEBUG) {
@@ -611,12 +611,12 @@ public class JarUtil {
if(!destFolder.exists()) {
if (DEBUG) {
System.err.println("JarUtil: MKDIR (parent): " + entryName + " -> " + destFolder );
- }
+ }
destFolder.mkdirs();
}
final InputStream in = new BufferedInputStream(jarFile.getInputStream(entry));
final OutputStream out = new BufferedOutputStream(new FileOutputStream(destFile));
- int numBytes = -1;
+ int numBytes = -1;
try {
numBytes = IOUtil.copyStream2Stream(BUFFER_SIZE, in, out, -1);
} finally {
@@ -626,7 +626,7 @@ public class JarUtil {
boolean addedAsNativeLib = false;
if (numBytes>0) {
num++;
- if (isNativeLib && ( isRootEntry || !nativeLibMap.containsKey(libBaseName) ) ) {
+ if (isNativeLib && ( isRootEntry || !nativeLibMap.containsKey(libBaseName) ) ) {
nativeLibMap.put(libBaseName, destFile.getAbsolutePath());
addedAsNativeLib = true;
}
@@ -647,7 +647,7 @@ public class JarUtil {
getCodeSource().getCertificates();
</pre>
*/
- public static final void validateCertificates(Certificate[] rootCerts, JarFile jarFile)
+ public static final void validateCertificates(Certificate[] rootCerts, JarFile jarFile)
throws IOException, SecurityException {
if (DEBUG) {
@@ -673,7 +673,7 @@ public class JarUtil {
* Check the certificates with the ones in the jar file
* (all must match).
*/
- private static final void validateCertificate(Certificate[] rootCerts,
+ private static final void validateCertificate(Certificate[] rootCerts,
JarFile jar, JarEntry entry, byte[] buf) throws IOException, SecurityException {
if (DEBUG) {
diff --git a/src/java/com/jogamp/common/util/JogampVersion.java b/src/java/com/jogamp/common/util/JogampVersion.java
index 046f18c..2789de7 100644
--- a/src/java/com/jogamp/common/util/JogampVersion.java
+++ b/src/java/com/jogamp/common/util/JogampVersion.java
@@ -46,16 +46,16 @@ public class JogampVersion {
public static final Attributes.Name IMPLEMENTATION_BRANCH = new Attributes.Name("Implementation-Branch");
/** See {@link #getImplementationCommit()} */
public static final Attributes.Name IMPLEMENTATION_COMMIT = new Attributes.Name("Implementation-Commit");
-
+
private String packageName;
private Manifest mf;
private int hash;
private Attributes mainAttributes;
private Set<?>/*<Attributes.Name>*/ mainAttributeNames;
-
+
private final String androidPackageVersionName;
-
- protected JogampVersion(String packageName, Manifest mf) {
+
+ protected JogampVersion(String packageName, Manifest mf) {
this.packageName = packageName;
this.mf = ( null != mf ) ? mf : new Manifest();
this.hash = this.mf.hashCode();
@@ -104,7 +104,7 @@ public class JogampVersion {
}
/**
- * @return set of type {@link Attributes.Name}, disguised as anonymous
+ * @return set of type {@link Attributes.Name}, disguised as anonymous
*/
public final Set<?>/*<Attributes.Name>*/ getAttributeNames() {
return mainAttributeNames;
@@ -117,13 +117,13 @@ public class JogampVersion {
return this.getAttribute(Attributes.Name.EXTENSION_NAME);
}
- /**
+ /**
* Returns the implementation build number, e.g. <code>2.0-b456-20130328</code>.
*/
public final String getImplementationBuild() {
return this.getAttribute(GlueGenVersion.IMPLEMENTATION_BUILD);
}
-
+
/**
* Returns the SCM branch name
*/
@@ -168,7 +168,7 @@ public class JogampVersion {
public final String getAndroidPackageVersionName() {
return androidPackageVersionName;
}
-
+
public final String getSpecificationTitle() {
return this.getAttribute(Attributes.Name.SPECIFICATION_TITLE);
}
@@ -220,7 +220,7 @@ public class JogampVersion {
return sb;
}
-
+
@Override
public String toString() {
return toString(null).toString();
diff --git a/src/java/com/jogamp/common/util/LFRingbuffer.java b/src/java/com/jogamp/common/util/LFRingbuffer.java
index f704047..1ca1e20 100644
--- a/src/java/com/jogamp/common/util/LFRingbuffer.java
+++ b/src/java/com/jogamp/common/util/LFRingbuffer.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -31,7 +31,7 @@ package com.jogamp.common.util;
import java.io.PrintStream;
import java.lang.reflect.Array;
-/**
+/**
* Simple implementation of {@link Ringbuffer},
* exposing <i>lock-free</i>
* {@link #get() get*(..)} and {@link #put(Object) put*(..)} methods.
@@ -80,11 +80,11 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
private volatile int readPos;
private volatile int writePos;
private volatile int size;
-
+
public final String toString() {
return "LFRingbuffer<?>[filled "+size+" / "+(capacityPlusOne-1)+", writePos "+writePos+", readPos "+readPos+"]";
}
-
+
public final void dump(PrintStream stream, String prefix) {
stream.println(prefix+" "+toString()+" {");
for(int i=0; i<capacityPlusOne; i++) {
@@ -92,10 +92,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
stream.println("}");
}
-
- /**
+
+ /**
* Create a full ring buffer instance w/ the given array's net capacity and content.
- * <p>
+ * <p>
* Example for a 10 element Integer array:
* <pre>
* Integer[] source = new Integer[10];
@@ -111,7 +111,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
* and copy all elements from array <code>copyFrom</code> into the internal array.
* </p>
* @param copyFrom mandatory source array determining ring buffer's net {@link #capacity()} and initial content.
- * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code>
+ * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code>
*/
@SuppressWarnings("unchecked")
public LFRingbuffer(T[] copyFrom) throws IllegalArgumentException {
@@ -119,10 +119,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
array = (T[]) newArray(copyFrom.getClass(), capacityPlusOne);
resetImpl(true, copyFrom);
}
-
- /**
+
+ /**
* Create an empty ring buffer instance w/ the given net <code>capacity</code>.
- * <p>
+ * <p>
* Example for a 10 element Integer array:
* <pre>
* Ringbuffer<Integer> rb = new LFRingbuffer<Integer>(10, Integer[].class);
@@ -142,13 +142,13 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
array = (T[]) newArray(arrayType, capacityPlusOne);
resetImpl(false, null /* empty, nothing to copy */ );
}
-
+
@Override
public final T[] getInternalArray() { return array; }
-
+
@Override
public final int capacity() { return capacityPlusOne-1; }
-
+
@Override
public final void clear() {
synchronized ( syncGlobal ) {
@@ -158,12 +158,12 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
}
}
-
+
@Override
public final void resetFull(T[] copyFrom) throws IllegalArgumentException {
resetImpl(true, copyFrom);
}
-
+
private final void resetImpl(boolean full, T[] copyFrom) throws IllegalArgumentException {
synchronized ( syncGlobal ) {
if( null != copyFrom ) {
@@ -185,21 +185,21 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
}
}
-
+
@Override
public final int size() { return size; }
-
+
@Override
public final int getFreeSlots() { return capacityPlusOne - 1 - size; }
@Override
public final boolean isEmpty() { return 0 == size; }
-
+
@Override
public final boolean isFull() { return capacityPlusOne - 1 == size; }
-
+
/**
- * {@inheritDoc}
+ * {@inheritDoc}
* <p>
* Implementation advances the read position and returns the element at it, if not empty.
* </p>
@@ -212,7 +212,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}
* <p>
* Implementation advances the read position and returns the element at it, if not empty.
* </p>
@@ -221,7 +221,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
public final T getBlocking() throws InterruptedException {
return getImpl(true, false);
}
-
+
@Override
public final T peek() {
try {
@@ -232,7 +232,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
public final T peekBlocking() throws InterruptedException {
return getImpl(true, true);
}
-
+
private final T getImpl(boolean blocking, boolean peek) throws InterruptedException {
int localReadPos = readPos;
if( localReadPos == writePos ) {
@@ -258,9 +258,9 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
return r;
}
-
+
/**
- * {@inheritDoc}
+ * {@inheritDoc}
* <p>
* Implementation advances the write position and stores the given element at it, if not full.
* </p>
@@ -271,9 +271,9 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
return putImpl(e, false, false);
} catch (InterruptedException ie) { throw new RuntimeException(ie); }
}
-
- /**
- * {@inheritDoc}
+
+ /**
+ * {@inheritDoc}
* <p>
* Implementation advances the write position and stores the given element at it, if not full.
* </p>
@@ -284,10 +284,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
throw new InternalError("Blocking put failed: "+this);
}
}
-
+
/**
* {@inheritDoc}
- * <p>
+ * <p>
* Implementation advances the write position and keeps the element at it, if not full.
* </p>
*/
@@ -295,7 +295,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
public final boolean putSame(boolean blocking) throws InterruptedException {
return putImpl(null, true, blocking);
}
-
+
private final boolean putImpl(T e, boolean sameRef, boolean blocking) throws InterruptedException {
int localWritePos = writePos;
localWritePos = (localWritePos + 1) % capacityPlusOne;
@@ -320,8 +320,8 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
return true;
}
-
-
+
+
@Override
public final void waitForFreeSlots(int count) throws InterruptedException {
synchronized ( syncRead ) {
@@ -332,10 +332,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
}
}
-
+
@Override
public final void growEmptyBuffer(final T[] newElements) throws IllegalStateException, IllegalArgumentException {
- synchronized( syncGlobal ) {
+ synchronized( syncGlobal ) {
if( null == newElements ) {
throw new IllegalArgumentException("newElements is null");
}
@@ -355,15 +355,15 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
if( readPos != writePos ) {
throw new InternalError("R/W pos not equal at empty: "+this);
}
-
+
final int growAmount = newElements.length;
final int newCapacity = capacityPlusOne + growAmount;
final T[] oldArray = array;
final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity);
-
+
// writePos == readPos
writePos += growAmount; // warp writePos to the end of the new data location
-
+
if( readPos >= 0 ) {
System.arraycopy(oldArray, 0, newArray, 0, readPos+1);
}
@@ -374,13 +374,13 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
if( tail > 0 ) {
System.arraycopy(oldArray, readPos+1, newArray, writePos+1, tail);
}
- size = growAmount;
-
+ size = growAmount;
+
capacityPlusOne = newCapacity;
array = newArray;
}
}
-
+
@Override
public final void growFullBuffer(final int growAmount) throws IllegalStateException, IllegalArgumentException {
synchronized ( syncGlobal ) {
@@ -389,7 +389,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
if( capacityPlusOne-1 != size ) {
throw new IllegalStateException("Buffer is not full: "+this);
- }
+ }
final int wp1 = ( writePos + 1 ) % capacityPlusOne;
if( wp1 != readPos ) {
throw new InternalError("R != W+1 pos at full: "+this);
@@ -400,10 +400,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
final int newCapacity = capacityPlusOne + growAmount;
final T[] oldArray = array;
final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity);
-
+
// writePos == readPos - 1
readPos = ( writePos + 1 + growAmount ) % newCapacity; // warp readPos to the end of the new data location
-
+
if(writePos >= 0) {
System.arraycopy(oldArray, 0, newArray, 0, writePos+1);
}
@@ -411,12 +411,12 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
if( tail > 0 ) {
System.arraycopy(oldArray, writePos+1, newArray, readPos, tail);
}
-
+
capacityPlusOne = newCapacity;
array = newArray;
}
}
-
+
@SuppressWarnings("unchecked")
private static <T> T[] newArray(Class<? extends T[]> arrayType, int length) {
return ((Object)arrayType == (Object)Object[].class)
diff --git a/src/java/com/jogamp/common/util/PrimitiveStack.java b/src/java/com/jogamp/common/util/PrimitiveStack.java
index 89ae72e..e357e4a 100644
--- a/src/java/com/jogamp/common/util/PrimitiveStack.java
+++ b/src/java/com/jogamp/common/util/PrimitiveStack.java
@@ -31,50 +31,50 @@ package com.jogamp.common.util;
* Simple primitive-type stack.
*/
public interface PrimitiveStack {
-
- /**
+
+ /**
* Returns this stack's current capacity.
* <p>
* The capacity may grow with a put operation w/ insufficient {@link #remaining()} elements left, if {@link #getGrowSize()} &gt; 0.
- * </p>
+ * </p>
*/
int capacity();
-
- /**
+
+ /**
* Returns the current position of this stack.
* <p>
- * Position is in the range: 0 &le; position &lt; {@link #capacity()}.
+ * Position is in the range: 0 &le; position &lt; {@link #capacity()}.
* </p>
* <p>
* The position equals to the number of elements stored.
* </p>
**/
int position();
-
+
/**
* Sets the position of this stack.
- *
+ *
* @param newPosition the new position
* @throws IndexOutOfBoundsException if <code>newPosition</code> is outside of range: 0 &le; position &lt; {@link #capacity()}.
*/
void position(int newPosition) throws IndexOutOfBoundsException;
-
- /**
+
+ /**
* Returns the remaining elements left before stack will grow about {@link #getGrowSize()}.
* <pre>
* remaining := capacity() - position();
* </pre>
- * <p>
+ * <p>
* 0 denotes a full stack.
- * </p>
+ * </p>
* @see #capacity()
* @see #position()
**/
int remaining();
-
+
/** Returns the grow size. A stack grows by this size in case a put operation exceeds it's {@link #capacity()}. */
int getGrowSize();
/** Set new {@link #growSize(). */
- void setGrowSize(int newGrowSize);
+ void setGrowSize(int newGrowSize);
}
diff --git a/src/java/com/jogamp/common/util/PropertyAccess.java b/src/java/com/jogamp/common/util/PropertyAccess.java
index fdb2665..5a8f082 100644
--- a/src/java/com/jogamp/common/util/PropertyAccess.java
+++ b/src/java/com/jogamp/common/util/PropertyAccess.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -38,32 +38,32 @@ public class PropertyAccess {
public static final String jnlp_prefix = "jnlp." ;
/** trusted build-in property prefix 'javaws.' */
public static final String javaws_prefix = "javaws.";
-
+
static final HashSet<String> trustedPrefixes;
static final HashSet<String> trusted;
-
+
static {
trustedPrefixes = new HashSet<String>();
trustedPrefixes.add(javaws_prefix);
trustedPrefixes.add(jnlp_prefix);
// 'jogamp.' and maybe other trusted prefixes will be added later via 'addTrustedPrefix()'
-
+
trusted = new HashSet<String>();
trusted.add("sun.java2d.opengl");
trusted.add("sun.java2d.noddraw");
trusted.add("sun.java2d.d3d");
trusted.add("sun.awt.noerasebackground");
}
-
+
/**
* @param prefix New prefix to be registered as trusted.
- * @throws AccessControlException as thrown by {@link SecurityUtil#checkAllPermissions()}.
+ * @throws AccessControlException as thrown by {@link SecurityUtil#checkAllPermissions()}.
*/
protected static final void addTrustedPrefix(String prefix) throws AccessControlException {
SecurityUtil.checkAllPermissions();
trustedPrefixes.add(prefix);
}
-
+
public static final boolean isTrusted(String propertyKey) {
final int dot1 = propertyKey.indexOf('.');
if(0<=dot1) {
@@ -72,7 +72,7 @@ public class PropertyAccess {
return false;
}
}
-
+
/** @see #getProperty(String, boolean) */
public static final int getIntProperty(final String property, final boolean jnlpAlias, int defaultValue) {
int i=defaultValue;
@@ -120,22 +120,22 @@ public class PropertyAccess {
* Query the property with the name <code>propertyKey</code>.
* <p>
* If <code>jnlpAlias</code> is <code>true</code> and the plain <code>propertyKey</code>
- * could not be resolved, an attempt to resolve the JNLP aliased <i>trusted property</i> is made.<br>
+ * could not be resolved, an attempt to resolve the JNLP aliased <i>trusted property</i> is made.<br>
* Example: For the propertyName <code>OneTwo</code>, the jnlp alias name is <code>jnlp.OneTwo</code>, which is considered trusted.<br>
* </p>
- *
- * @param propertyKey the property name to query.
+ *
+ * @param propertyKey the property name to query.
* @param jnlpAlias true if a fallback attempt to query the JNLP aliased <i>trusted property</i> shall be made,
* otherwise false.
* @return the property value if exists, or null
- *
+ *
* @throws NullPointerException if the property name is null
* @throws IllegalArgumentException if the property name is of length 0
* @throws SecurityException if access is not allowed to the given <code>propertyKey</code>
- *
+ *
* @see System#getProperty(String)
*/
- public static final String getProperty(final String propertyKey, final boolean jnlpAlias)
+ public static final String getProperty(final String propertyKey, final boolean jnlpAlias)
throws SecurityException, NullPointerException, IllegalArgumentException {
if(null == propertyKey) {
throw new NullPointerException("propertyKey is NULL");
@@ -144,14 +144,14 @@ public class PropertyAccess {
throw new IllegalArgumentException("propertyKey is empty");
}
String s=null;
-
+
if( isTrusted(propertyKey) ) {
// 'trusted' property (jnlp., javaws., jogamp., ..)
s = getTrustedPropKey(propertyKey);
} else {
// may throw SecurityException, AccessControlerException
s = System.getProperty(propertyKey);
- }
+ }
if( null == s && jnlpAlias ) {
// Try 'jnlp.' aliased property ..
if( !propertyKey.startsWith(jnlp_prefix) ) {
@@ -162,9 +162,9 @@ public class PropertyAccess {
}
return s;
}
-
+
/** See {@link #getProperty(String, boolean)}, additionally allows a <code>defaultValue</code> if property value is <code>null</code>. */
- public static final String getProperty(final String propertyKey, final boolean jnlpAlias, String defaultValue)
+ public static final String getProperty(final String propertyKey, final boolean jnlpAlias, String defaultValue)
throws SecurityException, NullPointerException, IllegalArgumentException {
final String s = PropertyAccess.getProperty(propertyKey, jnlpAlias);
if( null != s ) {
@@ -173,7 +173,7 @@ public class PropertyAccess {
return defaultValue;
}
}
-
+
private static final String getTrustedPropKey(final String propertyKey) {
return AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
@@ -183,6 +183,6 @@ public class PropertyAccess {
throw new SecurityException("Could not access trusted property '"+propertyKey+"'", se);
}
}
- });
+ });
}
}
diff --git a/src/java/com/jogamp/common/util/ReflectionUtil.java b/src/java/com/jogamp/common/util/ReflectionUtil.java
index 8b9476f..598b8b1 100644
--- a/src/java/com/jogamp/common/util/ReflectionUtil.java
+++ b/src/java/com/jogamp/common/util/ReflectionUtil.java
@@ -1,22 +1,22 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* - Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* - Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
@@ -29,7 +29,7 @@
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
@@ -43,7 +43,7 @@ import com.jogamp.common.JogampRuntimeException;
import jogamp.common.Debug;
public final class ReflectionUtil {
-
+
public static final boolean DEBUG = Debug.debug("ReflectionUtil");
public static class AWTNames {
@@ -112,16 +112,16 @@ public final class ReflectionUtil {
* Returns a compatible constructor
* if available, otherwise throws an exception.
* <p>
- * It first attempts to get the specific Constructor
- * using the given <code>cstrArgTypes</code>.
+ * It first attempts to get the specific Constructor
+ * using the given <code>cstrArgTypes</code>.
* If this fails w/ <code>NoSuchMethodException</code>, a compatible
* Constructor is being looked-up w/ with parameter types assignable
* from the given <code>cstrArgs</code>.
- * </p>
- *
+ * </p>
+ *
* @throws JogampRuntimeException if the constructor can not be delivered.
*/
- public static final Constructor<?> getConstructor(Class<?> clazz, Class<?> ... cstrArgTypes)
+ public static final Constructor<?> getConstructor(Class<?> clazz, Class<?> ... cstrArgTypes)
throws JogampRuntimeException {
if(null == cstrArgTypes) {
cstrArgTypes = zeroTypes;
@@ -147,13 +147,13 @@ public final class ReflectionUtil {
if(types.length == j) {
cstr = c; // gotcha
}
- }
+ }
}
}
if(null == cstr) {
throw new JogampRuntimeException("Constructor: '" + clazz.getName() + "(" + asString(cstrArgTypes) + ")' not found");
}
- return cstr;
+ return cstr;
}
public static final Constructor<?> getConstructor(String clazzName, ClassLoader cl)
@@ -164,7 +164,7 @@ public final class ReflectionUtil {
/**
* @throws JogampRuntimeException if the instance can not be created.
*/
- public static final Object createInstance(Constructor<?> cstr, Object ... cstrArgs)
+ public static final Object createInstance(Constructor<?> cstr, Object ... cstrArgs)
throws JogampRuntimeException, RuntimeException
{
try {
@@ -183,17 +183,17 @@ public final class ReflectionUtil {
throw new JogampRuntimeException("can not create instance of "+cstr.getName(), t);
}
}
-
+
/**
* @throws JogampRuntimeException if the instance can not be created.
*/
- public static final Object createInstance(Class<?> clazz, Class<?>[] cstrArgTypes, Object ... cstrArgs)
+ public static final Object createInstance(Class<?> clazz, Class<?>[] cstrArgTypes, Object ... cstrArgs)
throws JogampRuntimeException, RuntimeException
{
return createInstance(getConstructor(clazz, cstrArgTypes), cstrArgs);
}
- public static final Object createInstance(Class<?> clazz, Object ... cstrArgs)
+ public static final Object createInstance(Class<?> clazz, Object ... cstrArgs)
throws JogampRuntimeException, RuntimeException
{
Class<?>[] cstrArgTypes = null;
@@ -206,7 +206,7 @@ public final class ReflectionUtil {
return createInstance(clazz, cstrArgTypes, cstrArgs);
}
- public static final Object createInstance(String clazzName, Class<?>[] cstrArgTypes, Object[] cstrArgs, ClassLoader cl)
+ public static final Object createInstance(String clazzName, Class<?>[] cstrArgTypes, Object[] cstrArgs, ClassLoader cl)
throws JogampRuntimeException, RuntimeException
{
try {
@@ -216,7 +216,7 @@ public final class ReflectionUtil {
}
}
- public static final Object createInstance(String clazzName, Object[] cstrArgs, ClassLoader cl)
+ public static final Object createInstance(String clazzName, Object[] cstrArgs, ClassLoader cl)
throws JogampRuntimeException, RuntimeException
{
Class<?>[] cstrArgTypes = null;
@@ -345,24 +345,24 @@ public final class ReflectionUtil {
}
/** Convenient Method access class */
- public static class MethodAccessor {
+ public static class MethodAccessor {
Method m = null;
-
+
/** Check {@link #available()} before using instance. */
public MethodAccessor(Class<?> clazz, String methodName, Class<?> ... argTypes) {
try {
m = ReflectionUtil.getMethod(clazz, methodName, argTypes);
} catch (JogampRuntimeException jre) { /* method n/a */ }
}
-
+
/** Returns true if method is available, otherwise false. */
public boolean available() {
return null != m;
}
-
- /**
+
+ /**
* Check {@link #available()} before calling to avoid throwing a JogampRuntimeException.
- * @throws JogampRuntimeException if method is not available
+ * @throws JogampRuntimeException if method is not available
*/
public Object callMethod(Object instance, Object ... args) {
if(null == m) {
@@ -371,6 +371,6 @@ public final class ReflectionUtil {
return ReflectionUtil.callMethod(instance, m, args);
}
}
-
+
}
diff --git a/src/java/com/jogamp/common/util/Ringbuffer.java b/src/java/com/jogamp/common/util/Ringbuffer.java
index e524768..7faf5dd 100644
--- a/src/java/com/jogamp/common/util/Ringbuffer.java
+++ b/src/java/com/jogamp/common/util/Ringbuffer.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -29,7 +29,7 @@ package com.jogamp.common.util;
import java.io.PrintStream;
-/**
+/**
* Ring buffer interface, a.k.a circular buffer.
* <p>
* Caller can chose whether to block until get / put is able to proceed or not.
@@ -39,26 +39,26 @@ import java.io.PrintStream;
* or using a preset array for circular access of same objects.
* </p>
* <p>
- * Synchronization and hence thread safety details belong to the implementation.
+ * Synchronization and hence thread safety details belong to the implementation.
* </p>
*/
public interface Ringbuffer<T> {
-
- /** Returns a short string representation incl. size/capacity and internal r/w index (impl. dependent). */
+
+ /** Returns a short string representation incl. size/capacity and internal r/w index (impl. dependent). */
public String toString();
/** Debug functionality - Dumps the contents of the internal array. */
public void dump(PrintStream stream, String prefix);
- /**
+ /**
* Returns the internal array as-is, i.e. w/o a copy.
* <p>
* The layout and size of the internal array is implementation dependent.
- * </p>
+ * </p>
* <p>
* Users shall not modify or rely on the returned array.
- * </p>
- * @deprecated This method should not be required
+ * </p>
+ * @deprecated This method should not be required
*/
public T[] getInternalArray();
@@ -66,7 +66,7 @@ public interface Ringbuffer<T> {
public int capacity();
/**
- * Resets the read and write position according to an empty ring buffer
+ * Resets the read and write position according to an empty ring buffer
* and set all ring buffer slots to <code>null</code>.
* <p>
* {@link #isEmpty()} will return <code>true</code> after calling this method.
@@ -75,14 +75,14 @@ public interface Ringbuffer<T> {
public void clear();
/**
- * Resets the read and write position according to a full ring buffer
+ * Resets the read and write position according to a full ring buffer
* and fill all slots w/ elements of array <code>copyFrom</code>.
* <p>
- * Array's <code>copyFrom</code> elements will be copied into the internal array,
+ * Array's <code>copyFrom</code> elements will be copied into the internal array,
* hence it's length must be equal to {@link #capacity()}.
* </p>
* @param copyFrom Mandatory array w/ length {@link #capacity()} to be copied into the internal array.
- * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code>.
+ * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code>.
* @throws IllegalArgumentException if <code>copyFrom</code>'s length is different from {@link #capacity()}.
*/
public void resetFull(T[] copyFrom) throws IllegalArgumentException;
@@ -108,7 +108,7 @@ public interface Ringbuffer<T> {
* <p>
* Method is non blocking and returns immediately;.
* </p>
- * @return the oldest put element if available, otherwise null.
+ * @return the oldest put element if available, otherwise null.
*/
public T get();
@@ -121,24 +121,24 @@ public interface Ringbuffer<T> {
* <p>
* Methods blocks until an element becomes available via put.
* </p>
- * @return the oldest put element
- * @throws InterruptedException
+ * @return the oldest put element
+ * @throws InterruptedException
*/
public T getBlocking() throws InterruptedException;
- /**
+ /**
* Peeks the next element at the read position w/o modifying pointer, nor blocking.
* @return <code>null</code> if empty, otherwise the element which would be read next.
*/
public T peek();
- /**
+ /**
* Peeks the next element at the read position w/o modifying pointer, but w/ blocking.
* @return <code>null</code> if empty, otherwise the element which would be read next.
*/
public T peekBlocking() throws InterruptedException;
- /**
+ /**
* Enqueues the given element.
* <p>
* Returns true if successful, otherwise false in case buffer is full.
@@ -149,16 +149,16 @@ public interface Ringbuffer<T> {
*/
public boolean put(T e);
- /**
+ /**
* Enqueues the given element.
* <p>
* Method blocks until a free slot becomes available via get.
* </p>
- * @throws InterruptedException
+ * @throws InterruptedException
*/
public void putBlocking(T e) throws InterruptedException;
- /**
+ /**
* Enqueues the same element at it's write position, if not full.
* <p>
* Returns true if successful, otherwise false in case buffer is full.
@@ -167,7 +167,7 @@ public interface Ringbuffer<T> {
* If <code>blocking</code> is true, method blocks until a free slot becomes available via get.
* </p>
* @param blocking if true, wait until a free slot becomes available via get.
- * @throws InterruptedException
+ * @throws InterruptedException
*/
public boolean putSame(boolean blocking) throws InterruptedException;
@@ -183,13 +183,13 @@ public interface Ringbuffer<T> {
* Growing an empty ring buffer increases it's size about the amount, i.e. renders it not empty.
* The new elements are inserted at the read position, able to be read out via {@link #get()} etc.
* </p>
- *
+ *
* @param newElements array of new full elements the empty buffer shall grow about.
* @throws IllegalStateException if buffer is not empty
* @throws IllegalArgumentException if newElements is null
*/
public void growEmptyBuffer(T[] newElements) throws IllegalStateException, IllegalArgumentException;
-
+
/**
* Grows a full ring buffer, increasing it's capacity about the amount.
* <p>
@@ -197,7 +197,7 @@ public interface Ringbuffer<T> {
* New <code>null</code> elements are inserted at the write position, able to be written to via {@link #put(Object)} etc.
* </p>
* @param amount the amount of elements the buffer shall grow about
- *
+ *
* @throws IllegalStateException if buffer is not full
* @throws IllegalArgumentException if amount is < 0
*/
diff --git a/src/java/com/jogamp/common/util/RunnableExecutor.java b/src/java/com/jogamp/common/util/RunnableExecutor.java
index 7bf9685..629bc8c 100644
--- a/src/java/com/jogamp/common/util/RunnableExecutor.java
+++ b/src/java/com/jogamp/common/util/RunnableExecutor.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -28,23 +28,23 @@
package com.jogamp.common.util;
public interface RunnableExecutor {
- /** This {@link RunnableExecutor} implementation simply invokes {@link Runnable#run()}
+ /** This {@link RunnableExecutor} implementation simply invokes {@link Runnable#run()}
* on the current thread.
*/
public static final RunnableExecutor currentThreadExecutor = new CurrentThreadExecutor();
-
+
/**
- * @param wait if true method waits until {@link Runnable#run()} is completed, otherwise don't wait.
+ * @param wait if true method waits until {@link Runnable#run()} is completed, otherwise don't wait.
* @param r the {@link Runnable} to be executed.
*/
void invoke(boolean wait, Runnable r);
-
+
static class CurrentThreadExecutor implements RunnableExecutor {
private CurrentThreadExecutor() {}
-
+
@Override
public void invoke(boolean wait, Runnable r) {
- r.run();
- }
+ r.run();
+ }
}
}
diff --git a/src/java/com/jogamp/common/util/RunnableTask.java b/src/java/com/jogamp/common/util/RunnableTask.java
index c18556b..1db4810 100644
--- a/src/java/com/jogamp/common/util/RunnableTask.java
+++ b/src/java/com/jogamp/common/util/RunnableTask.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.common.util;
import java.io.PrintStream;
@@ -39,13 +39,13 @@ public class RunnableTask extends TaskBase {
/**
* Invoks <code>runnable</code>.
- * @param waitUntilDone if <code>true</code>, waits until <code>runnable</code> execution is completed, otherwise returns immediately.
+ * @param waitUntilDone if <code>true</code>, waits until <code>runnable</code> execution is completed, otherwise returns immediately.
* @param runnable the {@link Runnable} to execute.
*/
public static void invoke(boolean waitUntilDone, Runnable runnable) {
Throwable throwable = null;
final Object sync = new Object();
- final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err );
+ final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err );
synchronized(sync) {
rt.run();
if( waitUntilDone ) {
@@ -63,14 +63,14 @@ public class RunnableTask extends TaskBase {
}
}
}
-
+
/**
* Create a RunnableTask object w/ synchronization,
- * ie. suitable for <code>invokeAndWait()</code>, i.e. {@link #invoke(boolean, Runnable) invoke(true, runnable)}.
- *
+ * ie. suitable for <code>invokeAndWait()</code>, i.e. {@link #invoke(boolean, Runnable) invoke(true, runnable)}.
+ *
* @param runnable The user action
* @param syncObject The synchronization object if caller wait until <code>runnable</code> execution is completed,
- * or <code>null</code> if waiting is not desired.
+ * or <code>null</code> if waiting is not desired.
* @param catchExceptions Influence an occurring exception during <code>runnable</code> execution.
* If <code>true</code>, the exception is silenced and can be retrieved via {@link #getThrowable()},
* otherwise the exception is thrown.
@@ -79,7 +79,7 @@ public class RunnableTask extends TaskBase {
public RunnableTask(Runnable runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut) {
super(syncObject, catchExceptions, exceptionOut);
this.runnable = runnable ;
- }
+ }
/** Return the user action */
public final Runnable getRunnable() {
@@ -104,7 +104,7 @@ public class RunnableTask extends TaskBase {
throw new RuntimeException(runnableException);
}
} finally {
- tExecuted = System.currentTimeMillis();
+ tExecuted = System.currentTimeMillis();
}
} else {
synchronized (syncObject) {
@@ -125,7 +125,7 @@ public class RunnableTask extends TaskBase {
syncObject.notifyAll();
}
}
- }
- }
+ }
+ }
}
diff --git a/src/java/com/jogamp/common/util/SecurityUtil.java b/src/java/com/jogamp/common/util/SecurityUtil.java
index 6b35c9c..742de84 100644
--- a/src/java/com/jogamp/common/util/SecurityUtil.java
+++ b/src/java/com/jogamp/common/util/SecurityUtil.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -39,11 +39,11 @@ public class SecurityUtil {
private static final SecurityManager securityManager;
private static final Permission allPermissions;
private static final boolean DEBUG = false;
-
+
static {
allPermissions = new AllPermission();
securityManager = System.getSecurityManager();
-
+
if( DEBUG ) {
final boolean hasAllPermissions;
{
@@ -55,12 +55,12 @@ public class SecurityUtil {
try {
insecPD.implies(allPermissions);
_hasAllPermissions = true;
- } catch( SecurityException ace ) {
+ } catch( SecurityException ace ) {
_hasAllPermissions = false;
}
hasAllPermissions = _hasAllPermissions;
}
-
+
System.err.println("SecurityUtil: Has SecurityManager: "+ ( null != securityManager ) ) ;
System.err.println("SecurityUtil: Has AllPermissions: "+hasAllPermissions);
final Certificate[] certs = AccessController.doPrivileged(new PrivilegedAction<Certificate[]>() {
@@ -75,7 +75,7 @@ public class SecurityUtil {
}
}
}
-
+
/**
* Returns <code>true</code> if no {@link SecurityManager} has been installed
* or the installed {@link SecurityManager}'s <code>checkPermission(new AllPermission())</code>
@@ -84,7 +84,7 @@ public class SecurityUtil {
public static final boolean hasAllPermissions() {
return hasPermission(allPermissions);
}
-
+
/**
* Returns <code>true</code> if no {@link SecurityManager} has been installed
* or the installed {@link SecurityManager}'s <code>checkPermission(perm)</code>
@@ -94,11 +94,11 @@ public class SecurityUtil {
try {
checkPermission(perm);
return true;
- } catch( SecurityException ace ) {
+ } catch( SecurityException ace ) {
return false;
}
}
-
+
/**
* Throws an {@link SecurityException} if an installed {@link SecurityManager}
* does not permit the requested {@link AllPermission}.
@@ -106,7 +106,7 @@ public class SecurityUtil {
public static final void checkAllPermissions() throws SecurityException {
checkPermission(allPermissions);
}
-
+
/**
* Throws an {@link SecurityException} if an installed {@link SecurityManager}
* does not permit the requested {@link Permission}.
@@ -116,7 +116,7 @@ public class SecurityUtil {
securityManager.checkPermission(perm);
}
}
-
+
/**
* Returns <code>true</code> if no {@link SecurityManager} has been installed
* or the installed {@link SecurityManager}'s <code>checkLink(libName)</code>
@@ -126,11 +126,11 @@ public class SecurityUtil {
try {
checkLinkPermission(libName);
return true;
- } catch( SecurityException ace ) {
+ } catch( SecurityException ace ) {
return false;
}
}
-
+
/**
* Throws an {@link SecurityException} if an installed {@link SecurityManager}
* does not permit to dynamically link the given libName.
@@ -140,7 +140,7 @@ public class SecurityUtil {
securityManager.checkLink(libName);
}
}
-
+
/**
* Throws an {@link SecurityException} if an installed {@link SecurityManager}
* does not permit to dynamically link to all libraries.
@@ -151,7 +151,7 @@ public class SecurityUtil {
}
}
private static final RuntimePermission allLinkPermission = new RuntimePermission("loadLibrary.*");
-
+
/**
* @param clz
* @return
@@ -163,7 +163,7 @@ public class SecurityUtil {
final Certificate[] certs = (null != cs) ? cs.getCertificates() : null;
return (null != certs && certs.length>0) ? certs : null;
}
-
+
public static final boolean equals(Certificate[] a, Certificate[] b) {
if(a == b) {
return true;
@@ -174,11 +174,11 @@ public class SecurityUtil {
if(a.length != b.length) {
return false;
}
-
+
int i = 0;
while( i < a.length && a[i].equals(b[i]) ) {
i++;
- }
+ }
return i == a.length;
- }
+ }
}
diff --git a/src/java/com/jogamp/common/util/SyncedRingbuffer.java b/src/java/com/jogamp/common/util/SyncedRingbuffer.java
index 747629b..8ef2970 100644
--- a/src/java/com/jogamp/common/util/SyncedRingbuffer.java
+++ b/src/java/com/jogamp/common/util/SyncedRingbuffer.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -31,7 +31,7 @@ package com.jogamp.common.util;
import java.io.PrintStream;
import java.lang.reflect.Array;
-/**
+/**
* Simple synchronized implementation of {@link Ringbuffer}.
* <p>
* All methods utilize global synchronization.
@@ -56,12 +56,12 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
private int readPos;
private int writePos;
private int size;
-
+
@Override
public final String toString() {
return "SyncedRingbuffer<?>[filled "+size+" / "+capacity+", writePos "+writePos+", readPos "+readPos+"]";
}
-
+
@Override
public final void dump(PrintStream stream, String prefix) {
stream.println(prefix+" "+toString()+" {");
@@ -70,10 +70,10 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
}
stream.println("}");
}
-
- /**
+
+ /**
* Create a full ring buffer instance w/ the given array's net capacity and content.
- * <p>
+ * <p>
* Example for a 10 element Integer array:
* <pre>
* Integer[] source = new Integer[10];
@@ -89,7 +89,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
* and copy all elements from array <code>copyFrom</code> into the internal array.
* </p>
* @param copyFrom mandatory source array determining ring buffer's net {@link #capacity()} and initial content.
- * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code>
+ * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code>
*/
@SuppressWarnings("unchecked")
public SyncedRingbuffer(T[] copyFrom) throws IllegalArgumentException {
@@ -97,10 +97,10 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
array = (T[]) newArray(copyFrom.getClass(), capacity);
resetImpl(true, copyFrom);
}
-
- /**
+
+ /**
* Create an empty ring buffer instance w/ the given net <code>capacity</code>.
- * <p>
+ * <p>
* Example for a 10 element Integer array:
* <pre>
* Ringbuffer<Integer> rb = new SyncedRingbuffer<Integer>(10, Integer[].class);
@@ -120,13 +120,13 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
this.array = (T[]) newArray(arrayType, capacity);
resetImpl(false, null /* empty, nothing to copy */ );
}
-
+
@Override
public final T[] getInternalArray() { return array; }
-
+
@Override
public final int capacity() { return capacity; }
-
+
/**
* {@inheritDoc}
* <p>
@@ -142,12 +142,12 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
}
}
}
-
+
@Override
public final void resetFull(T[] copyFrom) throws IllegalArgumentException {
resetImpl(true, copyFrom);
}
-
+
private final void resetImpl(boolean full, T[] copyFrom) throws IllegalArgumentException {
synchronized ( syncGlobal ) {
if( null != copyFrom ) {
@@ -163,14 +163,14 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
size = full ? capacity : 0;
}
}
-
+
@Override
public final int size() {
synchronized ( syncGlobal ) {
return size;
}
}
-
+
@Override
public final int getFreeSlots() {
synchronized ( syncGlobal ) {
@@ -184,14 +184,14 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
return 0 == size;
}
}
-
+
@Override
public final boolean isFull() {
synchronized ( syncGlobal ) {
return capacity == size;
}
}
-
+
/**
* {@inheritDoc}
* <p>
@@ -215,7 +215,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
public final T getBlocking() throws InterruptedException {
return getImpl(true, false);
}
-
+
@Override
public final T peek() {
try {
@@ -226,9 +226,9 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
public final T peekBlocking() throws InterruptedException {
return getImpl(true, true);
}
-
+
private final T getImpl(boolean blocking, boolean peek) throws InterruptedException {
- synchronized( syncGlobal ) {
+ synchronized( syncGlobal ) {
if( 0 == size ) {
if( blocking ) {
while( 0 == size ) {
@@ -249,8 +249,8 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
return r;
}
}
-
- /**
+
+ /**
* {@inheritDoc}
* <p>
* Implementation stores the element at the current write position and advances it, if not full.
@@ -262,8 +262,8 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
return putImpl(e, false, false);
} catch (InterruptedException ie) { throw new RuntimeException(ie); }
}
-
- /**
+
+ /**
* {@inheritDoc}
* <p>
* Implementation stores the element at the current write position and advances it, if not full.
@@ -275,8 +275,8 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
throw new InternalError("Blocking put failed: "+this);
}
}
-
- /**
+
+ /**
* {@inheritDoc}
* <p>
* Implementation keeps the element at the current write position and advances it, if not full.
@@ -286,9 +286,9 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
public final boolean putSame(boolean blocking) throws InterruptedException {
return putImpl(null, true, blocking);
}
-
+
private final boolean putImpl(T e, boolean sameRef, boolean blocking) throws InterruptedException {
- synchronized( syncGlobal ) {
+ synchronized( syncGlobal ) {
if( capacity == size ) {
if( blocking ) {
while( capacity == size ) {
@@ -308,7 +308,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
return true;
}
}
-
+
@Override
public final void waitForFreeSlots(int count) throws InterruptedException {
synchronized ( syncGlobal ) {
@@ -319,8 +319,8 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
}
}
}
-
-
+
+
@Override
public final void growEmptyBuffer(final T[] newElements) throws IllegalStateException, IllegalArgumentException {
synchronized ( syncGlobal ) {
@@ -340,15 +340,15 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
if( readPos != writePos ) {
throw new InternalError("R/W pos not equal: "+this);
}
-
+
final int growAmount = newElements.length;
final int newCapacity = capacity + growAmount;
final T[] oldArray = array;
final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity);
-
+
// writePos == readPos
writePos += growAmount; // warp writePos to the end of the new data location
-
+
if( readPos > 0 ) {
System.arraycopy(oldArray, 0, newArray, 0, readPos);
}
@@ -360,12 +360,12 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
System.arraycopy(oldArray, readPos, newArray, writePos, tail);
}
size = growAmount;
-
+
capacity = newCapacity;
array = newArray;
}
}
-
+
@Override
public final void growFullBuffer(final int growAmount) throws IllegalStateException, IllegalArgumentException {
synchronized ( syncGlobal ) {
@@ -374,7 +374,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
}
if( capacity != size ) {
throw new IllegalStateException("Buffer is not full: "+this);
- }
+ }
if( readPos != writePos ) {
throw new InternalError("R/W pos not equal: "+this);
}
@@ -384,10 +384,10 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
final int newCapacity = capacity + growAmount;
final T[] oldArray = array;
final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity);
-
+
// writePos == readPos
readPos += growAmount; // warp readPos to the end of the new data location
-
+
if(writePos > 0) {
System.arraycopy(oldArray, 0, newArray, 0, writePos);
}
@@ -395,12 +395,12 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> {
if( tail > 0 ) {
System.arraycopy(oldArray, writePos, newArray, readPos, tail);
}
-
+
capacity = newCapacity;
array = newArray;
}
}
-
+
@SuppressWarnings("unchecked")
private static <T> T[] newArray(Class<? extends T[]> arrayType, int length) {
return ((Object)arrayType == (Object)Object[].class)
diff --git a/src/java/com/jogamp/common/util/TaskBase.java b/src/java/com/jogamp/common/util/TaskBase.java
index 35571e3..e76893d 100644
--- a/src/java/com/jogamp/common/util/TaskBase.java
+++ b/src/java/com/jogamp/common/util/TaskBase.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.common.util;
import java.io.PrintStream;
@@ -39,17 +39,17 @@ import jogamp.common.Debug;
public abstract class TaskBase implements Runnable {
/** Enable via the property <code>jogamp.debug.TaskBase.TraceSource</code> */
private static final boolean TRACE_SOURCE;
-
+
static {
Debug.initSingleton();
TRACE_SOURCE = Debug.isPropertyDefined("jogamp.debug.TaskBase.TraceSource", true);
}
-
+
protected final Object syncObject;
protected final boolean catchExceptions;
- protected final PrintStream exceptionOut;
+ protected final PrintStream exceptionOut;
protected final Throwable sourceStack;
-
+
protected Object attachment;
protected Throwable runnableException;
protected long tCreated, tStarted;
@@ -66,7 +66,7 @@ public abstract class TaskBase implements Runnable {
tExecuted = 0;
isFlushed = false;
}
-
+
protected final String getExceptionOutIntro() {
return catchExceptions ? "A catched" : "An uncatched";
}
@@ -76,25 +76,25 @@ public abstract class TaskBase implements Runnable {
}
}
- /**
+ /**
* Return the synchronization object if any.
- * @see #RunnableTask(Runnable, Object, boolean)
+ * @see #RunnableTask(Runnable, Object, boolean)
*/
public final Object getSyncObject() {
return syncObject;
}
-
- /**
- * Attach a custom object to this task.
- * Useful to piggybag further information, ie tag a task final.
+
+ /**
+ * Attach a custom object to this task.
+ * Useful to piggybag further information, ie tag a task final.
*/
public final void setAttachment(Object o) {
attachment = o;
}
- /**
+ /**
* Return the attachment object if any.
- * @see #setAttachment(Object)
+ * @see #setAttachment(Object)
*/
public final Object getAttachment() {
return attachment;
@@ -102,20 +102,20 @@ public abstract class TaskBase implements Runnable {
@Override
public abstract void run();
-
- /**
+
+ /**
* Simply flush this task and notify a waiting executor.
* The executor which might have been blocked until notified
* will be unblocked and the task removed from the queue.
- *
+ *
* @see #isFlushed()
* @see #isInQueue()
- */
+ */
public final void flush() {
if(!isExecuted() && hasWaiter()) {
synchronized (syncObject) {
isFlushed = true;
- syncObject.notifyAll();
+ syncObject.notifyAll();
}
}
}
@@ -124,7 +124,7 @@ public abstract class TaskBase implements Runnable {
* @return !{@link #isExecuted()} && !{@link #isFlushed()}
*/
public final boolean isInQueue() { return 0 != tExecuted && !isFlushed; }
-
+
/**
* @return True if executed, otherwise false;
*/
@@ -136,7 +136,7 @@ public abstract class TaskBase implements Runnable {
public final boolean isFlushed() { return isFlushed; }
/**
- * @return True if invoking thread waits until done,
+ * @return True if invoking thread waits until done,
* ie a <code>notifyObject</code> was passed, otherwise false;
*/
public final boolean hasWaiter() { return null != syncObject; }
diff --git a/src/java/com/jogamp/common/util/ValueConv.java b/src/java/com/jogamp/common/util/ValueConv.java
index fa49341..9a16b64 100644
--- a/src/java/com/jogamp/common/util/ValueConv.java
+++ b/src/java/com/jogamp/common/util/ValueConv.java
@@ -5,14 +5,14 @@ package com.jogamp.common.util;
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -22,7 +22,7 @@ package com.jogamp.common.util;
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -51,7 +51,7 @@ public class ValueConv {
} else {
return (short) ( v * 65535.0f );
}
- }
+ }
public static final int float_to_int(float v, boolean dSigned) {
// float significand 0x007fffff
// double significand 0x000fffffffffffffL
@@ -63,7 +63,7 @@ public class ValueConv {
return (int) (long) ( v * 4294967295.0 );
}
}
-
+
public static final byte double_to_byte(double v, boolean dSigned) {
// lossy
if( dSigned ) {
@@ -88,27 +88,27 @@ public class ValueConv {
return (int) (long) ( v * 4294967295.0 );
}
}
-
+
public static final float byte_to_float(byte v, boolean sSigned) {
if( sSigned ) {
return (v & 0xff) / ( v > 0 ? 127.0f : -128.0f ) ;
} else {
return (v & 0xff) / 255.0f ;
- }
+ }
}
public static final double byte_to_double(byte v, boolean sSigned) {
if( sSigned ) {
return (v & 0xff) / ( v > 0 ? 127.0 : -128.0 ) ;
} else {
return (v & 0xff) / 255.0 ;
- }
- }
+ }
+ }
public static final float short_to_float(short v, boolean sSigned) {
if( sSigned ) {
return (v & 0xffff) / ( v > 0 ? 32767.0f : -32768.0f ) ;
} else {
return (v & 0xffff) / 65535.0f ;
- }
+ }
}
public static final double short_to_double(short v, boolean sSigned) {
// lossy
@@ -116,8 +116,8 @@ public class ValueConv {
return (v & 0xffff) / ( v > 0 ? 32767.0 : -32768.0 ) ;
} else {
return (v & 0xffff) / 65535.0 ;
- }
- }
+ }
+ }
public static final float int_to_float(int v, boolean sSigned) {
// lossy
// float significand 0x007fffff
@@ -128,30 +128,30 @@ public class ValueConv {
return (float) ( v / ( v > 0 ? 2147483647.0 : 2147483648.0 ) );
} else {
return (float) ( ((long)v & 0xffffffffL) / 4294967295.0 );
- }
+ }
}
public static final double int_to_double(int v, boolean sSigned) {
if( sSigned ) {
return v / ( v > 0 ? 2147483647.0 : 2147483648.0 ) ;
} else {
return ((long)v & 0xffffffffL) / 4294967295.0 ;
- }
+ }
}
-
+
public static final short byte_to_short(byte v, boolean sSigned, boolean dSigned) {
return float_to_short(byte_to_float(v, sSigned), dSigned);
}
public static final int byte_to_int(byte v, boolean sSigned, boolean dSigned) {
return float_to_int(byte_to_float(v, sSigned), dSigned);
}
-
+
public static final byte short_to_byte(short v, boolean sSigned, boolean dSigned) {
return float_to_byte(short_to_float(v, sSigned), dSigned);
}
public static final int short_to_int(short v, boolean sSigned, boolean dSigned) {
return float_to_int(short_to_float(v, sSigned), dSigned);
}
-
+
public static final byte int_to_byte(int v, boolean sSigned, boolean dSigned) {
return float_to_byte(int_to_float(v, sSigned), dSigned);
}
diff --git a/src/java/com/jogamp/common/util/VersionNumber.java b/src/java/com/jogamp/common/util/VersionNumber.java
index b1d8963..addc879 100644
--- a/src/java/com/jogamp/common/util/VersionNumber.java
+++ b/src/java/com/jogamp/common/util/VersionNumber.java
@@ -33,7 +33,7 @@ import java.util.regex.Matcher;
/**
* Simple version number class containing a version number
* either being {@link #VersionNumber(int, int, int) defined explicit}
- * or {@link #VersionNumber(String, String) derived from a string}.
+ * or {@link #VersionNumber(String, String) derived from a string}.
* <p>
* For the latter case, you can query whether a component has been defined explicitly by the given <code>versionString</code>,
* via {@link #hasMajor()}, {@link #hasMinor()} and {@link #hasSub()}.
@@ -46,45 +46,45 @@ import java.util.regex.Matcher;
*/
public class VersionNumber implements Comparable<Object> {
- /**
- * A {@link #isZero() zero} version instance, w/o any component defined explicitly.
+ /**
+ * A {@link #isZero() zero} version instance, w/o any component defined explicitly.
* @see #hasMajor()
* @see #hasMinor()
- * @see #hasSub()
+ * @see #hasSub()
*/
public static final VersionNumber zeroVersion = new VersionNumber(0, 0, 0, -1, (short)0);
-
+
/**
- * Returns the {@link java.util.regex.Pattern pattern}
- * with Perl regular expression:
+ * Returns the {@link java.util.regex.Pattern pattern}
+ * with Perl regular expression:
* <pre>
* "\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+))?)?"
* </pre>
* </p>
* <p>
- * A whitespace within the version number will end the parser.
+ * A whitespace within the version number will end the parser.
* </p>
* <p>
* Capture groups represent the major (1), optional minor (2) and optional sub version number (3) component in this order.
* </p>
* <p>
- * Each capture group ignores any leading non-digit and uses only contiguous digits, i.e. ignores pending non-digits.
+ * Each capture group ignores any leading non-digit and uses only contiguous digits, i.e. ignores pending non-digits.
* </p>
* @param delim the delimiter, e.g. "."
*/
public static java.util.regex.Pattern getVersionNumberPattern(String delim) {
return java.util.regex.Pattern.compile("\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+))?)?");
}
-
+
/**
- * Returns the default {@link java.util.regex.Pattern pattern} using {@link #getVersionNumberPattern(String)}
+ * Returns the default {@link java.util.regex.Pattern pattern} using {@link #getVersionNumberPattern(String)}
* with delimiter "<b>.</b>".
* <p>
* Instance is cached.
- * </p>
- */
+ * </p>
+ */
public static java.util.regex.Pattern getDefaultVersionNumberPattern() {
- if( null == defPattern ) { // volatile dbl-checked-locking OK
+ if( null == defPattern ) { // volatile dbl-checked-locking OK
synchronized( VersionNumber.class ) {
if( null == defPattern ) {
defPattern = getVersionNumberPattern(".");
@@ -96,7 +96,7 @@ public class VersionNumber implements Comparable<Object> {
private static volatile java.util.regex.Pattern defPattern = null;
protected final int major, minor, sub, strEnd;
-
+
protected final short state;
protected final static short HAS_MAJOR = 1 << 0 ;
protected final static short HAS_MINOR = 1 << 1 ;
@@ -109,12 +109,12 @@ public class VersionNumber implements Comparable<Object> {
strEnd = _strEnd;
state = _state;
}
-
- /**
+
+ /**
* Explicit version number instantiation, with all components defined explicitly.
* @see #hasMajor()
* @see #hasMinor()
- * @see #hasSub()
+ * @see #hasSub()
*/
public VersionNumber(int majorRev, int minorRev, int subMinorRev) {
this(majorRev, minorRev, subMinorRev, -1, (short)(HAS_MAJOR | HAS_MINOR | HAS_SUB));
@@ -124,41 +124,41 @@ public class VersionNumber implements Comparable<Object> {
* String derived version number instantiation.
* <p>
* Utilizing the default {@link java.util.regex.Pattern pattern} parser with delimiter "<b>.</b>", see {@link #getDefaultVersionNumberPattern()}.
- * </p>
+ * </p>
* <p>
* You can query whether a component has been defined explicitly by the given <code>versionString</code>,
* via {@link #hasMajor()}, {@link #hasMinor()} and {@link #hasSub()}.
* </p>
* @param versionString should be given as [MAJOR[.MINOR[.SUB]]]
- *
+ *
* @see #hasMajor()
* @see #hasMinor()
- * @see #hasSub()
+ * @see #hasSub()
*/
public VersionNumber(final String versionString) {
this(versionString, getDefaultVersionNumberPattern());
}
-
+
/**
* String derived version number instantiation.
* <p>
* Utilizing {@link java.util.regex.Pattern pattern} parser created via {@link #getVersionNumberPattern(String)}.
- * </p>
+ * </p>
* <p>
* You can query whether a component has been defined explicitly by the given <code>versionString</code>,
* via {@link #hasMajor()}, {@link #hasMinor()} and {@link #hasSub()}.
* </p>
* @param versionString should be given as [MAJOR[.MINOR[.SUB]]]
* @param delim the delimiter, e.g. "."
- *
+ *
* @see #hasMajor()
* @see #hasMinor()
- * @see #hasSub()
+ * @see #hasSub()
*/
public VersionNumber(final String versionString, final String delim) {
this(versionString, getVersionNumberPattern(delim));
}
-
+
/**
* String derived version number instantiation.
* <p>
@@ -167,10 +167,10 @@ public class VersionNumber implements Comparable<Object> {
* </p>
* @param versionString should be given as [MAJOR[.MINOR[.SUB]]]
* @param versionPattern the {@link java.util.regex.Pattern pattern} parser, must be compatible w/ {@link #getVersionNumberPattern(String)}
- *
+ *
* @see #hasMajor()
* @see #hasMinor()
- * @see #hasSub()
+ * @see #hasSub()
*/
public VersionNumber(final String versionString, final java.util.regex.Pattern versionPattern) {
// group1: \d* == digits major
@@ -198,32 +198,32 @@ public class VersionNumber implements Comparable<Object> {
}
}
} catch (Exception e) { }
-
+
major = val[0];
minor = val[1];
sub = val[2];
strEnd = _strEnd;
state = _state;
}
-
- /** Returns <code>true</code>, if all version components are zero, otherwise <code>false</code>. */
+
+ /** Returns <code>true</code>, if all version components are zero, otherwise <code>false</code>. */
public final boolean isZero() {
return major == 0 && minor == 0 && sub == 0;
}
-
+
/** Returns <code>true</code>, if the major component is defined explicitly, otherwise <code>false</code>. Undefined components has the value <code>0</code>. */
- public final boolean hasMajor() { return 0 != ( HAS_MAJOR & state ); }
+ public final boolean hasMajor() { return 0 != ( HAS_MAJOR & state ); }
/** Returns <code>true</code>, if the optional minor component is defined explicitly, otherwise <code>false</code>. Undefined components has the value <code>0</code>. */
public final boolean hasMinor() { return 0 != ( HAS_MINOR & state ); }
/** Returns <code>true</code>, if the optional sub component is defined explicitly, otherwise <code>false</code>. Undefined components has the value <code>0</code>. */
public final boolean hasSub() { return 0 != ( HAS_SUB & state ); }
-
- /**
+
+ /**
* If constructed with <code>version-string</code>, returns the string offset <i>after</i> the last matching character,
* or <code>0</code> if none matched, or <code>-1</code> if not constructed with a string.
*/
public final int endOfStringMatch() { return strEnd; }
-
+
@Override
public final int hashCode() {
// 31 * x == (x << 5) - x
@@ -239,7 +239,7 @@ public class VersionNumber implements Comparable<Object> {
}
return false;
}
-
+
@Override
public final int compareTo(Object o) {
if ( ! ( o instanceof VersionNumber ) ) {
@@ -265,7 +265,7 @@ public class VersionNumber implements Comparable<Object> {
}
return 0;
}
-
+
public final int getMajor() {
return major;
}
diff --git a/src/java/com/jogamp/common/util/VersionNumberString.java b/src/java/com/jogamp/common/util/VersionNumberString.java
index 143d57c..e23300c 100644
--- a/src/java/com/jogamp/common/util/VersionNumberString.java
+++ b/src/java/com/jogamp/common/util/VersionNumberString.java
@@ -34,28 +34,28 @@ package com.jogamp.common.util;
*/
public class VersionNumberString extends VersionNumber {
- /**
- * A {@link #isZero() zero} version instance, w/o any component defined explicitly.
+ /**
+ * A {@link #isZero() zero} version instance, w/o any component defined explicitly.
* @see #hasMajor()
* @see #hasMinor()
- * @see #hasSub()
+ * @see #hasSub()
*/
public static final VersionNumberString zeroVersion = new VersionNumberString(0, 0, 0, -1, (short)0, "n/a");
-
+
protected final String strVal;
protected VersionNumberString(int majorRev, int minorRev, int subMinorRev, int strEnd, short _state, String versionString) {
super(majorRev, minorRev, subMinorRev, strEnd, _state);
strVal = versionString;
}
-
+
/**
* See {@link VersionNumber#VersionNumber(int, int, int)}.
*/
public VersionNumberString(int majorRev, int minorRev, int subMinorRev, String versionString) {
this(majorRev, minorRev, subMinorRev, -1, (short)(HAS_MAJOR | HAS_MINOR | HAS_SUB), versionString);
}
-
+
/**
* See {@link VersionNumber#VersionNumber(String)}.
*/
@@ -63,7 +63,7 @@ public class VersionNumberString extends VersionNumber {
super( versionString);
strVal = versionString;
}
-
+
/**
* See {@link VersionNumber#VersionNumber(String, String)}.
*/
@@ -71,7 +71,7 @@ public class VersionNumberString extends VersionNumber {
super( versionString, delim);
strVal = versionString;
}
-
+
/**
* See {@link VersionNumber#VersionNumber(String, java.util.regex.Pattern)}.
*/
@@ -79,10 +79,10 @@ public class VersionNumberString extends VersionNumber {
super( versionString, versionPattern);
strVal = versionString;
}
-
+
/** Returns the version string this version number is derived from. */
public final String getVersionString() { return strVal; }
-
+
@Override
public String toString() {
return super.toString() + " ("+strVal+")" ;
diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java
index 8030e94..c4451ac 100644
--- a/src/java/com/jogamp/common/util/VersionUtil.java
+++ b/src/java/com/jogamp/common/util/VersionUtil.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.common.util;
import com.jogamp.common.os.AndroidVersion;
@@ -97,16 +97,16 @@ public class VersionUtil {
public static Manifest getManifest(ClassLoader cl, String extension) {
return getManifest(cl, new String[] { extension } );
}
-
+
/**
- * Returns the manifest of the jar which contains one of the specified extensions.
+ * Returns the manifest of the jar which contains one of the specified extensions.
* The provided ClassLoader is used for resource loading.
* @param cl A ClassLoader which should find the manifest.
* @param extensions The values of many 'Extension-Name's jar-manifest attribute; used to identify the manifest.
- * Matching is applied in decreasing order, i.e. first element is favored over the second, etc.
+ * Matching is applied in decreasing order, i.e. first element is favored over the second, etc.
* @return the requested manifest or null when not found.
*/
- public static Manifest getManifest(ClassLoader cl, String[] extensions) {
+ public static Manifest getManifest(ClassLoader cl, String[] extensions) {
final Manifest[] extManifests = new Manifest[extensions.length];
try {
Enumeration<URL> resources = cl.getResources("META-INF/MANIFEST.MF");
diff --git a/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java b/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java
index a43b738..e98478e 100644
--- a/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java
+++ b/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -37,12 +37,12 @@ import com.jogamp.common.util.RunnableExecutor;
*/
public class AWTEDTExecutor implements RunnableExecutor {
/** {@link RunnableExecutor} implementation invoking {@link Runnable#run()}
- * on the AWT EDT.
+ * on the AWT EDT.
*/
public static final AWTEDTExecutor singleton = new AWTEDTExecutor();
private AWTEDTExecutor() {}
-
+
@Override
public void invoke(boolean wait, Runnable r) {
if(EventQueue.isDispatchThread()) {
@@ -76,12 +76,12 @@ public class AWTEDTExecutor implements RunnableExecutor {
* <p>
* Otherwise the runnable is not executed and <code>false</code> is returned.
* </p>
- *
+ *
* @param treeLock representing the AWT-tree-lock, i.e. {@link java.awt.Component#getTreeLock()}
* @param allowOnNonEDT allow execution on non AWT-EDT in case current thread is not AWT-EDT and the tree-lock is being hold
- * @param wait if true method waits until {@link Runnable#run()} is completed, otherwise don't wait.
+ * @param wait if true method waits until {@link Runnable#run()} is completed, otherwise don't wait.
* @param r the {@link Runnable} to be executed.
- * @return <code>true</code> if the {@link Runnable} has been issued for execution, otherwise <code>false</code>
+ * @return <code>true</code> if the {@link Runnable} has been issued for execution, otherwise <code>false</code>
*/
public boolean invoke(Object treeLock, boolean allowOnNonEDT, boolean wait, Runnable r) {
if( EventQueue.isDispatchThread() ) {
@@ -93,7 +93,7 @@ public class AWTEDTExecutor implements RunnableExecutor {
EventQueue.invokeAndWait(r);
} else {
EventQueue.invokeLater(r);
- }
+ }
} catch (InvocationTargetException e) {
throw new RuntimeException(e.getTargetException());
} catch (InterruptedException e) {
diff --git a/src/java/com/jogamp/common/util/cache/TempFileCache.java b/src/java/com/jogamp/common/util/cache/TempFileCache.java
index 32f5c2a..5898d50 100644
--- a/src/java/com/jogamp/common/util/cache/TempFileCache.java
+++ b/src/java/com/jogamp/common/util/cache/TempFileCache.java
@@ -43,9 +43,9 @@ public class TempFileCache {
// Flag indicating that we got a fatal error in the static initializer.
private static boolean staticInitError = false;
-
+
private static final String tmpDirPrefix = "file_cache";
-
+
// Lifecycle: For one user's JVMs, ClassLoader and time.
private static final File tmpBaseDir;
@@ -71,12 +71,12 @@ public class TempFileCache {
static {
// Global Lock !
- synchronized (System.out) {
+ synchronized (System.out) {
// Create / initialize the temp root directory, starting the Reaper
// thread to reclaim old installations if necessary. If we get an
// exception, set an error code.
File _tmpBaseDir = null;
- try {
+ try {
_tmpBaseDir = new File(IOUtil.getTempDir(true /* executable */), tmpDirPrefix);
_tmpBaseDir = IOUtil.testDir(_tmpBaseDir, true /* create */, false /* executable */); // executable already checked
} catch (Exception ex) {
@@ -85,12 +85,12 @@ public class TempFileCache {
staticInitError = true;
}
tmpBaseDir = _tmpBaseDir;
-
+
if (DEBUG) {
System.err.println("TempFileCache: Static Initialization ---------------------------------------------- OK: "+(!staticInitError));
System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(TempFileCache.class.getClassLoader().hashCode())+", tempBaseDir "+tmpBaseDir.getAbsolutePath());
}
-
+
if(!staticInitError) {
try {
initTmpRoot();
@@ -105,15 +105,15 @@ public class TempFileCache {
}
}
}
-
+
/**
* Documented way to kick off static initialization
* @return true is static initialization was successful
*/
public static boolean initSingleton() {
- return !staticInitError;
+ return !staticInitError;
}
-
+
/**
* This method is called by the static initializer to create / initialize
* the temp root directory that will hold the temp directories for this
@@ -197,7 +197,7 @@ public class TempFileCache {
System.clearProperty(tmpRootPropName);
}
}
-
+
if (tmpRootPropValue == null) {
// Create ${tmpbase}/jlnNNNN.tmp then lock the file
File tmpFile = File.createTempFile("jln", ".tmp", tmpBaseDir);
@@ -413,7 +413,7 @@ public class TempFileCache {
System.err.println("TempFileCache: new TempFileCache() --------------------- (static ok: "+(!staticInitError)+")");
System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(TempFileCache.class.getClassLoader().hashCode())+", this 0x"+Integer.toHexString(hashCode()));
}
- if(!staticInitError) {
+ if(!staticInitError) {
try {
createTmpDir();
} catch (Exception ex) {
@@ -424,16 +424,16 @@ public class TempFileCache {
if (DEBUG) {
System.err.println("TempFileCache: tempDir "+individualTmpDir+" (ok: "+(!initError)+")");
System.err.println("----------------------------------------------------------");
- }
+ }
}
-
+
/** Delete the <code>individualTmpDir</code> recursively and remove it's reference. */
public void destroy() {
if (DEBUG) {
System.err.println("TempFileCache: destroy() --------------------- (static ok: "+(!staticInitError)+")");
System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(TempFileCache.class.getClassLoader().hashCode())+", this 0x"+Integer.toHexString(hashCode()));
}
- if(!staticInitError) {
+ if(!staticInitError) {
try {
removeAll(individualTmpDir);
} catch (Exception ex) {
@@ -443,26 +443,26 @@ public class TempFileCache {
individualTmpDir = null;
if (DEBUG) {
System.err.println("TempFileCache: destroy() END");
- }
+ }
}
-
+
/**
* @return true is static and object initialization was successful
*/
public boolean isValid() { return !staticInitError && !initError; }
-
+
/**
* Base temp directory used by TempFileCache.
- *
- * <p>
+ *
+ * <p>
* Lifecycle: For one user's JVMs, ClassLoader and time.
* </p>
- *
+ *
* This is set to:
* <pre>
* ${java.io.tmpdir}/tmpDirPrefix
* </pre>
- *
+ *
* @return
*/
public File getBaseDir() { return tmpBaseDir; }
@@ -481,18 +481,18 @@ public class TempFileCache {
*
* <p>
* Use Case: Per ClassLoader files, eg. native libraries.
- * </p>
+ * </p>
*
* <p>
* Old temp directories are cleaned up the next time a JVM is launched that
* uses TempFileCache.
* </p>
*
- *
+ *
* @return
*/
public File getRootDir() { return tmpRootDir; }
-
+
/**
* Temporary directory for individual files (eg. native libraries of one ClassLoader instance).
* The directory name is:
@@ -508,12 +508,12 @@ public class TempFileCache {
* where jlnMMMMM is the unique filename created by File.createTempFile()
* without the ".tmp" extension.
*
- *
+ *
* @return
*/
public File getTempDir() { return individualTmpDir; }
-
-
+
+
/**
* Create the temp directory in tmpRootDir. To do this, we create a temp
* file with a ".tmp" extension, and then create a directory of the
diff --git a/src/java/com/jogamp/common/util/cache/TempJarCache.java b/src/java/com/jogamp/common/util/cache/TempJarCache.java
index ecf6e56..48d8081 100644
--- a/src/java/com/jogamp/common/util/cache/TempJarCache.java
+++ b/src/java/com/jogamp/common/util/cache/TempJarCache.java
@@ -45,7 +45,7 @@ import com.jogamp.common.util.SecurityUtil;
public class TempJarCache {
private static final boolean DEBUG = Debug.debug("TempJarCache");
-
+
// A HashMap of native libraries that can be loaded with System.load()
// The key is the string name of the library as passed into the loadLibrary
// call; it is the file name without the directory or the platform-dependent
@@ -55,8 +55,8 @@ public class TempJarCache {
public enum LoadState {
LOOKED_UP, LOADED;
-
- public boolean compliesWith(LoadState o2) {
+
+ public boolean compliesWith(LoadState o2) {
return null != o2 ? compareTo(o2) >= 0 : false;
}
}
@@ -66,20 +66,20 @@ public class TempJarCache {
}
return has.compliesWith(exp);
}
-
+
// Set of jar files added
private static Map<URI, LoadState> nativeLibJars;
private static Map<URI, LoadState> classFileJars;
private static Map<URI, LoadState> resourceFileJars;
private static TempFileCache tmpFileCache;
-
+
private static boolean staticInitError = false;
private static volatile boolean isInit = false;
-
+
/**
* Documented way to kick off static initialization.
- *
+ *
* @return true is static initialization was successful
*/
public static boolean initSingleton() {
@@ -88,12 +88,12 @@ public class TempJarCache {
if (!isInit) {
isInit = true;
staticInitError = !TempFileCache.initSingleton();
-
+
if(!staticInitError) {
tmpFileCache = new TempFileCache();
- staticInitError = !tmpFileCache.isValid();
+ staticInitError = !tmpFileCache.isValid();
}
-
+
if(!staticInitError) {
// Initialize the collections of resources
nativeLibMap = new HashMap<String, String>();
@@ -109,20 +109,20 @@ public class TempJarCache {
}
return !staticInitError;
}
-
+
/**
* This is <b>not recommended</b> since the JNI libraries may still be
* in use by the ClassLoader they are loaded via {@link System#load(String)}.
* </p>
* <p>
- * In JogAmp, JNI native libraries loaded and registered by {@link JNILibLoaderBase}
- * derivations, where the native JARs might be loaded via {@link JNILibLoaderBase#addNativeJarLibs(Class, String) }.
+ * In JogAmp, JNI native libraries loaded and registered by {@link JNILibLoaderBase}
+ * derivations, where the native JARs might be loaded via {@link JNILibLoaderBase#addNativeJarLibs(Class, String) }.
* </p>
* <p>
* The only valid use case to shutdown the TempJarCache is at bootstrapping,
* i.e. when no native library is guaranteed to be loaded. This could be useful
* if bootstrapping needs to find the proper native library type.
- * </p>
+ * </p>
*
public static void shutdown() {
if (isInit) { // volatile: ok
@@ -141,7 +141,7 @@ public class TempJarCache {
classFileJars = null;
resourceFileJars.clear();
resourceFileJars = null;
-
+
tmpFileCache.destroy();
tmpFileCache = null;
}
@@ -149,32 +149,32 @@ public class TempJarCache {
}
}
} */
-
+
/**
* @return true if this class has been properly initialized, ie. is in use, otherwise false.
*/
public static boolean isInitialized() {
return isInit && !staticInitError;
}
-
+
/* package */ static void checkInitialized() {
if(!isInit) {
throw new RuntimeException("initSingleton() has to be called first.");
}
}
-
+
public static TempFileCache getTempFileCache() {
checkInitialized();
return tmpFileCache;
}
-
+
public synchronized static boolean checkNativeLibs(URI jarURI, LoadState exp) throws IOException {
checkInitialized();
if(null == jarURI) {
throw new IllegalArgumentException("jarURI is null");
}
return testLoadState(nativeLibJars.get(jarURI), exp);
- }
+ }
public synchronized static boolean checkClasses(URI jarURI, LoadState exp) throws IOException {
checkInitialized();
@@ -182,7 +182,7 @@ public class TempJarCache {
throw new IllegalArgumentException("jarURI is null");
}
return testLoadState(classFileJars.get(jarURI), exp);
- }
+ }
public synchronized static boolean checkResources(URI jarURI, LoadState exp) throws IOException {
checkInitialized();
@@ -191,29 +191,29 @@ public class TempJarCache {
}
return testLoadState(resourceFileJars.get(jarURI), exp);
}
-
+
/**
* Adds native libraries, if not yet added.
- *
- * @param certClass if class is certified, the JarFile entries needs to have the same certificate
+ *
+ * @param certClass if class is certified, the JarFile entries needs to have the same certificate
* @param jarURI
* @param nativeLibraryPath if not null, only extracts native libraries within this path.
* @return true if native libraries were added or previously loaded from given jarURI, otherwise false
* @throws IOException if the <code>jarURI</code> could not be loaded or a previous load attempt failed
* @throws SecurityException
- * @throws URISyntaxException
- * @throws IllegalArgumentException
+ * @throws URISyntaxException
+ * @throws IllegalArgumentException
*/
- public synchronized static final boolean addNativeLibs(Class<?> certClass, URI jarURI, String nativeLibraryPath) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
+ public synchronized static final boolean addNativeLibs(Class<?> certClass, URI jarURI, String nativeLibraryPath) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
final LoadState nativeLibJarsLS = nativeLibJars.get(jarURI);
- if( !testLoadState(nativeLibJarsLS, LoadState.LOOKED_UP) ) {
+ if( !testLoadState(nativeLibJarsLS, LoadState.LOOKED_UP) ) {
nativeLibJars.put(jarURI, LoadState.LOOKED_UP);
final JarFile jarFile = JarUtil.getJarFile(jarURI);
if(DEBUG) {
System.err.println("TempJarCache: addNativeLibs: "+jarURI+": nativeJar "+jarFile.getName()+" (NEW)");
}
validateCertificates(certClass, jarFile);
- final int num = JarUtil.extract(tmpFileCache.getTempDir(), nativeLibMap, jarFile, nativeLibraryPath, true, false, false);
+ final int num = JarUtil.extract(tmpFileCache.getTempDir(), nativeLibMap, jarFile, nativeLibraryPath, true, false, false);
nativeLibJars.put(jarURI, LoadState.LOADED);
return num > 0;
} else if( testLoadState(nativeLibJarsLS, LoadState.LOADED) ) {
@@ -224,78 +224,78 @@ public class TempJarCache {
}
throw new IOException("TempJarCache: addNativeLibs: "+jarURI+", previous load attempt failed");
}
-
+
/**
* Adds native classes, if not yet added.
- *
+ *
* TODO class access pending
* needs Classloader.defineClass(..) access, ie. own derivation - will do when needed ..
- *
- * @param certClass if class is certified, the JarFile entries needs to have the same certificate
+ *
+ * @param certClass if class is certified, the JarFile entries needs to have the same certificate
* @param jarURI
* @throws IOException if the <code>jarURI</code> could not be loaded or a previous load attempt failed
* @throws SecurityException
- * @throws URISyntaxException
- * @throws IllegalArgumentException
+ * @throws URISyntaxException
+ * @throws IllegalArgumentException
*/
public synchronized static final void addClasses(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
final LoadState classFileJarsLS = classFileJars.get(jarURI);
- if( !testLoadState(classFileJarsLS, LoadState.LOOKED_UP) ) {
+ if( !testLoadState(classFileJarsLS, LoadState.LOOKED_UP) ) {
classFileJars.put(jarURI, LoadState.LOOKED_UP);
final JarFile jarFile = JarUtil.getJarFile(jarURI);
if(DEBUG) {
System.err.println("TempJarCache: addClasses: "+jarURI+": nativeJar "+jarFile.getName());
}
validateCertificates(certClass, jarFile);
- JarUtil.extract(tmpFileCache.getTempDir(), null, jarFile,
- null /* nativeLibraryPath */, false, true, false);
+ JarUtil.extract(tmpFileCache.getTempDir(), null, jarFile,
+ null /* nativeLibraryPath */, false, true, false);
classFileJars.put(jarURI, LoadState.LOADED);
} else if( !testLoadState(classFileJarsLS, LoadState.LOADED) ) {
throw new IOException("TempJarCache: addClasses: "+jarURI+", previous load attempt failed");
}
}
-
+
/**
* Adds native resources, if not yet added.
- *
- * @param certClass if class is certified, the JarFile entries needs to have the same certificate
+ *
+ * @param certClass if class is certified, the JarFile entries needs to have the same certificate
* @param jarURI
* @return
* @throws IOException if the <code>jarURI</code> could not be loaded or a previous load attempt failed
* @throws SecurityException
- * @throws URISyntaxException
- * @throws IllegalArgumentException
+ * @throws URISyntaxException
+ * @throws IllegalArgumentException
*/
- public synchronized static final void addResources(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
+ public synchronized static final void addResources(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
final LoadState resourceFileJarsLS = resourceFileJars.get(jarURI);
- if( !testLoadState(resourceFileJarsLS, LoadState.LOOKED_UP) ) {
+ if( !testLoadState(resourceFileJarsLS, LoadState.LOOKED_UP) ) {
resourceFileJars.put(jarURI, LoadState.LOOKED_UP);
final JarFile jarFile = JarUtil.getJarFile(jarURI);
if(DEBUG) {
System.err.println("TempJarCache: addResources: "+jarURI+": nativeJar "+jarFile.getName());
}
validateCertificates(certClass, jarFile);
- JarUtil.extract(tmpFileCache.getTempDir(), null, jarFile,
- null /* nativeLibraryPath */, false, false, true);
+ JarUtil.extract(tmpFileCache.getTempDir(), null, jarFile,
+ null /* nativeLibraryPath */, false, false, true);
resourceFileJars.put(jarURI, LoadState.LOADED);
} else if( !testLoadState(resourceFileJarsLS, LoadState.LOADED) ) {
throw new IOException("TempJarCache: addResources: "+jarURI+", previous load attempt failed");
}
}
-
+
/**
* Adds all types, native libraries, class files and other files (resources)
* if not yet added.
- *
+ *
* TODO class access pending
* needs Classloader.defineClass(..) access, ie. own derivation - will do when needed ..
- *
- * @param certClass if class is certified, the JarFile entries needs to have the same certificate
+ *
+ * @param certClass if class is certified, the JarFile entries needs to have the same certificate
* @param jarURI
* @throws IOException if the <code>jarURI</code> could not be loaded or a previous load attempt failed
* @throws SecurityException
- * @throws URISyntaxException
- * @throws IllegalArgumentException
+ * @throws URISyntaxException
+ * @throws IllegalArgumentException
*/
public synchronized static final void addAll(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
checkInitialized();
@@ -305,14 +305,14 @@ public class TempJarCache {
final LoadState nativeLibJarsLS = nativeLibJars.get(jarURI);
final LoadState classFileJarsLS = classFileJars.get(jarURI);
final LoadState resourceFileJarsLS = resourceFileJars.get(jarURI);
- if( !testLoadState(nativeLibJarsLS, LoadState.LOOKED_UP) ||
- !testLoadState(classFileJarsLS, LoadState.LOOKED_UP) ||
+ if( !testLoadState(nativeLibJarsLS, LoadState.LOOKED_UP) ||
+ !testLoadState(classFileJarsLS, LoadState.LOOKED_UP) ||
!testLoadState(resourceFileJarsLS, LoadState.LOOKED_UP) ) {
-
+
final boolean extractNativeLibraries = !testLoadState(nativeLibJarsLS, LoadState.LOADED);
final boolean extractClassFiles = !testLoadState(classFileJarsLS, LoadState.LOADED);
final boolean extractOtherFiles = !testLoadState(resourceFileJarsLS, LoadState.LOOKED_UP);
-
+
// mark looked-up (those who are not loaded)
if(extractNativeLibraries) {
nativeLibJars.put(jarURI, LoadState.LOOKED_UP);
@@ -323,15 +323,15 @@ public class TempJarCache {
if(extractOtherFiles) {
resourceFileJars.put(jarURI, LoadState.LOOKED_UP);
}
-
+
final JarFile jarFile = JarUtil.getJarFile(jarURI);
if(DEBUG) {
System.err.println("TempJarCache: addAll: "+jarURI+": nativeJar "+jarFile.getName());
}
validateCertificates(certClass, jarFile);
- JarUtil.extract(tmpFileCache.getTempDir(), nativeLibMap, jarFile,
+ JarUtil.extract(tmpFileCache.getTempDir(), nativeLibMap, jarFile,
null /* nativeLibraryPath */, extractNativeLibraries, extractClassFiles, extractOtherFiles);
-
+
// mark loaded (those were just loaded)
if(extractNativeLibraries) {
nativeLibJars.put(jarURI, LoadState.LOADED);
@@ -342,20 +342,20 @@ public class TempJarCache {
if(extractOtherFiles) {
resourceFileJars.put(jarURI, LoadState.LOADED);
}
- } else if( !testLoadState(nativeLibJarsLS, LoadState.LOADED) ||
- !testLoadState(classFileJarsLS, LoadState.LOADED) ||
+ } else if( !testLoadState(nativeLibJarsLS, LoadState.LOADED) ||
+ !testLoadState(classFileJarsLS, LoadState.LOADED) ||
!testLoadState(resourceFileJarsLS, LoadState.LOADED) ) {
- throw new IOException("TempJarCache: addAll: "+jarURI+", previous load attempt failed");
+ throw new IOException("TempJarCache: addAll: "+jarURI+", previous load attempt failed");
}
}
-
+
public synchronized static final String findLibrary(String libName) {
checkInitialized();
// try with mapped library basename first
String path = nativeLibMap.get(libName);
if(null == path) {
// if valid library name, try absolute path in temp-dir
- if(null != NativeLibrary.isValidNativeLibraryName(libName, false)) {
+ if(null != NativeLibrary.isValidNativeLibraryName(libName, false)) {
final File f = new File(tmpFileCache.getTempDir(), libName);
if(f.exists()) {
path = f.getAbsolutePath();
@@ -364,9 +364,9 @@ public class TempJarCache {
}
return path;
}
-
+
/** TODO class access pending
- * needs Classloader.defineClass(..) access, ie. own derivation - will do when needed ..
+ * needs Classloader.defineClass(..) access, ie. own derivation - will do when needed ..
public static Class<?> findClass(String name, ClassLoader cl) throws IOException, ClassFormatError {
checkInitialized();
final File f = new File(nativeTmpFileCache.getTempDir(), IOUtil.getClassFileName(name));
@@ -379,7 +379,7 @@ public class TempJarCache {
}
return null;
} */
-
+
public synchronized static final String findResource(String name) {
checkInitialized();
final File f = new File(tmpFileCache.getTempDir(), name);
@@ -388,7 +388,7 @@ public class TempJarCache {
}
return null;
}
-
+
public synchronized static final URI getResource(String name) throws URISyntaxException {
checkInitialized();
final File f = new File(tmpFileCache.getTempDir(), name);
@@ -397,7 +397,7 @@ public class TempJarCache {
}
return null;
}
-
+
private static void validateCertificates(Class<?> certClass, JarFile jarFile) throws IOException, SecurityException {
if(null == certClass) {
throw new IllegalArgumentException("certClass is null");
@@ -411,9 +411,9 @@ public class TempJarCache {
JarUtil.validateCertificates(rootCerts, jarFile);
if(DEBUG) {
System.err.println("TempJarCache: validateCertificates: OK - Matching rootCerts in given class "+certClass.getName()+", nativeJar "+jarFile.getName());
- }
+ }
} else if(DEBUG) {
System.err.println("TempJarCache: validateCertificates: OK - No rootCerts in given class "+certClass.getName()+", nativeJar "+jarFile.getName());
}
- }
+ }
}
diff --git a/src/java/com/jogamp/common/util/locks/Lock.java b/src/java/com/jogamp/common/util/locks/Lock.java
index df645ed..5130876 100644
--- a/src/java/com/jogamp/common/util/locks/Lock.java
+++ b/src/java/com/jogamp/common/util/locks/Lock.java
@@ -43,8 +43,8 @@ public interface Lock {
/** The default {@link #TIMEOUT} value, of {@value} ms */
public static final long DEFAULT_TIMEOUT = 5000; // 5s default timeout
-
- /**
+
+ /**
* The <code>TIMEOUT</code> for {@link #lock()} in ms,
* defaults to {@link #DEFAULT_TIMEOUT}.
* <p>
@@ -78,7 +78,7 @@ public interface Lock {
* @throws RuntimeException in case the lock is not acquired by this thread.
*/
void unlock() throws RuntimeException;
-
+
/** Query if locked */
boolean isLocked();
}
diff --git a/src/java/com/jogamp/common/util/locks/LockFactory.java b/src/java/com/jogamp/common/util/locks/LockFactory.java
index bb2d5f4..e1ec2d7 100644
--- a/src/java/com/jogamp/common/util/locks/LockFactory.java
+++ b/src/java/com/jogamp/common/util/locks/LockFactory.java
@@ -35,25 +35,25 @@ import jogamp.common.util.locks.RecursiveThreadGroupLockImpl01Unfairish;
public class LockFactory {
public enum ImplType {
- Int01(0), Java5(1), Int02ThreadGroup(2);
-
+ Int01(0), Java5(1), Int02ThreadGroup(2);
+
public final int id;
ImplType(int id){
this.id = id;
}
- }
-
+ }
+
/** default is ImplType.Int01, unfair'ish (fastest w/ least deviation) */
public static RecursiveLock createRecursiveLock() {
return new RecursiveLockImpl01Unfairish();
}
-
+
/** default is ImplType.Int02ThreadGroup, unfair'ish (fastest w/ least deviation) */
public static RecursiveThreadGroupLock createRecursiveThreadGroupLock() {
return new RecursiveThreadGroupLockImpl01Unfairish();
}
-
+
public static RecursiveLock createRecursiveLock(ImplType t, boolean fair) {
switch(t) {
case Int01:
@@ -65,5 +65,5 @@ public class LockFactory {
}
throw new InternalError("XXX");
}
-
+
}
diff --git a/src/java/com/jogamp/common/util/locks/RecursiveLock.java b/src/java/com/jogamp/common/util/locks/RecursiveLock.java
index 3e0a873..c56a5ef 100644
--- a/src/java/com/jogamp/common/util/locks/RecursiveLock.java
+++ b/src/java/com/jogamp/common/util/locks/RecursiveLock.java
@@ -32,7 +32,7 @@ package com.jogamp.common.util.locks;
* Reentrance capable locking toolkit.
*/
public interface RecursiveLock extends ThreadLock {
- /**
+ /**
* Return the number of locks issued to this lock by the same thread.
* <ul>
* <li>A hold count of 0 identifies this lock as unlocked.</li>
diff --git a/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java b/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java
index 626199f..a23c320 100644
--- a/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java
+++ b/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java
@@ -34,67 +34,67 @@ package com.jogamp.common.util.locks;
* </p>
*/
public interface RecursiveThreadGroupLock extends RecursiveLock {
- /**
- * Returns true if the current thread is the original lock owner, ie.
+ /**
+ * Returns true if the current thread is the original lock owner, ie.
* successfully claimed this lock the first time, ie. {@link #getHoldCount()} == 1.
*/
boolean isOriginalOwner();
-
- /**
- * Returns true if the passed thread is the original lock owner, ie.
+
+ /**
+ * Returns true if the passed thread is the original lock owner, ie.
* successfully claimed this lock the first time, ie. {@link #getHoldCount()} == 1.
*/
boolean isOriginalOwner(Thread thread);
-
- /**
+
+ /**
* Add a thread to the list of additional lock owners, which enables them to recursively claim this lock.
* <p>
* The caller must hold this lock and be the original lock owner, see {@link #isOriginalOwner()}.
* </p>
* <p>
- * If the original owner releases this lock via {@link #unlock()}
+ * If the original owner releases this lock via {@link #unlock()}
* all additional lock owners are released as well.
* This ensures consistency of spawn off additional lock owner threads and it's release.
- * </p>
+ * </p>
* Use case:
* <pre>
* Thread2 thread2 = new Thread2();
- *
+ *
* Thread1 {
- *
+ *
* // Claim this lock and become the original lock owner.
* lock.lock();
- *
+ *
* try {
- *
+ *
* // Allow Thread2 to claim the lock, ie. make thread2 an additional lock owner
* addOwner(thread2);
- *
+ *
* // Start thread2
* thread2.start();
- *
+ *
* // Wait until thread2 has finished requiring this lock, but keep thread2 running
- * while(!thread2.waitForResult()) sleep();
- *
+ * while(!thread2.waitForResult()) sleep();
+ *
* // Optional: Only if sure that this thread doesn't hold the lock anymore,
- * // otherwise just release the lock via unlock().
+ * // otherwise just release the lock via unlock().
* removeOwner(thread2);
- *
+ *
* } finally {
- *
+ *
* // Release this lock and remove all additional lock owners.
* // Implicit wait until thread2 gets off the lock.
* lock.unlock();
- *
+ *
* }
- *
+ *
* }.start();
* </pre>
- *
- * @param t the thread to be added to the list of additional owning threads
+ *
+ * @param t the thread to be added to the list of additional owning threads
* @throws RuntimeException if the current thread does not hold the lock.
* @throws IllegalArgumentException if the passed thread is the lock owner or already added.
- *
+ *
* @see #removeOwner(Thread)
* @see #unlock()
* @see #lock()
@@ -109,31 +109,31 @@ public interface RecursiveThreadGroupLock extends RecursiveLock {
* <p>
* Only use this method if sure that the thread doesn't hold the lock anymore.
* </p>
- *
- * @param t the thread to be removed from the list of additional owning threads
+ *
+ * @param t the thread to be removed from the list of additional owning threads
* @throws RuntimeException if the current thread does not hold the lock.
* @throws IllegalArgumentException if the passed thread is not added by {@link #addOwner(Thread)}
*/
void removeOwner(Thread t) throws RuntimeException, IllegalArgumentException;
-
+
/**
* <p>
* Wait's until all additional owners released this lock before releasing it.
* </p>
- *
+ *
* {@inheritDoc}
*/
@Override
void unlock() throws RuntimeException;
-
+
/**
* <p>
* Wait's until all additional owners released this lock before releasing it.
* </p>
- *
+ *
* {@inheritDoc}
*/
@Override
- void unlock(Runnable taskAfterUnlockBeforeNotify);
-
+ void unlock(Runnable taskAfterUnlockBeforeNotify);
+
}
diff --git a/src/java/com/jogamp/common/util/locks/SingletonInstance.java b/src/java/com/jogamp/common/util/locks/SingletonInstance.java
index 825098d..f016d4b 100644
--- a/src/java/com/jogamp/common/util/locks/SingletonInstance.java
+++ b/src/java/com/jogamp/common/util/locks/SingletonInstance.java
@@ -44,7 +44,7 @@ public abstract class SingletonInstance implements Lock {
public static SingletonInstance createFileLock(long poll_ms, File lockFile) {
return new SingletonInstanceFileLock(poll_ms, lockFile);
}
-
+
/**
* A user shall use <b>ephemeral ports</b>:
* <ul>
@@ -54,23 +54,23 @@ public abstract class SingletonInstance implements Lock {
* <li>FreeBSD < 4.6 and BSD use ports 1024 through 4999.</li>
* <li>Microsoft Windows operating systems through Server 2003 use the range 1025 to 5000</li>
* <li>Windows Vista, Windows 7, and Server 2008 use the IANA range.</li>
- * </ul>
+ * </ul>
* @param pollPeriod
- * @param portNumber to be used for this single instance server socket.
+ * @param portNumber to be used for this single instance server socket.
*/
public static SingletonInstance createServerSocket(long poll_ms, int portNumber) {
return new SingletonInstanceServerSocket(poll_ms, portNumber);
}
-
+
protected SingletonInstance(long poll_ms) {
this.poll_ms = Math.max(10, poll_ms);
}
-
+
public final long getPollPeriod() { return poll_ms; }
public abstract String getName();
@Override
public final String toString() { return getName(); }
-
+
@Override
public synchronized void lock() throws RuntimeException {
try {
@@ -99,7 +99,7 @@ public abstract class SingletonInstance implements Lock {
if( DEBUG ) {
final long t2 = System.currentTimeMillis();
System.err.println(infoPrefix(t2)+" +++ "+getName()+" - Locked within "+(t2-t0)+" ms, "+(i+1)+" attempts");
- }
+ }
return true;
}
if( DEBUG && 0==i ) {
@@ -118,9 +118,9 @@ public abstract class SingletonInstance implements Lock {
System.err.println(infoPrefix(t2)+" +++ EEE (2) "+getName()+" - couldn't get lock within "+(t2-t0)+" ms, "+i+" attempts");
}
return false;
- }
+ }
protected abstract boolean tryLockImpl();
-
+
@Override
public void unlock() throws RuntimeException {
final long t0 = System.currentTimeMillis();
@@ -145,7 +145,7 @@ public abstract class SingletonInstance implements Lock {
protected String infoPrefix() {
return infoPrefix(System.currentTimeMillis());
}
-
+
private final long poll_ms;
private boolean locked = false;
}
diff --git a/src/java/com/jogamp/common/util/locks/ThreadLock.java b/src/java/com/jogamp/common/util/locks/ThreadLock.java
index 65260bc..26e7475 100644
--- a/src/java/com/jogamp/common/util/locks/ThreadLock.java
+++ b/src/java/com/jogamp/common/util/locks/ThreadLock.java
@@ -33,27 +33,27 @@ package com.jogamp.common.util.locks;
*/
public interface ThreadLock extends Lock {
- /** Query whether the lock is hold by the a thread other than the current thread. */
+ /** Query whether the lock is hold by the a thread other than the current thread. */
boolean isLockedByOtherThread();
- /** Query whether the lock is hold by the given thread. */
+ /** Query whether the lock is hold by the given thread. */
boolean isOwner(Thread thread);
-
+
/**
* @return the Thread owning this lock if locked, otherwise null
*/
Thread getOwner();
/**
- * @throws RuntimeException if current thread does not hold the lock
+ * @throws RuntimeException if current thread does not hold the lock
*/
void validateLocked() throws RuntimeException;
-
+
/**
* Execute the {@link Runnable Runnable taskAfterUnlockBeforeNotify} while holding the exclusive lock.
* <p>
* Then release the lock.
- * </p>
+ * </p>
*/
- void unlock(Runnable taskAfterUnlockBeforeNotify);
+ void unlock(Runnable taskAfterUnlockBeforeNotify);
}