List of usage examples for java.util LinkedList add
public boolean add(E e)
From source file:com.hp.alm.ali.idea.model.type.TeamType.java
@Override public FilterResolver getFilterResolver() { return new MultipleItemsResolver() { @Override//from w w w. j a v a 2 s.co m public String toRESTQuery(String value) { List<String> values = new LinkedList<String>(Arrays.asList(value.split(";"))); LinkedList<String> ids = new LinkedList<String>(); if (values.remove(MultipleItemsTranslatedResolver.NO_VALUE)) { ids.add(MultipleItemsTranslatedResolver.NO_VALUE); } if (!values.isEmpty()) { EntityList teams = teamService.getMultipleTeams(values); ids.addAll(teams.getIdStrings()); } return StringUtils.join(ids, " OR "); } }; }
From source file:edu.berkeley.wtchoi.swift.driver.drone.StableState.java
private void handleRequest(DriverPacket.Type r, LinkedList<Object> rv) { switch (r) {//from w w w . j ava 2 s.c om case RequestView: rv.add(handleRequestView()); break; case RequestCompressedLog: rv.add(handleRequestCompressedLog()); break; case RequestCoverage: rv.add(handleRequestCoverage()); break; case PrepareCommand: //instead of handling it directly, delay it until all results are collected postPrepare = true; break; } }
From source file:DBpediaSpotlightClient.java
@Override public List<DBpediaResource> extract(Text text) throws AnnotationException { LOG.info("Querying API."); String spotlightResponse;//from w w w . j ava 2 s. co m try { GetMethod getMethod = new GetMethod(API_URL + "rest/annotate/?" + "confidence=" + CONFIDENCE + "&support=" + SUPPORT + "&text=" + URLEncoder.encode(text.text(), "utf-8")); getMethod.addRequestHeader(new Header("Accept", "application/json")); spotlightResponse = request(getMethod); } catch (UnsupportedEncodingException e) { throw new AnnotationException("Could not encode text.", e); } assert spotlightResponse != null; JSONObject resultJSON = null; JSONArray entities = null; try { resultJSON = new JSONObject(spotlightResponse); entities = resultJSON.getJSONArray("Resources"); } catch (JSONException e) { throw new AnnotationException("Received invalid response from DBpedia Spotlight API."); } LinkedList<DBpediaResource> resources = new LinkedList<DBpediaResource>(); for (int i = 0; i < entities.length(); i++) { try { JSONObject entity = entities.getJSONObject(i); resources.add(new DBpediaResource(entity.getString("@URI"), Integer.parseInt(entity.getString("@support")))); } catch (JSONException e) { LOG.error("JSON exception " + e); } } return resources; }
From source file:net.dv8tion.jda.handle.GuildMemberUpdateHandler.java
private List<Role> toRolesList(GuildImpl guild, JSONArray array) { LinkedList<Role> roles = new LinkedList<>(); for (int i = 0; i < array.length(); i++) { Role r = guild.getRolesMap().get(array.getString(i)); if (r != null) { roles.add(r); }//from ww w .jav a 2 s. c o m } return roles; }
From source file:edu.iu.lda.DocWord.java
/** * Load input based on the number of threads * // w ww .j av a 2 s. com * @return */ public void load() { long start = System.currentTimeMillis(); LinkedList<VLoadTask> vLoadTasks = new LinkedList<>(); for (int i = 0; i < numThreads; i++) { vLoadTasks.add(new VLoadTask(conf, idGenerator)); } DynamicScheduler<String, Object, VLoadTask> vLoadCompute = new DynamicScheduler<>(vLoadTasks); vLoadCompute.start(); vLoadCompute.submitAll(inputFiles); vLoadCompute.stop(); while (vLoadCompute.hasOutput()) { vLoadCompute.waitForOutput(); } LinkedList<Int2ObjectOpenHashMap<DocWord>> localVDocMaps = new LinkedList<>(); int totalNumDocs = 0; for (VLoadTask task : vLoadCompute.getTasks()) { localVDocMaps.add(task.getDocMap()); totalNumDocs += task.getNumDocs(); } // Merge thread local vDMap // Should be done in multi-thread? merge(vDocMap, localVDocMaps); long end = System.currentTimeMillis(); // Report the total number of training points // loaded LOG.info("Load num training docs: " + totalNumDocs + ", took: " + (end - start)); }
From source file:com.linuxbox.enkive.statistics.consolidation.EmbeddedConsolidator.java
@Override protected void consolidateMaps(Map<String, Object> consolidatedData, List<Map<String, Object>> serviceData, ConsolidationKeyHandler keyDef, LinkedList<String> dataPath) { Map<String, Object> statConsolidatedData = new HashMap<String, Object>(); if (keyDef.getMethods() != null) { // loop over stat consolidation methods Collection<String> methods = new LinkedList<String>(keyDef.getMethods()); if (!keyDef.isPoint()) { methods.add(CONSOLIDATION_SUM); }//from w w w . j ava 2 s . co m for (String method : methods) { DescriptiveStatistics statsMaker = new DescriptiveStatistics(); Object dataVal = null; dataVal = null; // loop over data for consolidation Method LinkedList<String> tempPath = new LinkedList<String>(dataPath); if (keyDef.isPoint()) { tempPath.add(method); } else { tempPath.add(CONSOLIDATION_SUM); } double input = -1; for (Map<String, Object> dataMap : serviceData) { // go to end of path & get variable input = -1; dataVal = getDataVal(dataMap, tempPath); if (dataVal != null) { // extract relevant data from end of path input = statToDouble(dataVal); if (input > -1) { // add to stat maker if relevant statsMaker.addValue(input); } } } // store in map if method is valid methodMapBuilder(method, statsMaker, statConsolidatedData); } // store stat methods' data on main consolidated map putOnPath(dataPath, consolidatedData, statConsolidatedData); } }
From source file:cc.kune.core.server.rack.filters.gwts.DelegatedRemoteServlet.java
@SuppressWarnings({ "unused", "rawtypes" }) @Override//from w w w .j a v a 2 s . co m protected Method getMethod(final GwtRpcCommLayerPojoRequest stressTestRequest) throws NoSuchMethodException, ClassNotFoundException { final int count = 0; final Class<?> paramClasses[] = new Class[stressTestRequest.getMethodParameters().size()]; final LinkedList<Class<?>> lstParameterClasses = new LinkedList<Class<?>>(); for (final String methodName : stressTestRequest.getParameterClassNames()) { lstParameterClasses.add(Class.forName(methodName)); } final Class[] arrParameterClasses = lstParameterClasses.toArray(new Class[0]); // patched here for kune return service.getClass().getMethod(stressTestRequest.getMethodName(), arrParameterClasses); }
From source file:net.duckling.ddl.service.authenticate.impl.UmtSsoLoginProvider.java
public Collection<Principal> commit(HttpServletRequest request) { String signedCredential = request.getParameter("signedCredential"); if (umtKey == null) { downloadUMTKey(request);//from w w w. j ava2s .c om loadUMTKeyFromLocal(request); } if (umtKey != null) { if (StringUtils.isNotEmpty(signedCredential)) { signedCredential = Base64Util.decodeBase64(signedCredential); try { SignedEnvelope signedData = SignedEnvelope.valueOf(signedCredential); if (signedData.verify(umtKey)) { UserPrincipal user = UserCredentialEnvelope.valueOf(signedData.getContent()).getUser(); LinkedList<Principal> principals = new LinkedList<Principal>(); principals.add(user); return principals; } else { LOG.error("UMT credential verify failed."); } } catch (Throwable e) { LOG.error("Signed credential is incorrent" + e.getMessage()); LOG.debug(signedCredential); LOG.debug("Detail is :", e); } } else { LOG.error("signedCredential is empty"); } } return null; }
From source file:documentToVector.spotlight.evaluation.external.DBpediaSpotlightClient.java
@Override public List<DBpediaResource> extract(Text text) throws AnnotationException { LOG.info("Querying API."); String spotlightResponse;/* w ww.j a v a 2 s.c o m*/ try { GetMethod getMethod = new GetMethod(API_URL + "rest/annotate/?" + "confidence=" + CONFIDENCE + "&support=" + SUPPORT + "&text=" + URLEncoder.encode(text.text(), "utf-8")); getMethod.addRequestHeader(new Header("Accept", "application/json")); spotlightResponse = request(getMethod); } catch (UnsupportedEncodingException e) { throw new AnnotationException("Could not encode text.", e); } assert spotlightResponse != null; JSONObject resultJSON = null; JSONArray entities = null; try { resultJSON = new JSONObject(spotlightResponse); entities = resultJSON.getJSONArray("Resources"); } catch (JSONException e) { throw new AnnotationException("Received invalid response from DBpedia Spotlight API."); } LinkedList<DBpediaResource> resources = new LinkedList<DBpediaResource>(); for (int i = 0; i < entities.length(); i++) { try { JSONObject entity = entities.getJSONObject(i); resources.add(new DBpediaResource(entity.getString("@URI"), Integer.parseInt(entity.getString("@support"))) ); } catch (JSONException e) { LOG.error("JSON exception " + e); } } return resources; }
From source file:calculators.Calculator.java
/** * Creates the HashMap that states which sample belongs to which sample * group. It can be done on index because the order of the samples in the * group file is the same as the order of the samples in the intensity file. * The group file does not contain the sample names so this is also the only * way to do it/* ww w . j av a 2s .com*/ * * @param group_file the group file * @param control the control group * @param target the target group * @throws FileNotFoundException * @throws IOException */ private void createGroupMap(final File group_file, final String control, final String target) throws FileNotFoundException, IOException { BufferedReader br = new BufferedReader(new FileReader(group_file.getAbsolutePath())); String line; LinkedList<String> temporaryMap = new LinkedList<>(); while ((line = br.readLine()) != null) { temporaryMap.add(line.split("\\s+")[1]); } Integer index = 0; for (String key : groupMap.keySet()) { groupMap.replace(key, temporaryMap.get(index)); index++; } controlSize = Collections.frequency(new ArrayList<>(groupMap.values()), control); targetSize = Collections.frequency(new ArrayList<>(groupMap.values()), target); }