List of usage examples for com.google.gwt.corp.compatibility Endianness BIG_ENDIAN
Endianness BIG_ENDIAN
To view the source code for com.google.gwt.corp.compatibility Endianness BIG_ENDIAN.
Click Source Link
From source file:java.nio.ByteBuffer.java
License:Apache License
/** Returns the byte order used by this buffer when converting bytes from/to other primitive types. * <p>//from w w w. j av a 2 s . c om * The default byte order of byte buffer is always {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN} * </p> * * @return the byte order used by this buffer when converting bytes from/to other primitive types. * @since Android 1.0 */ public final ByteOrder order() { return order == Endianness.BIG_ENDIAN ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; }
From source file:java.nio.ByteBuffer.java
License:Apache License
ByteBuffer orderImpl(ByteOrder byteOrder) {
order = byteOrder == ByteOrder.BIG_ENDIAN ? Endianness.BIG_ENDIAN : Endianness.LITTLE_ENDIAN;
return this;
}
From source file:java.nio.DirectByteBuffer.java
License:Apache License
protected final int loadInt(int baseOffset) { int bytes = 0; if (order == Endianness.BIG_ENDIAN) { for (int i = 0; i < 4; i++) { bytes = bytes << 8;// w w w .jav a 2s . c o m bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); } } else { for (int i = 3; i >= 0; i--) { bytes = bytes << 8; bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); } } return bytes; }
From source file:java.nio.DirectByteBuffer.java
License:Apache License
protected final long loadLong(int baseOffset) { long bytes = 0; if (order == Endianness.BIG_ENDIAN) { for (int i = 0; i < 8; i++) { bytes = bytes << 8;/*w ww . ja v a 2s .c o m*/ bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); } } else { for (int i = 7; i >= 0; i--) { bytes = bytes << 8; bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); } } return bytes; }
From source file:java.nio.DirectByteBuffer.java
License:Apache License
protected final short loadShort(int baseOffset) { short bytes = 0; if (order == Endianness.BIG_ENDIAN) { bytes = (short) (byteArray.get(baseOffset) << 8); bytes |= (byteArray.get(baseOffset + 1) & 0xFF); } else {//from w w w.j a v a 2 s.c om bytes = (short) (byteArray.get(baseOffset + 1) << 8); bytes |= (byteArray.get(baseOffset) & 0xFF); } return bytes; }
From source file:java.nio.DirectByteBuffer.java
License:Apache License
protected final void store(int baseOffset, int value) { if (order == Endianness.BIG_ENDIAN) { for (int i = 3; i >= 0; i--) { byteArray.set(baseOffset + i, (byte) (value & 0xFF)); value = value >> 8;/*www.j a v a 2s . co m*/ } } else { for (int i = 0; i <= 3; i++) { byteArray.set(baseOffset + i, (byte) (value & 0xFF)); value = value >> 8; } } }
From source file:java.nio.DirectByteBuffer.java
License:Apache License
protected final void store(int baseOffset, long value) { if (order == Endianness.BIG_ENDIAN) { for (int i = 7; i >= 0; i--) { byteArray.set(baseOffset + i, (byte) (value & 0xFF)); value = value >> 8;/* w w w . ja v a 2 s . c o m*/ } } else { for (int i = 0; i <= 7; i++) { byteArray.set(baseOffset + i, (byte) (value & 0xFF)); value = value >> 8; } } }
From source file:java.nio.DirectByteBuffer.java
License:Apache License
protected final void store(int baseOffset, short value) { if (order == Endianness.BIG_ENDIAN) { byteArray.set(baseOffset, (byte) ((value >> 8) & 0xFF)); byteArray.set(baseOffset + 1, (byte) (value & 0xFF)); } else {// www .java 2 s. c o m byteArray.set(baseOffset + 1, (byte) ((value >> 8) & 0xFF)); byteArray.set(baseOffset, (byte) (value & 0xFF)); } }
From source file:java.nio.HeapByteBuffer.java
License:Apache License
protected final int loadInt(int index) { int baseOffset = offset + index; int bytes = 0; if (order == Endianness.BIG_ENDIAN) { for (int i = 0; i < 4; i++) { bytes = bytes << 8;/* w w w . jav a 2 s . c o m*/ bytes = bytes | (backingArray[baseOffset + i] & 0xFF); } } else { for (int i = 3; i >= 0; i--) { bytes = bytes << 8; bytes = bytes | (backingArray[baseOffset + i] & 0xFF); } } return bytes; }
From source file:java.nio.HeapByteBuffer.java
License:Apache License
protected final long loadLong(int index) { int baseOffset = offset + index; long bytes = 0; if (order == Endianness.BIG_ENDIAN) { for (int i = 0; i < 8; i++) { bytes = bytes << 8;//w w w . j ava2 s. c om bytes = bytes | (backingArray[baseOffset + i] & 0xFF); } } else { for (int i = 7; i >= 0; i--) { bytes = bytes << 8; bytes = bytes | (backingArray[baseOffset + i] & 0xFF); } } return bytes; }