public String[] getGroupNames() { LinkedHashSet<String> groups = new LinkedHashSet<String>(); for (ApiDoc apiDoc : docs) { groups.add(apiDoc.group); } return groups.toArray(new String[groups.size()]); }
public String[] getGroupRoutes(String group) { LinkedHashSet<String> routes = new LinkedHashSet<String>(); for (ApiDoc apiDoc : docs) { if (StringUtils.equals(group, apiDoc.group)) Collections.addAll(routes, apiDoc.routes); } return routes.toArray(new String[routes.size()]); }
public static ApiDocs scan(String... files) { try { result = new ApiDocs(); LinkedHashSet<String> sources = new LinkedHashSet<String>(); for (String file : files) findSourceFiles(sources, file); Main.execute( "borqs_server_api_doc_scanner", HttpApiDoclet.class.getName(), sources.toArray(new String[sources.size()])); return result; } finally { result = null; } }
private static void findSourceFiles(LinkedHashSet<String> files, String file) { File f = new File(file); if (f.isFile()) { String ext = FilenameUtils.getExtension(f.getName()); if ("java".equalsIgnoreCase(ext)) files.add(file); } else if (f.isDirectory()) { for (String sub : f.list()) { if (sub.equals(".") || sub.equals("..")) continue; findSourceFiles(files, FilenameUtils.concat(f.getAbsolutePath(), sub)); } } }