List of usage examples for java.util HashSet add
public boolean add(E e)
From source file:net.roboconf.dm.rest.services.internal.RestApplication.java
@Override public Set<Object> getSingletons() { HashSet<Object> set = new HashSet<Object>(); set.add(this.applicationResource); set.add(this.managementResource); set.add(this.debugResource); return set;/*ww w. ja v a 2 s .co m*/ }
From source file:javadepchecker.Main.java
private static boolean checkPkg(File env) { boolean needed = true; boolean found = true; HashSet<String> pkgs = new HashSet<String>(); Collection<String> deps = null; BufferedReader in = null;/*from w w w .j a v a 2s . co m*/ try { Pattern dep_re = Pattern.compile("^DEPEND=\"([^\"]*)\"$"); Pattern cp_re = Pattern.compile("^CLASSPATH=\"([^\"]*)\"$"); String line; in = new BufferedReader(new FileReader(env)); while ((line = in.readLine()) != null) { Matcher m = dep_re.matcher(line); if (m.matches()) { String atoms = m.group(1); for (String atom : atoms.split(":")) { String pkg = atom; if (atom.contains("@")) { pkg = atom.split("@")[1]; } pkgs.add(pkg); } continue; } m = cp_re.matcher(line); if (m.matches()) { Main classParser = new Main(); for (String jar : m.group(1).split(":")) { if (jar.endsWith(".jar")) { classParser.processJar(new JarFile(image + jar)); } } deps = classParser.getDeps(); } } for (String pkg : pkgs) { if (!depNeeded(pkg, deps)) { if (needed) { System.out.println("Possibly unneeded dependencies found"); } System.out.println("\t" + pkg); needed = false; } } found = depsFound(pkgs, deps); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } finally { try { in.close(); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } return needed && found; }
From source file:com.android.build.gradle.internal.transforms.ExtractJarsTransform.java
private static void extractJar(@NonNull File outJarFolder, @NonNull File jarFile, boolean extractCode) throws IOException { mkdirs(outJarFolder);// www . j a v a 2 s. c o m HashSet<String> lowerCaseNames = new HashSet<>(); boolean foundCaseInsensitiveIssue = false; try (Closer closer = Closer.create()) { FileInputStream fis = closer.register(new FileInputStream(jarFile)); ZipInputStream zis = closer.register(new ZipInputStream(fis)); // loop on the entries of the intermediary package and put them in the final package. ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { try { String name = entry.getName(); // do not take directories if (entry.isDirectory()) { continue; } foundCaseInsensitiveIssue = foundCaseInsensitiveIssue || !lowerCaseNames.add(name.toLowerCase(Locale.US)); Action action = getAction(name, extractCode); if (action == Action.COPY) { File outputFile = new File(outJarFolder, name.replace('/', File.separatorChar)); mkdirs(outputFile.getParentFile()); try (Closer closer2 = Closer.create()) { java.io.OutputStream outputStream = closer2 .register(new BufferedOutputStream(new FileOutputStream(outputFile))); ByteStreams.copy(zis, outputStream); outputStream.flush(); } } } finally { zis.closeEntry(); } } } if (foundCaseInsensitiveIssue) { LOGGER.error( "Jar '{}' contains multiple entries which will map to " + "the same file on case insensitive file systems.\n" + "This can be caused by obfuscation with useMixedCaseClassNames.\n" + "This build will be incorrect on case insensitive " + "file systems.", jarFile.getAbsolutePath()); } }
From source file:com.fatminds.cmis.AlfrescoCmisHelper.java
/** * /* w w w . j ava 2 s. c om*/ * @param alfrescoHostAndPort (i.e. dev2-instance.fatminds.com:8080) * @param cmisType (i.e. F:fminstitution:institution) * @return the set of all properties carried by each mandatory aspect defined in the alfresco * data model for the given cmisType */ public static Set<String> getMandatoryAspects(JsonNode root) { if (null == root || !root.has("defaultAspects")) { throw new RuntimeException("root must not be null, and must contain /defaultAspects path"); } HashSet<String> aspects = new HashSet<String>(); Iterator<String> i = root.path("defaultAspects").getFieldNames(); while (i.hasNext()) { String aspect = i.next(); // TODO: clean this up if (aspect.startsWith("sys")) continue; if (aspect.startsWith("cm:auditable")) continue; aspects.add(aspect); } return aspects; }
From source file:com.relicum.ipsum.Utils.LocUtils.java
/** * It will return players in a radius, from location. * * @param location Initial location/*from w w w .ja v a 2 s . c om*/ * @param radius distance from the "location" that will return all the entities from each block; * @return HashSet(Player) * credits skore87 */ public static HashSet<LivingEntity> getNearbyEntities(Location location, int radius) { int chunkRadius = radius < 16 ? 1 : (radius - (radius % 16)) / 16; HashSet<LivingEntity> radiusEntities = new HashSet<>(); for (int chX = 0 - chunkRadius; chX <= chunkRadius; chX++) { for (int chZ = 0 - chunkRadius; chZ <= chunkRadius; chZ++) { int x = (int) location.getX(), y = (int) location.getY(), z = (int) location.getZ(); for (Entity e : new Location(location.getWorld(), x + (chX * 16), y, z + (chZ * 16)).getChunk() .getEntities()) { if (e.getLocation().distance(location) <= radius && e.getLocation().getBlock() != location.getBlock()) { if (e instanceof LivingEntity) { radiusEntities.add((LivingEntity) e); } } } } } return radiusEntities; }
From source file:it.iit.genomics.cru.structures.bridges.uniprot.UniprotkbUtils.java
private static Collection<String> getUniprotAcs(Collection<String> xrefs) { HashSet<String> uniprotAcs = new HashSet<>(); for (String xref : xrefs) { if (xref.matches(".*\\-[0-9]+")) { xref = xref.split("-")[0]; }// w w w.ja va2s . c o m if (isUniprotAc(xref)) { uniprotAcs.add(xref); } } return uniprotAcs; }
From source file:eionet.cr.util.Util.java
/** * * @param <K>//w w w.j a va2 s . co m * @param <V> * @param map * @return */ public static <K, V> Set<K> getNullValueKeys(Map<K, V> map) { HashSet<K> result = new HashSet<K>(); if (map != null && !map.isEmpty()) { for (Map.Entry<K, V> entry : map.entrySet()) { if (entry.getValue() == null) { result.add(entry.getKey()); } } } return result; }
From source file:com.strandls.alchemy.webservices.config.AlchemyWebApplication.java
@Override public Set<Object> getSingletons() { final HashSet<Object> singletons = new HashSet<Object>(); singletons.add(getGuiceInjector().getInstance(JacksonJsonProvider.class)); return singletons; }
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
public static HashSet<String> getStarredSubjectsSet(Context context) { DBHelper db = new DBHelper(context); SQLiteDatabase dbread = db.getReadableDatabase(); Cursor c;/*from w w w.jav a 2 s.com*/ String query = "SELECT clean_subject FROM starred_threads"; c = dbread.rawQuery(query, null); HashSet<String> set = new HashSet<String>(c.getCount()); c.moveToFirst(); int count = c.getCount(); for (int i = 0; i < count; i++) { set.add(c.getString(0)); c.moveToNext(); } c.close(); dbread.close(); db.close(); return set; }
From source file:com.lynnlyc.web.taintanalysis.JSTaintAnalysis.java
public static String getTagsStr(HashSet<String> tags) { HashSet<String> filteredTags = new HashSet<>(); for (String tag : tags) { for (String tagSeg : tag.split(" |\\.|#|:|,")) { if (tagSeg.startsWith("LRoot") || tagSeg.startsWith("Lprologue") || tagSeg.length() == 0 || tagSeg.startsWith("Lpreamble") || tagSeg.startsWith("__WALA__")) continue; filteredTags.add(tagSeg); }/*from ww w .j av a 2 s. co m*/ } ArrayList<String> filteredTagsList = new ArrayList<>(filteredTags); Collections.sort(filteredTagsList); return StringUtils.join(filteredTagsList, ','); }