use of java.nio.ByteOrder in project hazelcast by hazelcast.
the class BinaryCompatibilityFileGenerator method main.
public static void main(String[] args) throws IOException {
Object[] objects = ReferenceObjects.allTestObjects;
OutputStream out = new FileOutputStream(createFileName());
DataOutputStream outputStream = new DataOutputStream(out);
ByteOrder[] byteOrders = { ByteOrder.BIG_ENDIAN, ByteOrder.LITTLE_ENDIAN };
for (Object object : objects) {
for (ByteOrder byteOrder : byteOrders) {
generateBinaryFile(outputStream, object, byteOrder);
}
}
outputStream.close();
}
use of java.nio.ByteOrder in project bytecode-viewer by Konloch.
the class ValuesPanel method longTextFieldKeyReleased.
// GEN-LAST:event_intTextFieldKeyReleased
private void longTextFieldKeyReleased(java.awt.event.KeyEvent evt) {
// GEN-FIRST:event_longTextFieldKeyReleased
if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) {
try {
ByteOrder byteOrder = getByteOrder();
if (isSigned()) {
long longValue = Long.parseLong(longTextField.getText());
byteBuffer.rewind();
if (byteBuffer.order() != byteOrder) {
byteBuffer.order(byteOrder);
}
byteBuffer.putLong(longValue);
} else {
BigInteger bigInteger = new BigInteger(longTextField.getText());
if (bigInteger.signum() == -1 || bigInteger.compareTo(ULONG_MAX_VALUE) > 0) {
throw new NumberFormatException(VALUE_OUT_OF_RANGE);
}
if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
for (int i = 0; i < 7; i++) {
BigInteger nextByte = bigInteger.and(BIG_INTEGER_BYTE_MASK);
valuesCache[7 - i] = nextByte.byteValue();
bigInteger = bigInteger.shiftRight(8);
}
} else {
for (int i = 0; i < 7; i++) {
BigInteger nextByte = bigInteger.and(BIG_INTEGER_BYTE_MASK);
valuesCache[i] = nextByte.byteValue();
bigInteger = bigInteger.shiftRight(8);
}
}
}
modifyValues(8);
updateValues();
} catch (NumberFormatException ex) {
showException(ex);
}
}
}
use of java.nio.ByteOrder in project bytecode-viewer by Konloch.
the class ValuesPanel method floatTextFieldKeyReleased.
// GEN-LAST:event_longTextFieldKeyReleased
private void floatTextFieldKeyReleased(java.awt.event.KeyEvent evt) {
// GEN-FIRST:event_floatTextFieldKeyReleased
if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable()) {
try {
ByteOrder byteOrder = getByteOrder();
float floatValue = Float.parseFloat(floatTextField.getText());
byteBuffer.rewind();
if (byteBuffer.order() != byteOrder) {
byteBuffer.order(byteOrder);
}
byteBuffer.putFloat(floatValue);
modifyValues(4);
updateValues();
} catch (NumberFormatException ex) {
showException(ex);
}
}
}
use of java.nio.ByteOrder in project hs4j by killme2008.
the class AbstractIoBuffer method capacity.
/**
* {@inheritDoc}
*/
@Override
public final IoBuffer capacity(int newCapacity) {
if (!recapacityAllowed) {
throw new IllegalStateException("Derived buffers and their parent can't be expanded.");
}
// Allocate a new buffer and transfer all settings to it.
if (newCapacity > capacity()) {
// Expand:
// // Save the state.
int pos = position();
int limit = limit();
ByteOrder bo = order();
// // Reallocate.
ByteBuffer oldBuf = buf();
ByteBuffer newBuf = getAllocator().allocateNioBuffer(newCapacity, isDirect());
oldBuf.clear();
newBuf.put(oldBuf);
buf(newBuf);
// // Restore the state.
buf().limit(limit);
if (mark >= 0) {
buf().position(mark);
buf().mark();
}
buf().position(pos);
buf().order(bo);
}
return this;
}
use of java.nio.ByteOrder in project hazelcast by hazelcast.
the class ObjectDataOutputStreamTest method testGetByteOrder.
@Test
public void testGetByteOrder() throws Exception {
ByteOrder byteOrderActual = dataOutputStream.getByteOrder();
assertEquals(serializationService.getByteOrder(), byteOrderActual);
}
Aggregations