List of usage examples for org.springframework.util StringUtils unqualify
public static String unqualify(String qualifiedName)
From source file:com.phoenixnap.oss.ramlapisync.generation.rules.basic.ClassFieldDeclarationRule.java
public ClassFieldDeclarationRule(String restTemplateFieldName, Class<?> fieldClazz) { if (fieldClazz != null) { this.fieldClazz = fieldClazz; } else {/*ww w.j a va 2s . co m*/ throw new IllegalStateException("Class not specified"); } if (StringUtils.hasText(restTemplateFieldName)) { this.fieldName = restTemplateFieldName; } else { this.fieldName = StringUtils.unqualify(fieldClazz.getSimpleName()); } }
From source file:fr.xebia.management.statistics.ProfileAspect.java
/** * <p>// w ww . ja va2 s . c o m * Formats the given <code>fullyQualifiedName</code> according to the given * <code>classNameStyle</code>. * </p> * <p> * Samples with <code>java.lang.String</code>: * <ul> * <li>{@link ClassNameStyle#FULLY_QUALIFIED_NAME} : * <code>java.lang.String</code></li> * <li>{@link ClassNameStyle#COMPACT_FULLY_QUALIFIED_NAME} : * <code>j.l.String</code></li> * <li>{@link ClassNameStyle#SHORT_NAME} : <code>String</code></li> * </ul> * </p> */ protected static String getFullyQualifiedMethodName(String fullyQualifiedClassName, String methodName, ClassNameStyle classNameStyle) { StringBuilder fullyQualifiedMethodName = new StringBuilder( fullyQualifiedClassName.length() + methodName.length() + 1); switch (classNameStyle) { case FULLY_QUALIFIED_NAME: fullyQualifiedMethodName.append(fullyQualifiedClassName); break; case COMPACT_FULLY_QUALIFIED_NAME: String[] splittedFullyQualifiedName = StringUtils.delimitedListToStringArray(fullyQualifiedClassName, "."); for (int i = 0; i < splittedFullyQualifiedName.length - 1; i++) { fullyQualifiedMethodName.append(splittedFullyQualifiedName[i].charAt(0)).append("."); } fullyQualifiedMethodName.append(splittedFullyQualifiedName[splittedFullyQualifiedName.length - 1]); break; case SHORT_NAME: fullyQualifiedMethodName.append(StringUtils.unqualify(fullyQualifiedClassName)); break; default: // should not occur fullyQualifiedMethodName.append(fullyQualifiedClassName); break; } fullyQualifiedMethodName.append(".").append(methodName); return fullyQualifiedMethodName.toString(); }
From source file:org.shredzone.commons.taglib.processor.TaglibProcessor.java
/** * Processes a {@link Tag} annotation.//from w ww.ja v a 2 s . c o m * * @param element * Program element with that tag */ private void processTag(Element element) { Tag tagAnno = element.getAnnotation(Tag.class); String className = element.toString(); String tagName = computeTagName(tagAnno.name(), className); // Try to evaluate the class name of the tag type String tagTypeClass = null; try { Class<? extends JspTag> tagType = tagAnno.type(); tagTypeClass = tagType.getName(); } catch (MirroredTypeException ex) { // This is a hack, see http://forums.sun.com/thread.jspa?threadID=791053 tagTypeClass = ex.getTypeMirror().toString(); } if (!PROXY_MAP.containsKey(tagTypeClass)) { throw new ProcessorException("No proxy for tag type " + tagTypeClass); } TagBean tag = new TagBean(tagName, className, tagAnno.bodycontent(), tagTypeClass); tag.setProxyClassName(className + "Proxy"); if (StringUtils.hasText(tagAnno.bean())) { tag.setBeanName(tagAnno.bean()); } else { tag.setBeanName(StringUtils.uncapitalize(StringUtils.unqualify(className))); } tag.setTryCatchFinally(tagAnno.tryCatchFinally()); taglib.addTag(tag); }
From source file:org.shredzone.commons.taglib.processor.TaglibProcessor.java
/** * Computes the name of a tag. If there was a name given in the annotation, it will be * used. Otherwise, a name is derived from the class name of the tag class, with a * "Tag" suffix removed./*from w ww.ja v a2s .com*/ * * @param annotation * Tag name, as given in the annotation * @param className * Name of the tag class * @return Name of the tag */ private String computeTagName(String annotation, String className) { String result = annotation; if (!StringUtils.hasText(result)) { result = StringUtils.unqualify(className); if (result.endsWith("Tag")) { result = result.substring(0, result.length() - 3); } result = StringUtils.uncapitalize(result); } return result; }
From source file:org.shredzone.commons.taglib.processor.TaglibProcessor.java
/** * Generates a proxy class that connects to Spring and allows all Spring features like * dependency injection in the implementing tag class. * * @param tag// ww w .ja v a 2 s.c o m * {@link TagBean} that describes the tag. * @throws IOException * when the generated Java code could not be saved. */ private void generateProxyClass(TagBean tag) throws IOException { String beanFactoryReference = tag.getBeanFactoryReference(); if (beanFactoryReference == null) { beanFactoryReference = taglib.getBeanFactoryReference(); } JavaFileObject src = processingEnv.getFiler().createSourceFile(tag.getProxyClassName()); String packageName = null; int packPos = tag.getClassName().lastIndexOf('.'); if (packPos >= 0) { packageName = tag.getClassName().substring(0, packPos); } String proxyClass = PROXY_MAP.get(tag.getType()); try (PrintWriter out = new PrintWriter(src.openWriter())) { if (packageName != null) { out.printf("package %s;\n", packageName).println(); } out.print("@javax.annotation.Generated(\""); out.print(TaglibProcessor.class.getName()); out.println("\")"); out.printf("public class %s extends %s<%s> %s {", StringUtils.unqualify(tag.getProxyClassName()), proxyClass, tag.getClassName(), (tag.isTryCatchFinally() ? "implements javax.servlet.jsp.tagext.TryCatchFinally" : "")) .println(); if (beanFactoryReference != null) { out.println( " protected org.springframework.beans.factory.BeanFactory getBeanFactory(javax.servlet.jsp.JspContext jspContext) {"); out.printf(" java.lang.Object beanFactory = jspContext.findAttribute(\"%s\");", beanFactoryReference).println(); out.println(" if (beanFactory == null) {"); out.printf(" throw new java.lang.NullPointerException(\"attribute '%s' not set\");", beanFactoryReference).println(); out.println(" }"); out.println(" return (org.springframework.beans.factory.BeanFactory) beanFactory;"); out.println(" }"); } out.println(" protected java.lang.String getBeanName() {"); out.printf(" return \"%s\";", tag.getBeanName()).println(); out.println(" }"); for (AttributeBean attr : new TreeSet<AttributeBean>(tag.getAttributes())) { out.printf(" public void set%s(%s _%s) {", StringUtils.capitalize(attr.getName()), attr.getType(), attr.getName()).println(); out.printf(" getTargetBean().set%s(_%s);", StringUtils.capitalize(attr.getName()), attr.getName()).println(); out.println(" }"); } out.println("}"); } }
From source file:org.finra.dm.dao.impl.BaseJpaDaoImpl.java
public <T> List<T> findAll(Class<T> entityClass) { Validate.notNull(entityClass);//from w w w . j a va 2 s. com return query("select type from " + StringUtils.unqualify(entityClass.getName()) + " type"); }
From source file:org.finra.dm.dao.impl.BaseJpaDaoImpl.java
@Override public <T> List<T> findByNamedProperties(Class<T> entityClass, Map<String, ?> params) { Validate.notNull(entityClass);//from w w w . j av a2 s. c o m Validate.notEmpty(params); StringBuilder queryStringBuilder = new StringBuilder( "select type from " + StringUtils.unqualify(entityClass.getName()) + " type where "); Iterator<String> iterator = params.keySet().iterator(); int index = 0; while (iterator.hasNext()) { String propertyName = iterator.next(); if (index > 0) { queryStringBuilder.append(" and "); } queryStringBuilder.append("(type.").append(propertyName).append(" = :").append(propertyName) .append(')'); index++; } return queryByNamedParams(queryStringBuilder.toString(), params); }
From source file:org.finra.dm.dao.impl.BaseJpaDaoImpl.java
@Override public <T> T findUniqueByNamedProperties(Class<T> entityClass, Map<String, ?> params) { Validate.notNull(entityClass);// w ww.j av a 2 s .c o m Validate.notEmpty(params); List<T> resultList = findByNamedProperties(entityClass, params); Validate.isTrue(resultList.isEmpty() || resultList.size() == 1, "Found more than one persistent instance of type " + StringUtils.unqualify(entityClass.getName() + " with parameters " + params.toString())); return resultList.size() == 1 ? resultList.get(0) : null; }
From source file:org.finra.herd.dao.impl.BaseJpaDaoImpl.java
@Override public <T> List<T> findAll(Class<T> entityClass) { Validate.notNull(entityClass);// w ww . j a v a2 s. c o m return query("select type from " + StringUtils.unqualify(entityClass.getName()) + " type"); }
From source file:org.finra.herd.dao.impl.BaseJpaDaoImpl.java
@Override public <T> T findUniqueByNamedProperties(Class<T> entityClass, Map<String, ?> params) { Validate.notNull(entityClass);/*from w ww. ja v a 2 s .c om*/ Validate.notEmpty(params); List<T> resultList = findByNamedProperties(entityClass, params); Validate.isTrue(resultList.size() < 2, "Found more than one persistent instance of type " + StringUtils.unqualify(entityClass.getName() + " with parameters " + params.toString())); return resultList.size() == 1 ? resultList.get(0) : null; }