Class Chunk

java.lang.Object
pixy.image.png.Chunk
All Implemented Interfaces:
java.lang.Comparable<Chunk>
Direct Known Subclasses:
UnknownChunk

public class Chunk
extends java.lang.Object
implements java.lang.Comparable<Chunk>
Class for PNG chunks
Version:
1.0 11/07/2012
Author:
Wen Yu, yuwen_66@yahoo.com
  • Constructor Summary

    Constructors 
    Constructor Description
    Chunk​(ChunkType chunkType, long length, byte[] data, long crc)  
  • Method Summary

    Modifier and Type Method Description
    static long calculateCRC​(int chunkValue, byte[] data)  
    static long calculateCRC​(int chunkValue, byte[] data, int offset, int length)  
    int compareTo​(Chunk that)
    Compare different chunks according to their Attribute ranking.
    boolean equals​(java.lang.Object that)  
    ChunkType getChunkType()  
    long getCRC()  
    byte[] getData()  
    long getLength()  
    int hashCode()  
    boolean isValidCRC()  
    java.lang.String toString()  
    void write​(java.io.OutputStream os)  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Chunk

      public Chunk​(ChunkType chunkType, long length, byte[] data, long crc)
  • Method Details

    • compareTo

      public int compareTo​(Chunk that)
      Compare different chunks according to their Attribute ranking. This is intended to be used for comparing chunks with different chunk types rather than chunks of the same chunkType which will always have the same ranking.
      Specified by:
      compareTo in interface java.lang.Comparable<Chunk>
    • getChunkType

      public ChunkType getChunkType()
    • getLength

      public long getLength()
    • getData

      public byte[] getData()
    • getCRC

      public long getCRC()
    • isValidCRC

      public boolean isValidCRC()
    • write

      public void write​(java.io.OutputStream os) throws java.io.IOException
      Throws:
      java.io.IOException
    • toString

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

      public boolean equals​(java.lang.Object that)
      Overrides:
      equals in class java.lang.Object
    • hashCode

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

      public static long calculateCRC​(int chunkValue, byte[] data)
    • calculateCRC

      public static long calculateCRC​(int chunkValue, byte[] data, int offset, int length)