Packagede.popforge.format.furnace
Classpublic class FurnaceFormat
Implementsflash.utils.IExternalizable

The FurnaceFormat class can read and write the popforge furnace format. Since the class implements IExternalizable it can be passed to a class that implements IDataInput or IDataOutput.

Using registerClassAlias makes calls to IDataInput.readObject() or IDataOutput.writeObject() possible.

The furnace file format supports streaming and has been designed for fast and easy read access.

The file structure is like this:

Data contains the raw GZip compressed bytes of the actual file.

Header:

LengthTypeDescription
3bStringIdentifier (should be "FUR")
4buintTotal filesize in bytes (including header)
4bNumberFormat version
4buintNumber of files

Item:

LengthTypeDescription
2buintLength of UTF encoded name in bytes
LEN bytesStringFilename
4buintPosition of file data
4buintLength of the file in bytes

Data: Raw GZip encoded file data.



Public Properties
 PropertyDefined by
  _header : FurnaceHeader
A reference to the file header.
FurnaceFormat
  _items : Array
Array of FurnaceItem items.
FurnaceFormat
  _library : Array
Array of file content represented as ByteArray objects.
FurnaceFormat
  numFiles : uint
[read-only] The number of items in the package.
FurnaceFormat
Public Methods
 MethodDefined by
  
Creates a new FurnaceFormat object.
FurnaceFormat
  
addFile(file:ByteArray, name:String):uint
Adds a new file to the format.
FurnaceFormat
  
fileById(index:uint):ByteArray
Returns the file at given item index.
FurnaceFormat
  
fileByName(fileName:String):ByteArray
Returns the file with given name.
FurnaceFormat
  
fileName(index:uint):String
Returns the filename at given index.
FurnaceFormat
  
readExternal(input:IDataInput):void
Reads the furnace format from a given IDataInput stream.
FurnaceFormat
  
toString():String
Creates and returns a string representation of the object.
FurnaceFormat
  
writeExternal(output:IDataOutput):void
Writes the furnace format to a given IDataOutput stream.
FurnaceFormat
Protected Methods
 MethodDefined by
  
Compresses all objects that are in the library.
FurnaceFormat
  
testBounds(index:uint):void
Tests if an index is out of bounds.
FurnaceFormat
  
Uncompresses all objects that are in the library.
FurnaceFormat
Public Constants
 ConstantDefined by
  VERSION : Number = 1.0
[static] Actual version of the format.
FurnaceFormat
Property detail
_headerproperty
public var _header:FurnaceHeader

A reference to the file header.

_itemsproperty 
public var _items:Array

Array of FurnaceItem items.

_libraryproperty 
public var _library:Array

Array of file content represented as ByteArray objects.

numFilesproperty 
numFiles:uint  [read-only]

The number of items in the package.

Implementation
    public function get numFiles():uint
Constructor detail
FurnaceFormat()constructor
public function FurnaceFormat()

Creates a new FurnaceFormat object.

Method detail
addFile()method
public function addFile(file:ByteArray, name:String):uint

Adds a new file to the format.

Parameters
file:ByteArray — Contents of the file.
 
name:String — Name of the file.

Returns
uint — Index of the new file.
compressLibrary()method 
protected function compressLibrary():void

Compresses all objects that are in the library.

fileById()method 
public function fileById(index:uint):ByteArray

Returns the file at given item index.

Parameters
index:uint — The item index.

Returns
ByteArray — Content of the file.

Throws
— If index is out of bounds.
fileByName()method 
public function fileByName(fileName:String):ByteArray

Returns the file with given name. In order to find the file all items are searched for the given name and returns the first occurence. If no file is found an error will be thrown.

Parameters
fileName:String — A filename.

Returns
ByteArray — Content of the file.

Throws
— If no file with given name exists.
fileName()method 
public function fileName(index:uint):String

Returns the filename at given index.

Parameters
index:uint — The index of the file.

Returns
String — Filename at given index.

Throws
— If index is out of bounds.
readExternal()method 
public function readExternal(input:IDataInput):void

Reads the furnace format from a given IDataInput stream.

Parameters
input:IDataInput — The stream to read from.
testBounds()method 
protected function testBounds(index:uint):void

Tests if an index is out of bounds.

Parameters
index:uint — Index to test.

Throws
— If index is out of bounds.
toString()method 
public function toString():String

Creates and returns a string representation of the object.

Returns
String — The string representation of the object.
uncompressLibrary()method 
protected function uncompressLibrary():void

Uncompresses all objects that are in the library.

writeExternal()method 
public function writeExternal(output:IDataOutput):void

Writes the furnace format to a given IDataOutput stream.

Parameters
output:IDataOutput — The stream to write to.
Constant detail
VERSIONconstant
public static const VERSION:Number = 1.0

Actual version of the format.