|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.helsinki.cs.ohtu.mpeg2.util.UnsignedIntegerField
public class UnsignedIntegerField
Represents an unsigned integer field in a MPEG stream. Fields have specific bit widths. This class enforces the width by not allowing setting values which won't fit into a field with the given size as unsigned binary integers. This limit is called the maximum width. In addition to the maximum width of the field, a minimum width for serializing to a bit stream can be specified. Any value in the field at the time of writing will be padded with zero bits, written before the actual value bits to the stream. The maximum width of a field supported by this class is one less than Long.SIZE. The highest bit in a long integer is used for the sign bit, which makes no sense in the unsigned integer context.
Field Summary | |
---|---|
private int |
maxWidth
|
private int |
minWidth
|
private long |
value
|
private int |
width
|
Constructor Summary | |
---|---|
UnsignedIntegerField(int width)
Constructs a new instance which is effectively fixed width. |
|
UnsignedIntegerField(int minWidth,
int maxWidth,
long value)
Constructs a new instance with variable width. |
|
UnsignedIntegerField(int width,
long value)
Constructs a new instance which is effectively fixed width. |
Method Summary | |
---|---|
int |
getMaxWidth()
Gets the maximum width of the field. |
int |
getMinWidth()
Gets the minimum width of the field. |
long |
getValue()
Gets the value of the field. |
void |
setValue(long newValue)
Sets the value of the field. |
void |
writeTo(BitOutputStream stream)
Writes the value of the field to the given stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final int minWidth
private final int maxWidth
private int width
private long value
Constructor Detail |
---|
public UnsignedIntegerField(int width)
width
- The width of the field, in bits. Both maximum and minimum width are set to this.public UnsignedIntegerField(int width, long value)
width
- The width of the field, in bits.Both maximum and minimum width are set to this.value
- The initial value to set the field to, as if setValue() was called.public UnsignedIntegerField(int minWidth, int maxWidth, long value)
minWidth
- Minimal allowed width for the field, in bits.maxWidth
- Maximum allowed width for the field, in bits.value
- The initial value to set the field to, as if setValue() was called.Method Detail |
---|
public int getMaxWidth()
public int getMinWidth()
public long getValue()
public void setValue(long newValue)
newValue
- The value to set the field to.public void writeTo(BitOutputStream stream) throws java.io.IOException
stream
- The bit stream to write to.
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |