Example usage for java.lang Package getName

List of usage examples for java.lang Package getName

Introduction

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

Prototype

public String getName() 

Source Link

Document

Return the name of this package.

Usage

From source file:io.sloeber.core.managers.InternalPackageManager.java

public static IPath getPlatformInstallPath(String vendor, String architecture) {

    for (PackageIndex index : getPackageIndices()) {
        for (Package pkg : index.getPackages()) {
            for (ArduinoPlatform curPlatform : pkg.getLatestInstalledPlatforms()) {
                if (architecture.equalsIgnoreCase(curPlatform.getArchitecture())
                        && (vendor.equalsIgnoreCase(pkg.getName()))) {
                    return new org.eclipse.core.runtime.Path(curPlatform.getInstallPath().toString());
                }//from   w  ww. j a v  a  2s  .  com
            }
        }
    }
    return null;
}

From source file:org.opennms.netmgt.config.PollerConfigFactory.java

/**
 * Load the config from the default config file and create the singleton
 * instance of this factory./*from w w  w .  java  2 s.  c  o m*/
 *
 * @exception java.io.IOException
 *                Thrown if the specified config file cannot be read
 * @throws java.io.IOException if any.
 */
public static synchronized void init() throws IOException {
    if (m_loaded) {
        // init already called - return
        // to reload, reload() will need to be called
        return;
    }

    try {
        OpennmsServerConfigFactory.init();
    } catch (final Exception e) {
        LOG.warn("Error while initializing OpennmsServerConfigFactory.", e);
    }
    OpennmsServerConfigFactory onmsSvrConfig = OpennmsServerConfigFactory.getInstance();

    final File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.POLLER_CONFIG_FILE_NAME);

    LOG.debug("init: config file path: {}", cfgFile.getPath());

    InputStream stream = null;
    PollerConfigFactory config = null;
    try {
        stream = new FileInputStream(cfgFile);
        config = new PollerConfigFactory(cfgFile.lastModified(), stream, onmsSvrConfig.getServerName(),
                onmsSvrConfig.verifyServer());
    } finally {
        IOUtils.closeQuietly(stream);
    }

    for (final org.opennms.netmgt.config.poller.Package pollerPackage : config.getConfiguration()
            .getPackages()) {
        for (final org.opennms.netmgt.config.poller.Service service : pollerPackage.getServices()) {
            for (final org.opennms.netmgt.config.poller.Parameter parm : service.getParameters()) {
                if (parm.getKey().equals("ds-name")) {
                    if (parm.getValue().length() > ConfigFileConstants.RRD_DS_MAX_SIZE) {
                        throw new IllegalStateException(String.format(
                                "ds-name '%s' in service '%s' (poller package '%s') is greater than %d characters",
                                parm.getValue(), service.getName(), pollerPackage.getName(),
                                ConfigFileConstants.RRD_DS_MAX_SIZE));
                    }
                }
            }
        }
    }

    setInstance(config);
}

From source file:com.netxforge.oss2.config.PollerConfigFactory.java

/**
 * Load the config from the default config file and create the singleton
 * instance of this factory./*from  www.j  av  a 2 s .  c  o m*/
 *
 * @exception java.io.IOException
 *                Thrown if the specified config file cannot be read
 * @exception org.exolab.castor.xml.MarshalException
 *                Thrown if the file does not conform to the schema.
 * @exception org.exolab.castor.xml.ValidationException
 *                Thrown if the contents do not match the required schema.
 * @throws java.io.IOException if any.
 * @throws org.exolab.castor.xml.MarshalException if any.
 * @throws org.exolab.castor.xml.ValidationException if any.
 */
public static synchronized void init() throws IOException, MarshalException, ValidationException {
    if (m_loaded) {
        // init already called - return
        // to reload, reload() will need to be called
        return;
    }

    OpennmsServerConfigFactory.init();
    OpennmsServerConfigFactory onmsSvrConfig = OpennmsServerConfigFactory.getInstance();

    final File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.POLLER_CONFIG_FILE_NAME);

    LogUtils.debugf(PollerConfigFactory.class, "init: config file path: %s", cfgFile.getPath());

    InputStream stream = null;
    PollerConfigFactory config = null;
    try {
        stream = new FileInputStream(cfgFile);
        config = new PollerConfigFactory(cfgFile.lastModified(), stream, onmsSvrConfig.getServerName(),
                onmsSvrConfig.verifyServer());
    } finally {
        IOUtils.closeQuietly(stream);
    }

    for (final org.opennms.netmgt.config.poller.Package pollerPackage : config.getConfiguration()
            .getPackageCollection()) {
        for (final org.opennms.netmgt.config.poller.Service service : pollerPackage.getServiceCollection()) {
            for (final org.opennms.netmgt.config.poller.Parameter parm : service.getParameterCollection()) {
                if (parm.getKey().equals("ds-name")) {
                    if (parm.getValue().length() > ConfigFileConstants.RRD_DS_MAX_SIZE) {
                        throw new ValidationException(String.format(
                                "ds-name '%s' in service '%s' (poller package '%s') is greater than %d characters",
                                parm.getValue(), service.getName(), pollerPackage.getName(),
                                ConfigFileConstants.RRD_DS_MAX_SIZE));
                    }
                }
            }
        }
    }

    setInstance(config);
}

From source file:com.quigley.moose.test.SpringMappingProvider.java

protected String getThisPackagePath(Package contextPackage) {
    return "classpath:/" + contextPackage.getName().replaceAll("[.]", "/");
}

From source file:com.link_intersystems.lang.reflect.SerializablePackage.java

@Override
protected Serializable serialize(Package nonSerializableObject2) {
    return nonSerializableObject2.getName();
}

From source file:com.virtualparadigm.packman.processor.JPackageManagerOld.java

private static Collection<Package> findInstalledPackages(String regex) {
    List<Package> installPackageList = new ArrayList<Package>();
    for (Package installPackage : JPackageManagerOld.findInstalledPackages()) {
        if (installPackage.getName().matches(regex)) {
            installPackageList.add(installPackage);
        }//from   www.j a v a  2s  .co  m
    }
    return installPackageList;
}

From source file:org.apache.axis2.jaxws.runtime.description.marshal.impl.PackageSetBuilder.java

/**
 * Add all of the packages/names in classSet to our package set collection
 * @param classSet/*  w  w w  .  ja v  a  2  s . c o m*/
 * @param set
 */
private static void addClassesToPackageSet(Set<Class> classSet, TreeSet<String> set) {
    if (log.isDebugEnabled()) {
        log.debug("enter addClassesToPackageSet");
    }
    if (classSet != null) {
        for (Class clz : classSet) {
            if (clz != null && clz != Holder.class && clz != Future.class && clz != Response.class) {
                Package pkg = clz.getPackage();
                //For primitive types there is no package
                String pkgText = (pkg != null) ? pkg.getName() : null;
                if (pkg != null) {
                    String name = clz.getCanonicalName();
                    if (log.isDebugEnabled()) {
                        log.debug(" adding class " + name);
                    }
                    set.add("@" + pkgText); // Indicates a package from an actual class reference
                    set.add("[" + name + "]"); // Indicates a actual class referenced
                }
            }
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("exit addClassesToPackageSet");
    }
}

From source file:com.nesscomputing.jdbi.JdbiStatement.java

public JdbiStatement(final Package pkg, final String queryName) {
    this(pkg.getName() + ":" + queryName);
}

From source file:edu.cornell.mannlib.vitro.webapp.web.beanswrappers.ReadOnlyBeansWrapper.java

@SuppressWarnings("rawtypes")
@Override//w ww.  j  av a 2 s  .c om
protected void finetuneMethodAppearance(Class cls, Method method, MethodAppearanceDecision decision) {

    // How to define a setter? This is a weak approximation: a method whose name
    // starts with "set" or returns void.
    if (method.getName().startsWith("set")) {
        decision.setExposeMethodAs(null);

    } else if (method.getReturnType().getName().equals("void")) {
        decision.setExposeMethodAs(null);

    } else {

        Class<?> declaringClass = method.getDeclaringClass();
        if (declaringClass.equals(java.lang.Object.class)) {
            decision.setExposeMethodAs(null);

        } else {
            Package pkg = declaringClass.getPackage();
            if (pkg.getName().equals("java.util")) {
                decision.setExposeMethodAs(null);
            }
        }
    }
}

From source file:com.link_intersystems.lang.reflect.SerializablePackageTest.java

@Test(expected = SerializationException.class)
public void classNotFound() throws Exception {
    Package packageObject = SerializablePackageTest.class.getPackage();
    String name = packageObject.getName();
    Whitebox.setInternalState(packageObject, String.class, "packagepath.that.does.not.exists", Package.class);
    try {/*from www  . j  a va 2s  .  c o m*/
        SerializablePackage serializablePackage = new SerializablePackage(packageObject);
        SerializablePackage deserialized = (SerializablePackage) SerializationUtils.clone(serializablePackage);
        deserialized.get();
    } finally {
        Whitebox.setInternalState(packageObject, String.class, name, Package.class);
    }
}