Copies the optional packageInfo files into the packages.
@param path
@param metadata
@throws IOException
514348
public static void copyPackageInfo(final MetadataParserPath path, final Metadata metadata, final boolean verbose) throws IOException {
        for (final MetadataDescriptor descriptor : metadata.getMetadataDescriptorList()) {
            if (descriptor.getPathToPackageInfoApi() != null) {
                final File sourceFile = new File(descriptor.getPathToPackageInfoApi());
                final String destDirectory = path.pathToApi + File.separatorChar + descriptor.getPackageApi().replace('.', '/');
                deleteExistingPackageInfo(destDirectory, verbose);
                copy(sourceFile, destDirectory, verbose);
            }

            if (descriptor.getPathToPackageInfoImpl() != null) {
                final File sourceFile = new File(descriptor.getPathToPackageInfoImpl());
                final String destDirectory = path.pathToImpl + File.separatorChar + descriptor.getPackageImpl().replace('.', '/');
                deleteExistingPackageInfo(destDirectory, verbose);
                copy(sourceFile, destDirectory, verbose);
            }
        }
    }
172241
protected void addSourceFolder(String path) {
		final List<String> existingFolders1 = this.project.getCompileSourceRoots();
		final List<String> existingFolders2 = this.project.getTestCompileSourceRoots();
		if (!existingFolders1.contains(path) && !existingFolders2.contains(path)) {
			getLog().info(MessageFormat.format(Messages.InitializeMojo_0, path));
			this.session.getCurrentProject().addCompileSourceRoot(path);
		} else {
			getLog().info(MessageFormat.format(Messages.InitializeMojo_1, path));
		}
	}
815233
protected String getPackageName(String path) throws IOException {
        return path.substring(getAssetPath().length() + 1, path.length() - 5).replace('/', '.');
    }
652270
private static void processPathPart(String path, Set<String> classes) {
        File rootFile = new File(path);
        if (rootFile.isDirectory() == false) {
            return;
        }

        File[] files = rootFile.listFiles();
        for (File f : files) {
            // classes in the anonymous package
            if (f.getName().endsWith(".class")) {
                String className = f.getName();
                // trim the trailing .class from the end
                className = className.substring(0, className.length() - ".class".length());
                classes.add(className);
            }
            if (f.isDirectory()) {
                Package p = new Package(null, f);
                p.process(classes);
            }
        }
    }
41072
private void initFileDirTables(Path path) throws IOException {
    FileStatus[] stats = fs.listStatus(path);
    if (stats != null) {
      for (FileStatus stat : stats) {
        if (stat.isDir()) {
          dirs.add(stat.getPath().toString());
          initFileDirTables(stat.getPath());
        } else {
          Path filePath = stat.getPath();
          if (filePath.getName().startsWith(StructureGenerator.FILE_NAME_PREFIX)) {
            files.add(filePath.toString());
          }
        }
      }
    }
  }
683441
def is_jar(path):
        
        if os.path.isfile(path) and zipfile.is_zipfile(path):
            try:
                with zipfile.ZipFile(path) as f:
                    if "META-INF/MANIFEST.MF" in f.namelist():
                        return True
            except (IOError, zipfile.BadZipfile):
                pass
        return False
499275
public byte[][] load (String packagePath, String key)
        throws IOException
    {
        String[] paths = getPaths(packagePath, key);
        if (paths == null) {
            log.warning("No such sound", "key", key);
            return null;
        }

        byte[][] data = new byte[paths.length][];
        String bundle = getBundle(packagePath);
        for (int ii = 0; ii < paths.length; ii++) {
            data[ii] = loadClipData(bundle, paths[ii]);
        }
        return data;
    }
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();
        }
    }
674701
public static VariantFileMetadata readVariantFileMetadata(Path path, VariantFileMetadata fileMetadata) throws IOException {
        Objects.requireNonNull(path);
        try (InputStream is = FileUtils.newInputStream(path)) {
            return readVariantFileMetadata(new VariantVcfHtsjdkReader(is, fileMetadata.toVariantStudyMetadata("")), fileMetadata);
        }
    }
1105175
public void writeTo(Path directory) throws IOException {
    checkArgument(Files.notExists(directory) || Files.isDirectory(directory),
        "path %s exists but is not a directory.", directory);
    Path outputDirectory = directory;
    if (!packageName.isEmpty()) {
      for (String packageComponent : packageName.split("\\.")) {
        outputDirectory = outputDirectory.resolve(packageComponent);
      }
      Files.createDirectories(outputDirectory);
    }

    Path outputPath = outputDirectory.resolve(typeSpec.name + ".java");
    try (Writer writer = new OutputStreamWriter(Files.newOutputStream(outputPath), UTF_8)) {
      writeTo(writer);
    }
  }
70319
public function setPackageMeta($pkg, $path = '') {
        $set = false;
        if (is_string($pkg) && !empty($pkg)) {
            $pkgPath = str_replace(array('.', '\\'), array('/', '/'), $pkg);
            $mapFile = $path . $pkgPath . '/metadata.' . $this->config['dbtype'] . '.php';
            if (file_exists($mapFile)) {
                $xpdo_meta_map = array();
                include $mapFile;
                if (!empty($xpdo_meta_map)) {
                    if (isset($xpdo_meta_map['version'])) {
                        if (version_compare($xpdo_meta_map['version'], '3.0', '>=')) {
                            $namespacePrefix = isset($xpdo_meta_map['namespacePrefix']) && !empty($xpdo_meta_map['namespacePrefix'])
                                ? $xpdo_meta_map['namespacePrefix'] . '\\'
                                : '';
                            self::getLoader()->addPsr4($namespacePrefix, $path);
                            $xpdo_meta_map = $xpdo_meta_map['class_map'];
                        }
                    }
                    foreach ($xpdo_meta_map as $className => $extends) {
                        if (!isset($this->classMap[$className])) {
                            $this->classMap[$className] = array();
                        }
                        $this->classMap[$className] = array_unique(array_merge($this->classMap[$className],$extends));
                    }
                    $set = true;
                }
            } else {
                $this->log(xPDO::LOG_LEVEL_WARN, "Could not load package metadata for package {$pkg}. Upgrade your model.");
            }
        } else {
            $this->log(xPDO::LOG_LEVEL_ERROR, 'setPackageMeta called with an invalid package name.');
        }
        return $set;
    }
44456
@FFDCIgnore(IllegalArgumentException.class)
    private void definePackage(final ByteResourceInformation classBytesResourceInformation, String packageName) {
        /*
         * We don't extend URL classloader so we automatically pass the manifest from the JAR to our supertype, still try to get hold of it though so that we can see if
         * we can load the information ourselves from it
         */
        Manifest manifest = classBytesResourceInformation.getManifest();
        try {
            if (manifest == null) {
                definePackage(packageName, null, null, null, null, null, null, null);
            } else {
                String classResourceName = classBytesResourceInformation.getResourcePath();

                /*
                 * Strip the class name off the end of the package, should always have at least one '/' as we have at least one . in the name, also end with a trailing
                 * '/' to match the name style for package definitions in manifest files
                 */
                String packageResourceName = classResourceName.substring(0, classResourceName.lastIndexOf('/') + 1);

                // Default all of the package info to null
                String specTitle = null;
                String specVersion = null;
                String specVendor = null;
                String implTitle = null;
                String implVersion = null;
                String implVendor = null;
                URL sealBaseUrl = null;

                // See if there is a package defined in the manifest 
                Attributes packageAttributes = manifest.getAttributes(packageResourceName);
                if (packageAttributes != null && !packageAttributes.isEmpty()) {
                    specTitle = packageAttributes.getValue(Attributes.Name.SPECIFICATION_TITLE);
                    specVersion = packageAttributes.getValue(Attributes.Name.SPECIFICATION_VERSION);
                    specVendor = packageAttributes.getValue(Attributes.Name.SPECIFICATION_VENDOR);

                    implTitle = packageAttributes.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
                    implVersion = packageAttributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
                    implVendor = packageAttributes.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);

                    String sealedValue = packageAttributes.getValue(Attributes.Name.SEALED);
                    if (sealedValue != null && Boolean.parseBoolean(sealedValue)) {
                        sealBaseUrl = classBytesResourceInformation.getResourceUrl();
                    }
                }

                definePackage(packageName, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBaseUrl);
            }
        } catch (IllegalArgumentException ignored) {
            // This happens if the package is already defined but it is hard to guard against this in a thread safe way. See:
            // http://bugs.sun.com/view_bug.do?bug_id=4841786
        }
    }
779642
public void addMetadata(Metadata meta) {
    for (String k : meta.keySet()) {
      for (TiffObject to : meta.getList(k)) {
        add(k, to, meta.getMetadataObject(k).isDublinCore(), meta.getMetadataObject(k).getPath());
      }
    }
  }
405575
public void mkPackage(String pkgName, File dir) {
        try {
            File metaDir = new File(dir + "/.mdw");
            if (!metaDir.exists() && !metaDir.mkdirs())
                throw new IOException("Cannot create directory: " + metaDir.getAbsolutePath());
            File pkgFile = new File(metaDir + "/package.yaml");
            if (!pkgFile.exists()) {
                JSONObject pkgJson = new JSONObject();
                pkgJson.put("name", pkgName);
                pkgJson.put("version", "1.0.01");
                pkgJson.put("schemaVersion", "6.1");
                Files.write(Paths.get(pkgFile.getPath()), pkgJson.toString(2).getBytes());
            }
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
    }
1309654
private void fillIn(PackageSymbol p) throws IOException {
        if (p.members_field == null) p.members_field = new Scope(p);
        String packageName = p.fullname.toString();

        Set<JavaFileObject.Kind> kinds = getPackageFileKinds();

        fillIn(p, PLATFORM_CLASS_PATH,
               fileManager.list(PLATFORM_CLASS_PATH,
                                packageName,
                                EnumSet.of(JavaFileObject.Kind.CLASS),
                                false));

        Set<JavaFileObject.Kind> classKinds = EnumSet.copyOf(kinds);
        classKinds.remove(JavaFileObject.Kind.SOURCE);
        boolean wantClassFiles = !classKinds.isEmpty();

        Set<JavaFileObject.Kind> sourceKinds = EnumSet.copyOf(kinds);
        sourceKinds.remove(JavaFileObject.Kind.CLASS);
        boolean wantSourceFiles = !sourceKinds.isEmpty();

        boolean haveSourcePath = fileManager.hasLocation(SOURCE_PATH);

        if (verbose && verbosePath) {
            if (fileManager instanceof StandardJavaFileManager) {
                StandardJavaFileManager fm = (StandardJavaFileManager)fileManager;
                if (haveSourcePath && wantSourceFiles) {
                    List<File> path = List.nil();
                    for (File file : fm.getLocation(SOURCE_PATH)) {
                        path = path.prepend(file);
                    }
                    log.printVerbose("sourcepath", path.reverse().toString());
                } else if (wantSourceFiles) {
                    List<File> path = List.nil();
                    for (File file : fm.getLocation(CLASS_PATH)) {
                        path = path.prepend(file);
                    }
                    log.printVerbose("sourcepath", path.reverse().toString());
                }
                if (wantClassFiles) {
                    List<File> path = List.nil();
                    for (File file : fm.getLocation(PLATFORM_CLASS_PATH)) {
                        path = path.prepend(file);
                    }
                    for (File file : fm.getLocation(CLASS_PATH)) {
                        path = path.prepend(file);
                    }
                    log.printVerbose("classpath",  path.reverse().toString());
                }
            }
        }

        if (wantSourceFiles && !haveSourcePath) {
            fillIn(p, CLASS_PATH,
                   fileManager.list(CLASS_PATH,
                                    packageName,
                                    kinds,
                                    false));
        } else {
            if (wantClassFiles)
                fillIn(p, CLASS_PATH,
                       fileManager.list(CLASS_PATH,
                                        packageName,
                                        classKinds,
                                        false));
            if (wantSourceFiles)
                fillIn(p, SOURCE_PATH,
                       fileManager.list(SOURCE_PATH,
                                        packageName,
                                        sourceKinds,
                                        false));
        }
        verbosePath = false;
    }
1007985
public static void setXwpfDocument(String path) throws IOException {
        InputStream is = new FileInputStream(path);
        xwpfDocument = new XWPFDocument(is);
        is.close();
    }
1029725
function buildMetadata(f, metadataTarget, options, isText) {

  var ext = path.extname(f);
  var name = path.basename(f, ext);

  var data = buildMetadataContent(name, options, ext, isText);

  fs.ensureFileSync(metadataTarget);
  fs.writeFileSync(metadataTarget, data, 'utf8');

}