Search in sources :

Example 56 with ByteOrder

use of java.nio.ByteOrder in project robovm by robovm.

the class ByteOrderTest method testNativeOrder.

public void testNativeOrder() {
    ByteOrder o = ByteOrder.nativeOrder();
    assertTrue(o == ByteOrder.BIG_ENDIAN || o == ByteOrder.LITTLE_ENDIAN);
}
Also used : ByteOrder(java.nio.ByteOrder)

Example 57 with ByteOrder

use of java.nio.ByteOrder in project jdk8u_jdk by JetBrains.

the class ImageInputStreamImpl method readUTF.

public String readUTF() throws IOException {
    this.bitOffset = 0;
    // Fix 4494369: method ImageInputStreamImpl.readUTF()
    // does not work as specified (it should always assume
    // network byte order).
    ByteOrder oldByteOrder = getByteOrder();
    setByteOrder(ByteOrder.BIG_ENDIAN);
    String ret;
    try {
        ret = DataInputStream.readUTF(this);
    } catch (IOException e) {
        // Restore the old byte order even if an exception occurs
        setByteOrder(oldByteOrder);
        throw e;
    }
    setByteOrder(oldByteOrder);
    return ret;
}
Also used : ByteOrder(java.nio.ByteOrder) IOException(java.io.IOException) IIOException(javax.imageio.IIOException)

Example 58 with ByteOrder

use of java.nio.ByteOrder in project jdk8u_jdk by JetBrains.

the class AbstractPerfDataBufferPrologue method getMagic.

/**
     * Get the magic number from the given byteBuffer.
     *
     * @return int - the magic number
     */
public static int getMagic(ByteBuffer bb) {
    // save buffer state
    int position = bb.position();
    ByteOrder order = bb.order();
    // the magic number is always stored in big-endian format
    bb.order(ByteOrder.BIG_ENDIAN);
    bb.position(PERFDATA_PROLOG_MAGIC_OFFSET);
    int magic = bb.getInt();
    // restore buffer state.
    bb.order(order);
    bb.position(position);
    return magic;
}
Also used : ByteOrder(java.nio.ByteOrder)

Example 59 with ByteOrder

use of java.nio.ByteOrder in project ignite by apache.

the class MurmurHash method hash64A.

/**
 * @param buf The data to hash.
 * @param seed The seed to start with.
 */
public static long hash64A(ByteBuffer buf, int seed) {
    ByteOrder byteOrder = buf.order();
    buf.order(ByteOrder.LITTLE_ENDIAN);
    long m = 0xc6a4a7935bd1e995L;
    int r = 47;
    long h = seed ^ (buf.remaining() * m);
    while (buf.remaining() >= 8) {
        long k = buf.getLong();
        k *= m;
        k ^= k >>> r;
        k *= m;
        h ^= k;
        h *= m;
    }
    if (buf.remaining() > 0) {
        ByteBuffer finish = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN);
        finish.put(buf).rewind();
        h ^= finish.getLong();
        h *= m;
    }
    h ^= h >>> r;
    h *= m;
    h ^= h >>> r;
    buf.order(byteOrder);
    return h;
}
Also used : ByteOrder(java.nio.ByteOrder) ByteBuffer(java.nio.ByteBuffer)

Example 60 with ByteOrder

use of java.nio.ByteOrder in project graal by oracle.

the class DefaultJavaLoweringProvider method lowerSecondHalf.

private void lowerSecondHalf(UnpackEndianHalfNode n) {
    ByteOrder byteOrder = target.arch.getByteOrder();
    n.lower(byteOrder);
}
Also used : ByteOrder(java.nio.ByteOrder)

Aggregations

ByteOrder (java.nio.ByteOrder)111 ByteBuffer (java.nio.ByteBuffer)39 IOException (java.io.IOException)8 Test (org.junit.Test)7 QuickTest (com.hazelcast.test.annotation.QuickTest)5 DataInputStream (java.io.DataInputStream)5 FileInputStream (java.io.FileInputStream)5 UUID (java.util.UUID)5 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 HKL (ffx.crystal.HKL)3 DataOutputStream (java.io.DataOutputStream)3 EOFException (java.io.EOFException)3 FileOutputStream (java.io.FileOutputStream)3 ShortBuffer (java.nio.ShortBuffer)3 ArrayList (java.util.ArrayList)3 Element (org.jdom.Element)3 InvalidDumpFormatException (com.ibm.j9ddr.corereaders.InvalidDumpFormatException)2 Point (com.revolsys.geometry.model.Point)2 Crystal (ffx.crystal.Crystal)2 BigInteger (java.math.BigInteger)2