List of usage examples for org.apache.commons.collections Bag add
boolean add(Object object);
From source file:com.otiliouine.flera.analyzer.SuccessionBasedDictionaryAnalyzer.java
private void addSuccessionInformations(String word) { char precedent = word.charAt(0); for (int index = 1; index < word.length(); index++) { char currentChar = word.charAt(index); Succession succession = new Succession(precedent, currentChar); Bag<Succession> successionBag = successionBags.get(precedent); if (successionBag == null) { successionBag = new HashBag<Succession>(); successionBags.put(precedent, successionBag); } else {/*from w w w .j a va2 s . c o m*/ successionBag.add(succession); } precedent = currentChar; } }
From source file:annis.sqlgen.TableAccessStrategy.java
protected Bag computeSourceTables() { Bag tables = new HashBag(); // hack to support table selections for ANNOTATE query if (node == null) { String[] tableNames = { NODE_TABLE, RANK_TABLE, COMPONENT_TABLE, NODE_ANNOTATION_TABLE, EDGE_ANNOTATION_TABLE }; for (String table : tableNames) tables.add(table); return tables; }//from ww w. j ava 2 s. c o m tables.add(tableName(NODE_ANNOTATION_TABLE), node.getNodeAnnotations().size()); if (node.getNodeAnnotations().isEmpty() && node.getNodeAnnotations().size() > 0) tables.add(tableName(NODE_ANNOTATION_TABLE)); tables.add(tableName(EDGE_ANNOTATION_TABLE), node.getEdgeAnnotations().size()); if (tables.getCount(tableName(RANK_TABLE)) == 0 && usesRankTable()) tables.add(tableName(RANK_TABLE)); if (tables.getCount(tableName(COMPONENT_TABLE)) == 0 && usesRankTable()) tables.add(tableName(COMPONENT_TABLE)); if (tables.getCount(tableName(NODE_TABLE)) == 0) tables.add(tableName(NODE_TABLE)); return tables; }
From source file:org.apache.maven.shared.jar.identification.exposers.TimestampExposer.java
public void expose(JarIdentification identification, JarAnalyzer jarAnalyzer) { List entries = jarAnalyzer.getEntries(); SimpleDateFormat tsformat = new SimpleDateFormat("yyyyMMdd", Locale.US); //$NON-NLS-1$ Bag timestamps = new HashBag(); Iterator it = entries.iterator(); while (it.hasNext()) { JarEntry entry = (JarEntry) it.next(); long time = entry.getTime(); String timestamp = tsformat.format(new Date(time)); timestamps.add(timestamp); }// www. j a v a 2 s . c o m it = timestamps.iterator(); String ts = ""; int tsmax = 0; while (it.hasNext()) { String timestamp = (String) it.next(); int count = timestamps.getCount(timestamp); if (count > tsmax) { ts = timestamp; tsmax = count; } } if (StringUtils.isNotEmpty(ts)) { identification.addVersion(ts); } }
From source file:org.codice.ddf.ui.searchui.query.model.Search.java
private void updateResultStatus(List<Result> results) { Bag hitSourceCount = new HashBag(); for (QueryStatus status : queryStatus.values()) { status.setResultCount(0);/* ww w. j av a 2s. co m*/ } for (Result result : results) { hitSourceCount.add(result.getMetacard().getSourceId()); } for (Object sourceId : hitSourceCount.uniqueSet()) { if (queryStatus.containsKey(sourceId)) { queryStatus.get(sourceId).setResultCount(hitSourceCount.getCount(sourceId)); } } }
From source file:org.rzo.yajsw.os.ms.win.w32.Pdh.java
/** * Enum object items./* w w w.j ava2 s . c o m*/ * * @param objectName * the object name * @param english * the english * * @return the list */ public static List enumObjectItems(String objectName, boolean english) { if (english) objectName = translate(objectName); Bag bag = new HashBag(); int pdhStatus = Pdhdll.ERROR_SUCCESS; Memory szCounterListBuffer = null; IntByReference dwCounterListSize = new IntByReference(); Memory szInstanceListBuffer = null; IntByReference dwInstanceListSize = new IntByReference(); String szThisInstance = null; // Determine the required buffer size for the data. pdhStatus = Pdhdll.INSTANCE.PdhEnumObjectItemsA(null, // real time // source null, // local machine objectName, // object to enumerate szCounterListBuffer, // pass NULL and 0 dwCounterListSize, // to get length required szInstanceListBuffer, // buffer size dwInstanceListSize, // Pdhdll.PERF_DETAIL_WIZARD, // counter detail level 0); if (pdhStatus == Pdhdll.PDH_MORE_DATA) { // Allocate the buffers and try the call again. szCounterListBuffer = new Memory(dwCounterListSize.getValue() * 4); szInstanceListBuffer = new Memory((dwInstanceListSize.getValue() * 4)); if ((szCounterListBuffer != null) && (szInstanceListBuffer != null)) { pdhStatus = Pdhdll.INSTANCE.PdhEnumObjectItemsA(null, // real // time // source null, // local machine objectName, // object to enumerate szCounterListBuffer, // buffer to receive counter // list dwCounterListSize, szInstanceListBuffer, // buffer to // receive // instance // list dwInstanceListSize, Pdhdll.PERF_DETAIL_WIZARD, // counter // detail // level 0); if (pdhStatus == Pdhdll.ERROR_SUCCESS) { // System.out.println ("Enumerating Processes:"); // Walk the instance list. The list can contain one // or more null-terminated strings. The last string // is followed by a second null-terminator. int i = 0; for (szThisInstance = szInstanceListBuffer.getString(0); szThisInstance != null && szThisInstance.length() > 0; i += szThisInstance.length() + 1, szThisInstance = szInstanceListBuffer.getString(i)) { // System.out.println( szThisInstance); bag.add(szThisInstance); } } else { System.out.println("PdhEnumObjectItems failed with " + Integer.toHexString(pdhStatus)); } } else { System.out.println("Unable to allocate buffers"); // pdhStatus = ERROR_OUTOFMEMORY; } } else { System.out.println("PdhEnumObjectItems failed with " + Integer.toHexString(pdhStatus)); } List result = new ArrayList(); for (Iterator it = bag.uniqueSet().iterator(); it.hasNext();) { String str = (String) it.next(); result.add(str); // System.out.println(str); for (int i = 1; i < bag.getCount(str); i++) { result.add(str + "#" + i); // System.out.println(str+"#"+i); } } return result; }
From source file:org.sipfoundry.sipxconfig.site.cdr.CdrReports.java
private List<CdrGraphBean> getCallDirectionGraphData(List<CdrCallDirectionDecorator> cdrdecorated) { List<CdrGraphBean> directionCalls = new ArrayList<CdrGraphBean>(); Bag directionCallsBag = new HashBag(); for (CdrCallDirectionDecorator cdr : cdrdecorated) { directionCallsBag.add(cdr.getCallDirection()); }/*w ww .j av a2s. c om*/ Set uniqueSetDirection = directionCallsBag.uniqueSet(); for (Object key : uniqueSetDirection) { CdrGraphBean bean = new CdrGraphBean((String) key, directionCallsBag.getCount(key)); directionCalls.add(bean); } return directionCalls; }
From source file:org.sipfoundry.sipxconfig.site.cdr.CdrReports.java
private List<CdrGraphBean> getActiveCallersData(List<Cdr> cdrs) { Bag bagCallers = new HashBag(); for (Cdr cdr : cdrs) { bagCallers.add(cdr.getCaller()); }/*from w ww . j a v a 2 s . c o m*/ List<CdrGraphBean> activeCallers = mostActiveExtensions(bagCallers); return activeCallers; }
From source file:org.sipfoundry.sipxconfig.site.cdr.CdrReports.java
private List<CdrGraphBean> getActiveReceiversData(List<Cdr> cdrs) { Bag bagReceivers = new HashBag(); for (Cdr cdr : cdrs) { bagReceivers.add(cdr.getCallee()); }/*from w w w.ja v a 2 s.c o m*/ List<CdrGraphBean> activeReceivers = mostActiveExtensions(bagReceivers); return activeReceivers; }
From source file:org.sipfoundry.sipxconfig.site.cdr.CdrReports.java
private List<CdrGraphBean> getTerminationCallsData(List<Cdr> cdrs, Locale locale) { List<CdrGraphBean> terminationCalls = new ArrayList<CdrGraphBean>(); Bag terminationCallsBag = new HashBag(); for (Cdr cdr : cdrs) { CdrDecorator cdrDecorator = new CdrDecorator(cdr, locale, getMessages()); terminationCallsBag.add(cdrDecorator.getTermination()); }/*from ww w .ja v a2 s.c o m*/ Set uniqueSetTermination = terminationCallsBag.uniqueSet(); for (Object key : uniqueSetTermination) { CdrGraphBean bean = new CdrGraphBean((String) key, terminationCallsBag.getCount(key)); terminationCalls.add(bean); } return terminationCalls; }
From source file:uk.ac.ebi.intact.dataexchange.cvutils.CvUpdater.java
/** * This method should check if the below constraint is violated * CONSTRAINT_INDEX_0 ON PUBLIC.IA_CONTROLLEDVOCAB(OBJCLASS, SHORTLABEL) * * @param allValidCvs List of all Uniq Cvs * @return true if violated or false if not *//*from w w w.j av a2 s .c o m*/ public boolean isConstraintViolated(List<CvDagObject> allValidCvs) { if (allValidCvs == null) { throw new NullPointerException("Cvs Null"); } Bag hashBag = new HashBag(); for (CvDagObject cvDag : allValidCvs) { String primaryKey = cvDag.getObjClass().toString() + ":" + cvDag.getShortLabel(); if (log.isTraceEnabled()) { log.trace("PrimaryKey: " + primaryKey); } hashBag.add(primaryKey); } for (Object aHashBag : hashBag) { String s = (String) aHashBag; if (hashBag.getCount(s) > 1) { if (log.isDebugEnabled()) { log.debug("Constraint violated by " + s); } return true; } } return false; }