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:com._4dconcept.springframework.data.marklogic.config.AbstractMarklogicConfiguration.java

/**
 * Return the base package to scan for mapped {@link Document}s. Will return the package name of the configuration
 * class' (the concrete class, not this one here) by default. So if you have a {@code com.acme.AppConfig} extending
 * {@link AbstractMarklogicConfiguration} the base package will be considered {@code com.acme} unless the method is
 * overriden to implement alternate behaviour.
 *
 * @return the base package to scan for mapped {@link Document} classes or {@literal null} to not enable scanning for
 * entities./*  w  w w. j  a  v a2s .  c  o m*/
 */
@Nullable
protected String getMappingBasePackage() {
    Package mappingBasePackage = getClass().getPackage();
    return mappingBasePackage == null ? null : mappingBasePackage.getName();
}

From source file:peapod.FramedGraph.java

public FramedGraph(Graph graph, Package pakkage) {
    this.graph = graph;
    this.registry.register(new Reflections(pakkage.getName() + ".").getTypesAnnotatedWith(Framer.class));
}

From source file:org.jasig.services.persondir.support.xml.CachingJaxbLoaderImpl.java

/**
 * @return The JAXB context to parse the XML resource with
 *//* ww w .ja v  a 2  s. c  o m*/
protected JAXBContext getJAXBContext() {
    final Package loadedPackage = this.loadedType.getPackage();
    final String filterDisplayPackage = loadedPackage.getName();
    try {
        return JAXBContext.newInstance(filterDisplayPackage);
    } catch (JAXBException e) {
        throw new RuntimeException("Failed to create " + JAXBContext.class + " to unmarshal " + this.loadedType,
                e);
    }
}

From source file:org.talend.dataprep.i18n.ActionsBundle.java

private ResourceBundle findBundle(Object action, Locale locale) {
    if (action == null) {
        return actionToResourceBundle.get(fallBackKey);
    }/*from  w  w w .  j  a va2  s  .  c  om*/
    if (actionToResourceBundle.containsKey(action.getClass())) {
        final ResourceBundle resourceBundle = actionToResourceBundle.get(action.getClass());
        LOGGER.debug("Cache hit for action '{}': '{}'", action, resourceBundle);
        return resourceBundle;
    }
    // Lookup for resource bundle in package hierarchy
    final Package actionPackage = action.getClass().getPackage();
    String currentPackageName = actionPackage.getName();
    ResourceBundle bundle = null;
    while (currentPackageName.contains(".")) {
        try {
            bundle = ResourceBundle.getBundle(currentPackageName + '.' + ACTIONS_MESSAGES, locale);
            break; // Found, exit lookup
        } catch (MissingResourceException e) {
            LOGGER.debug("No action resource bundle found for action '{}' at '{}'", action, currentPackageName,
                    e);
        }
        currentPackageName = StringUtils.substringBeforeLast(currentPackageName, ".");
    }
    if (bundle == null) {
        LOGGER.debug("Choose default action resource bundle for action '{}'", action);
        bundle = ResourceBundle.getBundle(BUNDLE_NAME, locale);
    }
    actionToResourceBundle.putIfAbsent(action.getClass(), bundle);
    return bundle;
}

From source file:springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.java

private Function<Package, String> toPackageName() {
    return new Function<Package, String>() {
        @Override//w w w .j  av a 2s  .  c  o  m
        public String apply(Package input) {
            return input.getName();
        }
    };
}

From source file:org.apereo.services.persondir.support.xml.CachingJaxbLoaderImpl.java

/**
 * @return The JAXB context to parse the XML resource with
 *//*from  w ww. ja v  a  2 s.co  m*/
protected JAXBContext getJAXBContext() {
    final Package loadedPackage = this.loadedType.getPackage();
    final String filterDisplayPackage = loadedPackage.getName();
    try {
        return JAXBContext.newInstance(filterDisplayPackage);
    } catch (final JAXBException e) {
        throw new RuntimeException("Failed to create " + JAXBContext.class + " to unmarshal " + this.loadedType,
                e);
    }
}

From source file:org.jadira.scanner.classpath.types.JPackage.java

protected JPackage(Package wrappedPackage, ClasspathResolver resolver) {
    super(wrappedPackage.getName(), resolver);
    this.wrappedPackage = wrappedPackage;
}

From source file:hcm.ssj.creator.dialogs.AddDialog.java

/**
 * @param clazzes Class[]//from   w  ww. j ava2 s .c o m
 */
public void setOption(ArrayList<Class> clazzes) {
    hashMap = new LinkedHashMap<>();
    //get each package once
    HashSet<Package> hashSet = new HashSet<>();
    for (Class clazz : clazzes) {
        hashSet.add(clazz.getPackage());
    }
    //only show last part of the package name
    String[] packages = new String[hashSet.size()];
    int count = 0;
    for (Package pack : hashSet) {
        String name = pack.getName();
        packages[count++] = name.substring(name.lastIndexOf(".") + 1);
    }
    //sort packages by name and add them to map
    Arrays.sort(packages);
    for (String name : packages) {
        hashMap.put(name, new ArrayList<Class>());
    }
    //sort classes by name
    Collections.sort(clazzes, new Comparator<Class>() {
        @Override
        public int compare(Class lhs, Class rhs) {
            return lhs.getSimpleName().compareTo(rhs.getSimpleName());
        }
    });
    //add every class to its corresponding package
    for (Class clazz : clazzes) {
        String name = clazz.getPackage().getName();
        hashMap.get(name.substring(name.lastIndexOf(".") + 1)).add(clazz);
    }
    //create internal variables to save the state of the list
    itemState = new boolean[hashMap.size()][];
    count = 0;
    allItems = 0;
    allItems += hashMap.size();
    for (Map.Entry<String, ArrayList<Class>> entry : hashMap.entrySet()) {
        itemState[count++] = new boolean[entry.getValue().size()];
        allItems += entry.getValue().size();
    }
}

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

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

From source file:org.echocat.jemoni.jmx.JmxRegistry.java

@Nonnull
public ObjectName getObjectNameFor(@Nonnull Class<?> type, @Nullable String instance,
        @Nullable String variant) {
    final StringBuilder sb = new StringBuilder();
    final Package aPackage = type.getPackage();
    final String packageName = aPackage != null ? aPackage.getName() : null;
    final String typeName = type.getName();
    if (!isEmpty(packageName)) {
        sb.append(packageName);/*from w ww  . j  a va2s .c o  m*/
        sb.append(!isEmpty(variant) ? ":type=" : ":name=");
        sb.append(typeName.substring(packageName.length() + 1));
    } else {
        sb.append("_");
        sb.append(!isEmpty(variant) ? ":type=" : ":name=");
        sb.append(typeName);
    }
    if (!isEmpty(instance)) {
        sb.append('.').append(normalize(instance));
    }
    if (!isEmpty(variant)) {
        sb.append(",name=").append(normalize(variant));
    }
    try {
        return new ObjectName(sb.toString());
    } catch (MalformedObjectNameException e) {
        throw new IllegalArgumentException(
                "Could not create a valid object name for " + typeName + " and variant '" + variant + "'.", e);
    }
}