List of usage examples for java.lang Class toString
public String toString()
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./* w w w .j a v a 2 s. c om*/ * @param oldOID object identifier of list type to be replaced * @param newOID object identifier of replacement list type */ public static void delete(Class[] peerClasses, String[] fields, Integer oldOID) { // Do this using reflection. Criteria selectCriteria = new Criteria(); for (int i = 0; i < peerClasses.length; ++i) { Class peerClass = peerClasses[i]; String field = fields[i]; selectCriteria.clear(); selectCriteria.add(field, oldOID, Criteria.EQUAL); try { Class partypes[] = new Class[1]; partypes[0] = Criteria.class; Method meth = peerClass.getMethod("doDelete", partypes); Object arglist[] = new Object[1]; arglist[0] = selectCriteria; meth.invoke(peerClass, arglist); } catch (Exception e) { LOGGER.error("Exception when trying to delete dependent data for oldOID " + oldOID + " class " + peerClass.toString() + " and field " + field + ": " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } }
From source file:org.jgentleframework.context.JGentle.java
/** * Adds a config class/* ww w. ja va2 s. c o m*/ * * @param interfaze * type (<code>interface</code>) of <code>config class</code>. * @param clazz * the <code>object class</code> of <code>config class</code> * need to be added. * @return returns the previous <code>object class</code> of * <code>config class</code> appropriate to <b><i>interfaze</i></b> * if it existed, if not, returns <b>null</b>. */ @SuppressWarnings("unchecked") public static <T> T addConfigClass(Class<T> interfaze, Class<? extends T> clazz) { Assertor.notNull(interfaze); Assertor.notNull(clazz); if (interfaze.equals(clazz)) { throw new JGentleRuntimeException("invalid arguments !"); } if (!interfaze.isInterface()) { throw new JGentleRuntimeException(interfaze.toString() + " must be a interface."); } return (T) JGentle.configObjClassList.put(interfaze, clazz); }
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./* w w w . 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, Integer oldOID) { // Do this using reflection. Criteria selectCriteria = new Criteria(); for (int i = 0; i < peerClasses.length; ++i) { Class peerClass = peerClasses[i]; String field = fields[i]; selectCriteria.clear(); selectCriteria.add(field, oldOID, Criteria.EQUAL); 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 " + "oldOID " + oldOID + " for class " + peerClass.toString() + " and field " + field + ": " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } return false; }
From source file:net.authorize.api.controller.test.ApiCoreTestBase.java
public static void showProperties(Object bean) { if (null == bean) { return;//from w ww . java 2s .c o m } try { BeanInfo info = Introspector.getBeanInfo(bean.getClass(), Object.class); PropertyDescriptor[] props = info.getPropertyDescriptors(); for (PropertyDescriptor pd : props) { String name = pd.getName(); Method getter = pd.getReadMethod(); Class<?> type = pd.getPropertyType(); if (null != getter && !"class".equals(name)) { Object value = getter.invoke(bean); logger.info(String.format("Type: '%s', Name:'%s', Value:'%s'", type, name, value)); processCollections(type, name, value); //process compositions of custom classes if (null != value && 0 <= type.toString().indexOf("net.authorize.")) { showProperties(value); } } } } catch (Exception e) { logger.error(String.format("Exception during navigating properties: Message: %s, StackTrace: %s", e.getMessage(), e.getStackTrace())); } }
From source file:org.smartfrog.test.SmartFrogTestBase.java
/** * Resolve an attribute and make an assertion about the return type * * @param prim app to resolve against * @param attribute attribute to resolve * @param expectedClass class that is required * * @return the object//from w w w.j a va 2 s. c o m * * @throws SmartFrogResolutionException resolution problems * @throws RemoteException network problems * @throws AssertionError if a condition is not met */ public static Object resolveAttributeWithTypeAssertion(Prim prim, String attribute, Class expectedClass) throws SmartFrogResolutionException, RemoteException { assertNotNull(expectedClass); Object value = resolveAttribute(prim, attribute); Class valueClass = value.getClass(); assertEquals("Expected " + describe(prim, attribute) + " to be of type " + expectedClass + " but instead it is an instance of class " + valueClass.toString() + " with value " + value.toString(), expectedClass, valueClass); return value; }
From source file:com.aurel.track.persist.ReflectionHelper.java
/** * This method replaces all occurrences of * oldOID with newOID going through all related * tables in the database./* w w w.j av a2s . c o m*/ * @param oldOID object identifier to be replaced * @param newOID object identifier of replacement */ public static void replace(Class[] peerClasses, String[] fields, Integer oldOID, Integer newOID) { Criteria selectCriteria = new Criteria(); Criteria updateCriteria = new Criteria(); for (int i = 0; i < peerClasses.length; ++i) { Class peerClass = peerClasses[i]; String field = fields[i]; selectCriteria.clear(); updateCriteria.clear(); selectCriteria.add(field, oldOID, Criteria.EQUAL); updateCriteria.add(field, newOID); try { Class partypes[] = new Class[2]; partypes[0] = Criteria.class; partypes[1] = Criteria.class; Method meth = peerClass.getMethod("doUpdate", partypes); Object arglist[] = new Object[2]; arglist[0] = selectCriteria; arglist[1] = updateCriteria; meth.invoke(peerClass, arglist); } catch (Exception e) { LOGGER.error("Exception when trying to replace " + "oldOID " + oldOID + " with " + "newOID " + newOID + " for class " + peerClass.toString() + " and field " + field + ": " + e.getMessage(), e); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } }
From source file:com.aurel.track.persist.ReflectionHelper.java
/** * This method sets to null all occurrences of oldOID * going through all related tables in the database. * @param oldOID object identifier to be replaced *///from w ww.ja v a 2 s . c o m public static void setToNull(Class[] peerClasses, String[] fields, Integer oldOID) { Criteria selectCriteria = new Criteria(); Criteria updateCriteria = new Criteria(); for (int i = 0; i < peerClasses.length; ++i) { Class peerClass = peerClasses[i]; String field = fields[i]; selectCriteria.clear(); updateCriteria.clear(); selectCriteria.add(field, oldOID, Criteria.EQUAL); updateCriteria.add(field, (Object) null, Criteria.ISNULL); try { Class partypes[] = new Class[2]; partypes[0] = Criteria.class; partypes[1] = Criteria.class; Method meth = peerClass.getMethod("doUpdate", partypes); Object arglist[] = new Object[2]; arglist[0] = selectCriteria; arglist[1] = updateCriteria; meth.invoke(peerClass, arglist); } catch (Exception e) { LOGGER.error("Exception when trying to set " + "oldOID " + oldOID + " to null " + " for class " + peerClass.toString() + " and field " + field + ": " + e.getMessage(), e); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } }
From source file:com.cloudera.crunch.impl.mr.exec.MRExecutor.java
public MRExecutor(Class<?> jarClass) { this.control = new JobControl(jarClass.toString()); }
From source file:org.springmodules.cache.interceptor.MetadataCacheAttributeSource.java
private String key(Method m, Class t) { return t.toString() + System.identityHashCode(m); }
From source file:org.globus.ftp.dc.AbstractDataChannel.java
public static void registerHandler(int transferMode, int transferType, int type, Class clazz) throws Exception { switch (type) { case SOURCE://from w w w .j ava 2 s .c om if (!DataChannelReader.class.isAssignableFrom(clazz)) { throw new Exception("Incorrect type"); } break; case SINK: if (!DataChannelWriter.class.isAssignableFrom(clazz)) { throw new Exception("Incorrect type"); } break; default: throw new IllegalArgumentException("Type not supported: " + type); } String id = getHandlerID(transferMode, transferType, type); if (dataHandlers == null) { dataHandlers = new HashMap(); } // Allow for overwrites /* if (dataHandlers.get(id) != null) { throw new Exception("Handler already registered."); } */ logger.debug("registering handler for class " + clazz.toString() + "; id = " + id); dataHandlers.put(id, clazz); }