NWNFiles
Class GFFFile.Structure

java.lang.Object
  |
  +--NWNFiles.GFFFile.Structure
All Implemented Interfaces:
Cloneable
Enclosing class:
GFFFile

public class GFFFile.Structure
extends Object
implements Cloneable

Author:
Alexandre Brunel This class represents a GFF file structure.

Constructor Summary
  GFFFile.Structure(long _type, GFFFile.Field[] fields)
          Constructs a Structure object.
protected GFFFile.Structure(long _type, GFFFile _owner, GFFFile.Field[] fields)
          Constructs a Structure object.
 
Method Summary
 void addField(GFFFile.Field newField)
          Adds a field to the structures.
 GFFFile.Field addField(long _type, String _label, Object _data)
          Creates and adds a field to the structures.
 Object clone()
           
 Object clone(GFFFile target)
          Creates a copy of this object to be used in the given GFFFile.
 GFFFile.Field getField(int index)
          REturns the index+1th field.
 GFFFile.Field getField(String label)
          Returns the field whose label is label.
 int getFieldCount()
           
 GFFFile getOwner()
           
 long getType()
           
protected  void setOwner(GFFFile _owner)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GFFFile.Structure

public GFFFile.Structure(long _type,
                         GFFFile.Field[] fields)
Constructs a Structure object. If fields is null, then the structure will be empty.

Parameters:
_type - Type of the structure.
fields - A list of the field in the structure.

GFFFile.Structure

protected GFFFile.Structure(long _type,
                            GFFFile _owner,
                            GFFFile.Field[] fields)
Constructs a Structure object. If fields is null, then the structure will be empty.

Parameters:
_type - Type of the structure.
_owner - The gff file to which belong the structure.
fields - A list of the field in the structure.
Method Detail

addField

public void addField(GFFFile.Field newField)
Adds a field to the structures. Changes to a structure are notified to its owner. The new field is added to the GFF file field list, so is its label.

Parameters:
newField - The field to be added to the structure.

addField

public GFFFile.Field addField(long _type,
                              String _label,
                              Object _data)
                       throws NameTooLong
Creates and adds a field to the structures. Changes to a structure are notified to its owner. The new field is added to the GFF file field list, so is its label. _data can be null.

Parameters:
_type - The field type, see the FieldType class for further information.
_label - The field label.
_data - The data contained by the field.
Returns:
Returns the newly created field.
Throws:
NameTooLong - if the label is longer than 16 characters.

getField

public GFFFile.Field getField(int index)
REturns the index+1th field.

Parameters:
index - index of the field to be returned.
Returns:
A Field object or null if index is gretter than the number of field in the structure.

getField

public GFFFile.Field getField(String label)
Returns the field whose label is label.

Parameters:
label - the label of the field to be returned.
Returns:
A Field object or null if no field matches the given label.

getFieldCount

public int getFieldCount()

getOwner

public GFFFile getOwner()

getType

public long getType()

setOwner

protected void setOwner(GFFFile _owner)

toString

public String toString()
Overrides:
toString in class Object

clone

public Object clone()
Overrides:
clone in class Object

clone

public Object clone(GFFFile target)
Creates a copy of this object to be used in the given GFFFile.

Parameters:
target - Target GFFFile.
Returns:
A copy of this object