|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteap.freeciv.Field
eap.freeciv.ArrayField
Represents a set of repeated fields in a packet. An array is composed of zero or more elements. Each element is composed of one or more fields. Each element has the same fields. These fields can be of any type, including other arrays - though currently the freeciv packets don't do that.
When referencing the data in a packet, this class indicates the element by
calling Field.addIndex(int)
. That means that in general, you indicate
the element you want by appending "[index]" to the keyword for a datum in
a packet.
There are three ways to specify the number of elements in an array.
Constructor Summary | |
ArrayField(String repeat)
Create a new array with the given repeat count. |
Method Summary | |
void |
addField(Field field)
Append a field to the end of the list of fields in this array. |
void |
addIndex(int index)
Add an index to this file. |
int |
getSize(Packet packet)
Sum the sizes of all the elements in this array. |
boolean |
isSet(Packet packet)
Returns true if all the fields for all the elements in the array are set in the given packet. |
void |
read(Packet packet,
PacketSource source)
Read the field from the given source and write its contents to the given packet. |
void |
removeIndex()
calls removeIndex for all of the fields in this array. |
void |
setRepeat(String repeat)
Sets the number of elements according to a given string. |
void |
write(Packet packet,
OutputStream out)
Write this field to the given stream, taking values from the given packet. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ArrayField(String repeat)
setRepeat(String)
.
Method Detail |
public void addIndex(int index)
addIndex
in class Field
ArrayField
public void removeIndex()
removeIndex
in class Field
addIndex(int)
public boolean isSet(Packet packet)
isSet
in class Field
public void setRepeat(String repeat)
Integer.parseInt(String)
, then it is interpreted as
a fixed number of elements. If the string is null or empty, then the array
continues to the end of the packet. Otherwise the string is
assumed to be the name of a field in the packet. The value of this field
will be interpreted as an integer indicating the repeat count.
public void addField(Field field)
public void read(Packet packet, PacketSource source) throws IOException
Field
read
in class Field
IOException
public void write(Packet packet, OutputStream out) throws IOException
Field
write
in class Field
IOException
public int getSize(Packet packet)
getSize
in class Field
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |