public class ShortField extends java.lang.Object implements FixedField
Constructor and Description |
---|
ShortField(int offset)
construct the ShortField with its offset into its containing byte array
|
ShortField(int offset, byte[] data)
Construct the ShortField with its offset into its containing byte array and initialize its value from its byte array
|
ShortField(int offset, short value)
construct the ShortField with its offset into its containing byte array and initialize its value
|
ShortField(int offset, short value, byte[] data)
construct the ShortField with its offset into its containing byte array, initialize its value, and write its value to its byte array
|
Modifier and Type | Method and Description |
---|---|
short |
get()
get the ShortField's current value
(获取 ShortField 的当前值)
|
void |
readFromBytes(byte[] data)
set the value from its offset into an array of bytes
(将值从其偏移量设置为字节数组)
|
void |
readFromStream(java.io.InputStream stream)
set the value from an InputStream
(从 InputStream 设置值)
|
void |
set(short value)
set the ShortField's current value
(设置 ShortField 的当前值)
|
void |
set(short value, byte[] data)
set the ShortField's current value and write it to a byte array
(设置 ShortField 的当前值并将其写入字节数组)
|
java.lang.String |
toString()
return the value as a String
(将值作为字符串返回)
|
void |
writeToBytes(byte[] data)
write the value out to an array of bytes at the appropriate offset
(在适当的偏移量处将值写入字节数组)
|
public ShortField(int offset) throws java.lang.ArrayIndexOutOfBoundsException
offset
- of the field within its byte array
(offset - 其字节数组中的字段)
java.lang.ArrayIndexOutOfBoundsException
- if offset is negative
(java.lang.ArrayIndexOutOfBoundsException - 如果偏移量为负)
public ShortField(int offset, short value) throws java.lang.ArrayIndexOutOfBoundsException
offset
- of the field within its byte array
(offset - 其字节数组中的字段)
value
- the initial value
(value - 初始值)
java.lang.ArrayIndexOutOfBoundsException
- if offset is negative
(java.lang.ArrayIndexOutOfBoundsException - 如果偏移量为负)
public ShortField(int offset, byte[] data) throws java.lang.ArrayIndexOutOfBoundsException
offset
- of the field within its byte array
(offset - 其字节数组中的字段)
data
- the byte array to read the value from
(data - 要从中读取值的字节数组)
java.lang.ArrayIndexOutOfBoundsException
- if the offset is not within the range of 0..(data.length - 1)
(java.lang.ArrayIndexOutOfBoundsException - 如果偏移量不在 0..(data.length - 1) 的范围内)
public ShortField(int offset, short value, byte[] data) throws java.lang.ArrayIndexOutOfBoundsException
offset
- of the field within its byte array
(offset - 其字节数组中的字段)
value
- the initial value
(value - 初始值)
data
- the byte array to write the value to
(data - 要将值写入的字节数组)
java.lang.ArrayIndexOutOfBoundsException
- if offset is negative
(java.lang.ArrayIndexOutOfBoundsException - 如果偏移量为负)
public short get()
public void set(short value)
value
- to be set
(值 - 待设置)
public void set(short value, byte[] data) throws java.lang.ArrayIndexOutOfBoundsException
value
- to be set
(值 - 待设置)
data
- the byte array to write the value to
(data - 要将值写入的字节数组)
java.lang.ArrayIndexOutOfBoundsException
- if the offset is out of range
(java.lang.ArrayIndexOutOfBoundsException - 如果偏移量超出范围)
public void readFromBytes(byte[] data) throws java.lang.ArrayIndexOutOfBoundsException
readFromBytes
in interface
FixedField
(接口 FixedField 中的 readFromBytes)
data
- the byte array from which the value is to be read
(data - 要从中读取值的字节数组)
java.lang.ArrayIndexOutOfBoundsException
- if the offset is out of range
(java.lang.ArrayIndexOutOfBoundsException - 如果偏移量超出范围)
public void readFromStream(java.io.InputStream stream) throws java.io.IOException
readFromStream
in interface
FixedField
(接口 FixedField 中的 readFromStream)
stream
- the InputStream from which the value is to be read
(stream - 要从中读取值的 InputStream)
LittleEndian.BufferUnderrunException
- if there is not enough data available from the InputStream
(LittleEndian.BufferUnderrunException - 如果 InputStream 没有足够的数据可用)
java.io.IOException
- if an IOException is thrown from reading the InputStream
(java.io.IOException - 如果读取 InputStream 时抛出 IOException)
public void writeToBytes(byte[] data) throws java.lang.ArrayIndexOutOfBoundsException
writeToBytes
in interface
FixedField
(接口 FixedField 中的 writeToBytes)
data
- the array of bytes to which the value is to be written
(data - 要写入值的字节数组)
java.lang.ArrayIndexOutOfBoundsException
- if the offset is out of range
(java.lang.ArrayIndexOutOfBoundsException - 如果偏移量超出范围)
public java.lang.String toString()
toString
in interface
FixedField
(接口 FixedField 中的 toString)
toString
in class
java.lang.Object
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.