Write the 'Metadata Document'.

@throws ODataRenderException if unable to render metadata document
173428
public void writeMetadataDocument() throws ODataRenderException {

        try {
            xmlWriter.writeStartElement(EDMX_NS, EDMX);
            xmlWriter.writeNamespace(EDMX_PREFIX, EDMX_NS);
            xmlWriter.writeAttribute(VERSION, ODATA_VERSION);
            xmlWriter.writeStartElement(EDMX_NS, EDMX_DATA_SERVICES);

            boolean entityContinerWritten = false;
            // Loop over all the schemas present in the Entity Data Model
            for (Schema schema : entityDataModel.getSchemas()) {
                xmlWriter.writeStartElement(SCHEMA);
                xmlWriter.writeDefaultNamespace(EDM_NS);
                xmlWriter.writeAttribute(NAMESPACE, schema.getNamespace());
                for (Type type : schema.getTypes()) {
                    switch (type.getMetaType()) {
                        case ENTITY:
                            entityTypeWriter.write((EntityType) type);
                            break;
                        case COMPLEX:
                            complexTypeWriter.write((ComplexType) type);
                            break;
                        case ENUM:
                            enumTypeWriter.write((EnumType) type);
                            break;
                        default:
                            LOG.error("Unexpected type: {}", type.getFullyQualifiedName());
                            throw new ODataRenderException("Unexpected type: " + type.getFullyQualifiedName());
                    }
                }
                if (!entityContinerWritten) {
                    writeEntityContainer(entityDataModel.getEntityContainer());
                    entityContinerWritten = true;
                }

                // End of <Schema> element
                xmlWriter.writeEndElement();
            }

            xmlWriter.writeEndElement();
        } catch (XMLStreamException e) {
            LOG.error("Not possible to start stream XML");
            throw new ODataRenderException("Not possible to start stream XML: ", e);
        }
    }
860592
public void write(ObjectWriter out, PersistedPropertyData propData) throws IOException
   {
      // write id
      out.writeInt(SerializationConstants.PERSISTED_PROPERTY_DATA);

      out.writeString(propData.getQPath().getAsString());
      out.writeString(propData.getIdentifier());

      if (propData.getParentIdentifier() != null)
      {
         out.writeByte(SerializationConstants.NOT_NULL_DATA);
         out.writeString(propData.getParentIdentifier());
      }
      else
         out.writeByte(SerializationConstants.NULL_DATA);

      out.writeInt(propData.getPersistedVersion());
      // -------------------

      out.writeInt(propData.getType());
      out.writeBoolean(propData.isMultiValued());
      out.writeLong(propData.getPersistedSize());

      List<ValueData> values = propData.getValues();
      if (values != null)
      {
         out.writeByte(SerializationConstants.NOT_NULL_DATA);
         int listSize = values.size();
         out.writeInt(listSize);
         PersistedValueDataWriter wr = new PersistedValueDataWriter();
         for (int i = 0; i < listSize; i++)
         {
            wr.write(out, (PersistedValueData)values.get(i));
         }
      }
      else
      {
         out.writeByte(SerializationConstants.NULL_DATA);
      }

   }
979238
@Override
    public void writeData(String tableName, EntityMetadata m, Object entity, Object rowId,
            List<RelationHolder> relations, boolean showQuery) throws IOException
    {
        HBaseRow hbaseRow = createHbaseRow(m, entity, rowId, relations);
        writeHbaseRowInATable(tableName, hbaseRow);
    }
1043267
private function writeStoredRoutineMetadata(): void
  {
    $json_data = json_encode($this->phpStratumMetadata, JSON_PRETTY_PRINT);
    if (json_last_error()!=JSON_ERROR_NONE)
    {
      throw new RuntimeException("Error of encoding to JSON: '%s'.", json_last_error_msg());
    }

    // Save the metadata.
    $this->writeTwoPhases($this->phpStratumMetadataFilename, $json_data);
  }
287096
public void writeEntryEntityLink(Object entity) throws XMLStreamException, ODataEdmException {

        EntityType entityType = getAndCheckEntityType(entityDataModel, entity.getClass());
        xmlWriter.writeStartElement(ATOM_LINK);
        if (entityType.isReadOnly()) {
            xmlWriter.writeAttribute(REL, SELF);
        } else {
            xmlWriter.writeAttribute(REL, EDIT);
        }
        xmlWriter.writeAttribute(TITLE, entityType.getName());
        xmlWriter.writeAttribute(HREF, getEntityWithKey(entity));
        xmlWriter.writeEndElement();
    }
72169
public void write(final Metadata metadata, final String pathToMetadata,
        final List<? extends MetadataJavaDoc> javadocTags) {
        try {
            final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

            // root elements
            final Document doc = docBuilder.newDocument();
            final Element rootElement = doc.createElement("metadata");
            doc.appendChild(rootElement);

            final Element javadocsElement = doc.createElement("javadocs");
            rootElement.appendChild(javadocsElement);

            final Set<String> commonPathSet = new HashSet<String>();
            final List<File> fileList = new ArrayList<File>();
            for (final MetadataDescriptor descr : metadata.getMetadataDescriptorList()) {
                if (descr.getCommon() != null) {
                    final String pathTo = descr.getCommon().getPathToCommonApi();
                    final String commonApi = descr.getCommon().getCommonApi().replace('.', '/');
                    commonPathSet.add(pathTo + "/" + commonApi);
                }
            }

            for (final String pathCommonApi : commonPathSet) {
                listFiles(fileList, pathCommonApi);
            }

            final JavaProjectBuilder builder = new JavaProjectBuilder();
            final Element generatedElement = doc.createElement("generatedClasses");
            rootElement.appendChild(generatedElement);
            for (final File file : fileList) {
                final Element generatedClassElement = doc.createElement("generatedClass");
                generatedClassElement.setAttribute("name", file.getName());
                generatedElement.appendChild(generatedClassElement);
                final JavaSource src = builder.addSource(file);
                final JavaClass class1  = src.getClasses().get(0);
                generatedClassElement.setAttribute("commonPackage", class1.getPackageName());
                final List<JavaAnnotation> annotationList = class1.getAnnotations();
                for (JavaAnnotation annotation : annotationList) {
                    final  AnnotationValue value = annotation.getProperty("common");
                    final List<String> commonExtendsList = (List<String>)value.getParameterValue();
                    for (String commonClass : commonExtendsList) {
                        final Element extendsElement = doc.createElement("commonExtends");
                        extendsElement.setAttribute("extends", commonClass.replace('"', ' ').trim());
                        generatedClassElement.appendChild(extendsElement);
                    }
                }
            }

            final Element commonPackagesElement = doc.createElement("commonPackages");
            rootElement.appendChild(commonPackagesElement);
            for (final MetadataDescriptor descr : metadata.getMetadataDescriptorList()) {
                if (descr.isGenerateCommonClasses() != null && !descr.isGenerateCommonClasses()) {
                    final Element generateElement = doc.createElement("package");
                    generateElement.setAttribute("packageApi", descr.getPackageApi());
                    generateElement.setAttribute("generate", Boolean.toString(descr.isGenerateCommonClasses()));
                    commonPackagesElement.appendChild(generateElement);
                }
            }

            final List<String> commonNewFiles = findCommonClasses(metadata);
            final Element commonNewFilesElement = doc.createElement("commonClasses");
            rootElement.appendChild(commonNewFilesElement);
            for (final String type : commonNewFiles) {
                final Element commonType = doc.createElement("typeName");
                commonType.setAttribute("name", type);
                commonNewFilesElement.appendChild(commonType);
            }

            if (javadocTags != null) {
                for (final MetadataJavaDoc javaDoc : javadocTags) {
                    final Attr javadocName = doc.createAttribute("tag");
                    javadocName.setValue(javaDoc.getTag());

                    final Attr javadocValue = doc.createAttribute("value");
                    javadocValue.setValue(javaDoc.getValue());

                    final Element tagElement = doc.createElement("tag");
                    tagElement.setAttributeNode(javadocName);
                    tagElement.setAttributeNode(javadocValue);

                    javadocsElement.appendChild(tagElement);
                }
            }

            // add packages
            final Element packages = doc.createElement("packages");
            rootElement.appendChild(packages);

            for (MetadataDescriptor descriptor : metadata.getMetadataDescriptorList()) {
                final Element packageApi = doc.createElement("api");
                final Attr packageApiName = doc.createAttribute("name");
                packageApiName.setValue(descriptor.getPackageApi());
                packageApi.setAttributeNode(packageApiName);

                final Attr schemaNameApi = doc.createAttribute("schema");
                schemaNameApi.setValue(descriptor.getSchemaName());
                packageApi.setAttributeNode(schemaNameApi);

                final Attr generateClassApi = doc.createAttribute("generateClass");
                generateClassApi.setValue(Boolean.toString(descriptor.isGenerateClasses()));
                packageApi.setAttributeNode(generateClassApi);

                if (descriptor.getPathToPackageInfoApi() != null) {
                    final Attr pathToPackageInfoApi = doc.createAttribute("packageInfo");
                    pathToPackageInfoApi.setValue(descriptor.getPathToPackageInfoApi());
                    packageApi.setAttributeNode(pathToPackageInfoApi);
                }

                if (descriptor.getCommonImports() != null) {
                    final Element commonImport = doc.createElement("commonImport");
                    for (String importDescl : descriptor.getCommonImports()) {
                        final Element importElement = doc.createElement("import");
                        importElement.setAttribute("package", importDescl);
                        commonImport.appendChild(importElement);
                    }
                    packageApi.appendChild(commonImport);
                }

                packages.appendChild(packageApi);
            }

            for (MetadataDescriptor descriptor : metadata.getMetadataDescriptorList()) {
                final Element packageImpl = doc.createElement("impl");
                final Attr packageImplName = doc.createAttribute("name");
                packageImplName.setValue(descriptor.getPackageImpl());
                packageImpl.setAttributeNode(packageImplName);

                final Attr schemaNameImpl = doc.createAttribute("schema");
                schemaNameImpl.setValue(descriptor.getSchemaName());
                packageImpl.setAttributeNode(schemaNameImpl);

                final Attr generateClassImpl = doc.createAttribute("generateClass");
                generateClassImpl.setValue(Boolean.toString(descriptor.isGenerateClasses()));
                packageImpl.setAttributeNode(generateClassImpl);

                if (descriptor.getPathToPackageInfoImpl() != null) {
                    final Attr pathToPackageInfoImpl = doc.createAttribute("packageInfo");
                    pathToPackageInfoImpl.setValue(descriptor.getPathToPackageInfoImpl());
                    packageImpl.setAttributeNode(pathToPackageInfoImpl);
                }

                packages.appendChild(packageImpl);
            }

            // add datatypes
            final Element datatypes = doc.createElement("datatypes");
            rootElement.appendChild(datatypes);
            for (MetadataItem metadataType : metadata.getDataTypeList()) {
                final Element datatype = doc.createElement("datatype");
                final Attr attrName = doc.createAttribute("name");
                attrName.setValue(metadataType.getName());
                datatype.setAttributeNode(attrName);

                final Attr attrMappedTo = doc.createAttribute("mappedTo");
                attrMappedTo.setValue(metadataType.getMappedTo());
                datatype.setAttributeNode(attrMappedTo);

                final Attr attrNamespace = doc.createAttribute("namespace");
                attrNamespace.setValue(metadataType.getNamespace());
                datatype.setAttributeNode(attrNamespace);

                final Attr attrSchemaName = doc.createAttribute("schemaName");
                attrSchemaName.setValue(metadataType.getSchemaName());
                datatype.setAttributeNode(attrSchemaName);

                datatypes.appendChild(datatype);
            }

            final Element enums = doc.createElement("enums");
            rootElement.appendChild(enums);
            for (MetadataEnum metadataEnum : metadata.getEnumList()) {
                final Element enumElement = doc.createElement("enum");
                final Attr attrName = doc.createAttribute("name");
                attrName.setValue(metadataEnum.getName());
                enumElement.setAttributeNode(attrName);

                final Attr attrNamespace = doc.createAttribute("namespace");
                attrNamespace.setValue(metadataEnum.getNamespace());
                enumElement.setAttributeNode(attrNamespace);

                final Attr attrSchemaName = doc.createAttribute("schemaName");
                attrSchemaName.setValue(metadataEnum.getSchemaName());
                enumElement.setAttributeNode(attrSchemaName);

                final Attr attrPackage = doc.createAttribute("package");
                attrPackage.setValue(metadataEnum.getPackageApi());
                enumElement.setAttributeNode(attrPackage);

                final Attr attrDocumentation = doc.createAttribute("documentation");
                attrDocumentation.setValue("");
                enumElement.setAttributeNode(attrDocumentation);

                for (String value : metadataEnum.getValueList()) {
                    final Element valueElement = doc.createElement("value");
                    valueElement.setTextContent(value);
                    enumElement.appendChild(valueElement);
                }

                enums.appendChild(enumElement);
            }

            final Element groups = doc.createElement("groups");
            rootElement.appendChild(groups);
            for (MetadataItem metadataClass : metadata.getGroupList()) {
                final Element classElement = doc.createElement("class");

                final Attr attrName = doc.createAttribute("name");
                attrName.setValue(metadataClass.getName());
                classElement.setAttributeNode(attrName);

                final Attr attrNamespace = doc.createAttribute("namespace");
                attrNamespace.setValue(metadataClass.getNamespace());
                classElement.setAttributeNode(attrNamespace);

                final Attr attrSchemaName = doc.createAttribute("schemaName");
                attrSchemaName.setValue(metadataClass.getSchemaName());
                classElement.setAttributeNode(attrSchemaName);

                final Attr attrPackageApi = doc.createAttribute("package");
                attrPackageApi.setValue(metadataClass.getPackageApi());
                classElement.setAttributeNode(attrPackageApi);

                final Attr attrDocumentation = doc.createAttribute("documentation");
                attrDocumentation.setValue("");
                classElement.setAttributeNode(attrDocumentation);

                for (MetadataElement element : metadataClass.getElements()) {
                    final Element childElement = doc.createElement("element");

                    final Attr elName = doc.createAttribute("name");
                    elName.setValue(element.getName());
                    childElement.setAttributeNode(elName);

                    final Attr elType = doc.createAttribute("type");
                    elType.setValue(element.getType());
                    childElement.setAttributeNode(elType);

                    if (element.getIsAttribute() == true) {
                        final Attr elAttribute = doc.createAttribute("attribute");
                        elAttribute.setValue(Boolean.toString(element.getIsAttribute()));
                        childElement.setAttributeNode(elAttribute);
                    }

                    if (element.getDefaultValue() != null) {
                        final Attr elAttribute = doc.createAttribute("default");
                        elAttribute.setValue(element.getDefaultValue());
                        childElement.setAttributeNode(elAttribute);
                    }

                    if (element.getFixedValue() != null) {
                        final Attr elAttribute = doc.createAttribute("fixed");
                        elAttribute.setValue(element.getFixedValue());
                        childElement.setAttributeNode(elAttribute);
                    }

                    if (element.getUse() != null) {
                        final Attr elAttribute = doc.createAttribute("use");
                        elAttribute.setValue(element.getUse());
                        childElement.setAttributeNode(elAttribute);
                    }

                    if (element.getMaxOccurs() != null) {
                        final Attr elMaxOccurs = doc.createAttribute("maxOccurs");
                        elMaxOccurs.setValue(element.getMaxOccurs());
                        childElement.setAttributeNode(elMaxOccurs);
                    }

                    classElement.appendChild(childElement);
                }

                for (MetadataElement element : metadataClass.getReferences()) {
                    final Element childElement = doc.createElement("include");

                    final Attr elName = doc.createAttribute("name");
                    elName.setValue(element.getRef());
                    childElement.setAttributeNode(elName);

                    classElement.appendChild(childElement);
                }

                groups.appendChild(classElement);
            }

            final Element classes = doc.createElement("classes");
            rootElement.appendChild(classes);
            for (MetadataItem metadataClass : metadata.getClassList()) {
                final Element classElement = doc.createElement("class");

                final Attr attrName = doc.createAttribute("name");
                attrName.setValue(metadataClass.getName());
                classElement.setAttributeNode(attrName);

                final Attr attrNamespace = doc.createAttribute("namespace");
                attrNamespace.setValue(metadataClass.getNamespace());
                classElement.setAttributeNode(attrNamespace);

                final Attr attrSchemaName = doc.createAttribute("schemaName");
                attrSchemaName.setValue(metadataClass.getSchemaName());
                classElement.setAttributeNode(attrSchemaName);

                final Attr attrPackageApi = doc.createAttribute("packageApi");
                attrPackageApi.setValue(metadataClass.getPackageApi());
                classElement.setAttributeNode(attrPackageApi);

                final Attr attrPackageImpl = doc.createAttribute("packageImpl");
                attrPackageImpl.setValue(metadataClass.getPackageImpl());
                classElement.setAttributeNode(attrPackageImpl);

                final Attr attrDocumentation = doc.createAttribute("documentation");
                attrDocumentation.setValue("");
                classElement.setAttributeNode(attrDocumentation);

                for (MetadataElement element : metadataClass.getElements()) {
                    final Element childElement = doc.createElement("element");

                    final Attr elName = doc.createAttribute("name");
                    elName.setValue(element.getName());
                    childElement.setAttributeNode(elName);

                    final Attr elType = doc.createAttribute("type");
                    elType.setValue(element.getType());
                    childElement.setAttributeNode(elType);

                    if (element.getMaxOccurs() != null) {
                        final Attr elMaxOccurs = doc.createAttribute("maxOccurs");
                        elMaxOccurs.setValue(element.getMaxOccurs());
                        childElement.setAttributeNode(elMaxOccurs);
                    }

                    if (element.getIsAttribute() == true) {
                        final Attr elAttribute = doc.createAttribute("attribute");
                        elAttribute.setValue(Boolean.toString(element.getIsAttribute()));
                        childElement.setAttributeNode(elAttribute);
                    }

                    if (element.getDefaultValue() != null) {
                        final Attr elAttribute = doc.createAttribute("default");
                        elAttribute.setValue(element.getDefaultValue());
                        childElement.setAttributeNode(elAttribute);
                    }

                    if (element.getFixedValue() != null) {
                        final Attr elAttribute = doc.createAttribute("fixed");
                        elAttribute.setValue(element.getFixedValue());
                        childElement.setAttributeNode(elAttribute);
                    }

                    if (element.getUse() != null) {
                        final Attr elAttribute = doc.createAttribute("use");
                        elAttribute.setValue(element.getUse());
                        childElement.setAttributeNode(elAttribute);
                    }

                    classElement.appendChild(childElement);
                }

                for (MetadataElement element : metadataClass.getReferences()) {
                    final Element childElement = doc.createElement("include");

                    final Attr elName = doc.createAttribute("name");
                    elName.setValue(element.getRef());
                    childElement.setAttributeNode(elName);

                    if (element.getMaxOccurs() != null) {
                        final Attr elMaxOccurs = doc.createAttribute("maxOccurs");
                        elMaxOccurs.setValue(element.getMaxOccurs());
                        childElement.setAttributeNode(elMaxOccurs);
                    }

                    classElement.appendChild(childElement);
                }

                classes.appendChild(classElement);
            }

            final Element descriptors = doc.createElement("descriptors");
            rootElement.appendChild(descriptors);

            for (MetadataDescriptor descriptor : metadata.getMetadataDescriptorList()) {
                if (descriptor.getRootElementName() != null && descriptor.getRootElementType() != null) {
                    final Element descriptorElement = doc.createElement("descriptor");
                    descriptors.appendChild(descriptorElement);

                    final Attr attrName = doc.createAttribute("name");
                    attrName.setValue(descriptor.getName());
                    descriptorElement.setAttributeNode(attrName);

                    final Attr attrSchemaName = doc.createAttribute("schemaName");
                    attrSchemaName.setValue(descriptor.getSchemaName());
                    descriptorElement.setAttributeNode(attrSchemaName);

                    final Attr attrPackageApi = doc.createAttribute("packageApi");
                    attrPackageApi.setValue(descriptor.getPackageApi());
                    descriptorElement.setAttributeNode(attrPackageApi);

                    final Attr attrPackageImpl = doc.createAttribute("packageImpl");
                    attrPackageImpl.setValue(descriptor.getPackageImpl());
                    descriptorElement.setAttributeNode(attrPackageImpl);

                    final Element element = doc.createElement("element");
                    descriptorElement.appendChild(element);

                    final Attr attElementName = doc.createAttribute("name");
                    attElementName.setValue(descriptor.getRootElementName());
                    element.setAttributeNode(attElementName);

                    final Attr attElementType = doc.createAttribute("type");
                    attElementType.setValue(descriptor.getRootElementType());
                    element.setAttributeNode(attElementType);

                    final Enumeration<?> em = descriptor.getNamespaces().keys();
                    while (em.hasMoreElements()) {
                        final String key = (String) em.nextElement();
                        final String value = (String) descriptor.getNamespaces().get(key);
                        final Attr namespaceAttrName = doc.createAttribute("name");
                        namespaceAttrName.setValue(key);

                        final Attr namespaceAttrValue = doc.createAttribute("value");
                        namespaceAttrValue.setValue(value);

                        final Element namespaceElement = doc.createElement("namespace");
                        namespaceElement.setAttributeNode(namespaceAttrName);
                        namespaceElement.setAttributeNode(namespaceAttrValue);

                        descriptorElement.appendChild(namespaceElement);
                    }

                    if (descriptor.getCommonRef() != null) {
                        final Element commonRefElement = doc.createElement("commonRef");
                        commonRefElement.setAttribute("refid", descriptor.getCommonRef().getRefid());
                        descriptorElement.appendChild(commonRefElement);
                    }

                    if (descriptor.getCommon() != null) {
                        final Element commonElement = doc.createElement("common");
                        commonElement.setAttribute("pathToCommonApi", descriptor.getCommon().getPathToCommonApi());
                        commonElement.setAttribute("commonDescriptorName", descriptor.getCommon().getCommonDescriptorName());
                        commonElement.setAttribute("commonApi", descriptor.getCommon().getCommonApi());
                        commonElement.setAttribute("commonNamespace", descriptor.getCommon().getCommonNamespace());
                        commonElement.setAttribute("id", descriptor.getCommon().getId());
                        commonElement.setAttribute("generate", descriptor.getCommon().getGenerate().toString());

                        if (descriptor.getCommon().getCommonImports() != null) {
                            final Element commonImport = doc.createElement("commonImport");
                            for (String importDescl : descriptor.getCommon().getCommonImports()) {
                                final Element importElement = doc.createElement("import");
                                importElement.setAttribute("package", importDescl);
                                commonImport.appendChild(importElement);
                            }
                            commonElement.appendChild(commonImport);
                        }

                        if (descriptor.getCommon().getTypes() != null) {
                            final Element commonTypes = doc.createElement("commonTypes");
                            for (String type : descriptor.getCommon().getTypes()) {
                                final Element typeElement = doc.createElement("type");
                                final String[] items = type.split(":", -1);
                                if (items.length == 2) {
                                    typeElement.setAttribute("namespace", items[0]);
                                    typeElement.setAttribute("name", items[1]);
                                    commonTypes.appendChild(typeElement);
                                }
                            }
                            commonElement.appendChild(commonTypes);
                        }

                        if (descriptor.getCommon().getExcludes() != null) {
                            final Element excludeTypes = doc.createElement("commonExcludes");
                            for (String exclude : descriptor.getCommon().getExcludes()) {
                                final Element excludeElement = doc.createElement("exclude");
                                final String[] items = exclude.split(":", -1);
                                if (items.length == 2) {
                                    excludeElement.setAttribute("namespace", items[0]);
                                    excludeElement.setAttribute("name", items[1]);
                                    excludeTypes.appendChild(excludeElement);
                                }
                            }
                            commonElement.appendChild(excludeTypes);
                        }

                        descriptorElement.appendChild(commonElement);
                    }
                }
            }

            final TransformerFactory transformerFactory = TransformerFactory.newInstance();
            final Transformer transformer = transformerFactory.newTransformer();
            final DOMSource source = new DOMSource(doc);
            final File file = new File(pathToMetadata);
            final StreamResult result = new StreamResult(file);

            // Output to console for testing
            // StreamResult result = new StreamResult(System.out);

            transformer.transform(source, result);

            if (log.isLoggable(Level.FINE)) {
                log.fine("Saved: " + file.getAbsolutePath());
            }

        } catch (ParserConfigurationException pce) {
            pce.printStackTrace();
        } catch (TransformerException tfe) {
            tfe.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
461097
public static boolean write(OutputStream os, Metadata data)
    {
        XmpDirectory dir = data.getFirstDirectoryOfType(XmpDirectory.class);
        if (dir == null)
            return false;
        XMPMeta meta = dir.getXMPMeta();
        try
        {
            SerializeOptions so = new SerializeOptions().setOmitPacketWrapper(true);
            XMPMetaFactory.serialize(meta, os, so);
        }
        catch (XMPException e)
        {
            e.printStackTrace();
            return false;
        }
        return true;
    }
117158
private void writeMetaData(ByteArrayOutputStream baos)
            throws UnsupportedEncodingException, IOException {
        if (settings.getMetadata() == null) {
            return;
        }

        for (Iterator<String> i = settings.getMetadata().iterator();
                i.hasNext();) {
            Object obj = i.next();
            if (obj instanceof String) {
                baos.write(((String)obj).getBytes(DEFAULT_ENCODING));
            } else if (obj instanceof File) {
                InputStream is = null;
                try {
                    is = new BufferedInputStream(
                        new FileInputStream((File)obj));
                    byte [] buffer = new byte[4096];
                    for (int read = -1; (read = is.read(buffer)) != -1;) {
                        baos.write(buffer, 0, read);
                    }
                } finally {
                    if (is != null) {
                        is.close();
                    }
                }
            } else if (obj != null) {
                logger.severe("Unsupported metadata type: " + obj);
            }
        }
        return;
    }
713512
public void write(DataOutput out) throws IOException {
    out.writeLong(version);
    Text.writeString(out, dir);
    out.writeLong(gen);
  }
618518
public function compileMetadata()
    {
        if (is_null($this->metadataCache))
        {
            $this->metadata = '{}';

            return;
        }

        $this->metadata = json_encode($this->metadataCache);
    }
1211399
private void serializeEntityDocument(EntityDocument entityDocument) {
		try {
			if (this.entityDocumentCount > 0) {
				this.outputStream.write(JSON_SEP);
			}
			mapper.writeValue(this.outputStream, entityDocument);
		} catch (IOException e) {
			reportException(e);
		}
		this.entityDocumentCount++;
	}
891658
public void writeMetaDataBlock( long metaDataOffset , byte[] metaData ) throws JournalException
    {
    	// Refuse any further operation in case of previous failure
    	if (failing)
    		throw new JournalException("Store journal is failing");
    	
        synchronized (journalWriteQueue)
        {
        	if (traceEnabled)
        		log.trace("["+baseName+"] #"+currentTransactionId+" Queueing metadata block write : offset="+metaDataOffset+" size="+metaData.length+" / queueSize="+(journalWriteQueue.size()+1));
        	
        	MetaDataBlockWriteOperation op = 
        		new MetaDataBlockWriteOperation(currentTransactionId,
							                    metaDataOffset, 
							                    metaData);
            journalWriteQueue.addLast(op);
            unflushedJournalSize += op.size();
            totalPendingOperations++;
        }
    }
538813
@Override
    public void endDocument(MetaData metadata)
    {
        this.builder.addBlock(new XDOM(this.builder.endBlockList(), metadata));
    }
935591
public void write(RowOutputInterface out,
                      ResultMetaData meta) throws IOException {

        beforeFirst();
        out.writeLong(id);
        out.writeInt(size);
        out.writeInt(0);    // offset
        out.writeInt(size);

        while (hasNext()) {
            Object[] data = getNext();

            out.writeData(meta.getColumnCount(), meta.columnTypes, data, null,
                          null);
        }

        beforeFirst();
    }
440933
private void writeMetaData(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Gets metadata for the Resource Adapter. \n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @return ResourceAdapterMetaData instance\n");
      writeWithIndent(out, indent, " * @throws ResourceException Failed to get metadata information \n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "@Override\n");
      writeWithIndent(out, indent, "public ResourceAdapterMetaData getMetaData() throws ResourceException");
      writeLeftCurlyBracket(out, indent);

      writeIndent(out, indent + 1);
      if (def.isUseRa())
      {
         out.write("return new " + def.getRaMetaClass() + "();");
      }
      else
      {
         out.write("return null;");
      }
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
869261
def write_metadata res
      File.open(@options[:output_parameters], 'wb') do |f|
        f.write(JSON.pretty_generate(res))
      end
    end
633661
void write(CallInfo callInfo, DataSetAssertion assertion) {
    Element rootNode = root(callInfo); 
    DataSource ds = assertion.getSource();
    write(rootNode, ds);
    Element saNode = createNode(rootNode, ASSERTION_TAG);
    List<MetaData.ColumnInfo> mdCols = ds.getMetaData().columns();
    write(saNode, 
        EXPECTED_TAG, 
        mdCols,
        assertion.data(DataSetAssertion.IteratorType.EXPECTED_DATA));
    if (! assertion.passed()) {
      Element errorsNode = createNode(saNode, ERRORS_TAG);
      write(errorsNode, 
          EXPECTED_TAG, 
          mdCols,
          assertion.data(DataSetAssertion.IteratorType.ERRORS_EXPECTED));
      write(errorsNode, 
          ACTUAL_TAG, 
          mdCols,
          assertion.data(DataSetAssertion.IteratorType.ERRORS_ACTUAL));
    }
    flush(rootNode);
  }