List of usage examples for java.lang Class getName
public String getName()
From source file:Main.java
public static String getClassName(Class<?> klass) { if (klass == null) { return null; }/*from www. j a va 2s . co m*/ String className = klass.getName(); if (className == null) { return null; } final int splitIndex = className.lastIndexOf('.'); return className.substring(splitIndex + 1); }
From source file:Main.java
public static String getPackageName(Class<?> klass) { if (klass == null) { return null; }/*from www . j av a2s . c o m*/ String className = klass.getName(); if (className == null) { return null; } final int splitIndex = className.lastIndexOf('.'); return className.substring(0, splitIndex); }
From source file:org.makersoft.activesql.persistence.MyBatisContext.java
public static <T> T find(Class<T> clazz, Long id) { return sqlSession.<T>selectOne(clazz.getName() + ".get", id); }
From source file:Main.java
public static String getClassNameInStr(Object obj) { Class<?> enclosingClass = obj.getClass().getEnclosingClass(); if (enclosingClass != null) { return enclosingClass.getName(); } else {/*from www .j a v a 2s .c o m*/ return obj.getClass().getName(); } }
From source file:Main.java
/** * Convenience method for retrieving a subset of the UIDefaults pertaining * to a particular class./*from w ww .j a va 2 s . c o m*/ * * @param clazz the class of interest * @return the UIDefaults of the class */ public static UIDefaults getUIDefaultsOfClass(Class<?> clazz) { String name = clazz.getName(); name = name.substring(name.lastIndexOf(".") + 2); return getUIDefaultsOfClass(name); }
From source file:com.alibaba.druid.support.logging.LogFactory.java
public static Log getLog(Class clazz) { return getLog(clazz.getName()); }
From source file:Main.java
private static String getPrettyClassName(Class<?> clazz) { String name = clazz.getCanonicalName(); if (name == null) { name = clazz.getName(); }//from w w w . j av a2s .co m return name; }
From source file:Main.java
/** * /*from w w w.j av a2s.c o m*/ * @Title: convertValType * @Description: TODO * @param value * @param fieldTypeClass * @return * @return: Object */ public static Object convertValType(Object value, Class<?> fieldTypeClass) { Object retVal = null; if (Long.class.getName().equals(fieldTypeClass.getName()) || long.class.getName().equals(fieldTypeClass.getName())) { retVal = Long.parseLong(value.toString()); } else if (Integer.class.getName().equals(fieldTypeClass.getName()) || int.class.getName().equals(fieldTypeClass.getName())) { retVal = Integer.parseInt(value.toString()); } else if (Float.class.getName().equals(fieldTypeClass.getName()) || float.class.getName().equals(fieldTypeClass.getName())) { retVal = Float.parseFloat(value.toString()); } else if (Double.class.getName().equals(fieldTypeClass.getName()) || double.class.getName().equals(fieldTypeClass.getName())) { retVal = Double.parseDouble(value.toString()); } else { retVal = value; } return retVal; }
From source file:Main.java
/** * Enable/Disable Broadcast Receiver//from w ww . j a va2 s . co m * * @param context * the context * @param brClass * the br class * @param enabled * the enabled */ public static void setStateOfReceiver(Context context, Class<?> brClass, boolean enabled) { ComponentName receiverName = new ComponentName(context, brClass.getName()); PackageManager pm = context.getPackageManager(); int newstate; if (enabled) { newstate = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; } else { newstate = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; } pm.setComponentEnabledSetting(receiverName, newstate, PackageManager.DONT_KILL_APP); }
From source file:Main.java
/** * Get the short name of the given class * // w ww.j a v a 2s . co m * @param clazz : Class to return the short name for * @return : short name of clazz */ public static String getShortName(Class<?> clazz) { if (clazz == null) { return "null"; } else { String name = clazz.getName(); if (name.lastIndexOf('.') > 0) { name = name.substring(name.lastIndexOf('.') + 1); } return name; } }