List of usage examples for java.util Set clear
void clear();
From source file:main.java.RMDupper.java
public static void flushQueue(DupStats dupStats, OccurenceCounterMerged occurenceCounterMerged, SAMFileWriter outputSam, Boolean allReadsAsMerged, PriorityQueue<ImmutableTriple<Integer, Integer, SAMRecord>> recordBuffer, PriorityQueue<ImmutableTriple<Integer, Integer, SAMRecord>> duplicateBuffer, Set<String> discardSet) { while (!recordBuffer.isEmpty()) { checkForDuplication(dupStats, occurenceCounterMerged, outputSam, allReadsAsMerged, recordBuffer, duplicateBuffer, discardSet); }/*from w w w . ja va 2 s .c o m*/ discardSet.clear(); }
From source file:com.kalessil.phpStorm.phpInspectionsEA.inspectors.security.rsaStrategies.OpensslRsaOraclePaddingStrategy.java
static private boolean isTargetCall(@NotNull FunctionReference reference) { boolean result = false; if (reference.getNameNode() == null) { final PsiElement name = reference.getFirstPsiChild(); if (name != null) { final Set<PsiElement> nameVariants = PossibleValuesDiscoveryUtil.discover(name); if (!nameVariants.isEmpty()) { for (final PsiElement variant : nameVariants) { if (variant instanceof StringLiteralExpression) { final String content = ((StringLiteralExpression) variant).getContents(); if (functions.contains(StringUtils.strip(content, "\\"))) { result = true; break; }//w w w . jav a2s .c om } } nameVariants.clear(); } } } else { result = functions.contains(reference.getName()); } return result; }
From source file:de.thischwa.pmcms.model.domain.PoInfo.java
private static void collectRenderables(final Level level, Set<IRenderable> renderables, StringBuilder messages) { for (Level tmpContainer : level.getSublevels()) { if (messages != null && !InstanceUtil.isSite(level) && CollectionUtils.isEmpty(level.getPages())) { messages.append(LabelHolder.get("task.export.error.pojo.levelhasnopage")); //$NON-NLS-1$ messages.append(level.getDecorationString()); messages.append('\n'); renderables.clear(); return; }//from w ww . j a v a 2 s . c o m collectRenderables(tmpContainer, renderables, messages); } for (Page page : level.getPages()) { renderables.add(page); if (InstanceUtil.isGallery(page)) { List<Image> images = ((Gallery) page).getImages(); if (renderables != null && CollectionUtils.isEmpty(images)) { messages.append(LabelHolder.get("task.export.error.pojo.galleryhasnoimage")); //$NON-NLS-1$ messages.append(page.getDecorationString()); messages.append('\n'); renderables.clear(); return; } else renderables.addAll(images); } } }
From source file:com.kalessil.phpStorm.phpInspectionsEA.inspectors.security.rsaStrategies.OpensslRsaOraclePaddingStrategy.java
static public boolean apply(@NotNull ProblemsHolder holder, @NotNull FunctionReference reference) { boolean result = false; final PsiElement[] arguments = reference.getParameters(); if (arguments.length == 3 && isTargetCall(reference)) { holder.registerProblem(reference, message); result = true;/*from w w w .jav a 2s .co m*/ } else if (arguments.length == 4 && isTargetCall(reference)) { final Set<PsiElement> modeVariants = PossibleValuesDiscoveryUtil.discover(arguments[3]); if (!modeVariants.isEmpty()) { for (final PsiElement variant : modeVariants) { if (variant instanceof ConstantReference) { final String constantName = ((ConstantReference) variant).getName(); if (constantName != null && constantName.equals("OPENSSL_PKCS1_PADDING")) { holder.registerProblem(reference, message); result = true; break; } } } modeVariants.clear(); } } return result; }
From source file:com.google.ipc.invalidation.ticl.android.c2dm.C2DMSettings.java
private static Set<C2DMObserver> createC2DMObserversFromJSON(String jsonString) { // The observer set is stored in a json array of objects that contain the // observer json representation produced by C2DMObserver.toJSON. Iterate over // this array and recreate observers from the objects. Set<C2DMObserver> observers = new HashSet<C2DMObserver>(); if (jsonString == null) { return observers; }/*ww w. ja v a 2s . c o m*/ try { JSONArray array = new JSONArray(jsonString); for (int i = 0; i < array.length(); i++) { JSONObject jsonObserver = array.getJSONObject(i); C2DMObserver observer = C2DMObserver.createFromJSON(jsonObserver); if (observer != null) { observers.add(observer); } } } catch (JSONException e) { Log.e(TAG, "Unable to parse observers. Source: " + jsonString); observers.clear(); // No partial result } return observers; }
From source file:org.apache.hadoop.raid.PlacementMonitor.java
static void countBlocksOnEachNode(List<BlockInfo> stripeBlocks, Map<String, Integer> nodeToNumBlocks, Set<String> nodesInThisStripe) throws IOException { nodeToNumBlocks.clear();//from ww w.j a v a 2 s . com nodesInThisStripe.clear(); for (BlockInfo block : stripeBlocks) { for (String node : block.getNames()) { Integer n = nodeToNumBlocks.get(node); if (n == null) { n = 0; } nodeToNumBlocks.put(node, n + 1); nodesInThisStripe.add(node); } } }
From source file:org.bibsonomy.webapp.util.GroupingCommandUtils.java
/** * Copy the groups from the command into provided groups set (make proper groups from * them)//from w ww. ja v a 2 s . co m * * @param command - * contains the groups as represented by the form fields. * @param groupsToInit - * the groups should be populated from the command. */ public static void initGroups(final GroupingCommand command, final Set<Group> groupsToInit) { log.debug("initializing groups from command"); /* * we can avoid some checks here, because they're done in the validator * ... */ final String abstractGrouping = command.getAbstractGrouping(); if (OTHER_ABSTRACT_GROUPING.equals(abstractGrouping)) { log.debug("found 'other' grouping"); /* * copy groups into post */ final List<String> groups = command.getGroups(); log.debug("groups in command: " + groups); for (final String groupname : groups) { groupsToInit.add(new Group(groupname)); } log.debug("groups: " + groupsToInit); } else { log.debug("public or private post"); /* * if the post is private or public --> remove all groups and add * one (private or public) */ groupsToInit.clear(); groupsToInit.add(new Group(abstractGrouping)); } }
From source file:ch.sdi.core.impl.data.converter.ConverterBoolean.java
/** * Clears the given list and fills it with found configured values according the given key * <p>/*from w w w. j av a 2 s. co m*/ * @param aEnv * @param aValuesToFill * @param aKey * either "trueValues" or "falseValues" */ private void resolveConfiguredValues(Environment aEnv, Set<String> aValuesToFill, String aKey) { aValuesToFill.clear(); String key = SdiMainProperties.KEY_PREFIX_CONVERTER + CONVERTER_NAME + "." + aKey; String values = aEnv.getProperty(key); if (!StringUtils.hasText(values)) { myLog.debug("No configured values found for key " + key); return; } // if !StringUtils.hasText( values ) String[] split = values.split(","); for (String value : split) { if (!StringUtils.hasText(value)) { continue; } // if !StringUtils.hasText( value ) value = value.trim().toLowerCase(); myLog.debug("Found configured value (aKey): " + value); aValuesToFill.add(value); } }
From source file:edu.uci.ics.asterix.test.aql.TestsUtils.java
private static boolean equalStrings(String s1, String s2) { String[] rowsOne = s1.split("\n"); String[] rowsTwo = s2.split("\n"); for (int i = 0; i < rowsOne.length; i++) { String row1 = rowsOne[i]; String row2 = rowsTwo[i]; if (row1.equals(row2)) continue; String[] fields1 = row1.split(" "); String[] fields2 = row2.split(" "); boolean bagEncountered = false; Set<String> bagElements1 = new HashSet<String>(); Set<String> bagElements2 = new HashSet<String>(); for (int j = 0; j < fields1.length; j++) { if (j >= fields2.length) { return false; } else if (fields1[j].equals(fields2[j])) { if (fields1[j].equals("{{")) bagEncountered = true; if (fields1[j].startsWith("}}")) { if (!bagElements1.equals(bagElements2)) return false; bagEncountered = false; bagElements1.clear(); bagElements2.clear(); }/*w w w .jav a2 s . c om*/ continue; } else if (fields1[j].indexOf('.') < 0) { if (bagEncountered) { bagElements1.add(fields1[j].replaceAll(",$", "")); bagElements2.add(fields2[j].replaceAll(",$", "")); continue; } return false; } else { // If the fields are floating-point numbers, test them // for equality safely fields1[j] = fields1[j].split(",")[0]; fields2[j] = fields2[j].split(",")[0]; try { Double double1 = Double.parseDouble(fields1[j]); Double double2 = Double.parseDouble(fields2[j]); float float1 = (float) double1.doubleValue(); float float2 = (float) double2.doubleValue(); if (Math.abs(float1 - float2) == 0) continue; else { return false; } } catch (NumberFormatException ignored) { // Guess they weren't numbers - must simply not be equal return false; } } } } return true; }
From source file:org.apdplat.superword.tools.WordClassifier.java
public static void save(Map<String, List<String>> data) { LOGGER.info("??"); data.keySet().forEach(key -> {/*w w w . j a va 2s .c o m*/ try { String path = "src/main/resources/word_" + key + ".txt"; LOGGER.error("??" + path); List<String> existWords = Files.readAllLines(Paths.get(path)); Set<String> allWords = new HashSet<>(); existWords.forEach(line -> { String[] attr = line.split("\\s+"); if (attr != null) { String w = ""; if (attr.length == 1) { w = attr[0]; } if (attr.length == 2) { w = attr[1]; } allWords.add(w); } }); allWords.addAll(data.get(key)); AtomicInteger i = new AtomicInteger(); List<String> list = allWords.stream().sorted().map(word -> i.incrementAndGet() + "\t" + word) .collect(Collectors.toList()); Files.write(Paths.get(path), list); data.get(key).clear(); existWords.clear(); allWords.clear(); list.clear(); } catch (Exception e) { LOGGER.error("??", e); } }); data.clear(); try { if (!NOT_FOUND_WORDS.isEmpty()) { String path = "src/main/resources/word_not_found.txt"; LOGGER.error("??" + path); AtomicInteger i = new AtomicInteger(); //NOT_FOUND_WORDS List<String> list = NOT_FOUND_WORDS.stream().sorted().map(word -> i.incrementAndGet() + "\t" + word) .collect(Collectors.toList()); Files.write(Paths.get(path), list); list.clear(); } //?HTML if (!ORIGIN_HTML.isEmpty()) { String path = "src/main/resources/origin_html_" + System.currentTimeMillis() + ".txt"; LOGGER.error("??" + path); Files.write(Paths.get(path), ORIGIN_HTML); ORIGIN_HTML.clear(); } } catch (Exception e) { LOGGER.error("??", e); } }