List of usage examples for java.util Hashtable elements
public synchronized Enumeration<V> elements()
From source file:edu.mayo.informatics.lexgrid.convert.directConversions.UMLSToSQL.java
private void populateSupportedAssociations(String UMLSCodingSchemeName) throws SQLException { messages_.info("Getting the descriptive associations"); PreparedStatement getRelations = umlsConnection_ .prepareStatement("SELECT DISTINCT RELA, DIR FROM MRREL WHERE SAB = ?"); getRelations.setString(1, UMLSCodingSchemeName); ResultSet relations = getRelations.executeQuery(); Hashtable relationsHolder = new Hashtable(); while (relations.next()) { String temp = relations.getString("RELA"); String tempDirFlag = relations.getString("DIR"); if (temp == null || temp.length() == 0) { continue; }/* w ww. j a v a 2 s . co m*/ mapSupportedAssociationsHelper(temp, UMLSCodingSchemeName, tempDirFlag, "RELA", relationsHolder); } messages_.info("Getting the base umls associations"); getRelations = umlsConnection_.prepareStatement("SELECT DISTINCT REL, DIR FROM MRREL WHERE SAB = ?"); getRelations.setString(1, UMLSCodingSchemeName); relations = getRelations.executeQuery(); while (relations.next()) { String temp = relations.getString("REL"); String tempDirFlag = relations.getString("DIR"); if (temp == null || temp.length() == 0) { continue; } mapSupportedAssociationsHelper(temp, UMLSCodingSchemeName, tempDirFlag, "REL", relationsHolder); } getRelations.close(); supportedAssociations_ = new Association[relationsHolder.size()]; Enumeration elements = relationsHolder.elements(); int i = 0; while (elements.hasMoreElements()) { Association temp = (Association) elements.nextElement(); supportedAssociations_[i++] = temp; } }
From source file:com.github.maven_nar.cpptasks.CCTask.java
protected LinkerConfiguration collectExplicitObjectFiles(final Vector<File> objectFiles, final Vector<File> sysObjectFiles, final VersionInfo versionInfo) { //// w w w.j av a 2 s.c o m // find the first eligible linker // // ProcessorConfiguration linkerConfig = null; LinkerDef selectedLinkerDef = null; Linker selectedLinker = null; final Hashtable<String, File> sysLibraries = new Hashtable<>(); final TargetDef targetPlatform = getTargetPlatform(); FileVisitor objCollector = null; FileVisitor sysLibraryCollector = null; for (int i = 0; i < this._linkers.size(); i++) { final LinkerDef currentLinkerDef = this._linkers.elementAt(i); if (currentLinkerDef.isActive()) { selectedLinkerDef = currentLinkerDef; selectedLinker = currentLinkerDef.getProcessor().getLinker(this.linkType); // // skip the linker if it doesn't know how to // produce the specified link type if (selectedLinker != null) { linkerConfig = currentLinkerDef.createConfiguration(this, this.linkType, this.linkerDef, targetPlatform, versionInfo); if (linkerConfig != null) { // // create collectors for object files // and system libraries objCollector = new ObjectFileCollector(selectedLinker, objectFiles); sysLibraryCollector = new SystemLibraryCollector(selectedLinker, sysLibraries); // // if the <linker> has embedded <fileset>'s // (such as linker specific libraries) // add them as object files. // if (currentLinkerDef.hasFileSets()) { currentLinkerDef.visitFiles(objCollector); } // // user libraries are just a specialized form // of an object fileset selectedLinkerDef.visitUserLibraries(selectedLinker, objCollector); } break; } } } if (linkerConfig == null) { linkerConfig = this.linkerDef.createConfiguration(this, this.linkType, null, targetPlatform, versionInfo); selectedLinker = this.linkerDef.getProcessor().getLinker(this.linkType); objCollector = new ObjectFileCollector(selectedLinker, objectFiles); sysLibraryCollector = new SystemLibraryCollector(selectedLinker, sysLibraries); } // // unless there was a <linker> element that // explicitly did not inherit files from // containing <cc> element if (selectedLinkerDef == null || selectedLinkerDef.getInherit()) { this.linkerDef.visitUserLibraries(selectedLinker, objCollector); this.linkerDef.visitSystemLibraries(selectedLinker, sysLibraryCollector); } // // if there was a <syslibset> in a nested <linker> // evaluate it last so it takes priority over // identically named libs from <cc> element // if (selectedLinkerDef != null) { // // add any system libraries to the hashtable // done in reverse order so the earliest // on the classpath takes priority selectedLinkerDef.visitSystemLibraries(selectedLinker, sysLibraryCollector); } // // copy over any system libraries to the // object files vector // final Enumeration<File> sysLibEnum = sysLibraries.elements(); while (sysLibEnum.hasMoreElements()) { sysObjectFiles.addElement(sysLibEnum.nextElement()); } return (LinkerConfiguration) linkerConfig; }
From source file:edu.ku.brc.specify.config.SpecifyAppContextMgr.java
/** * Sets up the "current" Collection by first checking prefs for the most recent primary key, * @param userArg the user object of the current object * @param promptForCollection indicates the User should always be asked which Collection to use * @param collectionName name of collection to choose (can be null) * @return the current Collection or null *//*from w w w . j a v a2 s . co m*/ protected Collection setupCurrentCollection(final SpecifyUser userArg, final boolean promptForCollection, final String collectionName) { DataProviderSessionIFace session = null; try { AppPreferences remotePrefs = AppPreferences.getRemote(); session = DataProviderFactory.getInstance().createSession(); SpecifyUser spUser = session.getData(SpecifyUser.class, "id", userArg.getId(), //$NON-NLS-1$ DataProviderSessionIFace.CompareType.Equals); String alwaysAskPref = "ALWAYS.ASK.COLL"; //$NON-NLS-1$ boolean askForColl = remotePrefs.getBoolean(alwaysAskPref, true); String prefName = mkUserDBPrefName("recent_collection_id"); //$NON-NLS-1$ // First get the Collections the User has access to. Hashtable<String, Pair<String, Integer>> collectionHash = new Hashtable<String, Pair<String, Integer>>(); String sqlStr = String.format( "SELECT DISTINCT cln.CollectionID, cln.CollectionName, cln.DisciplineID FROM collection AS cln " + "Inner Join spprincipal AS p ON cln.UserGroupScopeId = p.userGroupScopeID " + "Inner Join specifyuser_spprincipal AS su_pr ON p.SpPrincipalID = su_pr.SpPrincipalID " + "WHERE su_pr.SpecifyUserID = %d AND GroupSubClass = '%s'", //$NON-NLS-1$ spUser.getSpecifyUserId(), UserPrincipal.class.getName()); //log.debug(sqlStr); for (Object[] row : BasicSQLUtils.query(sqlStr)) { String collName = row[1].toString(); Integer collId = (Integer) row[0]; if (collectionHash.get(collName) != null) { String dispName = BasicSQLUtils .querySingleObj("SELECT Name FROM discipline WHERE DisciplineID = " + row[2]); collName += " - " + dispName; if (collectionHash.get(collName) != null) { String sql = "SELECT d.DivisionID FROM collection c INNER JOIN discipline d ON c.DisciplineID = d.UserGroupScopeId WHERE d.DisciplineID = " + row[2]; String divName = BasicSQLUtils.querySingleObj(sql); collName += " - " + divName; } } collectionHash.put(collName, new Pair<String, Integer>(collName, collId)); } Pair<String, Integer> currColl = null; if (collectionName == null) { String recentIds = askForColl || promptForCollection ? null : remotePrefs.get(prefName, null); if (StringUtils.isNotEmpty(recentIds)) { Vector<Object[]> rows = BasicSQLUtils.query( "SELECT CollectionName, UserGroupScopeId FROM collection WHERE UserGroupScopeId = " //$NON-NLS-1$ + recentIds); if (rows.size() == 1) { String collName = rows.get(0)[0].toString(); Integer collId = (Integer) rows.get(0)[1]; currColl = new Pair<String, Integer>(collName, collId); } else { log.debug("could NOT find recent ids"); //$NON-NLS-1$ } } if (currColl != null && collectionHash.get(currColl.first) == null) { currColl = null; } } if (currColl == null || (askForColl && promptForCollection)) { if (collectionHash.size() == 1) { currColl = collectionHash.elements().nextElement(); } else if (collectionHash.size() > 0) { if (collectionName == null) { List<Pair<String, Integer>> list = new Vector<Pair<String, Integer>>(); list.addAll(collectionHash.values()); Collections.sort(list, new Comparator<Pair<String, Integer>>() { @Override public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) { return o1.first.compareTo(o2.first); } }); int selectColInx = -1; ChooseCollectionDlg colDlg = null; do { colDlg = new ChooseCollectionDlg(list); colDlg.setSelectedIndex(selectColInx); colDlg.createUI(); colDlg.pack(); Dimension size = colDlg.getSize(); size.width = Math.max(size.width, 300); if (size.height < 150) { size.height += 100; } colDlg.setSize(size); UIHelper.centerWindow(colDlg); colDlg.setVisible(true); } while (colDlg.getSelectedObject() == null || colDlg.isCancelled()); currColl = colDlg.getSelectedObject(); } else { Integer colId = BasicSQLUtils.getCount(String.format( "SELECT CollectionID FROM collection WHERE CollectionName = '%s'", collectionName)); if (colId != null) { currColl = new Pair<String, Integer>(collectionName, colId); } else { return null; } } } } Collection collection = null; if (currColl != null) { collection = (Collection) session.getData("FROM Collection WHERE id = " + currColl.second); if (collection != null) { collection.forceLoad(); remotePrefs.put(prefName, (Long.toString(collection.getCollectionId()))); remotePrefs.flush(); } } if (collection == null) { UIRegistry.showLocalizedError(L10N + "ERR_NO_COLL"); return null; } setClassObject(Collection.class, collection); if (collectionName == null) { String colObjStr = "CollectionObject"; //$NON-NLS-1$ String iconName = remotePrefs.get(FormattingPrefsPanel.getDisciplineImageName(), colObjStr); if (StringUtils.isEmpty(iconName) || iconName.equals(colObjStr)) { iconName = "colobj_backstop"; //$NON-NLS-1$ } IconManager.aliasImages(iconName, // Source colObjStr); // Dest //$NON-NLS-1$ IconManager.aliasImages(iconName, // Source colObjStr.toLowerCase()); // Dest //$NON-NLS-1$ } Discipline discipline = collection.getDiscipline(); session.attach(discipline); Institution institution = discipline.getDivision().getInstitution(); session.attach(institution); setClassObject(Institution.class, institution); if (!Agent.setUserAgent(spUser, discipline.getDivision())) { return null; } AppContextMgr am = AppContextMgr.getInstance(); discipline.getTaxonTreeDef().forceLoad(); am.setClassObject(TaxonTreeDef.class, discipline.getTaxonTreeDef()); discipline.getGeologicTimePeriodTreeDef().forceLoad(); am.setClassObject(GeologicTimePeriodTreeDef.class, discipline.getGeologicTimePeriodTreeDef()); institution.getStorageTreeDef().forceLoad(); am.setClassObject(StorageTreeDef.class, institution.getStorageTreeDef()); discipline.getLithoStratTreeDef().forceLoad(); am.setClassObject(LithoStratTreeDef.class, discipline.getLithoStratTreeDef()); discipline.getGeographyTreeDef().forceLoad(); am.setClassObject(GeographyTreeDef.class, discipline.getGeographyTreeDef()); return collection; } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyAppContextMgr.class, ex); ex.printStackTrace(); showLocalizedError(ex.toString()); // Yes, I know it isn't localized. } finally { if (session != null) { session.close(); } } return null; }
From source file:nl.ellipsis.webdav.server.methods.AbstractMethod.java
/** * Send a multistatus element containing a complete error report to the client. * If the errorList contains only one error, send the error directly without * wrapping it in a multistatus message. * //from ww w . j a v a 2 s . c o m * @param req * Servlet request * @param resp * Servlet response * @param errorList * List of error to be displayed */ protected static void sendReport(HttpServletRequest req, HttpServletResponse resp, Hashtable<String, Integer> errorList) throws IOException { if (errorList.size() == 1) { int code = errorList.elements().nextElement(); HttpStatus s = HttpStatus.valueOf(code); String status = s.getReasonPhrase(); if (status != null && !status.isEmpty()) { resp.sendError(code, status); } else { resp.sendError(code); } } else { resp.setStatus(HttpStatus.MULTI_STATUS.value()); String absoluteUri = req.getRequestURI(); // String relativePath = getRelativePath(req); XMLWriter generatedXML = new XMLWriter(); generatedXML.writeXMLHeader(); generatedXML.writeElement(NS_DAV_PREFIX, NS_DAV_FULLNAME, WebDAVConstants.XMLTag.MULTISTATUS, XMLWriter.OPENING); Enumeration<String> pathList = errorList.keys(); while (pathList.hasMoreElements()) { String errorPath = (String) pathList.nextElement(); int errorCode = ((Integer) errorList.get(errorPath)).intValue(); generatedXML.writeElement(NS_DAV_PREFIX, WebDAVConstants.XMLTag.RESPONSE, XMLWriter.OPENING); generatedXML.writeElement(NS_DAV_PREFIX, WebDAVConstants.XMLTag.HREF, XMLWriter.OPENING); String toAppend = null; if (absoluteUri.endsWith(errorPath)) { toAppend = absoluteUri; } else if (absoluteUri.contains(errorPath)) { int endIndex = absoluteUri.indexOf(errorPath) + errorPath.length(); toAppend = absoluteUri.substring(0, endIndex); } if (StringUtils.isEmpty(toAppend)) { toAppend = CharsetUtil.FORWARD_SLASH; } else if (!toAppend.startsWith(CharsetUtil.FORWARD_SLASH) && !toAppend.startsWith(PROTOCOL_HTTP)) { toAppend = CharsetUtil.FORWARD_SLASH + toAppend; } generatedXML.writeText(errorPath); generatedXML.writeElement(NS_DAV_PREFIX, WebDAVConstants.XMLTag.HREF, XMLWriter.CLOSING); generatedXML.writeElement(NS_DAV_PREFIX, WebDAVConstants.XMLTag.STATUS, XMLWriter.OPENING); HttpStatus s = HttpStatus.valueOf(errorCode); generatedXML.writeText("HTTP/1.1 " + errorCode + " " + s.getReasonPhrase()); generatedXML.writeElement(NS_DAV_PREFIX, WebDAVConstants.XMLTag.STATUS, XMLWriter.CLOSING); generatedXML.writeElement(NS_DAV_PREFIX, WebDAVConstants.XMLTag.RESPONSE, XMLWriter.CLOSING); } generatedXML.writeElement(NS_DAV_PREFIX, WebDAVConstants.XMLTag.MULTISTATUS, XMLWriter.CLOSING); Writer writer = resp.getWriter(); writer.write(generatedXML.toString()); writer.close(); } }
From source file:org.accada.reader.rprm.core.ReaderDevice.java
/** * Conversion of Hashtable of strings to a string array. * @param h/*w w w . jav a 2 s.c o m*/ * The hashtable to convert * @return The array */ public final String[] stringsToArray(final Hashtable h) { String[] array = new String[h.size()]; Enumeration iterator = h.elements(); int i = 0; while (iterator.hasMoreElements()) { array[i] = (String) iterator.nextElement(); i++; } return array; }
From source file:org.accada.reader.rprm.core.ReaderDevice.java
/** * Conversion of Hashtable of sources to a source array. * @param h/*w w w . j a v a 2s . c o m*/ * The hashtable to convert * @return The array */ public final Source[] sourcesToArray(final Hashtable h) { Source[] array = new Source[h.size()]; Enumeration iterator = h.elements(); int i = 0; while (iterator.hasMoreElements()) { array[i] = (Source) iterator.nextElement(); i++; } return array; }
From source file:org.accada.reader.rprm.core.ReaderDevice.java
/** * Conversion of Hashtable of read points to a read point array. * @param h/* ww w .java2 s . co m*/ * The hashtable to convert * @return The array */ public final ReadPoint[] readPointsToArray(final Hashtable h) { ReadPoint[] array = new ReadPoint[h.size()]; Enumeration iterator = h.elements(); int i = 0; while (iterator.hasMoreElements()) { array[i] = (ReadPoint) iterator.nextElement(); i++; } return array; }
From source file:org.accada.reader.rprm.core.ReaderDevice.java
/** * Conversion of Hashtable of triggers to a trigger array. * @param h//from www .j av a 2 s . co m * The hashtable to convert * @return The array */ public final Trigger[] triggersToArray(final Hashtable h) { Trigger[] array = new Trigger[h.size()]; Enumeration iterator = h.elements(); int i = 0; while (iterator.hasMoreElements()) { array[i] = (Trigger) iterator.nextElement(); i++; } return array; }
From source file:org.accada.reader.rprm.core.ReaderDevice.java
/** * Conversion of Hashtable of tag selectors to a tag selector array. * @param h/*from w w w.j a v a 2s .c o m*/ * The hashtable to convert * @return The array */ public final TagSelector[] tagSelectorsToArray(final Hashtable h) { TagSelector[] array = new TagSelector[h.size()]; Enumeration iterator = h.elements(); int i = 0; while (iterator.hasMoreElements()) { array[i] = (TagSelector) iterator.nextElement(); i++; } return array; }
From source file:org.accada.reader.rprm.core.ReaderDevice.java
/** * Conversion of Hashtable of data selectors to a data selector array. * @param h/*from w ww . ja v a 2s . c o m*/ * The hashtable to convert * @return The array */ public final DataSelector[] dataSelectorsToArray(final Hashtable h) { DataSelector[] array = new DataSelector[h.size()]; Enumeration iterator = h.elements(); int i = 0; while (iterator.hasMoreElements()) { array[i] = (DataSelector) iterator.nextElement(); i++; } return array; }