List of usage examples for java.util Vector isEmpty
public synchronized boolean isEmpty()
From source file:org.ecoinformatics.seek.datasource.EcogridCompressedDataCacheItem.java
/** * This method will get a file path which matches the given file extension * in unzipped file list. If no match, null will be returned * //from ww w .j ava 2s . c om * @param fileExtension * String * @return String[] */ public String[] getUnzippedFilePath(String fileExtension) { String[] result = null; if (unCompressedFileList == null || fileExtension == null) { return result; } int length = unCompressedFileList.length; Vector tmp = new Vector(); for (int i = 0; i < length; i++) { String fileName = (String) unCompressedFileList[i]; if (fileName != null) { log.debug("file name in file list is " + fileName); int dotPosition = fileName.lastIndexOf(FILEEXTENSIONSEP); String extension = fileName.substring(dotPosition + 1, fileName.length()); log.debug("The file extension for file name " + fileName + " in file list is " + extension); if (extension.equals(fileExtension)) { // store the file path into a tmp array tmp.add(unCompressedFilePath + File.separator + fileName); } } } // transfer vector in array if (!tmp.isEmpty()) { int len = tmp.size(); result = new String[len]; for (int j = 0; j < len; j++) { result[j] = (String) tmp.elementAt(j); log.debug("The file path which math file extension " + fileExtension + " is " + result[j]); } } return result; }
From source file:org.ecoinformatics.seek.ecogrid.quicksearch.SearchScope.java
/** * Constructor//from w w w . ja va2 s . c o m * * @param nameSpace * String the namesapce need to be searched * @param metadataSpecificationClassName * String the metadata specification class name for the namespace * @param endPoints * Vector url need to go searching * @throws NULLSearchNamespaceException * @throws NoMetadataSpecificationClassException */ public SearchScope(String nameSpace, String metadataSpecificationClassName, Vector endPoints) throws NULLSearchNamespaceException, NULLEcogridConfigurationException, NoMetadataSpecificationClassException, NoSearchEndPointException { if (nameSpace == null || nameSpace.equals("")) { throw new NULLSearchNamespaceException("Search namespace is null"); } this.namespace = nameSpace; log.debug("The namespace in SearchScope is " + namespace); if (metadataSpecificationClassName == null || metadataSpecificationClassName.trim().equals("")) { throw new NoMetadataSpecificationClassException("No " + "metadataSpecificationClassName is given"); } this.metadataSpecificationClassName = metadataSpecificationClassName; metadataSpecification = generateMetadataSpecification(); if (endPoints == null || endPoints.isEmpty()) { throw new NoSearchEndPointException("No end points in Search Scope"); } endPointsVector = endPoints; }
From source file:at.gv.egiz.pdfas.lib.settings.Settings.java
public Vector<String> getFirstLevelKeys(String prefix) { String mPrefix = prefix.endsWith(".") ? prefix : prefix + "."; Iterator<Object> keyIterator = properties.keySet().iterator(); Vector<String> valueMap = new Vector<String>(); while (keyIterator.hasNext()) { String key = keyIterator.next().toString(); if (key.startsWith(prefix)) { int keyIdx = key.indexOf('.', mPrefix.length()) > 0 ? key.indexOf('.', mPrefix.length()) : key.length();// www.ja va 2s . c o m String firstLevels = key.substring(0, keyIdx); if (!valueMap.contains(firstLevels)) { valueMap.add(firstLevels); } } } if (valueMap.isEmpty()) { return null; } return valueMap; }
From source file:edu.ucsb.nceas.MCTestCase.java
protected String getAccessBlock(Vector<String> accessRules, String permOrder) { String accessBlock = "<access " + "authSystem=\"ldap://ldap.ecoinformatics.org:389/dc=ecoinformatics,dc=org\"" + " order=\"" + permOrder + "\"" + " scope=\"document\"" + ">"; // adding rules if (accessRules != null && !accessRules.isEmpty()) { for (int i = 0; i < accessRules.size(); i++) { String rule = (String) accessRules.elementAt(i); accessBlock += rule;//from w w w . ja v a 2s . c o m } } accessBlock += "</access>"; return accessBlock; }
From source file:com.skywomantechnology.app.guildviewer.sync.GuildViewerSyncAdapter.java
/** * Converts the ContentValue vector to an array and bulk inserts them * then clears out the vector array/* w ww . j av a 2 s . c om*/ * * @param cVVector records to insert * @return int count of how many were actually inserted */ private int insertNews(Vector<ContentValues> cVVector) { int insertCount = 0; if (cVVector == null || cVVector.isEmpty()) return insertCount; int numRecordsToInsert = cVVector.size(); if (numRecordsToInsert > 0) { // convert to an array for the bulk insert to work with ContentValues[] cvArray = new ContentValues[cVVector.size()]; cVVector.toArray(cvArray); // inserts into the storage insertCount = mContext.getContentResolver().bulkInsert(NewsEntry.CONTENT_URI, cvArray); // clear out the loaded records so there are not duplicates cVVector.clear(); } return insertCount; }
From source file:org.mahasen.node.MahasenNodeManager.java
/** * @param propertyName/* w w w. j a va2s.c o m*/ * @param propertyValue * @return * @throws InterruptedException */ public Vector<Id> getSearchResults(String propertyName, String propertyValue) throws InterruptedException { final Vector<Id> resultIds = new Vector<Id>(); // block until we get a result or time out. final BlockFlag blockFlag = new BlockFlag(true, 1500); mahasenPastTreeApp.getSearchResults(propertyName, propertyValue, new Continuation() { public void receiveResult(Object result) { if (result != null) { if (resultIds.isEmpty()) { resultIds.addAll((Vector<Id>) result); } else { Vector<Id> tempIdSet = (Vector<Id>) result; for (Id id : tempIdSet) { if (!resultIds.contains(id)) { resultIds.add(id); } } } } blockFlag.unblock(); } public void receiveException(Exception exception) { System.out.println(" Result not found "); blockFlag.unblock(); } }); while (blockFlag.isBlocked()) { env.getTimeSource().sleep(10); } return resultIds; }
From source file:org.mahasen.node.MahasenNodeManager.java
/** * @param propertyName//from w ww. j a va 2s . com * @param initialValue * @param lastValue * @return * @throws InterruptedException */ public Vector<Id> getRangeSearchResults(String propertyName, String initialValue, String lastValue) throws InterruptedException { final Vector<Id> resultIds = new Vector<Id>(); // block until we get a result or time out. final BlockFlag blockFlag = new BlockFlag(true, 1500); mahasenPastTreeApp.getRangeSearchResults(propertyName, initialValue, lastValue, new Continuation() { public void receiveResult(Object result) { if (result != null) { if (resultIds.isEmpty()) { resultIds.addAll((Vector<Id>) result); } else { Vector<Id> tempIdSet = (Vector<Id>) result; for (Id id : tempIdSet) { if (!resultIds.contains(id)) { resultIds.add(id); } } } } blockFlag.unblock(); } public void receiveException(Exception exception) { System.out.println(" Result not found "); blockFlag.unblock(); } }); while (blockFlag.isBlocked()) { env.getTimeSource().sleep(10); } return resultIds; }
From source file:edu.mayo.informatics.lexgrid.convert.directConversions.obo1_2.OBO2LGDynamicMapHolders.java
public void storeConceptAndRelations(OBOResourceReader oboReader, OBOTerm oboTerm, CodingScheme csclass) { try {//from ww w .j a v a2s. c om // OBO Term should not be null and either one of ID or term name // should be there. OBOContents contents = oboReader.getContents(false, false); if ((oboTerm != null) && ((!OBO2LGUtils.isNull(oboTerm.getId())) || (!OBO2LGUtils.isNull(oboTerm.getName())))) { propertyCounter = 0; Entity concept = new Entity(); concept.setEntityType(new String[] { EntityTypes.CONCEPT.toString() }); concept.setEntityCodeNamespace(csclass.getCodingSchemeName()); if (!OBO2LGUtils.isNull(oboTerm.getId())) concept.setEntityCode(oboTerm.getId()); else concept.setEntityCode(oboTerm.getName()); String termDesc = ""; if (!OBO2LGUtils.isNull(oboTerm.getName())) termDesc = oboTerm.getName(); else termDesc = oboTerm.getId(); EntityDescription ed = new EntityDescription(); ed.setContent(termDesc); concept.setEntityDescription(ed); if (oboTerm.isObsolete()) { concept.setIsActive(new Boolean(false)); } Presentation tp = new Presentation(); Text txt = new Text(); txt.setContent(termDesc); tp.setValue(txt); tp.setIsPreferred(new Boolean(true)); tp.setPropertyName(OBO2LGConstants.PROPERTY_TEXTPRESENTATION); String preferredPresetationID = OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter); tp.setPropertyId(preferredPresetationID); concept.getPresentationAsReference().add(tp); if (!OBO2LGUtils.isNull(oboTerm.getComment())) { Comment comment = new Comment(); txt = new Text(); txt.setContent(OBO2LGUtils.removeInvalidXMLCharacters(oboTerm.getComment(), null)); comment.setValue(txt); comment.setPropertyName(OBO2LGConstants.PROPERTY_COMMENT); comment.setPropertyId(OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter)); concept.getCommentAsReference().add(comment); } if (!OBO2LGUtils.isNull(oboTerm.getDefinition())) { Definition defn = new Definition(); txt = new Text(); txt.setContent(OBO2LGUtils.removeInvalidXMLCharacters(oboTerm.getDefinition(), null)); defn.setValue(txt); defn.setPropertyName(OBO2LGConstants.PROPERTY_DEFINITION); defn.setPropertyId(OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter)); concept.getDefinitionAsReference().add(defn); OBOAbbreviations abbreviations = contents.getOBOAbbreviations(); addOBODbxrefAsSource(defn, oboTerm.getDefinitionSources(), abbreviations); } addPropertyAttribute(oboTerm.getSubset(), concept, OBO2LGConstants.PROPERTY_SUBSET); Vector<String> dbxref_src_vector = OBODbxref.getSourceAndSubRefAsVector(oboTerm.getDbXrefs()); addPropertyAttribute(dbxref_src_vector, concept, "xref"); // Add Synonyms as presentations Vector<OBOSynonym> synonyms = oboTerm.getSynonyms(); if ((synonyms != null) && (!synonyms.isEmpty())) { for (OBOSynonym synonym : synonyms) { Presentation ip = new Presentation(); txt = new Text(); txt.setContent(synonym.getText()); ip.setValue(txt); ip.setPropertyName(OBO2LGConstants.PROPERTY_SYNONYM); String synPresID = OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter); ip.setPropertyId(synPresID); concept.getPresentationAsReference().add(ip); String scope = synonym.getScope(); if (scope != null && scope.length() > 0) ip.setDegreeOfFidelity(scope); // Add source information Vector<OBODbxref> dbxref = OBODbxref.parse(synonym.getDbxref()); OBOAbbreviations abbreviations = contents.getOBOAbbreviations(); addOBODbxrefAsSource(ip, dbxref, abbreviations); } } Vector<String> vec_altIds = oboTerm.getAltIds(); if ((vec_altIds != null) && (!vec_altIds.isEmpty())) { for (String altId : vec_altIds) { if (StringUtils.isNotBlank(altId)) { Property emfProp = new Property(); emfProp.setPropertyName(OBO2LGConstants.PROPERTY_ALTID); String prop_id = OBO2LGConstants.PROPERTY_ID_PREFIX + (++propertyCounter); emfProp.setPropertyId(prop_id); txt = new Text(); txt.setContent(altId); emfProp.setValue(txt); concept.getPropertyAsReference().add(emfProp); } } } String created_by = oboTerm.getCreated_by(); if (StringUtils.isNotBlank(created_by)) { addPropertyAttribute(created_by, concept, OBO2LGConstants.PROPERTY_CREATED_BY); } String creation_date = oboTerm.getCreation_date(); if (StringUtils.isNotBlank(creation_date)) { addPropertyAttribute(creation_date, concept, OBO2LGConstants.PROPERTY_CREATION_DATE); } Hashtable<String, Vector<String>> relationships = oboTerm.getRelationships(); if (relationships != null) { for (Enumeration<String> e = relationships.keys(); e.hasMoreElements();) { String relName = e.nextElement(); OBORelations relations = contents.getOBORelations(); OBORelation relation = relations.getMemberById(relName); Vector<String> targets = relationships.get(relName); if (targets != null) { addAssociationAttribute(concept, relation, targets); } } } codedEntriesList.add(concept); } } catch (Exception e) { e.printStackTrace(); messages_.info("Failed to store concept " + oboTerm.getName() + "(" + oboTerm.getId() + ")"); } }
From source file:GraficasForm.java
private void graficarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_graficarButtonActionPerformed Vector<String> keys = new Vector<String>(); Vector<Integer> indexes = new Vector<Integer>(); Boolean candSelected = false; if (candidatosRadio.isSelected()) { candSelected = true;//from w w w .j a va 2s . c o m indexes = getCandidatosSelected(); } else { indexes = getPartidosSelected(); } if (indexes.isEmpty()) { JOptionPane.showMessageDialog(null, "Escoja al menos un dato para graficar."); return; } else { if (candSelected) { for (int j = 0; j < indexes.size(); ++j) { keys.add(candidatosKeys[indexes.elementAt(j)]); } } else { for (int j = 0; j < indexes.size(); ++j) { keys.add(partidosKeys[indexes.elementAt(j)]); } } } panelGrafica.removeAll(); XYLineChartExample chart = new XYLineChartExample(); panelGrafica.add(chart.createChartPanel(keys), BorderLayout.CENTER); panelGrafica.revalidate(); panelGrafica.repaint(); }
From source file:edu.lternet.pasta.dml.database.DatabaseAdapter.java
/** * Creates a SQL command to insert data. If some error happens, null will be * returned./*w w w . j a v a 2 s. co m*/ * * @param attributeList AttributeList which will be inserted * @param tableName The name of the table which the data will be inserted into * @param oneRowData The data vector which contains data to be inserted * @return A SQL String that can be run to insert one row of data into table */ public String generateInsertSQL(AttributeList attributeList, String tableName, Vector oneRowData) throws DataNotMatchingMetadataException, SQLException { String sqlString = null; int NULLValueCounter = 0; int hasValueCounter = 0; if (attributeList == null) { throw new SQLException("The attribute list is null and couldn't generate insert sql statement"); } if (oneRowData == null || oneRowData.isEmpty()) { throw new SQLException("The the data is null and couldn't generte insert sql statement"); } StringBuffer sqlAttributePart = new StringBuffer(); StringBuffer sqlDataPart = new StringBuffer(); sqlAttributePart.append(INSERT); sqlAttributePart.append(SPACE); sqlAttributePart.append(tableName); sqlAttributePart.append(LEFTPARENTH); sqlDataPart.append(SPACE); sqlDataPart.append(VALUES); sqlDataPart.append(SPACE); sqlDataPart.append(LEFTPARENTH); Attribute[] list = attributeList.getAttributes(); if (list == null || list.length == 0) { throw new SQLException("The attributes is null and couldn't generate insert sql statement"); } int size = list.length; // column name part boolean firstAttribute = true; for (int i = 0; i < size; i++) { // if data vector Object obj = oneRowData.elementAt(i); String value = null; if (obj == null) { NULLValueCounter++; continue; } else { value = (String) obj; if (value.trim().equals("")) { continue; } } Attribute attribute = list[i]; if (attribute == null) { throw new SQLException("Attribute list contains a null attribute"); } String[] missingValues = attribute.getMissingValueCode(); boolean isMissingValue = isMissingValue(value, missingValues); if (isMissingValue) { continue; } String name = attribute.getDBFieldName(); String attributeType = getAttributeType(attribute); if (!firstAttribute) { sqlAttributePart.append(COMMA); sqlDataPart.append(COMMA); } sqlAttributePart.append(name); Domain domain = attribute.getDomain(); /* If attributeType is "datetime", convert to a timestamp * and wrap single quotes around the value. But only if we * have a format string! */ if (attributeType.equalsIgnoreCase("datetime")) { String formatString = ((DateTimeDomain) domain).getFormatString(); // Transform the datetime format string for database compatibility formatString = transformFormatString(formatString); // Transform the datetime value for database compatibility value = transformDatetime(value); value = escapeSpecialCharacterInData(value); sqlDataPart.append(TO_DATE_FUNCTION); sqlDataPart.append(LEFTPARENTH); sqlDataPart.append(SINGLEQUOTE); sqlDataPart.append(value); sqlDataPart.append(SINGLEQUOTE); sqlDataPart.append(COMMA); sqlDataPart.append(SINGLEQUOTE); sqlDataPart.append(formatString); sqlDataPart.append(SINGLEQUOTE); sqlDataPart.append(RIGHTPARENTH); hasValueCounter++; log.debug("datetime value expression= " + sqlDataPart.toString()); } /* If domain is null or it is not NumericDomain we assign it text type * and wrap single quotes around the value. */ else if (attributeType.equals("string")) { value = escapeSpecialCharacterInData(value); sqlDataPart.append(SINGLEQUOTE); sqlDataPart.append(value); sqlDataPart.append(SINGLEQUOTE); hasValueCounter++; } /* Else we have a NumericDomain. Determine whether it is a float or * integer. */ else { String dataType = mapDataType(attributeType); try { if (dataType.equals("FLOAT")) { Float floatObj = new Float(value); float floatNum = floatObj.floatValue(); sqlDataPart.append(floatNum); } else { Integer integerObj = new Integer(value); int integerNum = integerObj.intValue(); sqlDataPart.append(integerNum); } } catch (Exception e) { log.error("Error determining numeric value: " + e.getMessage()); throw new DataNotMatchingMetadataException( "Data value '" + value + "' is NOT the expected data type of '" + dataType + "'"); } hasValueCounter++; } firstAttribute = false; } // If all data is null, return null value for sql string. if (NULLValueCounter == list.length || hasValueCounter == 0) { return sqlString; } sqlAttributePart.append(RIGHTPARENTH); sqlDataPart.append(RIGHTPARENTH); sqlDataPart.append(SEMICOLON); // Combine the two parts sqlAttributePart.append(sqlDataPart.toString()); sqlString = sqlAttributePart.toString(); return sqlString; }