Javolution 6.0.0 java
javolution.io.Struct.Unsigned16 Class Reference
Inheritance diagram for javolution.io.Struct.Unsigned16:
[legend]
Collaboration diagram for javolution.io.Struct.Unsigned16:
[legend]

Public Member Functions

 Unsigned16 ()
 
 Unsigned16 (int nbrOfBits)
 
int get ()
 
void set (int value)
 
String toString ()
 
final Struct struct ()
 
final int offset ()
 
final int bitIndex ()
 
final int bitLength ()
 

Package Functions

final int get (int wordSize, int word)
 
final long get (int wordSize, long word)
 
final int set (int value, int wordSize, int word)
 
final long set (long value, int wordSize, long word)
 

Private Attributes

final int _offset
 
final int _bitIndex
 
final int _bitLength
 

Detailed Description

This class represents a 16 bits unsigned integer.

Definition at line 1269 of file Struct.java.

Constructor & Destructor Documentation

◆ Unsigned16() [1/2]

javolution.io.Struct.Unsigned16.Unsigned16 ( )

Definition at line 1271 of file Struct.java.

1271  {
1272  super(16, 2);
1273  }

◆ Unsigned16() [2/2]

javolution.io.Struct.Unsigned16.Unsigned16 ( int  nbrOfBits)

Definition at line 1275 of file Struct.java.

1275  {
1276  super(nbrOfBits, 2);
1277  }

Member Function Documentation

◆ bitIndex()

final int javolution.io.Struct.Member.bitIndex ( )
inherited

Holds the bit offset of this member (if any). The actual position of the bits data depends upon the endianess and the word size.

Definition at line 998 of file Struct.java.

998  {
999  return _bitIndex;
1000  }

References javolution.io.Struct.Member._bitIndex.

Referenced by javolution.io.Struct.Member.get(), javolution.io.Struct.BitField.longValue(), javolution.io.Struct.Member.set(), and javolution.io.Struct.BitField.set().

Here is the caller graph for this function:

◆ bitLength()

◆ get() [1/3]

int javolution.io.Struct.Unsigned16.get ( )

Definition at line 1279 of file Struct.java.

1279  {
1280  final int index = getByteBufferPosition() + offset();
1281  int word = getByteBuffer().getShort(index);
1282  return 0xFFFF & ((bitLength() == 16) ? word : get(2, word));
1283  }

References javolution.io.Struct.Member.bitLength(), javolution.io.Struct.getByteBuffer(), javolution.io.Struct.getByteBufferPosition(), and javolution.io.Struct.Member.offset().

Here is the call graph for this function:

◆ get() [2/3]

final int javolution.io.Struct.Member.get ( int  wordSize,
int  word 
)
packageinherited

Definition at line 1013 of file Struct.java.

1013  {
1014  final int shift = (byteOrder() == ByteOrder.BIG_ENDIAN) ? (wordSize << 3)
1015  - bitIndex() - bitLength()
1016  : bitIndex();
1017  word >>= shift;
1018  int mask = 0xFFFFFFFF >>> (32 - bitLength());
1019  return word & mask;
1020  }

References javolution.io.Struct.Member.bitIndex(), javolution.io.Struct.Member.bitLength(), and javolution.io.Struct.byteOrder().

Here is the call graph for this function:

◆ get() [3/3]

final long javolution.io.Struct.Member.get ( int  wordSize,
long  word 
)
packageinherited

Definition at line 1034 of file Struct.java.

1034  {
1035  final int shift = (byteOrder() == ByteOrder.BIG_ENDIAN) ? (wordSize << 3)
1036  - bitIndex() - bitLength()
1037  : bitIndex();
1038  word >>= shift;
1039  long mask = 0xFFFFFFFFFFFFFFFFL >>> (64 - bitLength());
1040  return word & mask;
1041  }

References javolution.io.Struct.Member.bitIndex(), javolution.io.Struct.Member.bitLength(), and javolution.io.Struct.byteOrder().

Here is the call graph for this function:

◆ offset()

final int javolution.io.Struct.Member.offset ( )
inherited

Returns the byte offset of this member in its struct. Equivalent to C/C++ offsetof(struct(), this)

Returns
the offset of this member in the Struct.

Definition at line 989 of file Struct.java.

989  {
990  return _offset;
991  }

References javolution.io.Struct.Member._offset.

Referenced by javolution.io.Struct.UTF8String.get(), javolution.io.Struct.Bool.get(), javolution.io.Struct.Signed8.get(), javolution.io.Struct.Unsigned8.get(), javolution.io.Struct.Signed16.get(), javolution.io.Struct.Unsigned16.get(), javolution.io.Struct.Signed32.get(), javolution.io.Struct.Unsigned32.get(), javolution.io.Struct.Signed64.get(), javolution.io.Struct.Float32.get(), javolution.io.Struct.Float64.get(), javolution.io.Struct.Enum8< T extends Enum< T >.get(), javolution.io.Struct.Enum16< T extends Enum< T >.get(), javolution.io.Struct.Enum32< T extends Enum< T >.get(), javolution.io.Struct.Enum64< T extends Enum< T >.get(), javolution.io.Struct.Reference32< S extends Struct >.isUpToDate(), javolution.io.Struct.Reference64< S extends Struct >.isUpToDate(), javolution.io.Struct.BitField.longValue(), javolution.io.Struct.UTF8String.set(), javolution.io.Struct.Bool.set(), javolution.io.Struct.Signed8.set(), javolution.io.Struct.Unsigned8.set(), javolution.io.Struct.Signed16.set(), javolution.io.Struct.Unsigned16.set(), javolution.io.Struct.Signed32.set(), javolution.io.Struct.Unsigned32.set(), javolution.io.Struct.Signed64.set(), javolution.io.Struct.BitField.set(), javolution.io.Struct.Float32.set(), javolution.io.Struct.Float64.set(), javolution.io.Struct.Reference32< S extends Struct >.set(), javolution.io.Struct.Reference64< S extends Struct >.set(), javolution.io.Struct.Enum8< T extends Enum< T >.set(), javolution.io.Struct.Enum16< T extends Enum< T >.set(), javolution.io.Struct.Enum32< T extends Enum< T >.set(), javolution.io.Struct.Enum64< T extends Enum< T >.set(), javolution.io.Struct.Reference32< S extends Struct >.value(), and javolution.io.Struct.Reference64< S extends Struct >.value().

Here is the caller graph for this function:

◆ set() [1/3]

void javolution.io.Struct.Unsigned16.set ( int  value)

Definition at line 1285 of file Struct.java.

1285  {
1286  final int index = getByteBufferPosition() + offset();
1287  if (bitLength() == 16) {
1288  getByteBuffer().putShort(index, (short) value);
1289  } else {
1290  getByteBuffer().putShort(index,
1291  (short) set(value, 2, getByteBuffer().getShort(index)));
1292  }
1293  }

References javolution.io.Struct.Member.bitLength(), javolution.io.Struct.getByteBuffer(), javolution.io.Struct.getByteBufferPosition(), and javolution.io.Struct.Member.offset().

Here is the call graph for this function:

◆ set() [2/3]

final int javolution.io.Struct.Member.set ( int  value,
int  wordSize,
int  word 
)
packageinherited

Definition at line 1023 of file Struct.java.

1023  {
1024  final int shift = (byteOrder() == ByteOrder.BIG_ENDIAN) ? (wordSize << 3)
1025  - bitIndex() - bitLength()
1026  : bitIndex();
1027  int mask = 0xFFFFFFFF >>> (32 - bitLength());
1028  mask <<= shift;
1029  value <<= shift;
1030  return (word & ~mask) | (value & mask);
1031  }

References javolution.io.Struct.Member.bitIndex(), javolution.io.Struct.Member.bitLength(), and javolution.io.Struct.byteOrder().

Here is the call graph for this function:

◆ set() [3/3]

final long javolution.io.Struct.Member.set ( long  value,
int  wordSize,
long  word 
)
packageinherited

Definition at line 1044 of file Struct.java.

1044  {
1045  final int shift = (byteOrder() == ByteOrder.BIG_ENDIAN) ? (wordSize << 3)
1046  - bitIndex() - bitLength()
1047  : bitIndex();
1048  long mask = 0xFFFFFFFFFFFFFFFFL >>> (64 - bitLength());
1049  mask <<= shift;
1050  value <<= shift;
1051  return (word & ~mask) | (value & mask);
1052  }

References javolution.io.Struct.Member.bitIndex(), javolution.io.Struct.Member.bitLength(), and javolution.io.Struct.byteOrder().

Here is the call graph for this function:

◆ struct()

final Struct javolution.io.Struct.Member.struct ( )
inherited

Returns the outer struct container.

Returns
the outer struct.

Definition at line 979 of file Struct.java.

979  {
980  return Struct.this;
981  }

◆ toString()

String javolution.io.Struct.Unsigned16.toString ( )

Definition at line 1295 of file Struct.java.

1295  {
1296  return String.valueOf(this.get());
1297  }

Member Data Documentation

◆ _bitIndex

final int javolution.io.Struct.Member._bitIndex
privateinherited

Holds the relative bit offset of this member to its struct offset.

Definition at line 903 of file Struct.java.

Referenced by javolution.io.Struct.Member.bitIndex(), and javolution.io.Struct.Member.Member().

◆ _bitLength

final int javolution.io.Struct.Member._bitLength
privateinherited

Holds the bit length of this member.

Definition at line 907 of file Struct.java.

Referenced by javolution.io.Struct.Member.bitLength(), and javolution.io.Struct.Member.Member().

◆ _offset

final int javolution.io.Struct.Member._offset
privateinherited

Holds the relative offset (in bytes) of this member within its struct.

Definition at line 899 of file Struct.java.

Referenced by javolution.io.Struct.Member.Member(), and javolution.io.Struct.Member.offset().


The documentation for this class was generated from the following file:
javolution.io.Struct.Member._offset
final int _offset
Definition: Struct.java:899
javolution.io.Struct.Member._bitLength
final int _bitLength
Definition: Struct.java:907
javolution.io.Struct.Struct
Struct()
Definition: Struct.java:214
javolution.io.Struct.Member.offset
final int offset()
Definition: Struct.java:989
javolution.io.Struct.Member._bitIndex
final int _bitIndex
Definition: Struct.java:903
javolution.io.Struct.getByteBufferPosition
final int getByteBufferPosition()
Definition: Struct.java:312
javolution.io.Struct.byteOrder
ByteOrder byteOrder()
Definition: Struct.java:480
javolution.io.Struct.Member.bitIndex
final int bitIndex()
Definition: Struct.java:998
javolution.io.Struct.Member.bitLength
final int bitLength()
Definition: Struct.java:1008
javolution.io.Struct.getByteBuffer
final ByteBuffer getByteBuffer()
Definition: Struct.java:254