it.tidalwave.imageio.raw
Class AbstractTag

java.lang.Object
  extended by it.tidalwave.imageio.raw.AbstractTag
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CIFFTag, TIFFTag

public abstract class AbstractTag
extends java.lang.Object
implements java.io.Serializable

This class represents an abstract tag, which is an aggregate of a numeric code, a type and a value. The value can be an integer, a short, a byte, a float or a rational; can be of any multiplicity. The detailed meaning of the type is not specified and demanded to concrete subclasses.
This class provides some protected readXXX() methods to read data from an image stream.

Version:
CVS $Id: AbstractTag.java,v 1.2 2006/02/08 20:19:08 fabriziogiudici Exp $
Author:
Fabrizio Giudici
See Also:
Serialized Form

Field Summary
protected  java.lang.String asciiValue
          The values as an ASCII string.
protected  int code
          The numerical tag code.
protected  float[] floatValue
          The values as floats.
protected  int[] intValue
          The values as integers.
protected  TagRational[] rationalValue
          The values as rationals.
protected  TagRegistry registry
          The registry this tag belongs to.
protected  int type
          The type of this tag.
protected  byte[] undefinedValue
          The values as bytes.
protected  int valuesCount
          The number of contained values.
 
Constructor Summary
AbstractTag(TagRegistry registry, int code)
          Creates an AbstractTag in a registry given s numeric code.
 
Method Summary
protected  void appendValues(java.lang.StringBuffer buffer)
          Appends the contained value(s) to the given StringBuffer.
 java.lang.String getASCIIValue()
          Returns the value as an ASCII string.
 byte[] getByteValues()
          Returns the value as bytes.
 int getCode()
          Returns the numeric code of this tag.
 float[] getFloatValues()
          Returns the value as floats.
 int[] getIntValues()
          Returns the value as integers.
 TagRational[] getRationalValues()
          Returns the value as rationals.
 int getType()
          Return the type of values contained in this tag.
 java.lang.Object getValue()
          Returns the value(s) contained in this tag as the most pertinent type.
 int getValuesCount()
          Returns the count of values in this tag.
protected  int[] readByteValues(javax.imageio.stream.ImageInputStream iis, long valueOffset, int valuesCount)
          Reads byte values from the given image input stream.
protected  int[] readIntValues(javax.imageio.stream.ImageInputStream iis, long valueOffset, int valuesCount)
          Reads integer values from the given image input stream.
protected  int[] readShortValues(javax.imageio.stream.ImageInputStream iis, long valueOffset, int valuesCount)
          Reads short values from the given image input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registry

protected transient TagRegistry registry
The registry this tag belongs to. This is transient so that this class can be serialized without carrying along the whole registry! Upon deserialization the link to the registry must be restored by using the registryName.


code

protected int code
The numerical tag code.


type

protected int type
The type of this tag. AbstractTag does not define any dictionary for this field - it leaves this task to concrete subclasses.


valuesCount

protected int valuesCount
The number of contained values.


undefinedValue

protected byte[] undefinedValue
The values as bytes.


intValue

protected int[] intValue
The values as integers.


rationalValue

protected TagRational[] rationalValue
The values as rationals.


floatValue

protected float[] floatValue
The values as floats.


asciiValue

protected java.lang.String asciiValue
The values as an ASCII string.

Constructor Detail

AbstractTag

public AbstractTag(TagRegistry registry,
                   int code)
Creates an AbstractTag in a registry given s numeric code.

Parameters:
registry - the registry this tag belongs to
code - the code
Method Detail

getCode

public int getCode()
Returns the numeric code of this tag.

Returns:
the code

getType

public int getType()
Return the type of values contained in this tag.

Returns:
the type

getValuesCount

public int getValuesCount()
Returns the count of values in this tag.

Returns:
the count of values

getValue

public java.lang.Object getValue()
Returns the value(s) contained in this tag as the most pertinent type.

Returns:
the value

getByteValues

public byte[] getByteValues()
Returns the value as bytes.

Returns:
the values as bytes

getIntValues

public int[] getIntValues()
Returns the value as integers.

Returns:
the values as integers

getFloatValues

public float[] getFloatValues()
Returns the value as floats.

Returns:
the values as floats

getRationalValues

public TagRational[] getRationalValues()
Returns the value as rationals.

Returns:
the values as rationals

getASCIIValue

public java.lang.String getASCIIValue()
Returns the value as an ASCII string.

Returns:
the values as an ASCII string

readIntValues

protected int[] readIntValues(javax.imageio.stream.ImageInputStream iis,
                              long valueOffset,
                              int valuesCount)
                       throws java.io.IOException
Reads integer values from the given image input stream.

Parameters:
iis - the stream to read from
valueOffset - the offset to read at
valuesCount - the number of values to read
Returns:
the integers
Throws:
java.io.IOException - if a I/O error occurs

readShortValues

protected int[] readShortValues(javax.imageio.stream.ImageInputStream iis,
                                long valueOffset,
                                int valuesCount)
                         throws java.io.IOException
Reads short values from the given image input stream.

Parameters:
iis - the stream to read from
valueOffset - the offset to read at
valuesCount - the number of values to read
Returns:
the integers
Throws:
java.io.IOException - if a I/O error occurs

readByteValues

protected int[] readByteValues(javax.imageio.stream.ImageInputStream iis,
                               long valueOffset,
                               int valuesCount)
                        throws java.io.IOException
Reads byte values from the given image input stream.

Parameters:
iis - the stream to read from
valueOffset - the offset to read at
valuesCount - the number of values to read
Returns:
the integers
Throws:
java.io.IOException - if a I/O error occurs

appendValues

protected void appendValues(java.lang.StringBuffer buffer)
Appends the contained value(s) to the given StringBuffer. This method is used by Object.toString().

Parameters:
buffer - buffer