List of usage examples for java.lang Class toString
public String toString()
From source file:com.thoughtworks.go.server.service.MagicalMaterialAndMaterialConfigConversionTest.java
private boolean isNotAConcrete_NonTest_MaterialConfigImplementation(Class aClass) { return Pattern.matches(".*(Test|Dummy).*", aClass.toString()) || Modifier.isAbstract(aClass.getModifiers()); }
From source file:nl.knaw.dans.common.lang.search.bean.GenericSearchBeanConverter.java
@SuppressWarnings("unchecked") public IndexDocument toIndexDocument(Object searchBean) throws SearchBeanConverterException, SearchBeanException { Class sbClass = searchBean.getClass(); if (!sbClass.isAnnotationPresent(SearchBean.class)) throw new ObjectIsNotASearchBeanException(sbClass.toString()); SimpleIndexDocument indexDocument = new SimpleIndexDocument(SearchBeanUtil.getDefaultIndex(sbClass)); for (java.lang.reflect.Field classField : ClassUtil.getAllFields(sbClass).values()) { if (classField.isAnnotationPresent(SearchField.class)) { SearchField sbField = classField.getAnnotation(SearchField.class); String fieldName = sbField.name(); boolean isRequired = sbField.required(); Class<? extends SearchFieldConverter<?>> converter = sbField.converter(); String propName = classField.getName(); String getMethodName = "get" + StringUtils.capitalize(propName); addFieldToDocument(searchBean, indexDocument, getMethodName, fieldName, isRequired, converter); if (classField.isAnnotationPresent(CopyField.class)) { for (Annotation annot : classField.getAnnotations()) { if (annot instanceof CopyField) { CopyField sbCopyField = (CopyField) annot; fieldName = sbCopyField.name(); isRequired = sbCopyField.required(); getMethodName = "get" + StringUtils.capitalize(propName) + StringUtils.capitalize(sbCopyField.getterPostfix()); converter = sbCopyField.converter(); addFieldToDocument(searchBean, indexDocument, getMethodName, fieldName, isRequired, converter); }/*from ww w .j a va 2 s. com*/ } } } } if (indexDocument.getIndex() != null) { if (indexDocument.getFields().getByFieldName(indexDocument.getIndex().getPrimaryKey()) == null) throw new PrimaryKeyMissingException("Primary key not set to search bean object."); } return indexDocument; }
From source file:com.jaspersoft.jasperserver.api.metadata.user.service.impl.ProfileAttributeServiceImpl.java
private Class<?> getObjectClass(Class<?> classObj) { if (classObj.toString().indexOf("_$$_") > 0) return classObj.getSuperclass(); return classObj; }
From source file:com.aurel.track.persist.ReflectionHelper.java
/** * This method replaces all occurrences of <code>ProjectType</code> * value oldOID with project type value newOID going through all related * tables in the database.//from w ww.j a va 2 s .c o m * @param oldOID object identifier of list type to be replaced * @param newOID object identifier of replacement list type */ public static boolean hasDependentData(Class[] peerClasses, String[] fields, List<Integer> oldOIDs) { // Do this using reflection. if (oldOIDs == null || oldOIDs.isEmpty()) { return false; } Criteria selectCriteria; for (int i = 0; i < peerClasses.length; ++i) { Class peerClass = peerClasses[i]; String field = fields[i]; List<int[]> chunkList = GeneralUtils.getListOfChunks(oldOIDs); Iterator<int[]> iterator = chunkList.iterator(); while (iterator.hasNext()) { int[] oIDsChunk = iterator.next(); selectCriteria = new Criteria(); selectCriteria.addIn(field, oIDsChunk); try { Class partypes[] = new Class[1]; partypes[0] = Criteria.class; Method meth = peerClass.getMethod("doSelect", partypes); Object arglist[] = new Object[1]; arglist[0] = selectCriteria; List results = (List) meth.invoke(peerClass, arglist); if (results != null && !results.isEmpty()) { return true; } } catch (Exception e) { LOGGER.error("Exception when trying to find dependent data for " + "oldOIDs " + oldOIDs.size() + " for class " + peerClass.toString() + " and field " + field + ": " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } return false; }
From source file:org.riksa.a3.fragment.CreateKeyPairFragment.java
private <T extends View> T findView(Class<? extends View> clazz, int id) throws ViewNotFoundException { View view = getActivity().findViewById(id); if (view != null && view.getClass().isAssignableFrom(clazz)) { return (T) view; }/*w ww . ja va2s. c om*/ log.error("Cannot find view of {} with id {}", clazz.toString(), id); throw new ViewNotFoundException(); }
From source file:org.gradle.internal.logging.text.TreeFormatter.java
/** * Appends a type name to the current node. *//*from w ww.ja va2 s.c om*/ public void appendType(Class<?> type) { // Implementation is currently dumb, can be made smarter append(type.toString()); }
From source file:org.seasar.mayaa.impl.cycle.script.rhino.RhinoUtil.java
/** * getter??????/*from w w w .ja va 2 s . co m*/ * JavaBean???????? * * @param bean ? * @param propertyName ?? * @return ?????????null * @throws NoSuchMethodException getter?????? */ protected static Object getWithGetterMethod(Object bean, String propertyName) throws NoSuchMethodException { Class beanClass = bean.getClass(); String baseName = capitalizePropertyName(propertyName); Method getter = null; try { getter = beanClass.getMethod("get" + baseName, VOID_ARGS_CLASS); } catch (NoSuchMethodException ignore) { // try boolean } if (getter == null) { try { // TODO Method Method booleanGetter = beanClass.getMethod("is" + baseName, VOID_ARGS_CLASS); if (booleanGetter != null) { Class returnType = booleanGetter.getReturnType(); if (returnType.equals(Boolean.class) || returnType.equals(Boolean.TYPE)) { getter = booleanGetter; } } } catch (NoSuchMethodException ignore) { // throw new exception for "getXxx" } } if (getter == null || Modifier.isPublic(getter.getModifiers()) == false) { throw new NoSuchMethodException(beanClass.toString() + ".get" + baseName + "()"); } if (getter.isAccessible() == false) { getter.setAccessible(true); } try { return getter.invoke(bean, null); } catch (IllegalAccessException e) { LOG.debug(StringUtil.getMessage(RhinoUtil.class, 1, propertyName, beanClass.getName())); } catch (InvocationTargetException e) { LOG.debug(StringUtil.getMessage(RhinoUtil.class, 1, propertyName, beanClass.getName())); } return null; }
From source file:org.makersoft.mvc.builder.PackageBasedUrlPathBuilder.java
/** * Converts the class name into an action name using the ActionNameBuilder. * /*from www. jav a 2s.c om*/ * @param actionClass * The action class. * @return The action name. */ protected String determineControllerName(Class<?> controllerClass) { String controllerName = builder.build(controllerClass.getSimpleName()); if (LOG.isTraceEnabled()) { LOG.trace("Got actionName for class [#0] of [#1]", controllerClass.toString(), controllerName); } return controllerName; }
From source file:net.kamhon.ieagle.orm.hibernate.HAnnotationSessionFactoryBean.java
public void setAnnotatationOrHbmXmlPackagePattern(String[] patterns) { List<Class<?>> annotationClasses = new ArrayList<Class<?>>(); List<String> hbmXmlFiles = new ArrayList<String>(); try {/*from w ww. ja va 2 s .c o m*/ for (String pattern : patterns) { Set<String> filePaths = ReflectionUtil.findFileNames(pattern.substring(0, pattern.indexOf("\\")), true, pattern, ".class", ".hbm.xml"); for (String filePath : filePaths) { if (filePath.endsWith(".class")) { try { Class<?> clazz = Class.forName(filePath.substring(0, filePath.indexOf(".class"))); if (clazz.isAnnotationPresent(Entity.class)) { annotationClasses.add(clazz); log.info("<mapping class=\"" + clazz.toString() + "\" />"); } } catch (Exception e) { log.debug("Class can't be loaded for hibernate mapping = " + filePath); } } else if (filePath.endsWith(".hbm.xml")) { filePath = filePath.replaceAll("\\.", "\\\\"); filePath = filePath.replaceAll("\\\\hbm\\\\xml", ".hbm.xml"); hbmXmlFiles.add(filePath); log.info("Hibernate hbm.xml mapping file: " + filePath); } } } } catch (Exception e) { e.printStackTrace(); } log.info((annotationClasses.size() + hbmXmlFiles.size()) + " hibernate mapping file."); setAnnotatedClasses(annotationClasses.toArray(new Class[] {})); setMappingResources(hbmXmlFiles.toArray(new String[0])); }
From source file:org.gradle.internal.logging.text.TreeFormatter.java
/** * Starts a new node with the given type name. *///w ww. ja va2s. c om public void node(Class<?> type) { // Implementation is currently dumb, can be made smarter node(StringUtils.capitalize(type.toString())); }