Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.swt.internal.image
Class PngChunk  view PngChunk download PngChunk.java

java.lang.Object
  extended byorg.eclipse.swt.internal.image.PngChunk
Direct Known Subclasses:
PngIdatChunk, PngIendChunk, PngIhdrChunk, PngPlteChunk, PngTrnsChunk

class PngChunk
extends java.lang.Object


Field Summary
(package private) static int CHUNK_IDAT
           
(package private) static int CHUNK_IEND
           
(package private) static int CHUNK_IHDR
           
(package private) static int CHUNK_PLTE
           
(package private) static int CHUNK_tRNS
           
(package private) static int CHUNK_UNKNOWN
           
(package private) static int[] CRC_TABLE
           
(package private) static int DATA_OFFSET
           
(package private) static int LENGTH_FIELD_LENGTH
           
(package private) static int LENGTH_OFFSET
           
(package private) static int MIN_LENGTH
           
(package private)  byte[] reference
           
(package private) static int TYPE_FIELD_LENGTH
           
(package private) static byte[] TYPE_IDAT
           
(package private) static byte[] TYPE_IEND
           
(package private) static byte[] TYPE_IHDR
           
(package private) static int TYPE_OFFSET
           
(package private) static byte[] TYPE_PLTE
           
(package private) static byte[] TYPE_tRNS
           
 
Constructor Summary
(package private) PngChunk(byte[] reference)
          Construct a PngChunk using the reference bytes given.
 
Method Summary
(package private)  boolean checkCRC()
          Compute the CRC value for the chunk's data.
(package private)  int computeCRC()
          Answer the CRC value of chunk's data.
(package private)  void contributeToString(java.lang.StringBuffer buffer)
          Provided so that subclasses can override and add data to the toString() call.
(package private)  int getChunkType()
           
(package private)  int getCRC()
          Get the CRC value for the chunk's data.
(package private)  byte[] getData()
          Get the chunk's data.
(package private)  int getInt32(int offset)
          Get the 32-bit integer from the reference byte array at the given offset.
(package private)  int getLength()
          Get the length of the data component of this chunk.
(package private)  byte[] getReference()
          Get the PngChunk's reference byteArray;
(package private)  int getSize()
          Get the chunk's total size including the length, type, and crc fields.
(package private)  byte[] getTypeBytes()
          Get the chunk type.
(package private)  boolean isCritical()
           
(package private) static PngChunk readNextFromStream(LEDataInputStream stream)
          Read the next PNG chunk from the input stream given.
(package private)  void setCRC(int value)
          Set the CRC value for the chunk's data.
(package private)  void setData(byte[] data)
          Set the chunk's data.
(package private)  void setInt32(int offset, int value)
          Set the 32-bit integer in the reference byte array at the given offset.
(package private)  void setLength(int value)
          Set the length of the data component of this chunk.
(package private)  void setReference(byte[] reference)
          Set the PngChunk's reference byteArray;
(package private)  void setType(byte[] value)
          Set the chunk type.
 java.lang.String toString()
          Convert this Object to a human-readable String.
(package private)  boolean typeMatchesArray(byte[] array)
           
(package private)  void validate(PngFileReadState readState, PngIhdrChunk headerChunk)
          Answer whether the chunk is a valid PNG chunk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

reference

byte[] reference

LENGTH_OFFSET

static final int LENGTH_OFFSET
See Also:
Constant Field Values

TYPE_OFFSET

static final int TYPE_OFFSET
See Also:
Constant Field Values

DATA_OFFSET

static final int DATA_OFFSET
See Also:
Constant Field Values

TYPE_FIELD_LENGTH

static final int TYPE_FIELD_LENGTH
See Also:
Constant Field Values

LENGTH_FIELD_LENGTH

static final int LENGTH_FIELD_LENGTH
See Also:
Constant Field Values

MIN_LENGTH

static final int MIN_LENGTH
See Also:
Constant Field Values

CHUNK_UNKNOWN

static final int CHUNK_UNKNOWN
See Also:
Constant Field Values

CHUNK_IHDR

static final int CHUNK_IHDR
See Also:
Constant Field Values

CHUNK_PLTE

static final int CHUNK_PLTE
See Also:
Constant Field Values

CHUNK_IDAT

static final int CHUNK_IDAT
See Also:
Constant Field Values

CHUNK_IEND

static final int CHUNK_IEND
See Also:
Constant Field Values

CHUNK_tRNS

static final int CHUNK_tRNS
See Also:
Constant Field Values

TYPE_IHDR

static final byte[] TYPE_IHDR

TYPE_PLTE

static final byte[] TYPE_PLTE

TYPE_IDAT

static final byte[] TYPE_IDAT

TYPE_IEND

static final byte[] TYPE_IEND

TYPE_tRNS

static final byte[] TYPE_tRNS

CRC_TABLE

static final int[] CRC_TABLE
Constructor Detail

PngChunk

PngChunk(byte[] reference)
Construct a PngChunk using the reference bytes given.

Method Detail

getReference

byte[] getReference()
Get the PngChunk's reference byteArray;


setReference

void setReference(byte[] reference)
Set the PngChunk's reference byteArray;


getInt32

int getInt32(int offset)
Get the 32-bit integer from the reference byte array at the given offset.


setInt32

void setInt32(int offset,
              int value)
Set the 32-bit integer in the reference byte array at the given offset.


getLength

int getLength()
Get the length of the data component of this chunk. This is not the length of the entire chunk.


setLength

void setLength(int value)
Set the length of the data component of this chunk. This is not the length of the entire chunk.


getTypeBytes

byte[] getTypeBytes()
Get the chunk type. This is a four byte value. Each byte should be an ASCII character. The first byte is upper case if the chunk is critical. The second byte is upper case if the chunk is publicly defined. The third byte must be upper case. The fourth byte is upper case if the chunk is unsafe to copy. Public chunk types are defined by the PNG Development Group.


setType

void setType(byte[] value)
Set the chunk type. This is a four byte value. Each byte should be an ASCII character. The first byte is upper case if the chunk is critical. The second byte is upper case if the chunk is publicly defined. The third byte must be upper case. The fourth byte is upper case if the chunk is unsafe to copy. Public chunk types are defined by the PNG Development Group.


getData

byte[] getData()
Get the chunk's data.


setData

void setData(byte[] data)
Set the chunk's data. This method has two side-effects. 1. It will set the length field to be the length of the data array given. 2. It will set the CRC field to the computed CRC value of the data array given.


getCRC

int getCRC()
Get the CRC value for the chunk's data. Ensure that the length field has a good value before making this call.


setCRC

void setCRC(int value)
Set the CRC value for the chunk's data. Ensure that the length field has a good value before making this call.


getSize

int getSize()
Get the chunk's total size including the length, type, and crc fields.


checkCRC

boolean checkCRC()
Compute the CRC value for the chunk's data. Answer whether this value matches the value stored in the chunk.


computeCRC

int computeCRC()
Answer the CRC value of chunk's data.


typeMatchesArray

boolean typeMatchesArray(byte[] array)

isCritical

boolean isCritical()

getChunkType

int getChunkType()

readNextFromStream

static PngChunk readNextFromStream(LEDataInputStream stream)
Read the next PNG chunk from the input stream given. If unable to read a chunk, return null.


validate

void validate(PngFileReadState readState,
              PngIhdrChunk headerChunk)
Answer whether the chunk is a valid PNG chunk.


contributeToString

void contributeToString(java.lang.StringBuffer buffer)
Provided so that subclasses can override and add data to the toString() call.


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).