PngChunkCode { public static PngChunkCode from(int code) { switch(code) { case PngConstants.IHDR_VALUE: return IHDR; case PngConstants.gAMA_VALUE: return gAMA; case PngConstants.bKGD_VALUE: return bKGD; case PngConstants.tRNS_VALUE: return tRNS; case PngConstants.IDAT_VALUE: return IDAT; case PngConstants.IEND_VALUE: return IEND; case PngConstants.acTL_VALUE: return acTL; case PngConstants.fdAT_VALUE: return fdAT; default: byte[] s = new byte[4]; s[0] = (byte)((code & 0xff000000) >> 24); s[1] = (byte)((code & 0x00ff0000) >> 16); s[2] = (byte)((code & 0x0000ff00) >> 8); s[3] = (byte)((code & 0x000000ff)); return new PngChunkCode(code, new String(s)); } } PngChunkCode(int numeric, String letters); boolean isCritical(); boolean isAncillary(); boolean isPrivate(); boolean isPublic(); boolean isReserved(); boolean isSafeToCopy(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static PngChunkCode from(int code); static final PngChunkCode IHDR; static final PngChunkCode PLTE; static final PngChunkCode IDAT; static final PngChunkCode IEND; static final PngChunkCode gAMA; static final PngChunkCode bKGD; static final PngChunkCode tRNS; static final PngChunkCode acTL; static final PngChunkCode fcTL; static final PngChunkCode fdAT; final int numeric; final String letters; }
@Test public void decodes_custom() { PngChunkCode c = PngChunkCode.from( 'H'<<24 | 'E'<<16 | 'L'<<8 | 'O' ); assertEquals("HELO", c.letters); assertEquals(1212501071, c.numeric); }