legacy.resource.codecs.image
Class ImageIOCodec

java.lang.Object
  extended by legacy.resource.Codec
      extended by legacy.resource.codecs.image.ImageIOCodec
Direct Known Subclasses:
BMPCodec, GIFCodec, JPEGCodec, JPGCodec, PNGCodec, WBMPCodec

public abstract class ImageIOCodec
extends Codec

ImageIOCodec.class

Author:
Benjamin Tarrant

Field Summary
 
Fields inherited from class legacy.resource.Codec
FONT_TYPE, IMAGE_TYPE, MIDI_TYPE, PALLET_TYPE, SOUND_TYPE
 
Constructor Summary
ImageIOCodec()
           
 
Method Summary
 java.io.InputStream decodeNative(java.io.InputStream in)
          decodeNative returns the native version of the resource from a given inputStream
 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 known ImageIO type
 java.lang.Object getType()
          getType returns the known ImageIO type in this case Codec.IMAGE_TYPE.
 boolean isDecodable()
          isDecodable returns true as allowed ImageIO types are decodeble.
 boolean isEncodeable()
          isEncodable returns true as allowed ImageIO types are encodeble.
 boolean validate(java.lang.String resource)
          validate checks if the resource is comaptible with ImageIO and this codec
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageIOCodec

public ImageIOCodec()
Method Detail

validate

public final boolean validate(java.lang.String resource)
validate checks if the resource is comaptible with ImageIO and this codec

Specified by:
validate in class Codec
Parameters:
resource - file to test
Returns:
true on success false otherwise

isDecodable

public final boolean isDecodable()
isDecodable returns true as allowed ImageIO types are decodeble.

Specified by:
isDecodable in class Codec
Returns:
true

decodeNative

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

Specified by:
decodeNative in class Codec
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 final boolean isEncodeable()
isEncodable returns true as allowed ImageIO types are encodeble.

Specified by:
isEncodeable in class Codec
Returns:
true

encodeNative

public final 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

Specified by:
encodeNative in class Codec
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 final java.lang.Object getType()
getType returns the known ImageIO type in this case Codec.IMAGE_TYPE.

Specified by:
getType in class Codec
Returns:
Codec.IMAGE_TYPE

getExtension

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

Specified by:
getExtension in class Codec
Returns:
the file extension associated with a type