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:py.una.pol.karaku.configuration.KarakuWSClientConfiguration.java

private Jaxb2Marshaller getJaxb2Marshaller() {

    if (!isEnabled()) {
        return null;
    }/*w  ww . j  ava  2  s  .c o m*/
    Pattern pattern = Pattern
            .compile(properties.get(KARAKU_WS_CLIENT_PACKAGES_TO_SCAN, DEFAULT_PACKAGES_TO_SCAN_EXPRESSION));

    Package[] packages = Package.getPackages();
    List<String> packagesFound = new ArrayList<String>();
    for (Package pa : packages) {
        Matcher matcher = pattern.matcher(pa.getName());
        if (matcher.matches()) {
            log.trace("Found a package to add to the marshaller: " + pa.getName());
            packagesFound.add(pa.getName());
        }
    }

    addSpecificPackages(packagesFound);

    return instanciateMarshaller(packagesFound);
}

From source file:org.springframework.web.method.ControllerAdviceBean.java

/**
 * Checks whether the given bean type should be assisted by this
 * {@code @ControllerAdvice} instance./*from w  w  w  .  j  a v  a2s . c o  m*/
 * @param beanType the type of the bean to check
 * @see org.springframework.web.bind.annotation.ControllerAdvice
 * @since 4.0
 */
public boolean isApplicableToBeanType(Class<?> beanType) {
    if (!hasSelectors()) {
        return true;
    } else if (beanType != null) {
        for (Class<?> clazz : this.assignableTypes) {
            if (ClassUtils.isAssignable(clazz, beanType)) {
                return true;
            }
        }
        for (Class<? extends Annotation> annotationClass : this.annotations) {
            if (AnnotationUtils.findAnnotation(beanType, annotationClass) != null) {
                return true;
            }
        }
        String packageName = beanType.getPackage().getName();
        for (Package basePackage : this.basePackages) {
            if (packageName.startsWith(basePackage.getName())) {
                return true;
            }
        }
    }
    return false;
}

From source file:net.sradonia.i18n.StringBundle.java

public StringBundle(Package pack, String baseName, Locale locale) {
    this(pack.getName() + "." + baseName, locale);
}

From source file:com.phonegap.plugin.sqlitePlugin.SQLitePlugin.java

/**
 * Open database.//w  ww .  j  av  a  2  s.c  o  m
 *
 * @param db
 *            The name of the database
 * @param version
 *            The version
 * @param display_name
 *            The display name
 * @param size
 *            The size in bytes
 */
public void openDatabase(String db, String version, String display_name, long size) {

    // If database is open, then close it
    if (this.myDb != null) {
        this.myDb.close();
    }

    // If no database path, generate from application package
    if (this.path == null) {
        Package pack = this.ctx.getClass().getPackage();
        String appPackage = pack.getName();
        this.setStorage(appPackage);
    }

    this.dbName = this.path + db + ".db";
    this.myDb = SQLiteDatabase.openOrCreateDatabase(this.dbName, null);
}

From source file:com.neiljbrown.brighttalk.channels.reportingapi.client.spring.AppConfig.java

/**
 * Creates and configures a {@link Marshaller} to be used for both marshalling and unmarshalling HTTP request and
 * response bodies.//  w w w .  j a v  a 2  s .c o m
 * <p>
 * The created Marshaller is configured with a custom JAXB {@link javax.xml.bind.ValidationEventHandler} which
 * supports logging not fatal validation errors that occur on unmarshalling, and optionally classifying them as fatal
 * errors depending on the class of causal ('linked') exception.
 * 
 * @return The created {@link Marshaller}.
 */
@Bean
public Marshaller marshaller() {
    Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
    CustomValidationEventHandler eventHandler = new CustomValidationEventHandler();
    eventHandler.setFatalLinkedExceptions(this.marshallingErrorFatalExceptions);
    jaxb2Marshaller.setValidationEventHandler(eventHandler);
    Package apiResourcesRootPackage = ChannelResource.class.getPackage();
    jaxb2Marshaller.setPackagesToScan(new String[] { apiResourcesRootPackage.getName() });
    return jaxb2Marshaller;
}

From source file:br.msf.commons.util.IOUtils.java

protected static String getClasspathResourcePath(final Package pack, final String simpleName) {
    if (CharSequenceUtils.isBlankOrNull(simpleName)) {
        return null;
    }/*from w  ww.  j a  va 2s.com*/
    final StringBuilder builder = new StringBuilder("/");
    if (pack != null) {
        builder.append(pack.getName().replaceAll("\\.", "/")).append("/");
    }
    return builder.append(simpleName).toString();
}

From source file:net.sradonia.i18n.StringBundle.java

public StringBundle(Package pack, String baseName, Locale locale, ClassLoader loader) {
    this(pack.getName() + "." + baseName, locale, loader);
}

From source file:com.bahmanm.karun.PackageCollection.java

/**
 * Adds packages in local database to collection.
 * //from  w w  w  .ja  v a  2  s .c  o m
 * @param onlyMatches Search only for those packages already in collection
 */
private void addLocalPackages(final boolean onlyMatches) throws FileNotFoundException, IOException {
    traversPkgDir(new File(dbPathSystem + "/local/"), new PackageAction() {

        @Override
        public void action(Package pkg) {
            if (collection.containsKey(pkg.getName())) {
                Package p = collection.get(pkg.getName());
                p.setLocalVersion(pkg.getRepoVersion());
            } else {
                if (!onlyMatches) {
                    collection.put(pkg.getName(), pkg);
                }
            }
        }
    });
}

From source file:de.fischer.thotti.core.configuration.ConfigDenormalizer.java

private void createHDTests(ThottiAnnotationHolder<HadoopJobFlow> flowHolder, Configuration config,
        ConfigurationWriter writer) {/*from www. j  ava2s  .  c  o m*/

    writer.startFlow();
    writer.withFlowName(flowHolder.getAnnotation().id());

    // find all tests in the same package or subpackages
    Package pack = getPackageOfJobFlow(flowHolder);
    String packageName = pack.getName();

    Collection<ThottiAnnotationHolder<DistributedTestJob>> allDistributedTestJobs = config
            .getAllDistributedTestJobs();

    for (ThottiAnnotationHolder<DistributedTestJob> dtholder : allDistributedTestJobs) {
        Package packageOfDTJ = getPackageOfDTJ(dtholder);
        String clazz = getFQCNFromHolderOfDTJ(dtholder);

        String packageNameOfDTJ = packageOfDTJ.getName();

        if (packageNameOfDTJ.startsWith(packageName)) {
            writer.startTestStep().withTestStepJobClass(clazz).withTestStepID(dtholder.getAnnotation().id())
                    .withActionOnFailure(dtholder.getAnnotation().onFailure());

            for (String argument : dtholder.getAnnotation().jobArguments()) {
                writer.addTestStepArgument(argument);
            }

            writer.finishTestStep();
        }
    }

    writer.finishFlow();
}

From source file:com.tojc.ormlite.android.compiler.AbstractAnnotationProcessorTest.java

protected String toPath(Package packageName) {
    return toPath(packageName.getName());
}