private void CheckStrips(IfdTags metadata, int n) {
    long offset;
    int id;

    // Strip offsets
    id = TiffTags.getTagId("StripOffsets");
    offset = metadata.get(id).getFirstNumericValue();
    int nso = metadata.get(id).getCardinality();
    if (offset <= 0)
      validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
          offset);

    // Strip Byte Counts
    id = TiffTags.getTagId("StripBYTECount");
    offset = metadata.get(id).getFirstNumericValue();
    int nsc = metadata.get(id).getCardinality();
    if (offset <= 0)
      validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
          offset);

    if (nso != nsc) {
      validation.addErrorLoc("Inconsistent strip lengths", "IFD" + n);
    }

    int pixelSize = 0;
    for (int i = 0; i < metadata.get("BitsPerSample").getCardinality(); i++) {
      pixelSize += metadata.get("BitsPerSample").getValue().get(i).toInt();
    }
    if (metadata.get("Compression").getFirstNumericValue() == 1
 && pixelSize >= 8) {
      int calculatedImageLength = 0;
      for (int i = 0; i < nsc; i++) {
        calculatedImageLength += metadata.get(id).getValue().get(i).toInt();
      }
      if (calculatedImageLength != metadata.get("ImageLength").getFirstNumericValue()
          * metadata.get("ImageWidth").getFirstNumericValue() * pixelSize / 8) {
        // validation.toString();
        validation.addErrorLoc("Calculated and declared image size do not match", "IFD" + n);
      }
    }

    // Rows per Strip
    id = TiffTags.getTagId("RowsPerStrip");
    if (!metadata.containsTagId(id)) {
      if (rowsPerStripTolerance > 0)
        validation.addWarning("Missing required field", TiffTags.getTag(id).getName(), "IFD" + n);
      else
        validation.addError("Missing required field", "IFD" + n, TiffTags.getTag(id).getName());
    } else {
      offset = metadata.get(id).getFirstNumericValue();
      if (offset <= 0)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            offset);
    }
  }
private void CheckStrips ( IfdTags metadata , int n ) { long offset ; int id ; id = TiffTags . getTagId ( "StripOffsets" ) ; offset = metadata . get ( id ) . getFirstNumericValue ( ) ; int nso = metadata . get ( id ) . getCardinality ( ) ; if ( offset <= 0 ) validation . addError ( "Invalid value for field " + TiffTags . getTag ( id ) . getName ( ) , "IFD" + n , offset ) ; id = TiffTags . getTagId ( "StripBYTECount" ) ; offset = metadata . get ( id ) . getFirstNumericValue ( ) ; int nsc = metadata . get ( id ) . getCardinality ( ) ; if ( offset <= 0 ) validation . addError ( "Invalid value for field " + TiffTags . getTag ( id ) . getName ( ) , "IFD" + n , offset ) ; if ( nso != nsc ) { validation . addErrorLoc ( "Inconsistent strip lengths" , "IFD" + n ) ; } int pixelSize = 0 ; for ( int i = 0 ; i < metadata . get ( "BitsPerSample" ) . getCardinality ( ) ; i ++ ) { pixelSize += metadata . get ( "BitsPerSample" ) . getValue ( ) . get ( i ) . toInt ( ) ; } if ( metadata . get ( "Compression" ) . getFirstNumericValue ( ) == 1 && pixelSize >= 8 ) { int calculatedImageLength = 0 ; for ( int i = 0 ; i < nsc ; i ++ ) { calculatedImageLength += metadata . get ( id ) . getValue ( ) . get ( i ) . toInt ( ) ; } if ( calculatedImageLength != metadata . get ( "ImageLength" ) . getFirstNumericValue ( ) * metadata . get ( "ImageWidth" ) . getFirstNumericValue ( ) * pixelSize / 8 ) { validation . addErrorLoc ( "Calculated and declared image size do not match" , "IFD" + n ) ; } } id = TiffTags . getTagId ( "RowsPerStrip" ) ; if ( ! metadata . containsTagId ( id ) ) { if ( rowsPerStripTolerance > 0 ) validation . addWarning ( "Missing required field" , TiffTags . getTag ( id ) . getName ( ) , "IFD" + n ) ; else validation . addError ( "Missing required field" , "IFD" + n , TiffTags . getTag ( id ) . getName ( ) ) ; } else { offset = metadata . get ( id ) . getFirstNumericValue ( ) ; if ( offset <= 0 ) validation . addError ( "Invalid value for field " + TiffTags . getTag ( id ) . getName ( ) , "IFD" + n , offset ) ; } }
Check that the strips containing the image are well-formed.

@param metadata the metadata
@param n the IFD number