rebuild.graphics.tiff
Class Tag

java.lang.Object
  extended by rebuild.graphics.tiff.Tag
Direct Known Subclasses:
ASCIITag, ByteTag, DoubleTag, FloatTag, ImageLengthTag, ImageWidthTag, Long8Tag, LongTag, RationalTag, RowsPerStripTag, ShortTag, StripByteCountsTag, StripOffsetsTag

public abstract class Tag
extends java.lang.Object

The abstract tag that will be used in TIFFs.

Since:
BBX 1.0.1

Field Summary
protected  long count
           
protected  java.lang.Object data
           
protected  short dataType
           
protected  long value
           
 
Constructor Summary
protected Tag(short tag, short dataType, int count, int value, java.lang.Object data)
          Create a new Tag.
protected Tag(short tag, short dataType, long count, long value, java.lang.Object data)
          Create a new Tag.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Determine if an Object is the same as this Tag.
protected abstract  boolean extraData(boolean big)
          This method figures out if any extra data is exists, this method can search the data type, extra data, value, and count.
 long getBigCount()
          Get the number of values contained in this tag.
 long getBigValue()
          Get the left-justified value that the tag contains, any values that do not fit in a 8 byte boundary should have it's value stored in data.
 int getCount()
          Get the number of values contained in this tag.
 short getDataType()
          Get the data type.
 java.lang.Object getExtraData()
          Get any extra data that the tag contains, that is any data that does not fit into 4/8 bytes.
 boolean getIfExtraDataExists(boolean big)
          Get if the tag contains extra data.
 short getTagType()
          Get the tag type.
static short getTagTypeValue()
          Get the Tag's type.
 int getValue()
          Get the left-justified value that the tag contains, any values that do not fit in a 4 byte boundary should have it's value stored in data.
abstract  boolean hasDefault()
          Get if this Tag can have a default value, often defined by a parameter-less constructor.
 int hashCode()
           
abstract  boolean isDefault()
          Get if this Tag's current value is the default value.
 void setCount(int count)
          Set the number of values contained in this tag.
 void setCount(long count)
          Set the number of values contained in this tag.
 void setDataType(short dataType)
          Set the data type.
protected  void setExtraData(java.lang.Object obj)
          Set any extra data that the tag should contain.
protected abstract  void setupForBigTIFF(boolean set)
          Setup/un-setup the tag for use in BigTIFF.
 void setValue(int value)
          Set the left-justified value that the tag contains.
 void setValue(long value)
          Set the left-justified value that the tag contains.
 java.lang.String toString()
           
 void write(Writer wr)
          Write the tag to a Writer.
 void write(Writer wr, int offset)
          Write the tag to a Writer.
 void write(Writer wr, long offset)
          Write the tag to a Writer.
 void write(Writer wr, long offset, boolean big)
          Write the tag to a Writer.
 void writeBig(Writer wr)
          Write the tag to a Writer.
abstract  void writeData(Writer wr)
          The extra data writer, if any extra data exists then this method will be called and (through internal methods) a offset to the data will be used in place of the value parameter.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

dataType

protected short dataType

count

protected long count

value

protected long value

data

protected java.lang.Object data
Constructor Detail

Tag

protected Tag(short tag,
              short dataType,
              int count,
              int value,
              java.lang.Object data)
Create a new Tag.

Parameters:
tag - The tag code for this tag.
dataType - The type of data that will be written.
count - The number of items that will be written. Note this is not the number of bytes to write but the number of items.
value - The value that this tag has. The tag must always be left justified, so if a Writer.SHORT is to be written then it's value must be value << 16. If the tag contains any data bigger then 4 bytes then it must be set in data and this value will be ignored.
data - Any data that does not fit in the 4 byte value parameter.

Tag

protected Tag(short tag,
              short dataType,
              long count,
              long value,
              java.lang.Object data)
Create a new Tag.

Parameters:
tag - The tag code for this tag.
dataType - The type of data that will be written.
count - The number of items that will be written. Note this is not the number of bytes to write but the number of items.
value - The value that this tag has. The tag must always be left justified, so if a Writer.SHORT is to be written then it's value must be value << 16. If the tag contains any data bigger then 4 bytes then it must be set in data and this value will be ignored.
data - Any data that does not fit in the 8 byte value parameter.
Method Detail

write

public final void write(Writer wr)
                 throws java.io.IOException
Write the tag to a Writer. This should only be called if no extra data exists else the tag will not be written.

Parameters:
wr - The writer to write the tag to.
Throws:
java.io.IOException - If any IO exception occurs.

writeBig

public final void writeBig(Writer wr)
                    throws java.io.IOException
Write the tag to a Writer. This should only be called if no extra data exists else the tag will not be written.

Parameters:
wr - The writer to write the tag to.
Throws:
java.io.IOException - If any IO exception occurs.

write

public final void write(Writer wr,
                        long offset)
                 throws java.io.IOException
Write the tag to a Writer.

Parameters:
wr - The writer to write the tag to.
offset - The absolute offset to write instead of the value data. If the value should be written then -1 should be passed here.
Throws:
java.io.IOException - If any IO exception occurs.

write

public final void write(Writer wr,
                        int offset)
                 throws java.io.IOException
Write the tag to a Writer.

Parameters:
wr - The writer to write the tag to.
offset - The absolute offset to write instead of the value data. If the value should be written then -1 should be passed here.
Throws:
java.io.IOException - If any IO exception occurs.

write

public final void write(Writer wr,
                        long offset,
                        boolean big)
                 throws java.io.IOException
Write the tag to a Writer.

Parameters:
wr - The writer to write the tag to.
offset - The absolute offset to write instead of the value data. If the value should be written then -1 should be passed here.
big - If this is writing a BigTIFF tag.
Throws:
java.io.IOException - If any IO exception occurs.

getTagType

public final short getTagType()
Get the tag type.

Returns:
The tag type.

getDataType

public final short getDataType()
Get the data type.

Returns:
The data type.
See Also:
Writer

setDataType

public void setDataType(short dataType)
Set the data type.

Parameters:
dataType - The data type to set.
See Also:
Writer

getCount

public final int getCount()
Get the number of values contained in this tag. If all the values can stay in a 4 byte boundary then the data is stored (left-justified) in the value parameter, else it is in the data parameter.

Returns:
The number of values contained in the tag.

getBigCount

public final long getBigCount()
Get the number of values contained in this tag. If all the values can stay in a 8 byte boundary then the data is stored (left-justified) in the value parameter, else it is in the data parameter.

Returns:
The number of values contained in the tag.

setCount

public void setCount(int count)
Set the number of values contained in this tag.

Parameters:
count - The number of values contained in the tag.
See Also:
getCount

setCount

public void setCount(long count)
Set the number of values contained in this tag.

Parameters:
count - The number of values contained in the tag.
See Also:
getCount

getValue

public final int getValue()
Get the left-justified value that the tag contains, any values that do not fit in a 4 byte boundary should have it's value stored in data.

Returns:
The value that the tag contains.

getBigValue

public final long getBigValue()
Get the left-justified value that the tag contains, any values that do not fit in a 8 byte boundary should have it's value stored in data.

Returns:
The value that the tag contains.

setValue

public void setValue(int value)
Set the left-justified value that the tag contains.

Parameters:
value - The value that the tag should contains.
See Also:
getValue

setValue

public void setValue(long value)
Set the left-justified value that the tag contains.

Parameters:
value - The value that the tag should contains.
See Also:
getValue

getExtraData

public final java.lang.Object getExtraData()
Get any extra data that the tag contains, that is any data that does not fit into 4/8 bytes. Note that this is not the value parameter AND the extra data, it is one or the other.

Returns:
The extra data that the tag contains.

setExtraData

protected void setExtraData(java.lang.Object obj)
Set any extra data that the tag should contain.

Parameters:
obj - The extra data that the tag should contain.
See Also:
getExtraData

getIfExtraDataExists

public final boolean getIfExtraDataExists(boolean big)
Get if the tag contains extra data.

Parameters:
big - true if the tag is being written to a BigTIFF, false if otherwise.
Returns:
true if the tag contains extra data, false if otherwise.

writeData

public abstract void writeData(Writer wr)
                        throws java.io.IOException
The extra data writer, if any extra data exists then this method will be called and (through internal methods) a offset to the data will be used in place of the value parameter.

Parameters:
wr - The writer used to write the extra data.
Throws:
java.io.IOException - If any IO exception occurs.

extraData

protected abstract boolean extraData(boolean big)
This method figures out if any extra data is exists, this method can search the data type, extra data, value, and count. It is called whenever one of these types change.

Parameters:
big - true if the tag is being written to a BigTIFF, false if otherwise.
Returns:
true if the tag contains extra data, false if otherwise.

setupForBigTIFF

protected abstract void setupForBigTIFF(boolean set)
Setup/un-setup the tag for use in BigTIFF.

Parameters:
set - true if the tag should be preped for BigTIFF, false if otherwise.

hasDefault

public abstract boolean hasDefault()
Get if this Tag can have a default value, often defined by a parameter-less constructor.

Returns:
true if the Tag has a default value, false if otherwise. Default is false.

isDefault

public abstract boolean isDefault()
Get if this Tag's current value is the default value. This is ignored if hasDefault() returns false.

Returns:
true if the Tag's value is the default value, false if otherwise.

getTagTypeValue

public static short getTagTypeValue()
Get the Tag's type.

Returns:
The Tag's type.

equals

public boolean equals(java.lang.Object obj)
Determine if an Object is the same as this Tag.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The Object to compare.
Returns:
true if the objects are the same, false if otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object