/** * Returns the alias for the described type, or <code>null</code> if none * has been set. * * @see #setTypeAlias */ public String getTypeAlias() { if (_alias == null) _alias = ClassUtil.getClassName(_type); return _alias; }
/** * Return Java file to write to. */ public File getFile() { String packageName = ClassUtil.getPackageName(_type); String fileName = ClassUtil.getClassName(_type) + ".java"; File dir = Files.getPackageFile(_dir, packageName, true); return new File(dir, fileName); }
/** * Return the class for the given string, correctly handling * primitive types. If the given class loader is null, the context * loader of the current thread will be used. * * @throws RuntimeException on load error * @author Abe White, taken from the Serp project */ public static Class toClass(String str, ClassLoader loader) { return toClass(str, false, loader); }
/** * Return only the package, or empty string if none. */ public static String getPackageName(Class cls) { return (cls == null) ? null : getPackageName(cls.getName()); }
/** * Return only the package, or empty string if none. */ public static String getPackageName(String fullName) { if (fullName == null) { return null; } if (fullName.isEmpty()) { return fullName; } int dims = getArrayDimensions(fullName); if (dims > 0) { if (fullName.length() == dims + 1) { // don't care, it's a primitive return ""; } else { fullName = fullName.substring(dims + 1); } } int lastDot = fullName.lastIndexOf('.'); return lastDot > -1 ? fullName.substring(0, lastDot) : ""; } }
/** * Return only the package, or empty string if none. */ public static String getPackageName(Class cls) { return (cls == null) ? null : getPackageName(cls.getName()); }
/** * Return only the package, or empty string if none. */ public static String getPackageName(String fullName) { if (fullName == null) { return null; } if (fullName.isEmpty()) { return fullName; } int dims = getArrayDimensions(fullName); if (dims > 0) { if (fullName.length() == dims + 1) { // don't care, it's a primitive return ""; } else { fullName = fullName.substring(dims + 1); } } int lastDot = fullName.lastIndexOf('.'); return lastDot > -1 ? fullName.substring(0, lastDot) : ""; } }
/** * Returns the alias for the described type, or <code>null</code> if none * has been set. * * @see #setTypeAlias */ public String getTypeAlias() { if (_alias == null) _alias = ClassUtil.getClassName(_type); return _alias; }
/** * Return Java file to write to. */ public File getFile() { String packageName = ClassUtil.getPackageName(_type); String fileName = ClassUtil.getClassName(_type) + ".java"; File dir = Files.getPackageFile(_dir, packageName, true); return new File(dir, fileName); }
/** * Whether or not <code>className</code> is the name for a * dynamically-created persistence-capable subclass. * * @since 1.1.0 */ public static boolean isPCSubclassName(String className) { return className.startsWith(ClassUtil.getPackageName(PCEnhancer.class)) && className.endsWith("$pcsubclass"); }
/** * Return the class for the given string, correctly handling * primitive types. If the given class loader is null, the context * loader of the current thread will be used. * * @throws RuntimeException on load error * @author Abe White, taken from the Serp project */ public static Class toClass(String str, ClassLoader loader) { return toClass(str, false, loader); }
int dims = getArrayDimensions(fullName); if (dims > 0) { if (fullName.length() == dims + 1) {
/** * Return only the class name, without package. */ public static String getClassName(Class cls) { if (cls == null) { return null; } return getClassName(cls.getName()); }
/** * Return the file that this tool should output to. */ private File getFile() { if (_meta == null) return null; String packageName = ClassUtil.getPackageName(_meta.getObjectIdType()); String fileName = ClassUtil.getClassName(_meta.getObjectIdType()) + ".java"; // if pc class in same package as oid class, try to find pc .java file File dir = null; if (_dir == null && ClassUtil.getPackageName(_type).equals(packageName)) { dir = Files.getSourceFile(_type); if (dir != null) dir = dir.getParentFile(); } if (dir == null) dir = Files.getPackageFile(_dir, packageName, true); return new File(dir, fileName); }
/** * Whether or not <code>className</code> is the name for a * dynamically-created persistence-capable subclass. * * @since 1.1.0 */ public static boolean isPCSubclassName(String className) { return className.startsWith(ClassUtil.getPackageName(PCEnhancer.class)) && className.endsWith("$pcsubclass"); }
/** * Return the {@link Class} representation of the class(es) named in the * given metadatas. */ public Class<?>[] parseTypes(MetaDataIterator itr) { String[] names = parseTypeNames(itr); Class<?>[] objs = new Class[names.length]; for (int i = 0; i < names.length; i++) objs[i] = ClassUtil.toClass(names[i], _loader); return objs; }
int dims = getArrayDimensions(fullName); if (dims > 0) { if (fullName.length() == dims + 1) {
/** * Return only the class name, without package. */ public static String getClassName(Class cls) { if (cls == null) { return null; } return getClassName(cls.getName()); }
/** * Return the file that this tool should output to. */ private File getFile() { if (_meta == null) return null; String packageName = ClassUtil.getPackageName(_meta.getObjectIdType()); String fileName = ClassUtil.getClassName(_meta.getObjectIdType()) + ".java"; // if pc class in same package as oid class, try to find pc .java file File dir = null; if (_dir == null && ClassUtil.getPackageName(_type).equals(packageName)) { dir = Files.getSourceFile(_type); if (dir != null) dir = dir.getParentFile(); } if (dir == null) dir = Files.getPackageFile(_dir, packageName, true); return new File(dir, fileName); }
static String toPCSubclassName(Class cls) { return ClassUtil.getPackageName(PCEnhancer.class) + "." + cls.getName().replace('.', '$') + "$pcsubclass"; }