Performs the IPTC data extraction, adding found values to the specified instance of {@link Metadata}.
775475
public void extract(@NotNull final SequentialReader reader, @NotNull final Metadata metadata, long length, @Nullable Directory parentDirectory)
    {
        IptcDirectory directory = new IptcDirectory();
        metadata.addDirectory(directory);

        if (parentDirectory != null)
            directory.setParent(parentDirectory);

        int offset = 0;

        // for each tag
        while (offset < length) {

            // identifies start of a tag
            short startByte;
            try {
                startByte = reader.getUInt8();
                offset++;
            } catch (IOException e) {
                directory.addError("Unable to read starting byte of IPTC tag");
                return;
            }

            if (startByte != IptcMarkerByte) {
                // NOTE have seen images where there was one extra byte at the end, giving
                // offset==length at this point, which is not worth logging as an error.
                if (offset != length)
                    directory.addError("Invalid IPTC tag marker at offset " + (offset - 1) + ". Expected '0x" + Integer.toHexString(IptcMarkerByte) + "' but got '0x" + Integer.toHexString(startByte) + "'.");
                return;
            }

            // we need at least four bytes left to read a tag
            if (offset + 4 > length) {
                directory.addError("Too few bytes remain for a valid IPTC tag");
                return;
            }

            int directoryType;
            int tagType;
            int tagByteCount;
            try {
                directoryType = reader.getUInt8();
                tagType = reader.getUInt8();
                tagByteCount = reader.getUInt16();
                if (tagByteCount > 32767) {
                    // Extended DataSet Tag (see 1.5(c), p14, IPTC-IIMV4.2.pdf)
                    tagByteCount = ((tagByteCount & 0x7FFF) << 16) | reader.getUInt16();
                    offset += 2;
                }
                offset += 4;
            } catch (IOException e) {
                directory.addError("IPTC data segment ended mid-way through tag descriptor");
                return;
            }

            if (offset + tagByteCount > length) {
                directory.addError("Data for tag extends beyond end of IPTC segment");
                return;
            }

            try {
                processTag(reader, directory, directoryType, tagType, tagByteCount);
            } catch (IOException e) {
                directory.addError("Error processing IPTC tag");
                return;
            }

            offset += tagByteCount;
        }
    }
1241297
private void fillMetaData() {
        metaDataBuffer.putInt(MONITOR_VERSION_OFFSET, MONITOR_VERSION);
        metaDataBuffer.putInt(GW_DATA_REFERENCE_OFFSET, GW_DATA_OFFSET);
        metaDataBuffer.putInt(SERVICE_DATA_REFERENCE_OFFSET, serviceDataOffset);
        metaDataBuffer.putStringUtf8(GW_ID_OFFSET, gatewayId, ByteOrder.nativeOrder());
        metaDataBuffer.putInt(gwCountersLblBuffersReferenceOffset, 0);
        metaDataBuffer.putInt(gwCountersLblBuffersLengthOffset, GATEWAY_COUNTER_LABELS_BUFFER_LENGTH);
        metaDataBuffer.putInt(gwCountersValueBuffersReferenceOffset, 0);
        metaDataBuffer.putInt(gwCountersValueBuffersLengthOffset, GATEWAY_COUNTER_VALUES_BUFFER_LENGTH);
        metaDataBuffer.putInt(noOfServicesOffset, 0);
    }
1138279
def add_metadata(klass)
      logger.debug("Adding #{self}::#{klass.qp} metadata...")
      # Mark the class as introspected. Do this first to preclude a recursive loop back
      # into this method when the references are introspected below.
      @introspected << klass
      # Add the superclass meta-data if necessary.
      add_superclass_metadata(klass)
      # Include this resource module into the class, unless this has already occurred.
      unless klass < self then
        m = self
        klass.class_eval { include m }
      end
      # Import the class into this resource module, unless this has already occurred.
      name = klass.name.demodulize
      unless const_defined?(name) then
        java_import(klass.java_class.name)
      end
      # Add introspection capability to the class.
      md_mod = @metadata_module || Metadata
      logger.debug { "Extending #{self}::#{klass.qp} with #{md_mod.name}..." }
      klass.extend(md_mod)
      # Set the class domain module.
      klass.domain_module = self
      # Introspect the Java properties.
      klass.introspect
      # Add the {attribute => value} initializer.
      klass.add_attribute_value_initializer if Class === klass
      # Add referenced domain class metadata as necessary.
      klass.each_property do |prop|
        ref = prop.type
        if ref.nil? then raise MetadataError.new("#{self} #{prop} domain type is unknown.") end
        if introspectible?(ref) then
          logger.debug { "Introspecting the #{klass.qp} #{prop} reference type #{ref.qp}..." }
          add_metadata(ref)
        end
      end
      # If the class has a definition file but does not resolve to a standard package, then
      # load it now based on the demodulized class name match.
      file = @unresolved_defs[name]
      load_definition(klass, file) if file
      
      logger.debug("#{self}::#{klass.qp} metadata added.")
    end
221499
private void updateMetadata(SegmentProperties segmentProperties) {
        this.metadata.setStorageLength(segmentProperties.getLength());
        if (segmentProperties.isSealed() && !this.metadata.isSealedInStorage()) {
            this.metadata.markSealed();
            this.metadata.markSealedInStorage();
        }
    }
640825
private RDBMetadata extractDBMetadata(SQLPPMapping ppMapping, Optional<RDBMetadata> optionalDBMetadata,
                                          OBDASpecInput specInput)
            throws DBMetadataExtractionException {

        boolean isDBMetadataProvided = optionalDBMetadata.isPresent();

        /*
         * Metadata extraction can be disabled when DBMetadata is already provided
         */
        if (isDBMetadataProvided && (!settings.isProvidedDBMetadataCompletionEnabled()))
            return optionalDBMetadata.get();

        try (Connection localConnection = LocalJDBCConnectionUtils.createConnection(settings)) {
            return isDBMetadataProvided
                    ? dbMetadataExtractor.extract(ppMapping, localConnection, optionalDBMetadata.get(),
                    specInput.getConstraintFile())
                    : dbMetadataExtractor.extract(ppMapping, localConnection, specInput.getConstraintFile());
        }
        /*
         * Problem while creating the connection
         */
        catch (SQLException e) {
            throw new DBMetadataExtractionException(e.getMessage());
        }
    }
1119799
public void add(String name, TiffObject value, String path, String schema) {
    if (!metadata.containsKey(name)) {
      metadata.put(name, new MetadataObject());
    }
    metadata.get(name).getObjectList().add(value);
    metadata.get(name).setPath(path);
    metadata.get(name).setSchema(schema);
  }
161222
def populate_metadata(model, MetadataClass):
    
    content_type = ContentType.objects.get_for_model(model)
    for instance in model.objects.all():
        create_metadata_instance(MetadataClass, instance)
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;
    }
782518
public AbstractFastFileBuilder<T> withMetaData(String name, String value) {
        this.metaDataSet.add(new MetaData(name, value));
        return this;
    }
680745
protected void readMetadata() throws IOException
	{
		int blockCount = super.read();
		// System.out.println ("blocks to read: " + blockCount);
		int byteCount = (blockCount * 16); // 16 bytes per block
		if (byteCount <= 0) return; // WTF?!
		byte[] metadataBlock = new byte[byteCount];
		int index = 0;
		// build an array of this metadata
		while (byteCount > 0)
		{
			int bytesRead = super.read(metadataBlock, index, byteCount);
			index += bytesRead;
			byteCount -= bytesRead;
		}
		// now parse it
		parseInlineIcyTags(metadataBlock);
	}
576430
public void extract(@NotNull final SequentialReader reader, @NotNull final Metadata metadata)
    {
        HuffmanTablesDirectory directory = metadata.getFirstDirectoryOfType(HuffmanTablesDirectory.class);
        if (directory == null) {
            directory = new HuffmanTablesDirectory();
            metadata.addDirectory(directory);
        }

        try {
            while (reader.available() > 0) {
                byte header = reader.getByte();
                HuffmanTableClass tableClass = HuffmanTableClass.typeOf((header & 0xF0) >> 4);
                int tableDestinationId = header & 0xF;

                byte[] lBytes = getBytes(reader, 16);
                int vCount = 0;
                for (byte b : lBytes) {
                    vCount += (b & 0xFF);
                }
                byte[] vBytes = getBytes(reader, vCount);
                directory.getTables().add(new HuffmanTable(tableClass, tableDestinationId, lBytes, vBytes));
            }
        } catch (IOException me) {
            directory.addError(me.getMessage());
        }

        directory.setInt(HuffmanTablesDirectory.TAG_NUMBER_OF_TABLES, directory.getTables().size());
    }
1289036
@Override
    public void beginMetaData(MetaData metadata)
    {
        for (Listener listener : this.listeners) {
            listener.beginMetaData(metadata);
        }
    }
1200859
public Application withMetadata(java.util.Map<String, String> metadata) {
        setMetadata(metadata);
        return this;
    }
1056880
protected void processContent(Content file) {
        // Handle metadata/special cases
        String lowerCaseFileName = file.name.toLowerCase();
        if (lowerCaseFileName.endsWith("pom.properties")) {
            // handle pom properties files
            InputStream is = new ByteArrayInputStream(file.bytes);
            Metadata md = Metadata.fromPomProperties(is);
            putMetadata(file.name, md);
        }

        // This is separate as we may or may not want to fingerprint
        // all files.
        if (RECURSIVE) {
            Artifact record = Processor.process(file.bytes, file.name, true);
            addContent(record, file.name);
        }
    }
368549
public static void putMetaDatas(Map<String, Object> metadatas, String contentType, String fileName){
        metadatas.put(MULTIPART_FLAG, true);
        if(isNotBlank(contentType)) {
            metadatas.put(CONTENT_TYPE, contentType);
        }
        if(isNotBlank(fileName)) {
            metadatas.put(FILENAME, fileName);
        }
    }
637142
def _to_meta_data(pif_obj, dataset_hit, mdf_acl):
    """"""
    pif = pif_obj.as_dictionary()
    dataset = dataset_hit.as_dictionary()
    mdf = {}
    try:
        if pif.get("names"):
            mdf["title"] = pif["names"][0]
        else:
            mdf["title"] = "Citrine PIF " + str(pif["uid"])

        if pif.get("chemicalFormula"):
            mdf["composition"] = pif["chemicalFormula"]
        elif pif.get("composition"):
            mdf["composition"] = ''.join([comp["element"] for comp in pif["composition"] if comp["element"]])
        if not mdf["composition"]:
            mdf.pop("composition")

        mdf["acl"] = mdf_acl
        mdf["source_name"] = _construct_new_key(dataset["name"])

        if pif.get("contacts"):
            mdf["data_contact"] = []
            for contact in pif["contacts"]:
                data_c = {
                    "given_name": contact["name"]["given"],  #REQ
                    "family_name": contact["name"]["family"]  #REQ
                    }
                if contact.get("email"):
                    data_c["email"] = contact.get("email", "")
                if contact.get("orcid"):
                    data_c["orcid"] = contact.get("orcid", "")
                mdf["data_contact"].append(data_c)
            if not mdf["data_contact"]:
                mdf.pop("data_contact")
        
        mdf["data_contributor"] = [{}] 
        if "owner" in dataset:
            name = dataset["owner"].split()
            contributor = {
                "given_name": name[0],
                "family_name": name[1],
                "email": dataset["email"]
            }
            mdf["data_contributor"] = [contributor]

        mdf["links"] = {
            "landing_page": "https://citrination.com/datasets/{}".format(dataset["id"]),
            "publication": []
            }
        if pif.get("references"):
            mdf["author"] = []
            mdf["citation"] = []
            for ref in pif["references"]:
                if ref.get("doi"):
                    mdf["citation"].append(ref["doi"]) #TODO: Make actual citation
                    mdf["links"]["publication"].append(ref["doi"])
                if ref.get("authors"):
                    for author in ref["authors"]:
                        if author.get("given") and author.get("family"):
                            mdf["author"].append({
                                "given_name": author["given"],
                                "family_name": author["family"]
                                })
            # Remove fields if blank
            if not mdf["author"]:
                mdf.pop("author")
            if not mdf["citation"]:
                mdf.pop("citation")
        if not mdf["links"]["publication"]:
            mdf["links"].pop("publication")

        if pif.get("licenses", [{}])[0].get("url"):
            mdf["license"] = pif["licenses"][0]["url"]
        if pif.get("tags"):
            mdf["tags"] = pif["tags"]

    # If required MDF metadata is missing from PIF, abort
    except KeyError as e:
        print("Error: Required MDF metadata", str(e), "not found in PIF", pif["uid"])
        return None

    return mdf
133462
private void buildPackageMetadata() throws IOException {
    metadata.validate();
    buildTemplatedMetadataFile(META_DIR + "/" + CONFIG_XML);
    buildPropertiesFile(META_DIR + "/" + PROPERTIES_XML);
    buildTemplatedMetadataFile(META_DIR + "/" + SETTINGS_XML);
    buildTemplatedMetadataFile(META_DIR + "/" + PACKAGE_DEFINITION_XML);
    writeXmlDocument(META_DIR + "/" + FILTER_XML, xmlContentBuilder.buildFilter(metadata.getFilters()));

    // package thumbnail
    byte[] thumbnailImage = metadata.getThumbnailImage();
    if (thumbnailImage != null) {
      zip.putNextEntry(new ZipEntry(META_DIR + "/definition/thumbnail.png"));
      try {
        zip.write(thumbnailImage);
      }
      finally {
        zip.closeEntry();
      }
    }
  }