J avolution v5.5 (J2SE 1.6+)

javolution.io
Class Struct.Member

java.lang.Object
  extended by javolution.io.Struct.Member
Direct Known Subclasses:
Struct.BitField, Struct.Bool, Struct.Enum16, Struct.Enum32, Struct.Enum64, Struct.Enum8, Struct.Float32, Struct.Float64, Struct.Reference32, Struct.Reference64, Struct.Signed16, Struct.Signed32, Struct.Signed64, Struct.Signed8, Struct.Unsigned16, Struct.Unsigned32, Struct.Unsigned8, Struct.UTF8String
Enclosing class:
Struct

protected class Struct.Member
extends java.lang.Object

This inner class represents the base class for all Struct members. It allows applications to define additional member types. For example:

    public class MyStruct extends Struct {
        BitSet bits = new BitSet(256);
        ...
        public BitSet extends Member {
            public BitSet(int nbrBits) {
                super(nbrBits, 0); // Direct bit access.
            }
            public boolean get(int i) { ... }
            public void set(int i, boolean value) { ...}
        }
    }


Constructor Summary
protected Struct.Member(int bitLength, int wordSize)
          Base constructor for custom member types.
 
Method Summary
 int bitIndex()
          Holds the bit offset of this member (if any).
 int bitLength()
          Returns the number of bits in this member.
 int offset()
          Returns the byte offset of this member in its struct.
 Struct struct()
          Returns the outer struct container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Struct.Member

protected Struct.Member(int bitLength,
                        int wordSize)
Base constructor for custom member types. The word size can be zero, in which case the offset() of the member does not change, only bitIndex() is incremented.

Parameters:
bitLength - the number of bits or 0 to force next member on next word boundary.
wordSize - the word size in bytes used when accessing this member data or 0 if the data is accessed at the bit level.
Method Detail

struct

public final Struct struct()
Returns the outer struct container.

Returns:
the outer struct.

offset

public final int offset()
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.

bitIndex

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


bitLength

public final int bitLength()
Returns the number of bits in this member. Can be zero if this member is used to force the next member to the next word boundary.

Returns:
the number of bits in the member.

J avolution v5.5 (J2SE 1.6+)

Copyright © 2005 - 2009 Javolution.