List of usage examples for org.apache.commons.collections.map LinkedMap put
public Object put(Object key, Object value)
From source file:de.innovationgate.wgpublisher.webtml.portlet.TMLPortlet.java
protected static void addEventToQueue(PortletEvent event, HttpSession session) { LinkedMap events = getFiredEventsQueue(session); synchronized (events) { event.retrieveIndex();//from w w w. j a va2s. c o m events.put(new Long(event.getIndex()), event); while (events.size() > EVENTQUEUE_MAX_SIZE) { events.remove(events.firstKey()); } } }
From source file:edu.isi.pfindr.learn.util.PairsFileIO.java
public static LinkedMap readDistinctElementsIntoMap(String pairsFilename) { File pairsFile = new File(pairsFilename); LinkedMap phenotypeIndexMap = new LinkedMap(); try {/* w w w. j a va 2 s.c om*/ List<String> fileWithPairs = FileUtils.readLines(pairsFile); //Read one at a time to consume less memory int index = 0; for (String s : fileWithPairs) { //distinctElementsSet.add(s.split("\t")[0]); //distinctElementsSet.add(s.split("\t")[1]); if (!phenotypeIndexMap.containsKey(s.split("\t")[0])) { phenotypeIndexMap.put(s.split("\t")[0], index); index++; } } for (String s : fileWithPairs) { if (!phenotypeIndexMap.containsKey(s.split("\t")[1])) { phenotypeIndexMap.put(s.split("\t")[1], index); index++; } } System.out.println("Index " + index); } catch (IOException e) { System.out.println("Error while reading/writing file with pairs" + e.getMessage()); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return phenotypeIndexMap; }
From source file:de.cosmocode.rendering.CollectionRenderer.java
private Renderer append(Object value) { if (mode == Mode.LIST) { peekList().add(value);/* w ww. ja va 2 s . c om*/ } else if (mode == Mode.KEY) { final LinkedMap map = peekMap(); map.put(map.lastKey(), value); mode = Mode.MAP; } else { throw new RenderingException(String.format("Appending only works in %s and %s", Mode.LIST, Mode.KEY)); } return this; }
From source file:de.cosmocode.rendering.CollectionRenderer.java
@Override public Renderer endList() throws RenderingException { if (mode == Mode.LIST) { final List<Object> peek = peekList(); stack.pop();/*from w ww .j a va2 s . c o m*/ if (stack.isEmpty()) { mode = Mode.DONE; build = peek; } else if (peekIsList()) { mode = Mode.LIST; peekList().add(peek); } else if (peekIsMap()) { mode = Mode.MAP; final LinkedMap map = peekMap(); map.put(map.lastKey(), peek); } else { throw new RenderingException("Unknown state"); } return this; } else { throw new RenderingException(String.format("endList is not allowed when in %s mode", mode)); } }
From source file:de.cosmocode.rendering.CollectionRenderer.java
@Override public Renderer endMap() throws RenderingException { if (mode == Mode.MAP) { final LinkedMap peek = peekMap(); stack.pop();// www. j a v a 2 s .c o m if (stack.isEmpty()) { mode = Mode.DONE; build = peek; } else if (peekIsList()) { mode = Mode.LIST; peekList().add(peek); } else if (peekIsMap()) { mode = Mode.MAP; final LinkedMap map = peekMap(); map.put(map.lastKey(), peek); } else { throw new RenderingException("Unknown state"); } return this; } else { throw new RenderingException(String.format("endMap is not allowed when in %s mode", mode)); } }
From source file:de.innovationgate.webgate.api.templates.QueryableSource.java
public Map find(String type, String query, Map parameters) throws WGAPIException { List results = find(query);/* w w w . j av a 2 s .c o m*/ if (results == null) { return null; } LinkedMap resultMap = new LinkedMap(); int keyNr = 0; Iterator resultsIt = results.iterator(); Object result; while (resultsIt.hasNext()) { result = resultsIt.next(); resultMap.put(new QueryableSourceKey(++keyNr), result); } return resultMap; }
From source file:cn.com.p2p.loan.service.impl.LoanSearchServiceImpl.java
/** * <p>//from w ww.j a v a2s . co m * ??? * </p> * .<br> * author<br> * =================================== * @param pfmTenantDepartment ??? * @return ????? */ public LinkedMap getGuaranteeCorporationInfo() { PfmTenantDepartmentCriteria criteria = new PfmTenantDepartmentCriteria(); criteria.setVilidFlag(Constants.VALID_FLAG_VALID, Operator.equal); criteria.setDepartmentType(DepartmentTypeEnum.DEPARTMENT_TYPE_3.getCode(), Operator.equal); // ??? List<PfmTenantDepartment> pfmTenantDepartment = pfmTenantDepartmentManageService .findDepartmentAll(criteria); // ??? LinkedMap if (pfmTenantDepartment != null && pfmTenantDepartment.size() > 0) { LinkedMap map = new LinkedMap(); for (PfmTenantDepartment p : pfmTenantDepartment) { map.put(p.getDepartmentCd(), p.getDepartmentName()); } return map; } else { return null; } }
From source file:de.innovationgate.wgpublisher.WGAUsageStatistics.java
public void usageTestData() { LinkedMap day = new LinkedMap(); HourStatistic stat = new HourStatistic(); for (int i = 0; i <= 23; i++) { stat.increment();/*from ww w . j a v a2 s. com*/ day.put(new Integer(i), stat); } _requestsPerDay.clear(); _requestsPerDay.put("01.01.2006", day); _requestsPerDay.put("02.01.2006", day); _requestsPerDay.put("03.01.2006", day); }
From source file:edu.isi.pfindr.learn.util.PairsFileIO.java
public LinkedMap readOriginalFileWithGoldClass(String originalTestFile) { //String originalTestFile = "data/cohort1/bio_nlp/cohort1_s_test.txt"; //Read the test file String thisLine;/*from w w w . j a v a2 s. co m*/ String[] lineArray; BufferedReader br = null; LinkedMap originalTestClassMap = new LinkedMap(); try { br = new BufferedReader(new FileReader(originalTestFile)); while ((thisLine = br.readLine()) != null) { thisLine = thisLine.trim(); if (thisLine.equals("")) continue; lineArray = thisLine.split("\t"); originalTestClassMap.put(lineArray[3], lineArray[1]); //phenotype, class //System.out.println("Adding "+ lineArray[1] + " : " + lineArray[3]); } } catch (IOException io) { try { if (br != null) br.close(); io.printStackTrace(); } catch (IOException e) { System.out.println("Problem occured while closing output stream while writing file " + br); e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } return originalTestClassMap; }
From source file:edu.isi.pfindr.learn.util.PairsFileIO.java
public void readDistinctElementsFromPairsAddClass(String pairsFilepath) { //readDistinctElementsIntoList List<Object> distinctElements = readDistinctElementsIntoList(pairsFilepath); System.out.println("Size of distinctElements" + distinctElements.size()); for (int i = 0; i < distinctElements.size(); i++) { System.out.println("distinctElements " + i + " " + distinctElements.get(i)); }//from ww w . ja v a 2 s .c o m //get class for those distinct elements from original cohort file String originalFile = "data/cohort1/bio_nlp/cohort1_s.txt"; BufferedReader br = null; String thisLine; String[] lineArray; LinkedMap originalMap = new LinkedMap(); BufferedWriter distinctPriorityPairsWriter = null; try { br = new BufferedReader(new FileReader(originalFile)); while ((thisLine = br.readLine()) != null) { thisLine = thisLine.trim(); if (thisLine.equals("")) continue; lineArray = thisLine.split("\t"); originalMap.put(lineArray[3], lineArray[1]); } //write distinct elements with class to an output file StringBuffer outfileBuffer = new StringBuffer(); for (int i = 0; i < distinctElements.size(); i++) outfileBuffer.append(distinctElements.get(i)).append("\t") .append(originalMap.get(distinctElements.get(i)) + "\n"); distinctPriorityPairsWriter = new BufferedWriter( new FileWriter(pairsFilepath.split("\\.")[0] + "_distinct_with_class.txt")); distinctPriorityPairsWriter.append(outfileBuffer.toString()); outfileBuffer.setLength(0); distinctPriorityPairsWriter.flush(); } catch (IOException io) { try { if (br != null) br.close(); io.printStackTrace(); } catch (IOException e) { System.out.println("Problem occured while closing output stream " + br); e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } }