Example usage for java.lang Package Package

List of usage examples for java.lang Package Package

Introduction

In this page you can find the example usage for java.lang Package Package.

Prototype

Package(String name, Module module) 

Source Link

Usage

From source file:org.openvpms.esci.adapter.map.invoice.PackageHelper.java

/**
 * Tries to determine the package information give the order, product and supplier.
 *
 * @param orderItem the order item. May be <tt>null</tt>
 * @param product   the product. May be <tt>null</tt>
 * @param supplier  the supplier//  ww  w. j  a v  a  2s.c  o  m
 * @return the package information, or <tt>null</tt> if none is available
 */
public Package getPackage(FinancialAct orderItem, Product product, Party supplier) {
    Package result = null;
    int packageSize = 0;
    String packageUnits = null;
    if (orderItem != null) {
        ActBean bean = factory.createActBean(orderItem);
        packageSize = bean.getInt("packageSize");
        packageUnits = bean.getString("packageUnits");
    }
    if (packageSize != 0 && !StringUtils.isEmpty(packageUnits)) {
        result = new Package(packageSize, packageUnits);
    } else if (product != null) {
        List<ProductSupplier> list = rules.getProductSuppliers(product, supplier);
        if (list.size() == 1) {
            ProductSupplier ps = list.get(0);
            result = new Package(ps);
        }
    }
    return result;
}

From source file:com.simplyian.voxelscript.script.JSLoader.java

/**
 * Loads a package provided its directory.
 *
 * @param name/*from  w w  w  .  j a v  a 2s. co  m*/
 * @param dir
 * @return
 * @throws IOException
 */
public Package loadPackage(String name, File dir) throws IOException {
    Scriptable packageScope = cx.newObject(scope);
    packageScope.setPrototype(scope);
    packageScope.setParentScope(scope);
    packageScope.put("include", scope, new IncludeFunction(plugin, dir, this, packageScope));
    packageScope.put("resource", scope, new ResourceFunction(plugin, dir));

    File mainFile = null;
    PackageDescription desc = null;

    File packageJson = new File(dir.getPath(), "package.json");
    if (!packageJson.exists()) {
        plugin.getLogger().log(Level.WARNING, "A package.json was not found for the package '" + name + "'.");
        mainFile = new File(dir.getPath(), "index.js");
        if (!mainFile.exists()) {
            plugin.getLogger().log(Level.WARNING,
                    "An index.js was not found for the package '" + name + "'. This package was not loaded.");
            return null;
        }
        desc = PackageDescription.load(name, null);
    } else {
        // TODO load package.json
    }

    String script = FileUtils.readFileToString(mainFile);
    if (loadingPackages.contains(name.toLowerCase())) {
        plugin.getLogger().log(Level.WARNING,
                "Circular dependency detected for something wanting package '" + name + "'. Stopping...");
        return null;
    }

    loadingPackages.add(name.toLowerCase());
    Scriptable exports = runScript(name, script, packageScope);
    loadingPackages.remove(name.toLowerCase());
    if (exports == null) {
        return null;
    }
    return new Package(desc, exports);
}