/** * Converts a "float" value between endian systems. * @param value value to convert * @return the converted value */ public static float swapFloat(final float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); }
/** * Converts a "float" value between endian systems. * @param value value to convert * @return the converted value */ public static float swapFloat(float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); }
@Test public void testSwapInteger() { assertEquals( 0, EndianUtils.swapInteger( 0 ) ); assertEquals( 0x04030201, EndianUtils.swapInteger( 0x01020304 ) ); assertEquals( 0x01000000, EndianUtils.swapInteger( 0x00000001 ) ); assertEquals( 0x00000001, EndianUtils.swapInteger( 0x01000000 ) ); assertEquals( 0x11111111, EndianUtils.swapInteger( 0x11111111 ) ); assertEquals( 0xabcdef10, EndianUtils.swapInteger( 0x10efcdab ) ); assertEquals( 0xab, EndianUtils.swapInteger( 0xab000000 ) ); }
/** * Tests all swapXxxx methods for symmetry when going from one endian * to another and back again. */ @Test public void testSymmetry() { assertEquals( (short) 0x0102, EndianUtils.swapShort( EndianUtils.swapShort( (short) 0x0102 ) ) ); assertEquals( 0x01020304, EndianUtils.swapInteger( EndianUtils.swapInteger( 0x01020304 ) ) ); assertEquals( 0x0102030405060708L, EndianUtils.swapLong( EndianUtils.swapLong( 0x0102030405060708L ) ) ); final float f1 = Float.intBitsToFloat( 0x01020304 ); assertEquals( f1, EndianUtils.swapFloat( EndianUtils.swapFloat( f1 ) ), 0.0 ); final double d1 = Double.longBitsToDouble( 0x0102030405060708L ); assertEquals( d1, EndianUtils.swapDouble( EndianUtils.swapDouble( d1 ) ), 0.0 ); }
/** * Converts a "float" value between endian systems. * @param value value to convert * @return the converted value */ public static float swapFloat(final float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); }
/** * Converts a "float" value between endian systems. * @param value value to convert * @return the converted value */ public static float swapFloat(float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); }
/** * Converts a "float" value between endian systems. * @param value value to convert * @return the converted value */ public static float swapFloat(float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); }
/** * Converts a "float" value between endian systems. * @param value value to convert * @return the converted value */ public static float swapFloat(float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); }
/** * Converts a "float" value between endian systems. * @param value value to convert * @return the converted value */ public static float swapFloat(float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); }
/** * Converts a "float" value between endian systems. * @param value value to convert * @return the converted value */ public static float swapFloat(final float value) { return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) ); }
@Override public String getName() { return StringMacroUtils.unmakeID(EndianUtils.swapInteger(getFourCC())); }
inputStream.readFully(date); numRecord = EndianUtils.swapInteger(inputStream.readInt());
inputStream.readFully(date); numRecord = EndianUtils.swapInteger(inputStream.readInt());
/** * abstract information from record header and then copy primitive bytes data of record to a primitive record. * * @return * @throws IOException */ public ShpRecord parseRecordPrimitiveContent() throws IOException { // get length of record content int contentLength = reader.readInt(); long recordLength = 2 * (contentLength + 4); remainLength -= recordLength; int typeID = EndianUtils.swapInteger(reader.readInt()); byte[] contentArray = new byte[contentLength * 2 - INT_LENGTH];// exclude the 4 bytes we read for shape type reader.read(contentArray, 0, contentArray.length); return new ShpRecord(contentArray, typeID); }
/** * abstract information from record header and then copy primitive bytes data of record to a primitive record. * * @return * @throws IOException */ public ShpRecord parseRecordPrimitiveContent(int length) throws IOException { // get length of record content int contentLength = reader.readInt(); long recordLength = 2 * (contentLength + 4); remainLength -= recordLength; int typeID = EndianUtils.swapInteger(reader.readInt()); byte[] contentArray = new byte[length];// exclude the 4 bytes we read for shape type reader.read(contentArray, 0, contentArray.length); return new ShpRecord(contentArray, typeID); }
/** * abstract information from record header and then copy primitive bytes data of record to a primitive record. * * @return * @throws IOException */ public ShpRecord parseRecordPrimitiveContent(int length) throws IOException { // get length of record content int contentLength = reader.readInt(); long recordLength = 2 * (contentLength + 4); remainLength -= recordLength; int typeID = EndianUtils.swapInteger(reader.readInt()); byte[] contentArray = new byte[length];// exclude the 4 bytes we read for shape type reader.read(contentArray, 0, contentArray.length); return new ShpRecord(contentArray, typeID); }
/** * abstract information from record header and then copy primitive bytes data of record to a primitive record. * * @return * @throws IOException */ public ShpRecord parseRecordPrimitiveContent() throws IOException { // get length of record content int contentLength = reader.readInt(); long recordLength = 2 * (contentLength + 4); remainLength -= recordLength; int typeID = EndianUtils.swapInteger(reader.readInt()); byte[] contentArray = new byte[contentLength * 2 - INT_LENGTH];// exclude the 4 bytes we read for shape type reader.read(contentArray, 0, contentArray.length); return new ShpRecord(contentArray, typeID); }
ident = EndianUtils.swapInteger(ident);
int magic = EndianUtils.swapInteger(din.readInt()); din.reset(); if (magic != WMFConstants.META_ALDUS_APM) {