Check that the tiles containing the image are well-formed.

@param ifd the ifd
@param metadata the metadata
@param n the ifd number
970538
private void CheckTiles(IFD ifd, IfdTags metadata, int n) {
    long offset;
    int id;

    // Check Tile Offsets
    id = TiffTags.getTagId("TileOffsets");
    offset = metadata.get(id).getFirstNumericValue();
    int no = metadata.get(id).getCardinality();
    if (offset <= 0)
      validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
          offset);

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

    if (no != nc) {
      validation.addErrorLoc("Inconsistent tile lengths", "IFD" + n);
    }

    // Check Tile Width
    long tileWidth = 0;
    id = TiffTags.getTagId("TileWidth");
    if (!metadata.containsTagId(id))
      validation.addErrorLoc("Missing required field for tiles " + TiffTags.getTag(id).getName(),
          "IFD" + n);
    else {
      tileWidth = metadata.get(id).getFirstNumericValue();
      if (tileWidth <= 0)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            tileWidth);
    }

    // Check Tile Length
    id = TiffTags.getTagId("TileLength");
    long tileLength = 0;
    if (!metadata.containsTagId(id))
      validation.addErrorLoc("Missing required field for tiles " + TiffTags.getTag(id).getName(),
          "IFD" + n);
    else {
      tileLength = metadata.get(id).getFirstNumericValue();
      if (tileLength <= 0)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            tileLength);
    }

    long tilesPerImage =
        ((metadata.get(TiffTags.getTagId("ImageWidth")).getFirstNumericValue() + tileWidth - 1) / tileWidth)
            * ((metadata.get(TiffTags.getTagId("ImageLength")).getFirstNumericValue() + tileLength - 1) / tileLength);

    // Check Plannar Configuration
    id = TiffTags.getTagId("PlanarConfiguration");
    int idspp = TiffTags.getTagId("SamplesPerPixel");
    if (metadata.containsTagId(id) && metadata.containsTagId(idspp)) {
      long planar = metadata.get(id).getFirstNumericValue();
      long spp = metadata.get(idspp).getFirstNumericValue();
      if (planar == 2) {
        long spp_tpi = spp * tilesPerImage;
        if (ifd.getImageTiles().getTiles().size() < spp_tpi) {
          validation.addErrorLoc("Insufficient tiles", "IFD" + n);
        }
      }
    }
  }
1005828
function isOnMetaSheet(node) {
            //MetaAspectSet
            var sets = self.isMemberOf(node);

            if (sets && sets[''] && sets[''].indexOf(CONSTANTS.META_SET_NAME) !== -1) {
                return true;
            }
            return false;
        }
952078
private boolean matchMetadata(MetaData metadata)
    {
        boolean match;

        if (this.metadataValue != null) {
            Object value = metadata.getMetaData(this.metadataKey);
            match = value != null && value.equals(this.metadataValue);
        } else {
            match = metadata.contains(this.metadataKey);
        }

        return match;
    }
1200006
def _init_metadata(self, **kwargs):
        """"""
        osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
        self._courses_default = self._mdata['courses']['default_id_values']
        self._assessments_default = self._mdata['assessments']['default_id_values']
        self._assets_default = self._mdata['assets']['default_id_values']
975616
@VisibleForTesting
  protected void initMetadata(
      @Nullable String encoding, long sizeFromMetadata, @Nullable String generation)
      throws IOException {
    checkState(
        !metadataInitialized,
        "can not initialize metadata, it already initialized for '%s'", resourceIdString);
    gzipEncoded = nullToEmpty(encoding).contains(GZIP_ENCODING);
    if (gzipEncoded) {
      size = Long.MAX_VALUE;
    } else {
      size = sizeFromMetadata;
    }
    randomAccess = !gzipEncoded && readOptions.getFadvise() == Fadvise.RANDOM;
    checkEncodingAndAccess();

    initGeneration(generation);

    metadataInitialized = true;

    logger.atFine().log(
        "Initialized metadata (gzipEncoded=%s, size=%s, randomAccess=%s, generation=%s) for '%s'",
        gzipEncoded, size, randomAccess, generation, resourceIdString);
  }
112329
def _init_metadata(self, **kwargs):
        """"""

        osid_objects.OsidContainableForm._init_metadata(self)
        osid_objects.OsidSourceableForm._init_metadata(self)
        osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
        self._children_default = self._mdata['children']['default_id_values']
351297
private void validateCreateTable(ConnectorTableMetadata meta)
    {
        validateColumns(meta);
        validateLocalityGroups(meta);
        if (!AccumuloTableProperties.isExternal(meta.getProperties())) {
            validateInternalTable(meta);
        }
    }
1171076
private void validateIfdLW(IFD ifd, int p) {
    IfdTags metadata = ifd.getMetadata();

    if (p == 1) {
      checkRequiredTag(metadata, "NewSubfileType", 1, new long[]{0});
    }
    checkRequiredTag(metadata, "ImageLength", 1);
    checkRequiredTag(metadata, "ImageWidth", 1);
    checkRequiredTag(metadata, "SamplesPerPixel", 1, new long[]{1});
    if (p == 0) {
      checkRequiredTag(metadata, "BitsPerSample", 1, new long[]{4});
    } else {
      checkRequiredTag(metadata, "BitsPerSample", 1, new long[]{8});
    }
    checkRequiredTag(metadata, "Compression", 1, new long[]{32896});
    checkRequiredTag(metadata, "PhotometricInterpretation", 1, new long[] {5});
    checkRequiredTag(metadata, "StripOffsets", 1);
    if (p == 1 || p == 2) {
      checkRequiredTag(metadata, "Orientation", 1, new long[]{1});
    }
    checkRequiredTag(metadata, "StripBYTECount", 1);
    checkRequiredTag(metadata, "XResolution", 1);
    checkRequiredTag(metadata, "YResolution", 1);
    if (p == 1 || p == 2) {
      checkRequiredTag(metadata, "ResolutionUnit", 1, new long[]{2, 3});
      checkRequiredTag(metadata, "InkSet", 1, new long[]{1});
      checkRequiredTag(metadata, "NumberOfInks", 1, new long[]{4});
    }
    if (p == 1) {
      checkRequiredTag(metadata, "DotRange", 2, new long[]{0, 255});
    }
    checkRequiredTag(metadata, "ColorTable", -1);
  }
17517
@SuppressWarnings("unused")
  @Deprecated
  private void validateSubIfd(IFD ifd, int n) {
    boolean thumbnail = ifd.getParent().getImageSize() > ifd.getImageSize();
    IfdTags metadata = ifd.getMetadata();

    checkRequiredTag(metadata, "ImageLength", 1, "SubIFD" + n);
    checkRequiredTag(metadata, "ImageWidth", 1, "SubIFD" + n);
    int spp = -1;
    if (checkRequiredTag(metadata, "SamplesPerPixel", 1, "SubIFD" + n)) {
      spp = (int) metadata.get("SamplesPerPixel").getFirstNumericValue();
      checkRequiredTag(metadata, "BitsPerSample", spp, "SubIFD" + n);
    }
    if (checkRequiredTag(metadata, "Compression", 1, "SubIFD" + n)) {
      int comp = (int) metadata.get("Compression").getFirstNumericValue();
      if (comp == 1)
        checkForbiddenTag(metadata, "CompressedBitsPerPixel", "IFD" + n);
    }
    checkRequiredTag(metadata, "XResolution", 1, "SubIFD" + n);
    checkRequiredTag(metadata, "YResolution", 1, "SubIFD" + n);
    checkForbiddenTag(metadata, "SubIFDs", "IFD" + n);
    if (thumbnail)
      checkRequiredTag(metadata, "NewSubfileType", 1, new long[] {1}, "SubIFD" + n);
    else
      checkRequiredTag(metadata, "NewSubfileType", 1, new long[] {0}, "SubIFD" + n);
    if (checkRequiredTag(metadata, "PhotometricInterpretation", 1, new long[] {1, 2, 6, 32803,
        32767}, "SubIFD" + n)) {
      int photo = (int) metadata.get("PhotometricInterpretation").getFirstNumericValue();
      if (photo != 6) {
        checkForbiddenTag(metadata, "YCbCrCoefficients", "SubIFD" + n);
        checkForbiddenTag(metadata, "YCbCrSubSampling", "SubIFD" + n);
        checkForbiddenTag(metadata, "YCbCrPositioning", "SubIFD" + n);
        checkForbiddenTag(metadata, "ReferenceBlackWhite", "SubIFD" + n);
      }
      if (photo == 2 || photo == 3) {
        if (spp != 3) {
          validation.addError("Invalid SampesPerPixel value fo TiffEP", "SubIFD" + n, spp);
        }
      } else if (photo == 1 || photo == 32803) {
        if (spp != 1) {
          validation.addError("Invalid SampesPerPixel value fo TiffEP", "SubIFD" + n, spp);
        }
        if (photo == 32803) {
          checkRequiredTag(metadata, "CFARepeatPatternDim", 2, "SubIFD" + n);
          checkRequiredTag(metadata, "CFAPattern", -1, "SubIFD" + n);
        }
      }
    }
    checkRequiredTag(metadata, "PlanarConfiguration", 1, new long[] {1, 2}, "SubIFD" + n);
    checkRequiredTag(metadata, "ResolutionUnit", 1, new long[] {1, 2, 3}, "SubIFD" + n);

    if (!thumbnail) {
      if (ifd.hasStrips()) {
        checkRequiredTag(metadata, "StripBYTECount", -1, "SubIFD" + n);
        checkRequiredTag(metadata, "StripOffsets", -1, "SubIFD" + n);
        checkRequiredTag(metadata, "RowsPerStrip", 1, "SubIFD" + n);
        if (ifd.hasTiles()) {
          validation.addErrorLoc("Image in both strips and tiles", "SubIFD");
        }
      } else if (ifd.hasTiles()) {
        checkRequiredTag(metadata, "TileLength", 1, "SubIFD" + n);
        checkRequiredTag(metadata, "TileOffsets", 1, "SubIFD" + n);
        checkRequiredTag(metadata, "TileWidth", -1, "SubIFD" + n);
      }
    } else {
      checkRequiredTag(metadata, "StripBYTECount", -1, "SubIFD" + n);
      checkRequiredTag(metadata, "StripOffsets", -1, "SubIFD" + n);
      checkRequiredTag(metadata, "RowsPerStrip", 1, "SubIFD" + n);
      checkForbiddenTag(metadata, "TileLength", "SubIFD" + n);
      checkForbiddenTag(metadata, "TileOffsets", "SubIFD" + n);
      checkForbiddenTag(metadata, "TileWidth", "SubIFD" + n);
    }

    int nycbcr = 0;
    if (metadata.containsTagId(TiffTags.getTagId("YCbCrCoefficients")))
      nycbcr++;
    if (metadata.containsTagId(TiffTags.getTagId("YCbCrSubSampling")))
      nycbcr++;
    if (metadata.containsTagId(TiffTags.getTagId("YCbCrPositioning")))
      nycbcr++;
    if (metadata.containsTagId(TiffTags.getTagId("ReferenceBlackWhite")))
      nycbcr++;
    if (nycbcr > 0 && nycbcr != 4) {
      checkRequiredTag(metadata, "YCbCrCoefficients", 3, "SubIFD" + n);
      checkRequiredTag(metadata, "YCbCrSubSampling", 2, "SubIFD" + n);
      checkRequiredTag(metadata, "YCbCrPositioning", 1, "SubIFD" + n);
      checkRequiredTag(metadata, "ReferenceBlackWhite", 6, "SubIFD" + n);
    }
    if (thumbnail) {
      checkForbiddenTag(metadata, "YCbCrCoefficients", "IFD" + n);
      checkForbiddenTag(metadata, "YCbCrSubSampling", "IFD" + n);
      checkForbiddenTag(metadata, "YCbCrPositioning", "IFD" + n);
      checkForbiddenTag(metadata, "ReferenceBlackWhite", "IFD" + n);
    }

    checkForbiddenTag(metadata, "PrimaryChromaticities", "IFD" + n);
    checkForbiddenTag(metadata, "WhitePoint", "IFD" + n);
    checkForbiddenTag(metadata, "TransferFunction", "IFD" + n);
  }
1256803
public static boolean hasMetadata(@NonNull final Context context, @NonNull final String metadataKey) {
        if (TextUtils.isEmpty(metadataKey)) {
            throw new IllegalArgumentException("Meta data key can't be null or empty.");
        }

        try {
            final PackageInfo info = context.getPackageManager()
                    .getPackageInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            final Bundle metaData = info.applicationInfo.metaData;
            if (metaData != null && metaData.get(metadataKey) != null) {
                return true;
            }
        } catch (PackageManager.NameNotFoundException e) {
            //ignore
        }
        return false;
    }
1307682
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);
    }
  }
1305366
def _init_metadata(self, **kwargs):
        """"""
        osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
        self._numeric_score_increment_default = self._mdata['numeric_score_increment']['default_decimal_values'][0]
        self._lowest_numeric_score_default = self._mdata['lowest_numeric_score']['default_decimal_values'][0]
        self._based_on_grades_default = self._mdata['based_on_grades']['default_boolean_values'][0]
        self._highest_numeric_score_default = self._mdata['highest_numeric_score']['default_decimal_values'][0]
45180
public int getIfdCount() {
    int c = 0;
    if (metadata != null && metadata.contains("IFD"))
      c = getMetadataList("IFD").size();
    return c;
  }
564254
public void addMetadata(final RuleMetadata metadata) {

        final RuleMetadata[] newList = new RuleMetadata[this.metadataList.length + 1];

        for (int i = 0; i < this.metadataList.length; i++) {
            newList[i] = this.metadataList[i];
        }
        newList[this.metadataList.length] = metadata;

        this.metadataList = newList;
    }
1366347
def _init_metadata(self, **kwargs):
        """"""
        osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
        self._cognitive_process_default = self._mdata['cognitive_process']['default_id_values'][0]
        self._assessment_default = self._mdata['assessment']['default_id_values'][0]
        self._knowledge_category_default = self._mdata['knowledge_category']['default_id_values'][0]
25918
function validateMetadata(metadataPath, cb) {
  validateJSonStructure(metadataPath, function(err, metadataObject) {
    if (err) {
      cb(err, null);
    } else {
      cb(null, metadataObject.files);
    }
  });
}
1297076
static public boolean metaFileExists(FSDatasetInterface dataset, int namespaceId, Block b) throws IOException {
    return getMetaFile(dataset, namespaceId, b).exists();
  }