NWNFiles
Class GFFFile

java.lang.Object
  |
  +--java.util.Observable
        |
        +--NWNFiles.NWNFile
              |
              +--NWNFiles.GFFFile

public class GFFFile
extends NWNFile

14 juil. 2003

Author:
Alexandre Brunel This class handles GFF files.

Nested Class Summary
 class GFFFile.Field
           
 class GFFFile.Structure
           
 
Nested classes inherited from class NWNFiles.NWNFile
NWNFile.FileState
 
Field Summary
static String DefaultVersion
          Default GFF file version.
static long FieldBlockSize
          Sise, in bytes, of a field block in a gff file.
static long HeaderSize
          Size, in bytes, of a gff file header.
static String[] KnownGFFExtensions
          List of the known gff file extensions.
static long LabelBlockSize
          Size, in bytes, of a label block in the gff file.
static long StructBlockSize
          Size, in bytes, of a sctructure block in the gff file.
 
Fields inherited from class NWNFiles.NWNFile
currentLanguage, fileState
 
Constructor Summary
GFFFile()
          Constructs GFFFile object, this file has the default root structure of type 0xFFFFFFFF
GFFFile(File file)
          Constructs a GFFFile object.
GFFFile(File file, Observer observer)
          Constructs a GFFFile object.
GFFFile(Observer observer)
          Constructs a GFFFile object, this file has the default root structure of type 0xFFFFFFFF An observer can be assigned to the file to monitor its modifications.
 
Method Summary
protected  void addField(GFFFile.Field newField)
           
protected  String addLabel(String label)
           
 void addStructure(GFFFile.Structure newStruct)
           
 GFFFile.Structure addStructure(long type, GFFFile.Field[] fields)
           
 long getFieldCount()
           
 long getFieldDataCount()
           
 long getFieldIndiciesCount()
           
 File getFilePath()
           
 String getFileType()
           
 String getFileVersion()
           
 long getLabelCount()
           
 long getListIndiciesCount()
           
 GFFFile.Structure getStruct(int index)
           
 long getStructCount()
           
 boolean isModified()
           
 void load(File file)
           
 void removeStruct(GFFFile.Structure structure)
          Removes a structure from the GFF file.
 void save()
           
 void save(File newFilePath)
           
protected  void setFieldCount(long _fieldCount)
           
 void setFileType(String fileType)
           
protected  void setIsModified(boolean modified)
           
 
Methods inherited from class NWNFiles.NWNFile
getCurrentLanguage, getFileState, setCurrentLanguage
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DefaultVersion

public static final String DefaultVersion
Default GFF file version.

See Also:
Constant Field Values

FieldBlockSize

public static final long FieldBlockSize
Sise, in bytes, of a field block in a gff file.

See Also:
Constant Field Values

HeaderSize

public static final long HeaderSize
Size, in bytes, of a gff file header.

See Also:
Constant Field Values

KnownGFFExtensions

public static final String[] KnownGFFExtensions
List of the known gff file extensions. Extensions are in uppercasse.


LabelBlockSize

public static final long LabelBlockSize
Size, in bytes, of a label block in the gff file.

See Also:
Constant Field Values

StructBlockSize

public static final long StructBlockSize
Size, in bytes, of a sctructure block in the gff file.

See Also:
Constant Field Values
Constructor Detail

GFFFile

public GFFFile()
Constructs GFFFile object, this file has the default root structure of type 0xFFFFFFFF


GFFFile

public GFFFile(File file)
        throws FileDoesNotExist,
               InvalidFile,
               NameTooLong,
               FileNotFoundException,
               IOException,
               InvalidType
Constructs a GFFFile object. The file represented by the argument of the constructor is parsed to get the gff file contence.

Parameters:
file - The file to parse.
Throws:
FileDoesNotExist - If the file cannot be found.
InvalidFile - If the file is not a valid gff file.
NameTooLong - If the file is not a valid gff file.
FileNotFoundException - If the file cannot be found.
IOException - If the file is not a valid gff file.
InvalidType - If the file is not a valid gff file.

GFFFile

public GFFFile(File file,
               Observer observer)
        throws FileDoesNotExist,
               InvalidFile,
               NameTooLong,
               FileNotFoundException,
               IOException,
               InvalidType
Constructs a GFFFile object. The file represented by the argument of the constructor is parsed to get the gff file contence. An observer can be assigned to the file to monitor its modifications. The GFFFile can pass a FileState object when it's modified.

Parameters:
file - The file to parse.
observer - An observer.
Throws:
FileDoesNotExist - If the file cannot be found.
InvalidFile - If the file is not a valid gff file.
NameTooLong - If the file is not a valid gff file.
FileNotFoundException - If the file cannot be found.
IOException - If the file is not a valid gff file.
InvalidType - If the file is not a valid gff file.

GFFFile

public GFFFile(Observer observer)
Constructs a GFFFile object, this file has the default root structure of type 0xFFFFFFFF An observer can be assigned to the file to monitor its modifications. The GFFFile can pass a FileState object when it's modified.

Parameters:
observer - An observer.
Throws:
FileDoesNotExist - If the file cannot be found.
InvalidFile - If the file is not a valid gff file.
NameTooLong - If the file is not a valid gff file.
FileNotFoundException - If the file cannot be found.
IOException - If the file is not a valid gff file.
InvalidType - If the file is not a valid gff file.
Method Detail

addField

protected void addField(GFFFile.Field newField)

addLabel

protected String addLabel(String label)

addStructure

public GFFFile.Structure addStructure(long type,
                                      GFFFile.Field[] fields)

addStructure

public void addStructure(GFFFile.Structure newStruct)

getFieldCount

public long getFieldCount()

getFieldDataCount

public long getFieldDataCount()

getFieldIndiciesCount

public long getFieldIndiciesCount()

getFilePath

public File getFilePath()

getFileType

public String getFileType()

getFileVersion

public String getFileVersion()

getLabelCount

public long getLabelCount()

getListIndiciesCount

public long getListIndiciesCount()

getStruct

public GFFFile.Structure getStruct(int index)

getStructCount

public long getStructCount()

isModified

public boolean isModified()

load

public void load(File file)
          throws FileDoesNotExist,
                 InvalidFile,
                 NameTooLong,
                 FileNotFoundException,
                 IOException,
                 InvalidType
FileDoesNotExist
InvalidFile
NameTooLong
FileNotFoundException
IOException
InvalidType

save

public void save()
          throws IOException,
                 InvalidType
IOException
InvalidType

save

public void save(File newFilePath)
          throws IOException,
                 InvalidType
IOException
InvalidType

setFieldCount

protected final void setFieldCount(long _fieldCount)

setFileType

public void setFileType(String fileType)

setIsModified

protected void setIsModified(boolean modified)

removeStruct

public void removeStruct(GFFFile.Structure structure)
Removes a structure from the GFF file. If other structures were refering to that strucutre, the GFF file may not be valid anymore. All field of the structures are removed from the file.

Parameters:
structure - To remove from the file.