Example usage for org.springframework.util ClassUtils getShortName

List of usage examples for org.springframework.util ClassUtils getShortName

Introduction

In this page you can find the example usage for org.springframework.util ClassUtils getShortName.

Prototype

public static String getShortName(Class<?> clazz) 

Source Link

Document

Get the class name without the qualified package name.

Usage

From source file:controllers.AbstractController.java

@ExceptionHandler(Throwable.class)
public ModelAndView panic(Throwable oops) {
    ModelAndView result;//from  w  w w.ja v  a2s  .c o  m

    result = new ModelAndView("misc/panic");
    result.addObject("name", ClassUtils.getShortName(oops.getClass()));
    result.addObject("exception", oops.getMessage());
    result.addObject("stackTrace", ExceptionUtils.getStackTrace(oops));

    return result;
}

From source file:org.lightadmin.core.util.DynamicRepositoryBeanNameGenerator.java

public String generateBeanNameDecapitalized(Class<?> clazz) {
    return decapitalize(ClassUtils.getShortName(clazz));
}

From source file:org.lightadmin.core.util.DynamicRepositoryBeanNameGenerator.java

public String generateBeanName(Class<?> domainType, Class<?> repositoryInterface) {
    String repositoryInterfaceClassName = ClassUtils.getShortName(repositoryInterface);
    String domainTypeClassName = ClassUtils.getShortName(domainType);

    return domainTypeClassName + repositoryInterfaceClassName;
}

From source file:es.us.isa.ideas.app.controllers.AbstractController.java

@ExceptionHandler(Throwable.class)
public ModelAndView panic(Throwable oops) {
    Assert.notNull(oops);/*from   w  w w  . j av  a 2s .  c  o  m*/

    ModelAndView result;

    result = new ModelAndView("misc/panic");
    result.addObject("name", ClassUtils.getShortName(oops.getClass()));
    result.addObject("message", oops.getMessage());
    result.addObject("message_type", "message.type.error");
    result.addObject("exception", oops);

    return result;
}

From source file:biz.deinum.multitenant.batch.item.excel.jxl.JxlItemReader.java

public JxlItemReader() {
    super();
    this.setName(ClassUtils.getShortName(JxlItemReader.class));
}

From source file:org.synyx.hades.dao.config.DaoContext.java

/**
 * Creates a {@link DaoContext} from the given DAO interface name. Derives
 * DAO id, as well as the package name to use from the given interface.
 * //w  ww .j  a v  a 2 s .  co m
 * @param interfaceName
 * @param parent
 * @return
 */
public static DaoContext fromInterfaceName(String interfaceName, DaoConfigContext parent) {

    String shortName = ClassUtils.getShortName(interfaceName);

    String id = StringUtils.uncapitalize(shortName);

    final String packageName = interfaceName.substring(0, interfaceName.lastIndexOf(shortName) - 1);

    return new DaoContext(id, parent) {

        /*
         * (non-Javadoc)
         * 
         * @see org.synyx.hades.dao.config.DaoContext#getDaoPackageName()
         */
        @Override
        protected String getDaoBasePackageName() {

            return packageName;
        }
    };
}

From source file:uk.ac.ebi.eva.pipeline.io.readers.MongoDbCursorItemReader.java

public MongoDbCursorItemReader() {
    super();
    setName(ClassUtils.getShortName(MongoDbCursorItemReader.class));
}

From source file:org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.java

public static Map<String, Object> getElasticMapping(SearchableClassMapping scm) {
    Map<String, Object> elasticTypeMappingProperties = new LinkedHashMap<String, Object>();

    if (!scm.isAll()) {
        // "_all" : {"enabled" : true}
        elasticTypeMappingProperties.put("_all", Collections.singletonMap("enabled", false));
    }//  w w  w . jav  a2 s . c o  m

    // Map each domain properties in supported format, or object for complex type
    for (SearchableClassPropertyMapping scpm : scm.getPropertiesMapping()) {
        // Does it have custom mapping?
        String propType = scpm.getGrailsProperty().getTypePropertyName();
        Map<String, Object> propOptions = new LinkedHashMap<String, Object>();
        // Add the custom mapping (searchable static property in domain model)
        propOptions.putAll(scpm.getAttributes());
        if (!(SUPPORTED_FORMAT.contains(scpm.getGrailsProperty().getTypePropertyName()))) {
            // Handle embedded persistent collections, ie List<String> listOfThings
            if (scpm.getGrailsProperty().isBasicCollectionType()) {
                String basicType = ClassUtils.getShortName(scpm.getGrailsProperty().getReferencedPropertyType())
                        .toLowerCase(Locale.ENGLISH);
                if (SUPPORTED_FORMAT.contains(basicType)) {
                    propType = basicType;
                }
                // Handle arrays
            } else if (scpm.getGrailsProperty().getReferencedPropertyType().isArray()) {
                String basicType = ClassUtils
                        .getShortName(scpm.getGrailsProperty().getReferencedPropertyType().getComponentType())
                        .toLowerCase(Locale.ENGLISH);
                if (SUPPORTED_FORMAT.contains(basicType)) {
                    propType = basicType;
                }
            } else if (isDateType(scpm.getGrailsProperty().getReferencedPropertyType())) {
                propType = "date";
            } else if (GrailsClassUtils.isJdk5Enum(scpm.getGrailsProperty().getReferencedPropertyType())) {
                propType = "string";
            } else if (scpm.getConverter() != null) {
                // Use 'string' type for properties with custom converter.
                // Arrays are automatically resolved by ElasticSearch, so no worries.
                propType = "string";
            } else {
                propType = "object";
            }

            if (scpm.getReference() != null) {
                propType = "object"; // fixme: think about composite ids.
            } else if (scpm.isComponent()) {
                // Proceed with nested mapping.
                // todo limit depth to avoid endless recursion?
                propType = "object";
                //noinspection unchecked
                propOptions.putAll((Map<String, Object>) (getElasticMapping(scpm.getComponentPropertyMapping())
                        .values().iterator().next()));

            }

            // Once it is an object, we need to add id & class mappings, otherwise
            // ES will fail with NullPointer.
            if (scpm.isComponent() || scpm.getReference() != null) {
                @SuppressWarnings({ "unchecked" })
                Map<String, Object> props = (Map<String, Object>) propOptions.get("properties");
                if (props == null) {
                    props = new LinkedHashMap<String, Object>();
                    propOptions.put("properties", props);
                }
                props.put("id", defaultDescriptor("long", "not_analyzed", true));
                props.put("class", defaultDescriptor("string", "no", true));
                props.put("ref", defaultDescriptor("string", "no", true));
            }
        }
        propOptions.put("type", propType);
        // See http://www.elasticsearch.com/docs/elasticsearch/mapping/all_field/
        if (!propType.equals("object") && scm.isAll()) {
            // does it make sense to include objects into _all?
            if (scpm.shouldExcludeFromAll()) {
                propOptions.put("include_in_all", false);
            } else {
                propOptions.put("include_in_all", true);
            }
        }
        // todo only enable this through configuration...
        if (propType.equals("string") && scpm.isAnalyzed()) {
            propOptions.put("term_vector", "with_positions_offsets");
        }
        elasticTypeMappingProperties.put(scpm.getPropertyName(), propOptions);
    }

    Map<String, Object> mapping = new LinkedHashMap<String, Object>();
    mapping.put(scm.getElasticTypeName(), Collections.singletonMap("properties", elasticTypeMappingProperties));

    return mapping;
}

From source file:org.eclipse.virgo.ide.runtime.internal.core.command.AbstractJmxServerDeployerCommand.java

/**
 * {@inheritDoc}//from w ww  . j  a  va 2  s . c  om
 */
@Override
public String toString() {
    StringBuilder builder = new StringBuilder("[");
    builder.append(ClassUtils.getShortName(getClass())).append(" -> ").append(getMBeanName()).append(".")
            .append(getOperationName()).append("(").append(Arrays.deepToString(getOperationArguments()))
            .append(")").append("]");
    return builder.toString();
}

From source file:org.jasig.ssp.util.importer.job.csv.RawItemCsvWriter.java

public RawItemCsvWriter(Resource writeDirectory) throws Exception {
    this.setExecutionContextName(ClassUtils.getShortName(RawItemCsvWriter.class));
    this.writeDirectory = writeDirectory;
    createDirectory();/*from w w  w.  j a v a 2s  .c o  m*/
}