List of usage examples for java.lang Class getName
public String getName()
From source file:Main.java
public static boolean isServiceRunning(Context context, Class serviceClass) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals(service.service.getClassName())) { return true; }//from w w w . j av a2 s .c o m } return false; }
From source file:Main.java
/** * Checks if is service running.//from w w w.j a v a 2 s . c om * * @param ctx the ctx * @param theService the the service * @return true, if is service running */ public static boolean isServiceRunning(Context ctx, Class theService) { ActivityManager manager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (theService.getName().equals(service.service.getClassName())) { return true; } } return false; }
From source file:com.netspective.axiom.TestUtils.java
static public DriverManagerConnectionProvider getConnProvider(Class connProviderId) { return getConnProvider(connProviderId.getName()); }
From source file:org.eel.kitchen.jsonschema.keyword.KeywordFactory.java
/** * Build an invalid validator in the event of instantiation failure * * @param e the exception raised by the instantiation attempt * @return a keyword validator which always fails *//*from w ww. j a v a 2s. c o m*/ private static KeywordValidator invalidValidator(final Class<? extends KeywordValidator> c, final Exception e) { final String className = c.getName(); return new KeywordValidator(className, NodeType.values()) { @Override protected void validate(final ValidationContext context, final ValidationReport report, final JsonNode instance) { final Message.Builder msg = Domain.VALIDATION.newMessage().setMessage("cannot build validator") .setKeyword(className).addInfo("exception", e.getClass().getName()) .addInfo("exceptionMessage", e.getMessage()).setFatal(true); report.addMessage(msg.build()); } @Override public String toString() { return className; } }; }
From source file:com.opensymphony.xwork2.util.ProxyUtil.java
/** * Check whether the specified class is a CGLIB-generated class. * @param clazz the class to check/*from w w w.ja v a 2 s . c om*/ */ private static boolean isCglibProxyClass(Class<?> clazz) { return (clazz != null && clazz.getName().contains("$$")); }
From source file:marshalsec.Jackson.java
private static String writeObject(Class<?> clazz, Map<String, String> values) { return writeObject(clazz.getName(), values); }
From source file:Main.java
public static boolean isMyServiceRunning(Context context, Class<?> serviceClass) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals(service.service.getClassName())) return true; }//w ww. j a v a2 s. c o m return false; }
From source file:Main.java
/** * Returns an index for accessing arrays in this class. * * @throws RuntimeException if a given type is not a primitive type. *///w ww .j av a 2 s . c o m public static final int typeIndex(Class type) { Class[] list = primitiveTypes; int n = list.length; for (int i = 0; i < n; i++) if (list[i] == type) return i; throw new RuntimeException("bad type:" + type.getName()); }
From source file:com.pmarlen.model.controller.EntityJPAToPlainPojoTransformer.java
public static void copyPlainValues(Entity entity, Object plain) { final Class entityClass; entityClass = entity.getClass();//from w w w. j ava 2 s .c om final String entityClassName = entityClass.getName(); Hashtable<String, Object> propertiesToCopy = new Hashtable<String, Object>(); Hashtable<String, Object> propertiesM2MToCopy = new Hashtable<String, Object>(); List<String> propertiesWithNULLValueToCopy = new ArrayList<String>(); List<String> propertiesKey = new ArrayList<String>(); try { final Field[] declaredFields = entityClass.getDeclaredFields(); for (Field f : declaredFields) { logger.trace("->create: \tcopy: " + entityClassName + "." + f.getName() + " accesible ? " + (f.isAccessible())); if (!f.isAccessible()) { if (f.isAnnotationPresent(javax.persistence.Id.class)) { propertiesKey.add(f.getName()); } if (f.isAnnotationPresent(javax.persistence.Id.class) && !f.isAnnotationPresent(javax.persistence.GeneratedValue.class) && !Modifier.isStatic(f.getModifiers())) { Object valueCopyed = PropertyUtils.getProperty(entity, f.getName()); if (valueCopyed != null) { propertiesToCopy.put(f.getName(), valueCopyed); } else { propertiesWithNULLValueToCopy.add(f.getName()); } logger.trace("->create:\t\t ID elegible 2 be copied, added to copy list: " + f.getName() + " = " + valueCopyed + ", is really null?" + (valueCopyed == null)); } else if (!f.isAnnotationPresent(javax.persistence.Id.class) && !f.isAnnotationPresent(javax.persistence.OneToMany.class) && !f.isAnnotationPresent(javax.persistence.ManyToMany.class) && !Modifier.isStatic(f.getModifiers())) { Object valueCopyed = PropertyUtils.getProperty(entity, f.getName()); if (valueCopyed != null) { propertiesToCopy.put(f.getName(), valueCopyed); } else { propertiesWithNULLValueToCopy.add(f.getName()); } logger.trace("->create:\t\t elegible 2 be copied, added to copy list: " + f.getName() + " = " + valueCopyed + ", is really null?" + (valueCopyed == null)); } else if (!f.isAnnotationPresent(javax.persistence.Id.class) && f.isAnnotationPresent(javax.persistence.ManyToMany.class)) { Object valueCopyed = PropertyUtils.getProperty(entity, f.getName()); if (valueCopyed != null) { propertiesM2MToCopy.put(f.getName(), valueCopyed); } else { propertiesWithNULLValueToCopy.add(f.getName()); } logger.trace("->create:\t\t M2M elegible 2 be copied, added to copy list: " + f.getName() + " = " + valueCopyed + ", is really null?" + (valueCopyed == null)); } } } logger.trace("->create:copy values ?"); for (String p2c : propertiesToCopy.keySet()) { Object valueCopyed = propertiesToCopy.get(p2c); logger.trace("->create:\t\t copy value with SpringUtils: " + p2c + " = " + valueCopyed + ", is null?" + (valueCopyed == null)); BeanUtils.copyProperty(plain, p2c, valueCopyed); } for (String p2c : propertiesWithNULLValueToCopy) { logger.trace("->create:\t\t copy null with SpringUtils"); BeanUtils.copyProperty(plain, p2c, null); } } catch (Exception e) { logger.error("..in copy", e); } }
From source file:ips1ap101.ejb.core.BeanLocator.java
public static synchronized Object getBean(Class<?> local) { Bitacora.trace(BeanLocator.class, "getBean", local); if (local == null) { return null; }// ww w. j a va2 s. co m Object bean; String name = local.getName(); if (cache.containsKey(name)) { bean = cache.get(name); } else { bean = lookup(local); cache.put(name, bean); } return bean; }