sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1585793 - in /sis/branches/JDK8: core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-utility/src/main/java/org/apache/sis/math/ core/sis-utility/src/main/java/org/apache/sis/measure/ core/sis-utility/src/main/java/org/apache/...
Date Tue, 08 Apr 2014 17:47:08 GMT
Author: desruisseaux
Date: Tue Apr  8 17:47:08 2014
New Revision: 1585793

URL: http://svn.apache.org/r1585793
Log:
Replaced masks by calls to JDK 8 "toUnsignedInt" methods for readability.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/Dimension.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/FieldDescriptor.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/index/GeoHashCoder.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -265,7 +265,7 @@ final class PropertyInformation<E> exten
      */
     @Override
     public Integer getMaximumOccurrence() {
-        final int n = maximumOccurs & 0xFF;
+        final int n = Byte.toUnsignedInt(maximumOccurs);
         return (n == 0xFF) ? Integer.MAX_VALUE : n;
     }
 

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -583,7 +583,7 @@ public final class MathFunctions extends
                 primes = MathFunctions.primes;
                 if (index >= primes.length) {
                     int i = primes.length;
-                    int n = primes[i - 1] & 0xFFFF;
+                    int n = Short.toUnsignedInt(primes[i - 1]);
                     // Compute by block of 16 values, for reducing the amount of array resize.
                     primes = Arrays.copyOf(primes, Math.min((index | 0xF) + 1, PRIMES_LENGTH_16_BITS));
                     do {
@@ -592,7 +592,7 @@ testNextNumber:         while (true) { /
                             int prime;
                             int j = 0;
                             do {
-                                prime = primes[++j] & 0xFFFF;
+                                prime = Short.toUnsignedInt(primes[++j]);
                                 if (n % prime == 0) {
                                     continue testNextNumber;
                                 }
@@ -605,7 +605,7 @@ testNextNumber:         while (true) { /
                 }
             }
         }
-        return primes[index] & 0xFFFF;
+        return Short.toUnsignedInt(primes[index]);
     }
 
     /**
@@ -638,7 +638,7 @@ testNextNumber:         while (true) { /
                 return p;
             }
         }
-        return primes[i] & 0xFFFF;
+        return Short.toUnsignedInt(primes[i]);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -61,7 +61,7 @@ final class UnitsMap extends Static {
     static {
         final byte[] codes = {1, 2, 30, 36, 101, 102, 103, 104, 105, 108, 109, 111, 110,
(byte) 201, (byte) 202};
         for (final byte c : codes) {
-            final int code = 9000 + (c & 0xFF);
+            final int code = 9000 + Byte.toUnsignedInt(c);
             EPSG_CODES.put(Units.valueOfEPSG(code), code);
         }
     }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -77,7 +77,7 @@ class KeyConstants {
                 names = new String[fields.length];
                 for (final Field field : fields) {
                     if (Modifier.isStatic(field.getModifiers()) && field.getType()
== Short.TYPE) {
-                        final int index = ((Short) field.get(null)) & 0xFFFF;
+                        final int index = Short.toUnsignedInt((Short) field.get(null));
                         if (index >= length) {
                             length = index + 1;
                             if (length > names.length) {
@@ -102,7 +102,7 @@ class KeyConstants {
      * our {@link IndexedResourceBundle#handleGetObject(String)} implementation.
      */
     final String getKeyName(final short index) {
-        final int i = index & 0xFFFF;
+        final int i = Short.toUnsignedInt(index);
         final String[] keys = getKeyNames();
         if (i < keys.length) {
             final String key = keys[i];

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -89,7 +89,7 @@ public abstract class Variable {
         buffer.append(Classes.getShortName(getDataType()));
         final int[] shape = getGridEnvelope();
         for (int i=shape.length; --i>=0;) {
-            buffer.append('[').append(shape[i] & 0xFFFFFFFFL).append(']');
+            buffer.append('[').append(Integer.toUnsignedLong(shape[i])).append(']');
         }
         return buffer.toString();
     }
@@ -146,7 +146,7 @@ public abstract class Variable {
     public final boolean isCoverage(final int minSpan) {
         int numVectors = 0; // Number of dimension having more than 1 value.
         for (final int length : getGridEnvelope()) {
-            if ((length & 0xFFFFFFFFL) >= minSpan) {
+            if (Integer.toUnsignedLong(length) >= minSpan) {
                 numVectors++;
             }
         }
@@ -214,7 +214,7 @@ public abstract class Variable {
                 .append(" : ").append(Classes.getShortName(getDataType()));
         final int[] shape = getGridEnvelope();
         for (int i=shape.length; --i>=0;) {
-            buffer.append('[').append(shape[i] & 0xFFFFFFFFL).append(']');
+            buffer.append('[').append(Integer.toUnsignedLong(shape[i])).append(']');
         }
         return buffer.toString();
     }

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -307,7 +307,7 @@ public final class ChannelDecoder extend
      */
     private int ensureBufferContains(final int n, final int dataSize, String name) throws
IOException, DataStoreException {
         // (n+3) & ~3  is a trick for rounding 'n' to the next multiple of 4.
-        final long size = ((n & 0xFFFFFFFFL) * dataSize + 3) & ~3;
+        final long size = (Integer.toUnsignedLong(n) * dataSize + 3) & ~3;
         if (size > input.buffer.capacity()) {
             name = input.filename + DefaultNameSpace.DEFAULT_SEPARATOR + name;
             final Errors errors = errors();

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/Dimension.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/Dimension.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/Dimension.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/Dimension.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -56,6 +56,6 @@ final class Dimension {
     @Debug
     @Override
     public String toString() {
-        return name + '[' + (length & 0xFFFFFFFFL) + ']';
+        return name + '[' + Integer.toUnsignedLong(length) + ']';
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/FieldDescriptor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/FieldDescriptor.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/FieldDescriptor.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/FieldDescriptor.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -43,7 +43,7 @@ public class FieldDescriptor {
     }
 
     public int getLength() {
-        return this.FieldLength & 0xFF;
+        return Byte.toUnsignedInt(this.FieldLength);
     }
 
     @Override

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/index/GeoHashCoder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/index/GeoHashCoder.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/index/GeoHashCoder.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/index/GeoHashCoder.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -182,7 +182,7 @@ public class GeoHashCoder implements Ser
         final int highestOneBit = format.highestOneBit;
         char[] geohash = buffer;
         if (geohash == null) {
-            buffer = geohash = new char[precision & 0xFF];
+            buffer = geohash = new char[Byte.toUnsignedInt(precision)];
         }
         /*
          * The current implementation assumes a two-dimensional coordinates. The 'isEven'
boolean takes

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -267,14 +267,14 @@ public class ChannelDataInput {
      * The implementation is as below:
      *
      * {@preformat java
-     *     return readByte() & 0xFF;
+     *     return Byte.toUnsignedInt(readByte());
      * }
      *
      * @return The value of the next unsigned byte from the stream.
      * @throws IOException If an error (including EOF) occurred while reading the stream.
      */
     public final int readUnsignedByte() throws IOException {
-        return readByte() & 0xFF;
+        return Byte.toUnsignedInt(readByte());
     }
 
     /**
@@ -295,14 +295,14 @@ public class ChannelDataInput {
      * The implementation is as below:
      *
      * {@preformat java
-     *     return readShort() & 0xFFFF;
+     *     return Short.toUnsignedInt(readShort());
      * }
      *
      * @return The value of the next unsigned short from the stream.
      * @throws IOException If an error (including EOF) occurred while reading the stream.
      */
     public final int readUnsignedShort() throws IOException {
-        return readShort() & 0xFFFF;
+        return Short.toUnsignedInt(readShort());
     }
 
     /**
@@ -336,14 +336,14 @@ public class ChannelDataInput {
      * The implementation is as below:
      *
      * {@preformat java
-     *     return readInt() & 0xFFFFFFFFL;
+     *     return Integer.toUnsignedLong(readInt());
      * }
      *
      * @return The value of the next unsigned integer from the stream.
      * @throws IOException If an error (including EOF) occurred while reading the stream.
      */
     public final long readUnsignedInt() throws IOException {
-        return readInt() & 0xFFFFFFFFL;
+        return Integer.toUnsignedLong(readInt());
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -327,7 +327,7 @@ loop:   while ((c = read()) >= 0) {
      */
     @Override
     public final int read() throws IOException {
-        return hasRemaining() ? buffer.get() & 0xFF : -1;
+        return hasRemaining() ? Byte.toUnsignedInt(buffer.get()) : -1;
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java?rev=1585793&r1=1585792&r2=1585793&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
[UTF-8] Tue Apr  8 17:47:08 2014
@@ -205,7 +205,7 @@ public final class IOUtilities extends S
                 }
                 for (final byte b : path.substring(i, i+n).getBytes(StandardCharsets.UTF_8))
{
                     buffer.append('%');
-                    final String hex = Integer.toHexString(b & 0xFF).toUpperCase(Locale.ROOT);
+                    final String hex = Integer.toHexString(Byte.toUnsignedInt(b)).toUpperCase(Locale.ROOT);
                     if (hex.length() < 2) {
                         buffer.append('0');
                     }



Mime
View raw message