legacy.resource
Class Codec

java.lang.Object
  extended by legacy.resource.Codec
Direct Known Subclasses:
ImageIOCodec

public abstract class Codec
extends java.lang.Object

Codec is deigned to handle resource types and the loading of. calls to encode and decode should encode from a native type or decode to a native type.
Note native types are a format recognized by legacy and any new implementaion of a type will require adding coding to the legacy and resource management classes.

Author:
Benjamin Tarrant

Field Summary
static java.lang.Object FONT_TYPE
          Internal reference for a font type
static java.lang.Object IMAGE_TYPE
          Internal reference for a image type
static java.lang.Object MIDI_TYPE
          Internal reference for a midi type
static java.lang.Object PALLET_TYPE
          Internal reference for a pallet type
static java.lang.Object SOUND_TYPE
          Internal reference for a sound type
 
Constructor Summary
Codec()
           
 
Method Summary
abstract  java.io.InputStream decodeNative(java.io.InputStream in)
          decodeNative returns the native version of the resource from a given inputStream
abstract  void encodeNative(java.io.OutputStream out, java.lang.Class format, java.lang.Object src)
          encodeNative writes to a given output stream from native version of the resource
abstract  java.lang.String getExtension()
          getExtension returns an extension of a knwon type
abstract  java.lang.Object getType()
          getType returns the known native type.
abstract  boolean isDecodable()
          isDecodable check if the ablility to read an input stream is infact possible
abstract  boolean isEncodeable()
          isEncodable check if the ablility to write an output stream is infact possible
abstract  boolean validate(java.lang.String resource)
          validate is a method wich is called to check if a resource is actualy associated with this Codec
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMAGE_TYPE

public static final java.lang.Object IMAGE_TYPE
Internal reference for a image type


PALLET_TYPE

public static final java.lang.Object PALLET_TYPE
Internal reference for a pallet type


FONT_TYPE

public static final java.lang.Object FONT_TYPE
Internal reference for a font type


MIDI_TYPE

public static final java.lang.Object MIDI_TYPE
Internal reference for a midi type


SOUND_TYPE

public static final java.lang.Object SOUND_TYPE
Internal reference for a sound type

Constructor Detail

Codec

public Codec()
Method Detail

validate

public abstract boolean validate(java.lang.String resource)
validate is a method wich is called to check if a resource is actualy associated with this Codec

Parameters:
resource - file to test
Returns:
true on success false otherwise

isDecodable

public abstract boolean isDecodable()
isDecodable check if the ablility to read an input stream is infact possible

Returns:
true on success false otherwise

decodeNative

public abstract java.io.InputStream decodeNative(java.io.InputStream in)
                                          throws java.io.IOException
decodeNative returns the native version of the resource from a given inputStream

Parameters:
in - input to transcode if needed
Returns:
an input stream for the file type
Throws:
java.io.IOException - if an unforseen issue reading a file has occoured

isEncodeable

public abstract boolean isEncodeable()
isEncodable check if the ablility to write an output stream is infact possible

Returns:
true on success false otherwise

encodeNative

public abstract void encodeNative(java.io.OutputStream out,
                                  java.lang.Class format,
                                  java.lang.Object src)
                           throws java.io.IOException
encodeNative writes to a given output stream from native version of the resource

Parameters:
out - the output
format - the file format to encode from
src - the Object it self
Throws:
java.io.IOException - if an unforseen issue reading a file has occoured

getType

public abstract java.lang.Object getType()
getType returns the known native type.

Returns:
an object of a known type

getExtension

public abstract java.lang.String getExtension()
getExtension returns an extension of a knwon type

Returns:
the file extension associated with a type