List of usage examples for java.util Vector iterator
public synchronized Iterator<E> iterator()
From source file:org.apache.ctakes.lvg.ae.LvgAnnotator.java
private void setLemma(WordToken wordAnnotation, String word, JCas jcas) throws AnalysisEngineProcessException { // apply LVG processing to get lemmas // key = lemma string, value = Set of POS tags Map<String, Set<String>> lemmaMap = null; if (useLemmaCache) { Set<?> lemmaSet = lemmaCacheMap.get(word); if (lemmaSet == null) { // logger.info("["+ word+ // "] was not found in LVG lemma cache."); } else {/*from w w w. j av a 2s. c om*/ lemmaMap = new HashMap<>(); Iterator<?> lemmaItr = lemmaSet.iterator(); while (lemmaItr.hasNext()) { LemmaLocalClass l = (LemmaLocalClass) lemmaItr.next(); lemmaMap.put(l.word, l.posSet); } } } if (lemmaMap == null) { lemmaMap = new HashMap<>(); try { Vector<?> lexItems = lvgLexItem.MutateLexItem(word); Iterator<?> lexItemItr = lexItems.iterator(); while (lexItemItr.hasNext()) { LexItem li = (LexItem) lexItemItr.next(); Category c = li.GetTargetCategory(); String lemmaStr = li.GetTargetTerm(); long[] bitValues = Category.ToValuesArray(c.GetValue()); for (int i = 0; i < bitValues.length; i++) { // note that POS is Xerox tagset String lemmaPos = Category.ToName(bitValues[i]); // convert Xerox tagset to PennTreebank tagset String treebankTag = xeroxTreebankMap.get(lemmaPos); if (treebankTag != null) { Set<String> posSet = null; if (lemmaMap.containsKey(lemmaStr)) { posSet = lemmaMap.get(lemmaStr); } else { posSet = new HashSet<>(); } posSet.add(treebankTag); lemmaMap.put(lemmaStr, posSet); } } } } catch (Exception e) { throw new AnalysisEngineProcessException(e); } } // add lemma information to CAS // FSArray lemmas = new FSArray(jcas, lemmaMap.keySet().size()); Collection<Lemma> lemmas = new ArrayList<>(lemmaMap.keySet().size()); Iterator<String> lemmaStrItr = lemmaMap.keySet().iterator(); while (lemmaStrItr.hasNext()) { String form = lemmaStrItr.next(); Set<?> posTagSet = lemmaMap.get(form); Iterator<?> posTagItr = posTagSet.iterator(); while (posTagItr.hasNext()) { String pos = (String) posTagItr.next(); // part of speech Lemma lemma = new Lemma(jcas); lemma.setKey(form); lemma.setPosTag(pos); lemmas.add(lemma); } } Lemma[] lemmaArray = lemmas.toArray(new Lemma[lemmas.size()]); FSList fsList = ListFactory.buildList(jcas, lemmaArray); wordAnnotation.setLemmaEntries(fsList); }
From source file:nl.nn.adapterframework.jdbc.XmlQuerySender.java
private boolean existLob(Vector columns) { Iterator iter = columns.iterator(); while (iter.hasNext()) { Column column = (Column) iter.next(); if (column.getType().equalsIgnoreCase(TYPE_BLOB) || column.getType().equalsIgnoreCase(TYPE_CLOB)) { return true; }/* w ww. ja va2s.c om*/ } return false; }
From source file:org.apache.james.mailetcontainer.impl.JamesMailetContext.java
@Override public Iterator<String> getAttributeNames() { Vector<String> names = new Vector<String>(); for (Enumeration<String> e = attributes.keys(); e.hasMoreElements();) { names.add(e.nextElement());/*from w w w . j av a 2 s . c o m*/ } return names.iterator(); }
From source file:org.kuali.rice.krad.service.impl.PersistenceServiceOjbImpl.java
/** * * @see org.kuali.rice.krad.service.PersistenceService#allForeignKeyValuesPopulatedForReference(org.kuali.rice.krad.bo.BusinessObject, * java.lang.String)/*from ww w .j av a 2 s . c o m*/ */ @Override public boolean allForeignKeyValuesPopulatedForReference(PersistableBusinessObject bo, String referenceName) { boolean allFkeysHaveValues = true; // yelp if nulls were passed in if (bo == null) { throw new IllegalArgumentException("The Class passed in for the BusinessObject argument was null."); } if (StringUtils.isBlank(referenceName)) { throw new IllegalArgumentException( "The String passed in for the referenceName argument was null or empty."); } PropertyDescriptor propertyDescriptor = null; // make sure the attribute exists at all, throw exception if not try { propertyDescriptor = PropertyUtils.getPropertyDescriptor(bo, referenceName); } catch (Exception e) { throw new RuntimeException(e); } if (propertyDescriptor == null) { throw new ReferenceAttributeDoesntExistException("Requested attribute: '" + referenceName + "' does not exist " + "on class: '" + bo.getClass().getName() + "'."); } // get the class of the attribute name Class referenceClass = getBusinessObjectAttributeClass(bo.getClass(), referenceName); if (referenceClass == null) { referenceClass = propertyDescriptor.getPropertyType(); } // make sure the class of the attribute descends from BusinessObject, // otherwise throw an exception if (!PersistableBusinessObject.class.isAssignableFrom(referenceClass)) { throw new ObjectNotABusinessObjectRuntimeException("Attribute requested (" + referenceName + ") is of class: " + "'" + referenceClass.getName() + "' and is not a " + "descendent of BusinessObject. Only descendents of BusinessObject " + "can be used."); } // make sure the attribute designated is listed as a // reference-descriptor // on the clazz specified, otherwise throw an exception (OJB); ClassDescriptor classDescriptor = getClassDescriptor(bo.getClass()); ObjectReferenceDescriptor referenceDescriptor = classDescriptor .getObjectReferenceDescriptorByName(referenceName); if (referenceDescriptor == null) { throw new ReferenceAttributeNotAnOjbReferenceException( "Attribute requested (" + referenceName + ") is not listed " + "in OJB as a reference-descriptor for class: '" + bo.getClass().getName() + "'"); } // get the list of the foreign-keys for this reference-descriptor // (OJB) Vector fkFields = referenceDescriptor.getForeignKeyFields(); Iterator fkIterator = fkFields.iterator(); // walk through the list of the foreign keys, get their types while (fkIterator.hasNext()) { // get the field name of the fk & pk field String fkFieldName = (String) fkIterator.next(); // get the value for the fk field Object fkFieldValue = null; try { fkFieldValue = PropertyUtils.getSimpleProperty(bo, fkFieldName); } // if we cant retrieve the field value, then // it doesnt have a value catch (IllegalAccessException e) { return false; } catch (InvocationTargetException e) { return false; } catch (NoSuchMethodException e) { return false; } // test the value if (fkFieldValue == null) { return false; } else if (String.class.isAssignableFrom(fkFieldValue.getClass())) { if (StringUtils.isBlank((String) fkFieldValue)) { return false; } } } return allFkeysHaveValues; }
From source file:edu.tufts.osidimpl.repository.fedora_2_2.Repository.java
private void loadFedoraObjectAssetTypes() { try {//from w w w. j ava 2s . c om // System.out.println("fedora types " + fedoraProperties.getProperty("fedora.types")); Vector fedoraTypesVector = FedoraUtils.stringToVector(fedoraProperties.getProperty("fedora.types")); Iterator i = fedoraTypesVector.iterator(); while (i.hasNext()) { createFedoraObjectAssetType((String) i.next()); } } catch (Throwable t) { t.printStackTrace(); System.out.println("Unable to load fedora types" + t.getMessage()); } }
From source file:org.kuali.rice.krad.service.impl.PersistenceServiceOjbImpl.java
private void linkObjectsWithCircularReferenceCheck(Object persistableObject, Set referenceSet) { if (ObjectUtils.isNull(persistableObject) || referenceSet.contains(persistableObject)) { return;/* w w w .ja va 2 s. co m*/ } referenceSet.add(persistableObject); ClassDescriptor classDescriptor = getClassDescriptor(persistableObject.getClass()); String className = null; String fieldName = null; try { // iterate through all object references for the persistableObject Vector objectReferences = classDescriptor.getObjectReferenceDescriptors(); for (Iterator iter = objectReferences.iterator(); iter.hasNext();) { ObjectReferenceDescriptor referenceDescriptor = (ObjectReferenceDescriptor) iter.next(); // get the actual reference object className = persistableObject.getClass().getName(); fieldName = referenceDescriptor.getAttributeName(); Object referenceObject = PropertyUtils.getProperty(persistableObject, fieldName); if (ObjectUtils.isNull(referenceObject) || referenceSet.contains(referenceObject)) { continue; } // recursively link object linkObjectsWithCircularReferenceCheck(referenceObject, referenceSet); // iterate through the keys for the reference object and set // value FieldDescriptor[] refFkNames = referenceDescriptor.getForeignKeyFieldDescriptors(classDescriptor); ClassDescriptor refCld = getClassDescriptor(referenceDescriptor.getItemClass()); FieldDescriptor[] refPkNames = refCld.getPkFields(); Map objFkValues = new HashMap(); for (int i = 0; i < refPkNames.length; i++) { objFkValues.put(refFkNames[i].getAttributeName(), ObjectUtils.getPropertyValue(referenceObject, refPkNames[i].getAttributeName())); } for (int i = 0; i < refFkNames.length; i++) { FieldDescriptor fkField = refFkNames[i]; String fkName = fkField.getAttributeName(); // if the fk from object and use if main object does not // have value Object fkValue = null; if (objFkValues.containsKey(fkName)) { fkValue = objFkValues.get(fkName); } // if fk is set in main object, take value from there Object mainFkValue = ObjectUtils.getPropertyValue(persistableObject, fkName); if (ObjectUtils.isNotNull(mainFkValue) && StringUtils.isNotBlank(mainFkValue.toString())) { fkValue = mainFkValue; } else if (ObjectUtils.isNull(fkValue) || StringUtils.isBlank(fkValue.toString())) { // find the value from one of the other reference // objects for (Iterator iter2 = objectReferences.iterator(); iter2.hasNext();) { ObjectReferenceDescriptor checkDescriptor = (ObjectReferenceDescriptor) iter2.next(); fkValue = getReferenceFKValue(persistableObject, checkDescriptor, fkName); if (ObjectUtils.isNotNull(fkValue) && StringUtils.isNotBlank(fkValue.toString())) { break; } } } // set the fk value if (ObjectUtils.isNotNull(fkValue)) { fieldName = refPkNames[i].getAttributeName(); ObjectUtils.setObjectProperty(referenceObject, fieldName, fkValue.getClass(), fkValue); // set fk in main object if (ObjectUtils.isNull(mainFkValue)) { ObjectUtils.setObjectProperty(persistableObject, fkName, fkValue.getClass(), fkValue); } } } } } catch (NoSuchMethodException e) { throw new IntrospectionException("no setter for property '" + className + "." + fieldName + "'", e); } catch (IllegalAccessException e) { throw new IntrospectionException("problem accessing property '" + className + "." + fieldName + "'", e); } catch (InvocationTargetException e) { throw new IntrospectionException( "problem invoking getter for property '" + className + "." + fieldName + "'", e); } }
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Generate a pie graph representing test counts for each product area. * * @param suites List of test suites * @param areas List of product areas * //from ww w .jav a 2 s . com * @return Pie graph representing build execution times across all builds */ public static final JFreeChart getAverageAreaTestCountChart(Vector<CMnDbBuildData> builds, Vector<CMnDbTestSuite> suites, Vector<CMnDbFeatureOwnerData> areas) { JFreeChart chart = null; // Collect the average of all test types Hashtable countAvg = new Hashtable(); DefaultPieDataset dataset = new DefaultPieDataset(); if ((suites != null) && (suites.size() > 0)) { // Collect test data for each of the suites in the list Enumeration suiteList = suites.elements(); while (suiteList.hasMoreElements()) { // Process the data for the current suite CMnDbTestSuite suite = (CMnDbTestSuite) suiteList.nextElement(); Integer testCount = new Integer(suite.getTestCount()); CMnDbFeatureOwnerData area = null; // Iterate through each product area to determine who owns this suite CMnDbFeatureOwnerData currentArea = null; Iterator iter = areas.iterator(); while (iter.hasNext()) { currentArea = (CMnDbFeatureOwnerData) iter.next(); if (currentArea.hasFeature(suite.getGroupName())) { Integer avgValue = null; String areaName = currentArea.getDisplayName(); if (countAvg.containsKey(areaName)) { Integer oldAvg = (Integer) countAvg.get(areaName); avgValue = oldAvg + testCount; } else { avgValue = testCount; } countAvg.put(areaName, avgValue); } } } // while list has elements // Populate the data set with the average values for each metric Enumeration keys = countAvg.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); Integer total = (Integer) countAvg.get(key); Integer avg = new Integer(total.intValue() / builds.size()); dataset.setValue(key, avg); } } // if list has elements // API: ChartFactory.createPieChart(title, data, legend, tooltips, urls) chart = ChartFactory.createPieChart("Avg Test Count by Area", dataset, true, true, false); // get a reference to the plot for further customization... PiePlot plot = (PiePlot) chart.getPlot(); chartFormatter.formatAreaChart(plot, "tests"); return chart; }
From source file:org.kepler.sms.SemanticTypeManager.java
/** * Removes all objects from this manager that have no associated types *///from w w w .j a va 2 s . c o m public void pruneUntypedObjects() { Vector<Object> removeList = new Vector<Object>(); Iterator<Object> objsIter = getObjects().iterator(); while (objsIter.hasNext()) { Object obj = objsIter.next(); Vector<Object> types = getTypes(obj); if (types.size() == 0) removeList.add(obj); } Iterator<Object> iter = removeList.iterator(); while (iter.hasNext()) removeObject(iter.next()); }
From source file:org.ecoinformatics.seek.sms.AnnotationEngine.java
/** *@param classname//from w w w .j a v a 2 s. c o m * the classname (as a term/keyword) to search for *@param approx * if true, find approximate term matches, and if false, do exact * matches Searches the ontology matching the term and for * matches, finds annotated items. For example, * search("RichnessIndex") finds all actors that instantiate * either the class named "RichnessIndex" or one of its * subclasses. *@return Description of the Return Value */ public Vector<NamedObj> search(String classname, boolean approx) { if (isDebugging) log.debug("search(" + classname + ", " + approx + ")"); // check if valid concept name if (!isValidClass(classname, approx)) { debug("didn't find classname", true); return new Vector<NamedObj>(); } Vector<NamedObj> result = new Vector<NamedObj>(); // find all the matching class names and their subclasses Vector<OntClass> classes = getMatchingClassNames(classname, approx); Iterator<OntClass> iter = classes.iterator(); while (iter.hasNext()) { // find the matching lsids for the class name OntClass cls = iter.next(); Vector<Object> ids = getMatchingAnnotatedItemIds(cls); Iterator<Object> idIter = ids.iterator(); while (idIter.hasNext()) { // get the associated objects NamedObj obj = _libService.getData(idIter.next().toString()); if (obj != null && !result.contains(obj)) { result.add(obj); } // add the results } } return result; }
From source file:sos.scheduler.job.JobSchedulerHttpPostJob.java
public int postFile(File inputFile, String inputFileSpec, File outputFile, String contentType, String url) throws Exception { int rc = 0;// w ww.j ava 2s . c om try { if (inputFile.isDirectory()) { Vector filelist = SOSFile.getFilelist(inputFile.getCanonicalPath(), inputFileSpec, 0); Iterator iterator = filelist.iterator(); while (iterator.hasNext()) { rc = this.postFile((File) iterator.next(), inputFileSpec, outputFile, contentType, url); } return rc; } else { PostMethod post = new PostMethod(url); String content = SOSFile.readFile(inputFile); getLogger().debug9("post before replacements: " + content); content = mergedVariables.substitute(content); getLogger().debug5("Posting: " + content); StringRequestEntity req = new StringRequestEntity(content); // post.setRequestEntity(new InputStreamRequestEntity(new FileInputStream(inputFile), inputFile.length())); post.setRequestEntity(req); post.setRequestHeader("Content-type", contentType); HttpClient httpClient = new HttpClient(); if (this.getTimeout() > 0) { HttpConnectionManager httpManager = httpClient.getHttpConnectionManager(); HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams(); httpParams.setConnectionTimeout(this.getTimeout() * 1000); httpManager.setParams(httpParams); } rc = httpClient.executeMethod(post); if (outputFile != null) logResponse(inputFile, outputFile, post.getResponseBodyAsStream()); return rc; } } catch (Exception e) { throw new Exception("error occurred in HTTP POST: " + e.getMessage()); } }