com.flagstone.transform
Class Movie

java.lang.Object
  extended by com.flagstone.transform.Movie
All Implemented Interfaces:
Copyable<Movie>

public final class Movie
extends Object
implements Copyable<Movie>

Movie is a container class for the objects that represents the data structures in a Flash file.

Movie is the core class of the Transform package. It is used to parse and generate Flash files, translating the binary format of the Flash file into an list objects that can be inspected and updated.

A Movie object also contains the attributes that make up the header information of the Flash file, identifying the version support, size of the Flash Player screen, etc.

Movie is also used to generate the unique identifiers that are used to reference objects. Each call to newIdentifier() returns a unique number for the current. The identifiers are generated using a simple counter. When a movie is decoded this counter is updated each time an object definition is decoded. This allows new objects to be added and ensures that the identifier does not conflict with an existing object.


Field Summary
static byte[] CWS
          Signature identifying Compressed Flash (SWF) files.
static byte[] FWS
          Signature identifying Flash (SWF) files.
static int VERSION
          The version of Flash supported.
 
Constructor Summary
Movie()
          Creates a new Movie.
Movie(Movie movie)
          Creates a complete copy of this movie.
 
Method Summary
 Movie add(MovieTag anObject)
          Adds the object to the Movie.
 Movie copy()
          Creates a complete copy of this object.
 void decodeFromFile(File file)
          Decodes the contents of the specified file.
 void decodeFromStream(InputStream stream)
          Decodes the binary Flash data from an input stream.
 void decodeFromUrl(URL url)
          Decodes a Flash file referenced by a URL.
 void encodeToFile(File file)
          Encodes the list of objects and writes the data to the specified file.
 void encodeToStream(OutputStream stream)
          Returns the encoded representation of the list of objects that this Movie contains.
 List<MovieTag> getObjects()
          Get the list of objects contained in the Movie.
 void setEncoding(CharacterEncoding enc)
          Sets the encoding scheme for strings encoded and decoded from Flash files.
 void setObjects(List<MovieTag> list)
          Sets the list of objects contained in the Movie.
 void setRegistry(DecoderRegistry decoderRegistry)
          Sets the registry containing the object used to decode the different types of object found in a movie.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final int VERSION
The version of Flash supported.

See Also:
Constant Field Values

FWS

public static final byte[] FWS
Signature identifying Flash (SWF) files.


CWS

public static final byte[] CWS
Signature identifying Compressed Flash (SWF) files.

Constructor Detail

Movie

public Movie()
Creates a new Movie.


Movie

public Movie(Movie movie)
Creates a complete copy of this movie.

Parameters:
movie - the Movie to copy.
Method Detail

setRegistry

public void setRegistry(DecoderRegistry decoderRegistry)
Sets the registry containing the object used to decode the different types of object found in a movie.

Parameters:
decoderRegistry - a central registry to decoders of different types of object.

setEncoding

public void setEncoding(CharacterEncoding enc)
Sets the encoding scheme for strings encoded and decoded from Flash files.

Parameters:
enc - the character encoding used for strings.

getObjects

public List<MovieTag> getObjects()
Get the list of objects contained in the Movie.

Returns:
the list of objects that make up the movie.

setObjects

public void setObjects(List<MovieTag> list)
Sets the list of objects contained in the Movie.

Parameters:
list - the list of objects that describe a coder. Must not be null.

add

public Movie add(MovieTag anObject)
Adds the object to the Movie.

Parameters:
anObject - the object to be added to the movie. Must not be null.
Returns:
this object.

copy

public Movie copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<Movie>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

toString

public String toString()

Overrides:
toString in class Object

decodeFromFile

public void decodeFromFile(File file)
                    throws DataFormatException,
                           IOException
Decodes the contents of the specified file.

Parameters:
file - the Flash file that will be parsed.
Throws:
DataFormatException - - if the file does not contain Flash data.
IOException - - if an I/O error occurs while reading the file.

decodeFromUrl

public void decodeFromUrl(URL url)
                   throws DataFormatException,
                          IOException
Decodes a Flash file referenced by a URL.

Parameters:
url - the Uniform Resource Locator referencing the file.
Throws:
IOException - if there is an error reading the file.
DataFormatException - if there is a problem decoding the font, either it is in an unsupported format or an error occurred while decoding the font data.

decodeFromStream

public void decodeFromStream(InputStream stream)
                      throws DataFormatException,
                             IOException
Decodes the binary Flash data from an input stream. If an error occurs while the data is being decoded an exception is thrown. The list of objects in the Movie will contain the last tag successfully decoded.

Parameters:
stream - an InputStream from which the objects will be decoded.
Throws:
DataFormatException - if the file does not contain Flash data.
IOException - if an I/O error occurs while reading the file.

encodeToFile

public void encodeToFile(File file)
                  throws IOException,
                         DataFormatException
Encodes the list of objects and writes the data to the specified file. If an error occurs while encoding the file then an exception is thrown.

Parameters:
file - the Flash file that the movie will be encoded to.
Throws:
IOException - - if an I/O error occurs while writing the file.
DataFormatException - if an error occurs when compressing the flash file.

encodeToStream

public void encodeToStream(OutputStream stream)
                    throws DataFormatException,
                           IOException
Returns the encoded representation of the list of objects that this Movie contains. If an error occurs while encoding the file then an exception is thrown.

Parameters:
stream - the output stream that the video will be encoded to.
Throws:
IOException - - if an I/O error occurs while encoding the file.
DataFormatException - if an error occurs when compressing the flash file.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.