/** * {@inheritDoc} */ @Override public void putDouble(double d) { prepareForAccess(8); if (componentCursor.getRemaining() >= 4) { componentCursor.putDouble(d); index += 8; } else { long l = Double.doubleToLongBits(d); putLong(l); } }
/** * {@inheritDoc} */ @Override public void putFloat(float f) { prepareForAccess(4); if (componentCursor.getRemaining() >= 4) { componentCursor.putFloat(f); index += 4; } else { int i = Float.floatToIntBits(f); putInt(i); } }
/** * {@inheritDoc} */ @Override public double getDouble() { prepareForAccess(8); if (componentCursor.getRemaining() >= 4) { double d = componentCursor.getDouble(); index += 8; return d; } else { long l = getLong(); return Double.longBitsToDouble(l); } }
/** * @inheritDoc */ public float getFloat() { prepareForAccess( 4 ); if ( componentCursor.getRemaining() >= 4 ) { float f = componentCursor.getFloat(); index += 4; return f; } else { int i = getInt(); return Float.intBitsToFloat( i ); } }
/** * @inheritDoc */ public ByteArray slice( int length ) { CompositeByteArray slice = new CompositeByteArray( byteArrayFactory ); int remaining = length; while ( remaining > 0 ) { prepareForAccess( remaining ); int componentSliceSize = Math.min( remaining, componentCursor.getRemaining() ); ByteArray componentSlice = componentCursor.slice( componentSliceSize ); slice.addLast( componentSlice ); index += componentSliceSize; remaining -= componentSliceSize; } return slice; }
/** * {@inheritDoc} */ @Override public short getShort() { prepareForAccess(2); if (componentCursor.getRemaining() >= 4) { short s = componentCursor.getShort(); index += 2; return s; } else { byte b0 = get(); byte b1 = get(); if (order.equals(ByteOrder.BIG_ENDIAN)) { return (short) ((b0 << 8) | (b1 & 0xFF)); } else { return (short) ((b1 << 8) | (b0 & 0xFF)); } } }
/** * @inheritDoc */ public void putDouble( double d ) { prepareForAccess( 8 ); if ( componentCursor.getRemaining() >= 4 ) { componentCursor.putDouble( d ); index += 8; } else { long l = Double.doubleToLongBits( d ); putLong( l ); } }
/** * {@inheritDoc} */ @Override public char getChar() { prepareForAccess(2); if (componentCursor.getRemaining() >= 4) { char c = componentCursor.getChar(); index += 2; return c; } else { byte b0 = get(); byte b1 = get(); if (order.equals(ByteOrder.BIG_ENDIAN)) { return (char)((b0 << 8) | (b1 & 0xFF)); } else { return (char)((b1 << 8) | (b0 & 0xFF)); } } }
/** * {@inheritDoc} */ @Override public ByteArray slice(int length) { CompositeByteArray slice = new CompositeByteArray(byteArrayFactory); int remaining = length; while (remaining > 0) { prepareForAccess(remaining); int componentSliceSize = Math.min(remaining, componentCursor.getRemaining()); ByteArray componentSlice = componentCursor.slice(componentSliceSize); slice.addLast(componentSlice); index += componentSliceSize; remaining -= componentSliceSize; } return slice; }
/** * {@inheritDoc} */ @Override public void putShort(short s) { prepareForAccess(2); if (componentCursor.getRemaining() >= 4) { componentCursor.putShort(s); index += 2; } else { if (order.equals(ByteOrder.BIG_ENDIAN)) { put((byte) ((s >> 8) & 0xff)); put((byte) (s & 0xff)); } else { put((byte) (s & 0xff)); put((byte) ((s >> 8) & 0xff)); } } }
/** * @inheritDoc */ public void putFloat( float f ) { prepareForAccess( 4 ); if ( componentCursor.getRemaining() >= 4 ) { componentCursor.putFloat( f ); index += 4; } else { int i = Float.floatToIntBits( f ); putInt( i ); } }
/** * {@inheritDoc} */ @Override public ByteArray slice(int length) { CompositeByteArray slice = new CompositeByteArray(byteArrayFactory); int remaining = length; while (remaining > 0) { prepareForAccess(remaining); int componentSliceSize = Math.min(remaining, componentCursor.getRemaining()); ByteArray componentSlice = componentCursor.slice(componentSliceSize); slice.addLast(componentSlice); index += componentSliceSize; remaining -= componentSliceSize; } return slice; }
/** * {@inheritDoc} */ @Override public float getFloat() { prepareForAccess(4); if (componentCursor.getRemaining() >= 4) { float f = componentCursor.getFloat(); index += 4; return f; } else { int i = getInt(); return Float.intBitsToFloat(i); } }
/** * {@inheritDoc} */ @Override public double getDouble() { prepareForAccess(8); if (componentCursor.getRemaining() >= 4) { double d = componentCursor.getDouble(); index += 8; return d; } else { long l = getLong(); return Double.longBitsToDouble(l); } }
/** * {@inheritDoc} */ @Override public void putDouble(double d) { prepareForAccess(8); if (componentCursor.getRemaining() >= 4) { componentCursor.putDouble(d); index += 8; } else { long l = Double.doubleToLongBits(d); putLong(l); } }
/** * {@inheritDoc} */ @Override public void putFloat(float f) { prepareForAccess(4); if (componentCursor.getRemaining() >= 4) { componentCursor.putFloat(f); index += 4; } else { int i = Float.floatToIntBits(f); putInt(i); } }
/** * {@inheritDoc} */ @Override public float getFloat() { prepareForAccess(4); if (componentCursor.getRemaining() >= 4) { float f = componentCursor.getFloat(); index += 4; return f; } else { int i = getInt(); return Float.intBitsToFloat(i); } }
/** * @inheritDoc */ public final int getRemaining() { return cursor.getRemaining(); }
/** * @return The number of remaining bytes */ public final int getRemaining() { return cursor.getRemaining(); }
/** * @return The number of remaining bytes */ public final int getRemaining() { return cursor.getRemaining(); }