List of usage examples for java.util Hashtable elements
public synchronized Enumeration<V> elements()
From source file:Util.java
/********************************************************************* * Removes duplicate elements from the array. *********************************************************************/ public static Object[] removeDuplicates(Object[] array) ////////////////////////////////////////////////////////////////////// { Hashtable hashtable = new Hashtable(); for (int i = 0; i < array.length; i++) { hashtable.put(array[i], array[i]); }// w w w .j a va 2 s . c o m Object[] newArray = (Object[]) Array.newInstance(array.getClass().getComponentType(), hashtable.size()); int index = 0; Enumeration enumeration = hashtable.elements(); while (enumeration.hasMoreElements()) { newArray[index++] = enumeration.nextElement(); } return newArray; }
From source file:Flowchart.java
public ConnectionAnchor ConnectionAnchorAt(Point p) { ConnectionAnchor closest = null;//from w w w. jav a2 s . c o m long min = Long.MAX_VALUE; Hashtable conn = getSourceConnectionAnchors(); conn.putAll(getTargetConnectionAnchors()); Enumeration e = conn.elements(); while (e.hasMoreElements()) { ConnectionAnchor c = (ConnectionAnchor) e.nextElement(); Point p2 = c.getLocation(null); long d = p.getDistance2(p2); if (d < min) { min = d; closest = c; } } return closest; }
From source file:LruHashtable.java
LruHashtableEnumerator(Hashtable oldTable, Hashtable newTable, boolean keys) { if (keys) {/*www.j a v a 2 s. c om*/ oldEnum = oldTable.keys(); newEnum = newTable.keys(); } else { oldEnum = oldTable.elements(); newEnum = newTable.elements(); } old = true; }
From source file:com.alfaariss.oa.engine.attribute.gather.processor.file.FileGatherer.java
/** * Gathers attributes from file./*from w w w .ja v a 2s . c o m*/ * * First adds the optionaly configured global attributes then updates with * the specific user attributes. * @see com.alfaariss.oa.engine.core.attribute.gather.processor.IProcessor#process(java.lang.String, com.alfaariss.oa.api.attribute.IAttributes) */ public void process(String id, IAttributes attributes) throws AttributeException { if (attributes == null) throw new IllegalArgumentException("Suplied attributes parameter is empty"); try { ConfigurationManager fileConfig = getConfiguration(); Enumeration enumGlobal = _htGlobal.elements(); while (enumGlobal.hasMoreElements()) { FileAttribute fAttr = (FileAttribute) enumGlobal.nextElement(); String sName = fAttr.getName(); List<?> listValues = fAttr.getValues(); String sMappedName = _htMapper.get(sName); if (sMappedName != null) sName = sMappedName; if (_listGather.isEmpty() || _listGather.contains(sName)) { if (listValues.size() > 1) attributes.put(sName, fAttr.getFormat(), listValues); else attributes.put(sName, fAttr.getFormat(), listValues.get(0)); } } Element eUser = fileConfig.getSection(null, "user", "id=" + id); if (eUser != null) { Hashtable htAttributes = getFileAttributes(fileConfig, eUser); if (!htAttributes.isEmpty()) { Enumeration enumAttributes = htAttributes.elements(); while (enumAttributes.hasMoreElements()) { FileAttribute fAttr = (FileAttribute) enumAttributes.nextElement(); String sName = fAttr.getName(); List<?> listValues = fAttr.getValues(); String sMappedName = _htMapper.get(sName); if (sMappedName != null) sName = sMappedName; if (_listGather.isEmpty() || _listGather.contains(sName)) { if (listValues.size() > 1) attributes.put(sName, fAttr.getFormat(), listValues); else attributes.put(sName, fAttr.getFormat(), listValues.get(0)); } } } else _logger.debug("No user specific attributes found"); } else _logger.debug("No user found in attributes file"); } catch (AttributeException e) { throw e; } catch (Exception e) { _logger.fatal("Internal error during attribute processing", e); throw new AttributeException(SystemErrors.ERROR_INTERNAL); } }
From source file:org.hdiv.urlProcessor.AbstractUrlProcessor.java
/** * Determines if the url contains a extension to exclude for Hdiv state inclusion. * /*from ww w. j a v a2 s . co m*/ * @param urlData * url data object * @return is excluded or not */ protected boolean hasExtensionToExclude(UrlData urlData) { String contextPathRelativeUrl = urlData.getContextPathRelativeUrl(); if (contextPathRelativeUrl.charAt(contextPathRelativeUrl.length() - 1) == '/') { return false; } List excludedExtensions = this.config.getExcludedURLExtensions(); if (excludedExtensions != null) { for (Iterator iter = excludedExtensions.iterator(); iter.hasNext();) { String extension = (String) iter.next(); if (contextPathRelativeUrl.endsWith(extension)) { return true; } } } Hashtable protectedExtension = this.config.getProtectedURLPatterns(); // jsp is always protected if (contextPathRelativeUrl.endsWith(".jsp")) { return false; } if (protectedExtension != null) { for (Enumeration extensionsIds = protectedExtension.elements(); extensionsIds.hasMoreElements();) { Pattern extensionPattern = (Pattern) extensionsIds.nextElement(); Matcher m = extensionPattern.matcher(contextPathRelativeUrl); if (m.matches()) { return false; } } } return (!contextPathRelativeUrl.startsWith("/")) && (contextPathRelativeUrl.indexOf(".") == -1); }
From source file:VrmlPickingTest.java
private BranchGroup loadVrmlFile(String location) { BranchGroup sceneGroup = null;//from w w w. java 2 s. c o m Scene scene = null; VrmlLoader loader = new VrmlLoader(); try { URL loadUrl = new URL(location); try { // load the scene scene = loader.load(new URL(location)); } catch (Exception e) { System.out.println("Exception loading URL:" + e); e.printStackTrace(); } } catch (MalformedURLException badUrl) { // location may be a path name try { // load the scene scene = loader.load(location); } catch (Exception e) { System.out.println("Exception loading file from path:" + e); e.printStackTrace(); } } if (scene != null) { // get the scene group sceneGroup = scene.getSceneGroup(); sceneGroup.setCapability(BranchGroup.ALLOW_BOUNDS_READ); sceneGroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ); Hashtable namedObjects = scene.getNamedObjects(); System.out.println("*** Named Objects in VRML file: \n" + namedObjects); // recursively set the user data here // so we can find our objects when they are picked java.util.Enumeration enumValues = namedObjects.elements(); java.util.Enumeration enumKeys = namedObjects.keys(); if (enumValues != null) { while (enumValues.hasMoreElements() != false) { Object value = enumValues.nextElement(); Object key = enumKeys.nextElement(); recursiveSetUserData(value, key); } } } return sceneGroup; }
From source file:edu.ku.brc.specify.tasks.ExpressSearchTask.java
/** * Traverses through the results and adds to the panel to be displayed. * @param resultsMap the primary result tables * @param resultsForJoinsMap the related results table *///from www. ja v a2s .c om protected void displayResults(final ExpressSearchResultsPaneIFace esrPane, final QueryForIdResultsIFace queryResults, final Hashtable<String, QueryForIdResultsSQL> resultsForJoinsMap) { // For Debug Only if (false && resultsForJoinsMap != null) { for (Enumeration<QueryForIdResultsSQL> e = resultsForJoinsMap.elements(); e.hasMoreElements();) { QueryForIdResultsSQL qfirsql = e.nextElement(); if (qfirsql.getRecIds().size() > 0) { log.debug("\n\n------------------------------------"); log.debug("------------------------------------"); log.debug("Search Id " + qfirsql.getTableInfo().getId() + " Table Id " + qfirsql.getTableInfo().getTableId() + " Column Name " + qfirsql.getJoinColTableId()); log.debug("------------------------------------"); for (Integer l : qfirsql.getRecIds()) { log.debug(l + " "); } } } } if (queryResults.size() > 0) { esrPane.addSearchResults(queryResults); } if (resultsForJoinsMap != null) { for (QueryForIdResultsSQL rs : resultsForJoinsMap.values()) { if (rs.getRecIds().size() > 0) { esrPane.addSearchResults(rs); } } resultsForJoinsMap.clear(); } }
From source file:org.medcare.Dicom.DicomActivity.java
void drawInfoWindow() { ImageController curentImageController = dicomView.getCurrentImageController(); if (curentImageController == null) return;/*from w ww . java2s . c om*/ if (curentImageController != null) { // GeoPoint geoPoint = DicomActivity.this.selectedSearchPoint // .getPoint(); ImageDicom id = curentImageController._imageDicom; // initialisation de la liste a partir de la Hashtable Hashtable h = id.getListGroupDicom(); Enumeration en = h.elements(); en = h.keys(); Log.e("DicomActivity", "getStringInfoDicom " + curentImageController._imageName); String page = "<html><body><font size=-2><p>" + curentImageController._imageName + "</p>"; while (en.hasMoreElements()) { int groupId = ((Integer) en.nextElement()).intValue(); page = page + "<p>" + groupId + "</p>" + "<p>" + id.getStringInfoDicom(groupId) + "</p>"; } page = page + "</font></body></html>"; mPopupWebView.loadData(page, "text/html", "utf-8"); Bitmap img = curentImageController.getDrawable().getBitmap(); int bitmapWidth = img.getWidth(); int bitmapHeight = img.getHeight(); Log.e("DicomActivity", "BitMap width = " + bitmapWidth + " height " + bitmapHeight); showPopup(DicomActivity.this.dicomView, Gravity.NO_GRAVITY, (int) (curentImageController.getCenterX() - bitmapWidth / 2), (int) (curentImageController.getCenterY() - bitmapHeight / 2), bitmapWidth, bitmapHeight); } }
From source file:com.netscape.admin.certsrv.Console.java
protected void createPerInstanceUI(String host) { if (!DN.isDN(host)) { host = serverIDtoDN(host);//from w ww.j a v a 2s . c om } LDAPConnection ldc = _info.getLDAPConnection(); String configDN = "cn=configuration," + host; try { LDAPEntry configEntry = ldc.read(configDN); String className = LDAPUtil .flatting(configEntry.getAttribute("nsclassname", LDAPUtil.getLDAPAttributeLocale())); if (className == null) { Debug.println("ERROR Console: no 'nsclassname' attribute in " + configDN); System.exit(0); } String adminURL = getInstanceAdminURL(ldc, host); if (adminURL == null) { Debug.println("ERROR Console: could not set the adminURL for " + host); } else { _info.setAdminURL(adminURL); } String adminOS = getInstanceAdminOS(ldc, host); if (adminOS == null) { Debug.println("ERROR Console.constructor: could not set the adminOS for " + host); } else { _info.setAdminOS(adminOS); } _info.setCurrentDN(host); Class<?> c = ClassLoaderUtil.getClass(_info, className); if (c == null) { Debug.println("ERROR Console.constructor: could not get class " + className); System.exit(0); } try { Hashtable<String, ITopologyPlugin> topologyplugin = TopologyInitializer .getTopologyPluginFromDS(_info); Enumeration<ITopologyPlugin> ePlugins = topologyplugin.elements(); while (ePlugins.hasMoreElements()) { ITopologyPlugin plugin = ePlugins.nextElement(); ResourceObject resObj = plugin.getResourceObjectByID(host); if (resObj != null) { if (resObj instanceof ServerNode) { ServerNode srvNode = ((ServerNode) resObj); IServerObject srvObj = null; // ServerNode is loaded asynchronously srvNode.reload(); while ((srvObj = srvNode.getServerObject()) == null) { try { Thread.sleep(200); } catch (Exception e) { } } IResourceObject sel[] = new IResourceObject[1]; sel[0] = srvObj; srvObj.run((IPage) null, sel); return; } else if (resObj instanceof ServerNode) { } } } Debug.println("ERROR Console.constructor: cannot find associated plugin for " + host); } catch (Exception e) { if (Debug.isEnabled()) { e.printStackTrace(); } Debug.println("ERROR Console.constructor: could not create " + className); Debug.println(" Exception: " + e); } } catch (LDAPException e) { if (Debug.isEnabled()) { e.printStackTrace(); } Debug.println("ERROR Console.constructor: createServerInstance failed"); Debug.println(" LDAPException: " + e); } System.exit(0); }
From source file:org.agnitas.backend.Data.java
/** * Set standard field to be retreived from database * @param predef the hashset to store field name to *//*from w w w .j av a2 s. co m*/ public void setStandardFields(HashSet<String> predef, Hashtable<String, EMMTag> tags) { predef.add("email"); for (Enumeration<EMMTag> e = tags.elements(); e.hasMoreElements();) { EMMTag tag = e.nextElement(); try { tag.requestFields(this, predef); } catch (Exception ex) { logging(Log.ERROR, "tag", "Failed to get required fields for tag " + tag.mTagFullname + ": " + ex.toString()); } } }