test_class.declarator: ITXTCHUNK_PNG_FILEPATH = "src/test/resources/png/FileWithiTXtChunks.png"
test_class.modifier: private static final
test_class.original_string: private static final String ITXTCHUNK_PNG_FILEPATH = "src/test/resources/png/FileWithiTXtChunks.png";
test_class.type: String
test_class.var_name: ITXTCHUNK_PNG_FILEPATH
test_class.declarator: PNG_MIMETYPE = "image/png"
test_class.modifier: private static final
test_class.original_string: private static final String PNG_MIMETYPE = "image/png";
test_class.type: String
test_class.var_name: PNG_MIMETYPE
test_class.file: jhove-ext-modules/src/test/java/com/mcgath/jhove/module/PngModuleTest.java
test_class.identifier: PngModuleTest
test_case.body: @Test
      public void parsePngWithItxtChunk() throws Exception {
          final String EXPECTED_ITXTTITLE_VALUE = "PngSuite";
          final String EXPECTED_ITXTDISCLAIMER_VALUE = "Freeware.";
          final String PROP_KEYWORDS = "Keywords";
          final String PROP_VALUE = "Value";
  
          File pngFile = new File(ITXTCHUNK_PNG_FILEPATH);
  
          RepInfo info = new RepInfo(pngFile.getAbsolutePath());
          PngModule pngMod = new PngModule();
          pngMod.parse(new FileInputStream(pngFile), info, 0);
  
          int wellformed = info.getWellFormed();
          int valid = info.getValid();
          String type = info.getMimeType();
  
          // General checks
          assertEquals(1, wellformed);
          assertEquals(1, valid);
          assertEquals(PNG_MIMETYPE, type);
  
          // Check the value of the first iTXt is as expected
          Set<String> keywordValues = new HashSet<String>();
          @SuppressWarnings("unchecked")
          LinkedList<Property> iTxtKeywordProperties = (LinkedList<Property>) info.getByName(PROP_KEYWORDS).getValue();
          for (Property prop : iTxtKeywordProperties) {
              keywordValues.add(prop.getByName(PROP_VALUE).getValue().toString());
          }
  
          assertEquals(6, keywordValues.size());
          assertTrue(keywordValues.contains(EXPECTED_ITXTTITLE_VALUE));
          assertTrue(keywordValues.contains(EXPECTED_ITXTDISCLAIMER_VALUE));
      }
test_case.class_method_signature: PngModuleTest.parsePngWithItxtChunk()
test_case.full_signature: @Test public void parsePngWithItxtChunk()
test_case.identifier: parsePngWithItxtChunk
test_case.invocations: getAbsolutePath parse getWellFormed getValid getMimeType assertEquals assertEquals assertEquals getValue getByName add toString getValue getByName assertEquals size assertTrue contains assertTrue contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void parsePngWithItxtChunk()
focal_class.declarator: NAME = "PNG-gdm"
focal_class.modifier: private static final
focal_class.original_string: private static final String NAME = "PNG-gdm";
focal_class.type: String
focal_class.var_name: NAME
focal_class.declarator: RELEASE = "1.0"
focal_class.modifier: private static final
focal_class.original_string: private static final String RELEASE = "1.0";
focal_class.type: String
focal_class.var_name: RELEASE
focal_class.declarator: DATE = {2016, 2, 25}
focal_class.modifier: private static final
focal_class.original_string: private static final int [] DATE = {2016, 2, 25};
focal_class.type: int []
focal_class.var_name: DATE
focal_class.declarator: FORMAT = {
      	"PNG", " ISO/IEC 15948:2003", "Portable Network Graphics"
      }
focal_class.modifier: private static final
focal_class.original_string: private static final String [] FORMAT = {
      	"PNG", " ISO/IEC 15948:2003", "Portable Network Graphics"
      };
focal_class.type: String []
focal_class.var_name: FORMAT
focal_class.declarator: COVERAGE = 
      	"PNG (ISO/IEC 15948:2003)"
focal_class.modifier: private static final
focal_class.original_string: private static final String COVERAGE = 
      	"PNG (ISO/IEC 15948:2003)";
focal_class.type: String
focal_class.var_name: COVERAGE
focal_class.declarator: MIMETYPE = {"image/png"}
focal_class.modifier: private static final
focal_class.original_string: private static final String [] MIMETYPE = {"image/png"};
focal_class.type: String []
focal_class.var_name: MIMETYPE
focal_class.declarator: WELLFORMED = "Put well-formedness criteria here"
focal_class.modifier: private static final
focal_class.original_string: private static final String WELLFORMED = "Put well-formedness criteria here";
focal_class.type: String
focal_class.var_name: WELLFORMED
focal_class.declarator: VALIDITY = "Put validity criteria here"
focal_class.modifier: private static final
focal_class.original_string: private static final String VALIDITY = "Put validity criteria here";
focal_class.type: String
focal_class.var_name: VALIDITY
focal_class.declarator: REPINFO = "Put repinfo note here"
focal_class.modifier: private static final
focal_class.original_string: private static final String REPINFO = "Put repinfo note here";
focal_class.type: String
focal_class.var_name: REPINFO
focal_class.declarator: NOTE = null
focal_class.modifier: private static final
focal_class.original_string: private static final String NOTE = null;
focal_class.type: String
focal_class.var_name: NOTE
focal_class.declarator: RIGHTS = "Copyright 2016 by Gary McGath. " +
  			"Released under the GNU Lesser General Public License."
focal_class.modifier: private static final
focal_class.original_string: private static final String RIGHTS = "Copyright 2016 by Gary McGath. " +
  			"Released under the GNU Lesser General Public License.";
focal_class.type: String
focal_class.var_name: RIGHTS
focal_class.declarator: NISO_IMAGE_MD = "NisoImageMetadata"
focal_class.modifier: private static final
focal_class.original_string: private static final String NISO_IMAGE_MD = "NisoImageMetadata";
focal_class.type: String
focal_class.var_name: NISO_IMAGE_MD
focal_class.declarator: _ckSummer
focal_class.modifier: protected
focal_class.original_string: protected Checksummer _ckSummer;
focal_class.type: Checksummer
focal_class.var_name: _ckSummer
focal_class.declarator: _propList
focal_class.modifier: protected
focal_class.original_string: protected List<Property> _propList;
focal_class.type: List<Property>
focal_class.var_name: _propList
focal_class.declarator: _keywordPropList
focal_class.modifier: protected
focal_class.original_string: protected List<Property> _keywordPropList;
focal_class.type: List<Property>
focal_class.var_name: _keywordPropList
focal_class.declarator: _spltList
focal_class.modifier: protected
focal_class.original_string: protected List<Property> _spltList;
focal_class.type: List<Property>
focal_class.var_name: _spltList
focal_class.declarator: _cstream
focal_class.modifier: protected
focal_class.original_string: protected ChecksumInputStream _cstream;
focal_class.type: ChecksumInputStream
focal_class.var_name: _cstream
focal_class.declarator: _dstream
focal_class.modifier: protected
focal_class.original_string: protected DataInputStream _dstream;
focal_class.type: DataInputStream
focal_class.var_name: _dstream
focal_class.declarator: _metadata
focal_class.modifier: protected
focal_class.original_string: protected Property _metadata;
focal_class.type: Property
focal_class.var_name: _metadata
focal_class.declarator: _nisoData
focal_class.original_string: NisoImageMetadata _nisoData;
focal_class.type: NisoImageMetadata
focal_class.var_name: _nisoData
focal_class.declarator: _colorType
focal_class.modifier: protected
focal_class.original_string: protected int _colorType;
focal_class.type: int
focal_class.var_name: _colorType
focal_class.declarator: _ancillaryChunks
focal_class.modifier: private
focal_class.original_string: private Set<Integer> _ancillaryChunks;
focal_class.type: Set<Integer>
focal_class.var_name: _ancillaryChunks
focal_class.declarator: ihdrSeen
focal_class.modifier: private
focal_class.original_string: private boolean ihdrSeen;
focal_class.type: boolean
focal_class.var_name: ihdrSeen
focal_class.declarator: plteSeen
focal_class.modifier: private
focal_class.original_string: private boolean plteSeen;
focal_class.type: boolean
focal_class.var_name: plteSeen
focal_class.declarator: idatSeen
focal_class.modifier: private
focal_class.original_string: private boolean idatSeen;
focal_class.type: boolean
focal_class.var_name: idatSeen
focal_class.declarator: idatFinished
focal_class.modifier: private
focal_class.original_string: private boolean idatFinished;
focal_class.type: boolean
focal_class.var_name: idatFinished
focal_class.declarator: iendSeen
focal_class.modifier: private
focal_class.original_string: private boolean iendSeen;
focal_class.type: boolean
focal_class.var_name: iendSeen
focal_class.declarator: _sigBytes[] = { 137, 80, 78, 71, 13, 10, 26, 10 }
focal_class.modifier: private final static
focal_class.original_string: private final static int _sigBytes[] = { 137, 80, 78, 71, 13, 10, 26, 10 };
focal_class.type: int
focal_class.var_name: _sigBytes
focal_class.file: jhove-ext-modules/src/main/java/com/mcgath/jhove/module/PngModule.java
focal_class.identifier: PngModule
focal_class.class_method_signature: PngModule.PngModule()
focal_class.full_signature: public  PngModule()
focal_class.identifier: PngModule
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  PngModule()
focal_class.class_method_signature: PngModule.checkSignatures(File file, InputStream stream, RepInfo info)
focal_class.full_signature: @Override public void checkSignatures(File file, InputStream stream, RepInfo info)
focal_class.identifier: checkSignatures
focal_class.modifiers: @Override public
focal_class.parameters: (File file, InputStream stream, RepInfo info)
focal_class.return: void
focal_class.signature: void checkSignatures(File file, InputStream stream, RepInfo info)
focal_class.class_method_signature: PngModule.parse(InputStream stream, RepInfo info, int parseIndex)
focal_class.full_signature: @Override public int parse(InputStream stream, RepInfo info, int parseIndex)
focal_class.identifier: parse
focal_class.modifiers: @Override public
focal_class.parameters: (InputStream stream, RepInfo info, int parseIndex)
focal_class.return: int
focal_class.signature: int parse(InputStream stream, RepInfo info, int parseIndex)
focal_class.class_method_signature: PngModule.eatChunk(PNGChunk chnk)
focal_class.full_signature: public void eatChunk(PNGChunk chnk)
focal_class.identifier: eatChunk
focal_class.modifiers: public
focal_class.parameters: (PNGChunk chnk)
focal_class.return: void
focal_class.signature: void eatChunk(PNGChunk chnk)
focal_class.class_method_signature: PngModule.addKeyword(String keywd, String val)
focal_class.full_signature: public void addKeyword(String keywd, String val)
focal_class.identifier: addKeyword
focal_class.modifiers: public
focal_class.parameters: (String keywd, String val)
focal_class.return: void
focal_class.signature: void addKeyword(String keywd, String val)
focal_class.class_method_signature: PngModule.addKeyword(String keywd, String translatedKeywd, String val, String language)
focal_class.full_signature: public void addKeyword(String keywd, String translatedKeywd, String val, String language)
focal_class.identifier: addKeyword
focal_class.modifiers: public
focal_class.parameters: (String keywd, String translatedKeywd, String val, String language)
focal_class.return: void
focal_class.signature: void addKeyword(String keywd, String translatedKeywd, String val, String language)
focal_class.class_method_signature: PngModule.addSplt(String name, int sampleDepth, int numSamples)
focal_class.full_signature: public void addSplt(String name, int sampleDepth, int numSamples)
focal_class.identifier: addSplt
focal_class.modifiers: public
focal_class.parameters: (String name, int sampleDepth, int numSamples)
focal_class.return: void
focal_class.signature: void addSplt(String name, int sampleDepth, int numSamples)
focal_class.class_method_signature: PngModule.initParse()
focal_class.full_signature: @Override protected void initParse()
focal_class.identifier: initParse
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void initParse()
focal_class.class_method_signature: PngModule.readChunkHead(DataInputStream dstrm)
focal_class.full_signature: private PNGChunk readChunkHead(DataInputStream dstrm)
focal_class.identifier: readChunkHead
focal_class.modifiers: private
focal_class.parameters: (DataInputStream dstrm)
focal_class.return: PNGChunk
focal_class.signature: PNGChunk readChunkHead(DataInputStream dstrm)
focal_class.class_method_signature: PngModule.setIhdrSeen(boolean b)
focal_class.full_signature: public void setIhdrSeen(boolean b)
focal_class.identifier: setIhdrSeen
focal_class.modifiers: public
focal_class.parameters: (boolean b)
focal_class.return: void
focal_class.signature: void setIhdrSeen(boolean b)
focal_class.class_method_signature: PngModule.isIhdrSeen()
focal_class.full_signature: public boolean isIhdrSeen()
focal_class.identifier: isIhdrSeen
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isIhdrSeen()
focal_class.class_method_signature: PngModule.setIdatSeen(boolean b)
focal_class.full_signature: public void setIdatSeen(boolean b)
focal_class.identifier: setIdatSeen
focal_class.modifiers: public
focal_class.parameters: (boolean b)
focal_class.return: void
focal_class.signature: void setIdatSeen(boolean b)
focal_class.class_method_signature: PngModule.setPlteSeen(boolean b)
focal_class.full_signature: public void setPlteSeen(boolean b)
focal_class.identifier: setPlteSeen
focal_class.modifiers: public
focal_class.parameters: (boolean b)
focal_class.return: void
focal_class.signature: void setPlteSeen(boolean b)
focal_class.class_method_signature: PngModule.setIendSeen(boolean b)
focal_class.full_signature: public void setIendSeen(boolean b)
focal_class.identifier: setIendSeen
focal_class.modifiers: public
focal_class.parameters: (boolean b)
focal_class.return: void
focal_class.signature: void setIendSeen(boolean b)
focal_class.class_method_signature: PngModule.isIdatSeen()
focal_class.full_signature: public boolean isIdatSeen()
focal_class.identifier: isIdatSeen
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isIdatSeen()
focal_class.class_method_signature: PngModule.isIdatFinished()
focal_class.full_signature: public boolean isIdatFinished()
focal_class.identifier: isIdatFinished
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isIdatFinished()
focal_class.class_method_signature: PngModule.isPlteSeen()
focal_class.full_signature: public boolean isPlteSeen()
focal_class.identifier: isPlteSeen
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isPlteSeen()
focal_class.class_method_signature: PngModule.setChunkSeen(int chunkType)
focal_class.full_signature: public void setChunkSeen(int chunkType)
focal_class.identifier: setChunkSeen
focal_class.modifiers: public
focal_class.parameters: (int chunkType)
focal_class.return: void
focal_class.signature: void setChunkSeen(int chunkType)
focal_class.class_method_signature: PngModule.isChunkSeen(int chunkType)
focal_class.full_signature: public boolean isChunkSeen(int chunkType)
focal_class.identifier: isChunkSeen
focal_class.modifiers: public
focal_class.parameters: (int chunkType)
focal_class.return: boolean
focal_class.signature: boolean isChunkSeen(int chunkType)
focal_class.class_method_signature: PngModule.setColorType(int ct)
focal_class.full_signature: public void setColorType(int ct)
focal_class.identifier: setColorType
focal_class.modifiers: public
focal_class.parameters: (int ct)
focal_class.return: void
focal_class.signature: void setColorType(int ct)
focal_class.class_method_signature: PngModule.getColorType()
focal_class.full_signature: public int getColorType()
focal_class.identifier: getColorType
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getColorType()
focal_class.superclass: extends ModuleBase
focal_method.body: @Override
  	public int parse (InputStream stream, RepInfo info, int parseIndex)
          throws IOException
      {
          initParse ();
          info.setFormat (_format[0]);
          info.setMimeType (_mimeType[0]);
          info.setModule (this);
          /* We may have already done the checksums while converting a
          temporary file. */
          _ckSummer = null;
          if (_je != null && _je.getChecksumFlag () &&
          		info.getChecksum ().size () == 0) {
          	_ckSummer = new Checksummer ();
          	_cstream = new ChecksumInputStream (stream, _ckSummer);
          	_dstream = getBufferedDataStream (_cstream, _je != null ?
                   _je.getBufferSize () : 0);
          }
          else {
          	_dstream = getBufferedDataStream (stream, _je != null ?
                   _je.getBufferSize () : 0);
          }
          _propList = new LinkedList<> ();
          _metadata = new Property ("PNGMetadata",
               PropertyType.PROPERTY,
               PropertyArity.LIST,
               _propList);
          _nisoData = new NisoImageMetadata();
          Property nisoProp = new Property(NISO_IMAGE_MD,
                  PropertyType.NISOIMAGEMETADATA, _nisoData);
          _propList.add(nisoProp);
          _keywordPropList = new LinkedList<> ();
          _spltList = new LinkedList<> ();
          ErrorMessage msg;
          
          // Check that the file header matching the PNG magic numbers
          for (int i = 0; i < _sigBytes.length; i++) {
          	int byt = readUnsignedByte (_dstream);
          	if (byt != _sigBytes[i]) {
          		msg = new ErrorMessage(MessageConstants.PNG_GDM_66);
          		info.setMessage(msg);
          		info.setWellFormed(false);
          		return 0;
          	}
          }
          
          // Loop through the chunks
          try {
          	for (;;) {
          		PNGChunk chunk = readChunkHead(_dstream);
          		if (chunk == null) {
          			break;
          		}
          		if (iendSeen) {
          			msg = new ErrorMessage (MessageConstants.PNG_GDM_67);
          			info.setMessage (msg);
          			info.setWellFormed (false);
          			return 0;
          		}
          		if (idatSeen && !(chunk instanceof IdatChunk)) {
          			idatFinished = true;
          		}
          		chunk.setModule(this);
          		chunk.setInputStream(_dstream);
          		chunk.setNisoMetadata(_nisoData);
          		chunk.setPropertyList(_propList);
          		chunk.processChunk(info);
          		long storedCRC = chunk.readCRC();
          		long calculatedCRC = chunk.getCRC();
          		if (storedCRC != calculatedCRC) {
          			msg = new ErrorMessage(String.format (
  							MessageConstants.PNG_GDM_68.getMessage() , 
  							chunk.chunkTypeString()));
          			info.setMessage(msg);
          			info.setWellFormed(false);
          			return 0;
          		}
          	}
          }
          catch (PNGException e) {
          	// We've already reported a problem, so we just clean up here.
          	return 0;
          }
          catch (EOFException e) {
          	msg = new ErrorMessage (
          			String.format (
          					MessageConstants.PNG_GDM_69.getMessage(),
          					_nByte));
          	info.setMessage (msg);
          	info.setWellFormed (false);
          	return 0;
          }
          catch (Exception e) {
          	// Miscellaneous exceptions really shouldn't come here.
          	// But it's better to catch them than let them fall through.
          	// Treat them as bugs.
          	msg = new ErrorMessage (
          			String.format (
          					MessageConstants.PNG_GDM_70.getMessage() , 
          					e.getClass().getName()));
          	info.setMessage (msg);
          	info.setWellFormed (false);
          	return 0;
          }
          
          /* Check for required chunks. */
          boolean criticalMissing = false;
          if (!ihdrSeen) {
          	msg = new ErrorMessage(MessageConstants.PNG_GDM_71);
          	info.setMessage (msg);
          	criticalMissing = true;
          }
          if (!idatSeen) {
          	msg = new ErrorMessage(MessageConstants.PNG_GDM_72);
          	info.setMessage (msg);
          	criticalMissing = true;
          }
          if (!iendSeen) {
          	msg = new ErrorMessage(MessageConstants.PNG_GDM_73);
          	info.setMessage (msg);
          	criticalMissing = true;
          }
          if (criticalMissing) {
          	info.setWellFormed (false);
          	return 0;
  		}
          
          /** PLTE is required with color type 3 and forbidden with types 0 and 4 */
          if (_colorType == 3 && !plteSeen) {
          	msg = new ErrorMessage (MessageConstants.PNG_GDM_74);
  			info.setMessage (msg);
          	info.setWellFormed (false);
  			return 0;
          }
          
          if ((_colorType == 0 || _colorType == 4) && plteSeen) {
  			msg = new ErrorMessage (MessageConstants.PNG_GDM_75);
  			info.setMessage (msg);
          	info.setWellFormed (false);
  			return 0;
          }
  
          // Add the keyword property list if it isn't empty.
          if (!_keywordPropList.isEmpty()) {
          	_propList.add(new Property ("Keywords",
          			PropertyType.PROPERTY,
          			PropertyArity.LIST,
          			_keywordPropList));
          			
          }
          
          // Add the splat property list if it isn't empty.
          if (!_spltList.isEmpty()) {
          	_propList.add(new Property ("Suggested palettes",
          			PropertyType.PROPERTY,
          			PropertyArity.LIST,
          			_spltList));
          }
          info.setProperty (_metadata);
          return 0;
      }
focal_method.class_method_signature: PngModule.parse(InputStream stream, RepInfo info, int parseIndex)
focal_method.full_signature: @Override public int parse(InputStream stream, RepInfo info, int parseIndex)
focal_method.identifier: parse
focal_method.invocations: initParse setFormat setMimeType setModule getChecksumFlag size getChecksum getBufferedDataStream getBufferSize getBufferedDataStream getBufferSize add readUnsignedByte setMessage setWellFormed readChunkHead setMessage setWellFormed setModule setInputStream setNisoMetadata setPropertyList processChunk readCRC getCRC format getMessage chunkTypeString setMessage setWellFormed format getMessage setMessage setWellFormed format getMessage getName getClass setMessage setWellFormed setMessage setMessage setMessage setWellFormed setMessage setWellFormed setMessage setWellFormed isEmpty add isEmpty add setProperty
focal_method.modifiers: @Override public
focal_method.parameters: (InputStream stream, RepInfo info, int parseIndex)
focal_method.return: int
focal_method.signature: int parse(InputStream stream, RepInfo info, int parseIndex)