List of usage examples for java.util HashSet add
public boolean add(E e)
From source file:fi.helsinki.lib.simplerest.CollectionsResource.java
@Delete public Representation delete(Representation dummy) { HashSet<Method> allowed = new HashSet(); allowed.add(Method.GET); allowed.add(Method.POST);// w ww .j a v a2 s . c om setAllowedMethods(allowed); return error(null, "Collections resource does not allow DELETE method.", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); }
From source file:edu.amc.sakai.user.RegexpBlacklistEidValidator.java
private Collection<Pattern> eidBlacklistAsPatterns(Collection<String> eidBlacklistStrings) { if (eidBlacklistStrings == null || eidBlacklistStrings.isEmpty()) { return new HashSet<Pattern>(0); }//from ww w. j a v a2 s . com HashSet<Pattern> patterns = new HashSet<Pattern>(eidBlacklistStrings.size()); for (String patternString : eidBlacklistStrings) { Pattern pattern = Pattern.compile(patternString, regexpFlags); patterns.add(pattern); } return patterns; }
From source file:functionaltests.execremote.TestExecRemote.java
@Test public void action() throws Exception { final String miscDir = System.getProperty("pa.rm.home") + File.separator + "samples" + File.separator + "scripts" + File.separator + "misc" + File.separator; boolean isLinux = OperatingSystem.getOperatingSystem().equals(OperatingSystem.unix); final String valueToEcho = "111"; String nsName = "TestExecRemote"; rmHelper.createNodeSource(nsName);/*w w w. ja v a 2 s.c om*/ RMInitialState state = ((RMMonitorEventReceiver) rmHelper.getResourceManager()).getInitialState(); String hostname = state.getNodesEvents().get(0).getHostName(); HashSet<String> nodesUrls = new HashSet<>(); for (RMNodeEvent ne : state.getNodesEvents()) { nodesUrls.add(ne.getNodeUrl()); } simpleScript(nodesUrls); selectionScript(nodesUrls); processBuilderScript(miscDir, isLinux, valueToEcho, nodesUrls); processBuilderWithDSScript(miscDir, isLinux, valueToEcho, nodesUrls); scriptOnNodeSource(nsName, nodesUrls); scriptOnHost(hostname); }
From source file:com.metaparadigm.jsonrpc.JSONRPCBridge.java
/** * Registers a Class to be removed from the exported method signatures and * instead be resolved locally using context information from the transport. * //from ww w .ja v a 2s. c o m * @param argClazz * The class to be resolved locally * @param argResolver * The user defined class that resolves the and returns the * method argument using transport context information * @param contextInterface * The type of transport Context object the callback is * interested in eg. HttpServletRequest.class for the servlet * transport */ public static void registerLocalArgResolver(Class argClazz, Class contextInterface, LocalArgResolver argResolver) { synchronized (localArgResolverMap) { HashSet resolverSet = (HashSet) localArgResolverMap.get(argClazz); if (resolverSet == null) { resolverSet = new HashSet(); localArgResolverMap.put(argClazz, resolverSet); } resolverSet.add(new LocalArgResolverData(argResolver, argClazz, contextInterface)); classCache = new HashMap(); // invalidate class cache } log.info("registered local arg resolver " + argResolver.getClass().getName() + " for local class " + argClazz.getName() + " with context " + contextInterface.getName()); }
From source file:edu.cornell.mannlib.vitro.webapp.servlet.setup.FileGraphSetup.java
private Set<String> pathsToURIs(Set<Path> paths, String type) { HashSet<String> uriSet = new HashSet<String>(); for (Path path : paths) { uriSet.add(pathToURI(path, type)); }/* w w w.j a v a2 s . com*/ log.debug("uriSet = " + uriSet); return uriSet; }
From source file:de.da_sense.moses.client.com.requests.RequestSendSurveyAnswers.java
/** * Constructs a new {@link RequestSendSurveyAnswers}. * @param e the executor/*from ww w. j a va 2s .com*/ * @param sessionID the sesion ID * @param apkID apk for which answers are sent */ public RequestSendSurveyAnswers(ReqTaskExecutor e, String sessionID, String apkID) { j = new JSONObject(); this.e = e; try { j.put("MESSAGE", "SURVEY_RESULT"); j.put("SESSIONID", sessionID); j.put("APKID", apkID); // setting answers for (Form form : InstalledExternalApplicationsManager.getInstance().getAppForId(apkID).getSurvey() .getForms()) for (Question question : form.getQuestions()) { int questionType = question.getType(); if (questionType == Question.TYPE_MULTIPLE_CHOICE) { // extra care for multiple choice answers String answer = question.getAnswer(); String newAnswer = ""; String[] splits = answer.split(","); HashSet<String> theAnswers = new HashSet<String>(); for (String split : splits) { String temp = split.replaceAll(",", "").trim(); if (!temp.isEmpty()) theAnswers.add(temp); } if (!theAnswers.isEmpty()) { newAnswer = "["; for (String anAnswer : theAnswers) newAnswer = newAnswer + anAnswer + ","; newAnswer = newAnswer.substring(0, newAnswer.length() - 1); newAnswer = newAnswer + "]"; } j.put(String.valueOf(question.getId()), newAnswer); } else j.put(String.valueOf(question.getId()), question.getAnswer()); } } catch (JSONException ex) { e.handleException(ex); } }
From source file:edu.harvard.i2b2.patientMapping.serviceClient.PatientMappingQueryClient.java
public static String getlldString(ArrayList<TimelineRow> tlrows, String patientRefId, int minPatient, int maxPatient, boolean bDisplayAll, boolean writeFile, boolean displayDemographics, MainComposite explorer) {/*from w w w .j ava 2 s .c om*/ try { HashSet<String> conceptPaths = new HashSet<String>(); // HashSet<String> providerPaths = new HashSet<String>(); // HashSet<String> visitPaths = new HashSet<String>(); ArrayList<PDOItem> items = new ArrayList<PDOItem>(); for (int i = 0; i < tlrows.size(); i++) { for (int j = 0; j < tlrows.get(i).pdoItems.size(); j++) { PDOItem pdoItem = tlrows.get(i).pdoItems.get(j); String path = pdoItem.fullPath; if (conceptPaths.contains(path)) { //continue; } conceptPaths.add(path); // for(int k=0; k<pdoItem.valDisplayProperties.size(); k++) // { items.add(pdoItem); // } } } PDORequestMessageModel pdoFactory = new PDORequestMessageModel(); String pid = null; if (patientRefId.equalsIgnoreCase("All")) { pid = "-1"; } else { pid = patientRefId; } String xmlStr = pdoFactory.requestXmlMessage(items, pid, new Integer(minPatient), new Integer(maxPatient), false); // explorer.lastRequestMessage(xmlStr); String result = null;// sendPDOQueryRequestREST(xmlStr); if (System.getProperty("webServiceMethod").equals("SOAP")) { result = PatientMappingQueryClient.sendPDOQueryRequestSOAP(xmlStr); } else { result = PatientMappingQueryClient.sendPDOQueryRequestREST(xmlStr); } if (result == null || result.equalsIgnoreCase("memory error")) { return result; } // explorer.lastResponseMessage(result); return new PatientMappingFactory().generateTimelineData(result, tlrows, writeFile, bDisplayAll, displayDemographics, explorer); } /* * catch(org.apache.axis2.AxisFault e) { e.printStackTrace(); * java.awt.EventQueue.invokeLater(new Runnable() { public void run() { * JOptionPane.showMessageDialog(null, * "Trouble with connection to the remote server, " + * "this is often a network error, please try again", "Network Error", * JOptionPane.INFORMATION_MESSAGE); } }); * * return null; } */ catch (Exception e) { e.printStackTrace(); return null; } }
From source file:ca.uhn.fhir.jpa.dao.dstu3.SearchParamRegistryDstu3.java
private Set<String> toStrings(List<CodeType> theTarget) { HashSet<String> retVal = new HashSet<String>(); for (CodeType next : theTarget) { if (isNotBlank(next.getValue())) { retVal.add(next.getValue()); }/*from w w w . ja va 2 s. c o m*/ } return retVal; }
From source file:com.mythesis.profileanalysis.Utils.java
/** * Method that gets the results form sWebRank and puts them all together in the same file * @param inputDirectory the output directory of sWebRank * @param outputDirectory the directory where im gonna save the new file * @param file the name of the file where im gonna save the results e.g. xxx.txt *///from ww w. j a va2 s. co m public void getLDAcontent(String inputDirectory, String outputDirectory, String file) { System.out.println("Getting webpages from " + inputDirectory); //Find output paths File root = new File(inputDirectory); File[] contents = root.listFiles(); List<String> sWebRanklevels = new ArrayList<>(); for (File f : contents) { if (f.getAbsolutePath().contains("level")) sWebRanklevels.add(f.getAbsolutePath()); } //Find all query paths //for now this only works for bing search engine List<String> totalQueries = new ArrayList<>(); for (String s : sWebRanklevels) { File level = new File(s); File[] queries = level.listFiles(); for (File f : queries) { if (!f.getAbsolutePath().contains("txt")) totalQueries.add(f.getAbsolutePath() + "\\" + "bing" + "\\"); } } int totalDocs = 0; //String totalContent=""; List<String> totalContent = new ArrayList<>(); String webpage = ""; for (String s : totalQueries) { File level = new File(s); File[] docPaths = level.listFiles(); for (File f : docPaths) { String str = f.getAbsolutePath(); if (StringUtils.isNumeric(str.substring(str.lastIndexOf("\\") + 1))) { File webPagePath = new File(str + "\\html_parse_content.txt"); try { if (!directoryContains(f, webPagePath)) { webPagePath = new File(f.getAbsolutePath() + "\\youtube_content.txt"); if (!directoryContains(f, webPagePath)) continue; webpage = readFileToString(webPagePath).replace("\n", "").replace("\r", ""); YoutubeContent ytc = new YoutubeContent(); webpage = ytc.parse(webpage); } else { webpage = readFileToString(webPagePath); } } catch (IOException ex) { Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex); } if (webpage.isEmpty()) continue; totalContent.add(webpage); } } } Set<String> hs = new HashSet<>(); hs.addAll(totalContent); totalContent.clear(); totalContent.addAll(hs); //find for each word the documents that appears in Map<String, HashSet<Integer>> wordsToSetOfDocsMap = new TreeMap<>(); int size = totalContent.size(); for (int d = 0; d < size; d++) { String doc = totalContent.get(d); String[] words = doc.trim().split(" "); int length = words.length; for (int w = 0; w < length; w++) { String word = words[w]; if (!wordsToSetOfDocsMap.containsKey(word)) { wordsToSetOfDocsMap.put(word, new HashSet<Integer>()); } HashSet<Integer> setOfDocs = wordsToSetOfDocsMap.get(word); setOfDocs.add(d); wordsToSetOfDocsMap.put(word, setOfDocs); } } //remove frequent words totalContent = removeFrequentWords(wordsToSetOfDocsMap, totalContent); //remove infrequent words totalContent = removeInfrequentWords(wordsToSetOfDocsMap, totalContent); //store results for (int i = 0; i < totalContent.size(); i++) { String content = totalContent.get(i).replaceAll("\\s+", " ").trim(); totalContent.set(i, content); } totalDocs = totalContent.size(); totalContent.add(0, String.valueOf(totalDocs)); String LDAdirectory = outputDirectory; File ldaContent = new File(LDAdirectory + file); try { FileUtils.writeLines(ldaContent, totalContent); } catch (IOException ex) { Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("I stored the results in " + outputDirectory + file); }