@Override public ClassArgParser newClassArgParser() { ClassArgParser parser = new ClassArgParser(); parser.setMetaDataStructure("package", null, new String[]{ "entity", "embeddable", "mapped-superclass" }, "class"); return parser; }
/** * Return a mapping of each metadata resource to an array of its * contained classes. */ public Map mapTypes(MetaDataIterator itr) { Map map = mapTypeNames(itr); Map.Entry entry; String[] names; Class[] objs; for (Iterator i = map.entrySet().iterator(); i.hasNext();) { entry = (Map.Entry) i.next(); names = (String[]) entry.getValue(); objs = new Class[names.length]; for (int j = 0; j < names.length; j++) objs[j] = Strings.toClass(names[j], _loader); entry.setValue(objs); } return map; }
/** * 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; }
/** * Parse the names in the given metadata iterator stream, closing the * stream on completion. */ private void appendTypeNames(Object source, InputStream in, List<String> names) throws IOException { try { if (source.toString().endsWith(".class")) names.add(getFromClass(in)); names.addAll(getFromMetaData(new InputStreamReader(in))); } finally { try { in.close(); } catch (IOException ioe) { } } }
cap.setClassLoader(loader); Class<?> cls = cap.parseTypes(args[0])[0];
/** * Return the names of the class(es) from the given arg. * * @param arg a class name, .java file, .class file, or metadata * file naming the type(s) to act on * @throws IllegalArgumentException with appropriate message on error */ public String[] parseTypeNames(String arg) { if (arg == null) return new String[0]; try { File file = Files.getFile(arg, _loader); if (arg.endsWith(".class")) return new String[]{ getFromClassFile(file) }; if (arg.endsWith(".java")) return new String[]{ getFromJavaFile(file) }; if ((AccessController.doPrivileged( J2DoPrivHelper.existsAction(file))).booleanValue()) { Collection<String> col = getFromMetaDataFile(file); return col.toArray(new String[col.size()]); } } catch (Exception e) { throw new RuntimeException( _loc.get("class-arg", arg).getMessage(), e); } // must be a class name return new String[]{ arg }; }
public ClassArgParser newClassArgParser() { return new ClassArgParser(); }
/** * Return a mapping of each metadata resource to an array of its contained * class names. */ public Map<Object, String[]> mapTypeNames(MetaDataIterator itr) { if (itr == null) return Collections.emptyMap(); Map<Object, String []> map = new HashMap<Object, String[]>(); Object source = null; List<String> names = new ArrayList<String>(); try { while (itr.hasNext()) { source = itr.next(); appendTypeNames(source, itr.getInputStream(), names); if (!names.isEmpty()) { map.put(source, names.toArray(new String[names.size()])); } names.clear(); } } catch (Exception e) { throw new RuntimeException( _loc.get("class-arg", source).getMessage(), e); } return map; }
/** * Returns the class named in the given .class file. */ private String getFromClassFile(File file) throws IOException { FileInputStream fin = null; try { fin = AccessController.doPrivileged( J2DoPrivHelper.newFileInputStreamAction(file)); return getFromClass(fin); } catch (PrivilegedActionException pae) { throw (FileNotFoundException) pae.getException(); } finally { if (fin != null) try { fin.close(); } catch (IOException ioe) { } } }
if (charsUnique(buf)) break;
cap.setClassLoader(loader); Class<?> cls = cap.parseTypes(args[0])[0];
/** * Return the names of the class(es) from the given arg. * * @param arg a class name, .java file, .class file, or metadata * file naming the type(s) to act on * @throws IllegalArgumentException with appropriate message on error */ public String[] parseTypeNames(String arg) { if (arg == null) return new String[0]; try { File file = Files.getFile(arg, _loader); if (arg.endsWith(".class")) return new String[]{ getFromClassFile(file) }; if (arg.endsWith(".java")) return new String[]{ getFromJavaFile(file) }; if ((AccessController.doPrivileged( J2DoPrivHelper.existsAction(file))).booleanValue()) { Collection<String> col = getFromMetaDataFile(file); return col.toArray(new String[col.size()]); } } catch (Exception e) { throw new NestableRuntimeException( _loc.get("class-arg", arg).getMessage(), e); } // must be a class name return new String[]{ arg }; }
public ClassArgParser newClassArgParser() { return new ClassArgParser(); }
/** * Parse the names in the given metadata iterator stream, closing the * stream on completion. */ private void appendTypeNames(Object source, InputStream in, List names) throws IOException { try { if (source.toString().endsWith(".class")) names.add(getFromClass(in)); names.addAll(getFromMetaData(new InputStreamReader(in))); } finally { try { in.close(); } catch (IOException ioe) { } } }
/** * Return a mapping of each metadata resource to an array of its contained * class names. */ public Map<Object, String[]> mapTypeNames(MetaDataIterator itr) { if (itr == null) return Collections.emptyMap(); Map<Object, String []> map = new HashMap<Object, String[]>(); Object source = null; List<String> names = new ArrayList<String>(); try { while (itr.hasNext()) { source = itr.next(); appendTypeNames(source, itr.getInputStream(), names); if (!names.isEmpty()) { map.put(source, names.toArray(new String[names.size()])); } names.clear(); } } catch (Exception e) { throw new RuntimeException( _loc.get("class-arg", source).getMessage(), e); } return map; }
/** * Returns the class named in the given .class file. */ private String getFromClassFile(File file) throws IOException { FileInputStream fin = null; try { fin = AccessController.doPrivileged( J2DoPrivHelper.newFileInputStreamAction(file)); return getFromClass(fin); } catch (PrivilegedActionException pae) { throw (FileNotFoundException) pae.getException(); } finally { if (fin != null) try { fin.close(); } catch (IOException ioe) { } } }
cap.setClassLoader(loader); Class cls = cap.parseTypes(args[0])[0];
@Override public ClassArgParser newClassArgParser() { ClassArgParser parser = new ClassArgParser(); parser.setMetaDataStructure("package", null, new String[]{ "entity", "embeddable", "mapped-superclass" }, "class"); return parser; }
/** * Return the names of the class(es) from the given arg. * * @param arg a class name, .java file, .class file, or metadata * file naming the type(s) to act on * @throws IllegalArgumentException with appropriate message on error */ public String[] parseTypeNames(String arg) { if (arg == null) return new String[0]; try { File file = Files.getFile(arg, _loader); if (arg.endsWith(".class")) return new String[]{ getFromClassFile(file) }; if (arg.endsWith(".java")) return new String[]{ getFromJavaFile(file) }; if ((AccessController.doPrivileged( J2DoPrivHelper.existsAction(file))).booleanValue()) { Collection<String> col = getFromMetaDataFile(file); return col.toArray(new String[col.size()]); } } catch (Exception e) { throw new RuntimeException( _loc.get("class-arg", arg).getMessage(), e); } // must be a class name return new String[]{ arg }; }