List of usage examples for java.util Vector elements
public Enumeration<E> elements()
From source file:de.betterform.xml.xforms.model.constraints.MainDependencyGraph.java
/** * Adds a single bind's ref node to the Main Graph * called by MainDependencyGraph.buildBindGraph() *//* www.j av a 2s . co m*/ private void addReferredNodesToGraph(BetterFormXPathContext relativeContext, Node instanceNode, String expression, short property, Set references, String customMIP) throws XFormsException { //creates a new vertex for this Node or return it, in case it already existed //RKU Vertex vertex = this.addVertex(relativeContext, instanceNode, expression, property, customMIP); boolean hadVertex = vertex.wasAlreadyInGraph; vertex.wasAlreadyInGraph = false; // Analyze the Xpath Expression 'calculate'. Read nodeset RefNS // (the nodes this XPAth references) String xpath = vertex.getXPathExpression(); // String xpath = expression; vertex.setXpathExpression(expression); if ((xpath == null) || (xpath.length() == 0)) { // bind without xpath, remove vertex if (!hadVertex) { this.removeVertex(vertex); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("addReferredNodesToGraph: ignoring vertex " + vertex + " without xpath"); } return; } //Analyse xpath-expression to determine the Referenced dataitems Vector refns = this.getXPathRefNodes(relativeContext, xpath, references); if (refns == null) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("addReferredNodesToGraph: ignoring vertex " + vertex + " without references"); } return; } if (refns.size() == 0) { // this is a calculated value, that is not depending on anything, let's calculate it now vertex.compute(); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("addReferredNodesToGraph: processing vertex " + vertex + " with " + refns.size() + " references"); } Enumeration enumeration = refns.elements(); while (enumeration.hasMoreElements()) { Node referencedNode = (Node) enumeration.nextElement(); // pre-build vertex Vertex refVertex = this.addVertex(null, referencedNode, null, Vertex.CALCULATE_VERTEX, null); this.addEdge(refVertex, vertex); } }
From source file:com.sun.grizzly.http.jk.server.JkMain.java
private void preProcessProperties() { Enumeration keys = props.keys(); Vector v = new Vector(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); Object newName = replacements.get(key); if (newName != null) { v.addElement(key);//from w ww . ja v a 2 s .c om } } keys = v.elements(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); Object propValue = props.getProperty(key); String replacement = (String) replacements.get(key); props.put(replacement, propValue); if (LoggerUtils.getLogger().isLoggable(Level.FINEST)) { LoggerUtils.getLogger().log(Level.FINEST, "Substituting " + key + " " + replacement + " " + propValue); } } }
From source file:net.wastl.webmail.storage.FileStorage.java
protected void initLanguages() { log.info("Initializing available languages ... "); File f = new File(parent.getProperty("webmail.template.path") + System.getProperty("file.separator")); String[] flist = f.list(new FilenameFilter() { public boolean accept(File myf, String s) { if (myf.isDirectory() && s.equals(s.toLowerCase()) && (s.length() == 2 || s.equals("default"))) { return true; } else { return false; }//from w w w .j a va 2s. co m } }); File cached = new File( parent.getProperty("webmail.data.path") + System.getProperty("file.separator") + "locales.cache"); Locale[] available1 = null; /* Now we try to cache the Locale list since it takes really long to gather it! */ boolean exists = cached.exists(); if (exists) { try { ObjectInputStream in = new ObjectInputStream(new FileInputStream(cached)); available1 = (Locale[]) in.readObject(); in.close(); log.info("Using disk cache for langs... "); } catch (Exception ex) { exists = false; } } if (!exists) { // We should cache this on disk since it is so slow! available1 = Collator.getAvailableLocales(); ObjectOutputStream os = null; try { os = new ObjectOutputStream(new FileOutputStream(cached)); os.writeObject(available1); } catch (IOException ioe) { log.error("Failed to write to storage", ioe); } finally { try { os.close(); } catch (IOException ioe) { log.error("Failed to close stream", ioe); } } } // Do this manually, as it is not JDK 1.1 compatible ... //Vector available=new Vector(Arrays.asList(available1)); Vector<Locale> available = new Vector<Locale>(available1.length); for (int i = 0; i < available1.length; i++) { available.addElement(available1[i]); } String s = ""; int count = 0; for (int i = 0; i < flist.length; i++) { String cur_lang = flist[i]; Locale loc = new Locale(cur_lang, "", ""); Enumeration<Locale> enumVar = available.elements(); boolean added = false; while (enumVar.hasMoreElements()) { Locale l = (Locale) enumVar.nextElement(); if (l.getLanguage().equals(loc.getLanguage())) { s += l.toString() + " "; count++; added = true; } } if (!added) { s += loc.toString() + " "; count++; } } log.info(count + " languages initialized."); cs.configRegisterStringKey(this, "LANGUAGES", s, "Languages available in WebMail"); setConfig("LANGUAGES", s); /* Setup list of themes for each language */ for (int j = 0; j < flist.length; j++) { File themes = new File(parent.getProperty("webmail.template.path") + System.getProperty("file.separator") + flist[j] + System.getProperty("file.separator")); String[] themelist = themes.list(new FilenameFilter() { public boolean accept(File myf, String s3) { if (myf.isDirectory() && !s3.equals("CVS")) { return true; } else { return false; } } }); String s2 = ""; for (int k = 0; k < themelist.length; k++) { s2 += themelist[k] + " "; } cs.configRegisterStringKey(this, "THEMES_" + flist[j].toUpperCase(), s2, "Themes for language " + flist[j]); setConfig("THEMES_" + flist[j].toUpperCase(), s2); } }
From source file:com.ruforhire.utils.Stopwords.java
/** * Returns a sorted enumeration over all stored stopwords * * @return the enumeration over all stopwords *//*w w w .j a v a 2 s .c o m*/ public Enumeration elements() { Iterator iter; Vector list; iter = m_Words.iterator(); list = new Vector(); while (iter.hasNext()) list.add(iter.next()); // sort list Collections.sort(list); return list.elements(); }
From source file:net.wastl.webmail.xml.XMLSystemData.java
public WebMailVirtualDomain getVirtualDomain(String domname) { // Check if virtual domains are disabled if (getVirtuals() == false) { // No, default to localhost return new WebMailVirtualDomain() { public String getDomainName() { return "localhost"; }/*from w w w . ja va 2s . co m*/ public void setDomainName(String name) throws Exception { log.error("Ignoring DefaultDomain.setDomainName(). " + "Should not call this method."); } public String getDefaultServer() { return "localhost"; } public void setDefaultServer(String name) { log.error("Ignoring DefaultDomain.setDomainServer(). " + "Should not call this method."); } public String getAuthenticationHost() { return "localhost"; } public void setAuthenticationHost(String name) { log.error("Ignoring DefaultDomain.setAuthenticationHost(). " + "Should not call this method."); } public boolean isAllowedHost(String host) { return true; } public void setAllowedHosts(String hosts) { log.error("Ignoring DefaultDomain.setAllowedHosts(). " + "Should not call this method."); } public Enumeration<String> getAllowedHosts() { return new Enumeration<String>() { int i = 0; public boolean hasMoreElements() { return i < 1; } public String nextElement() { i++; return "localhost"; } }; } public void setHostsRestricted(boolean b) { log.error("Ignoring DefaultDomain.setHostsRestricted(). " + "Should not call this method."); } public boolean getHostsRestricted() { return false; } public String getImapBasedir() { return null; } }; } // Virtual domains are allowed, get that wanted one NodeList nodel = sysdata.getElementsByTagName("DOMAIN"); Element elem = null; int j; for (j = 0; j < nodel.getLength(); j++) { elem = (Element) nodel.item(j); elem.normalize(); NodeList namel = elem.getElementsByTagName("NAME"); if (namel.getLength() > 0) { if (XMLCommon.getElementTextValue((Element) namel.item(0)).equals(domname)) { break; } } } if (j < nodel.getLength() && elem != null) { final Element domain = elem; return new WebMailVirtualDomain() { public String getDomainName() { String value = XMLCommon.getTagValue(domain, "NAME"); return value == null ? "unknown" : value; } public void setDomainName(String name) throws Exception { XMLCommon.setTagValue(domain, "NAME", name, true, "Virtual Domain names must be unique!"); } public String getDefaultServer() { String value = XMLCommon.getTagValue(domain, "DEFAULT_HOST"); return value == null ? "unknown" : value; } /* Override the IMAP base directory for this domain, * for imap and imaps protocols */ public String getImapBaseDir() { String value = XMLCommon.getTagValue(domain, "IMAP_BASEDIR"); return value == null ? "unknown" : value; } public void setDefaultServer(String name) { XMLCommon.setTagValue(domain, "DEFAULT_HOST", name); } public String getAuthenticationHost() { String value = XMLCommon.getTagValue(domain, "AUTHENTICATION_HOST"); return value == null ? "unknown" : value; } public void setAuthenticationHost(String name) { XMLCommon.setTagValue(domain, "AUTHENTICATION_HOST", name); } public boolean isAllowedHost(String host) { if (getHostsRestricted()) { Vector<String> v = new Vector<String>(); v.addElement(getDefaultServer()); Enumeration<String> e = getAllowedHosts(); while (e.hasMoreElements()) { v.addElement(e.nextElement()); } Enumeration<String> enumVar = v.elements(); while (enumVar.hasMoreElements()) { String next = enumVar.nextElement(); if (host.toUpperCase().endsWith(next.toUpperCase())) { return true; } } return false; } else { return true; } } public void setAllowedHosts(String hosts) { NodeList nl = domain.getElementsByTagName("ALLOWED_HOST"); for (int i = 0; i < nl.getLength(); i++) { domain.removeChild(nl.item(i)); } StringTokenizer tok = new StringTokenizer(hosts, ", "); while (tok.hasMoreElements()) { Element ahost = root.createElement("ALLOWED_HOST"); XMLCommon.setElementTextValue(ahost, tok.nextToken()); domain.appendChild(ahost); } } public Enumeration<String> getAllowedHosts() { final NodeList nl = domain.getElementsByTagName("ALLOWED_HOST"); return new Enumeration<String>() { int i = 0; public boolean hasMoreElements() { return i < nl.getLength(); } public String nextElement() { String value = XMLCommon.getElementTextValue((Element) nl.item(i++)); return value == null ? "error" : value; } }; } public void setHostsRestricted(boolean b) { NodeList nl = domain.getElementsByTagName("RESTRICTED"); for (int i = 0; i < nl.getLength(); i++) { domain.removeChild(nl.item(i)); } if (b) { domain.appendChild(root.createElement("RESTRICTED")); } } public boolean getHostsRestricted() { NodeList nl = domain.getElementsByTagName("RESTRICTED"); return nl.getLength() > 0; } public String getImapBasedir() { NodeList nl = domain.getElementsByTagName("IMAP_BASEDIR"); return ((nl.getLength() > 0) ? XMLCommon.getElementTextValue((Element) nl.item(0)) : null); } }; } else { return null; } }
From source file:fr.inrialpes.exmo.align.cli.GroupEval.java
/** * A plot of the precision recall points on a triangular space * Added level lines provides by Christian Meilicke (U. Mannheim) * See his program in comment below// w w w . j ava2 s.co m * * @param result: the vector of vector result to be printed * @param writer: the writer in which to print it */ public void printTRIANGLE(Vector<Vector<Object>> result, PrintStream writer) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far int correctVect[]; // correct so far long timeVect[]; // time so far foundVect = new int[size]; correctVect = new int[size]; timeVect = new long[size]; for (int k = size - 1; k >= 0; k--) { foundVect[k] = 0; correctVect[k] = 0; timeVect[k] = 0; } for (Vector<Object> test : result) { int nexpected = -1; Enumeration<Object> f = test.elements(); // Too bad the first element must be skipped f.nextElement(); for (int k = 0; f.hasMoreElements(); k++) { PRecEvaluator eval = (PRecEvaluator) f.nextElement(); if (eval != null) { // iterative H-means computation if (nexpected == -1) { nexpected = 0; expected += eval.getExpected(); } foundVect[k] += eval.getFound(); correctVect[k] += eval.getCorrect(); timeVect[k] += eval.getTime(); } } } writer.println("\\documentclass[11pt]{book}"); writer.println(); writer.println("\\usepackage{pgf}"); writer.println("\\usepackage{tikz}"); writer.println(); writer.println("\\begin{document}"); writer.println("\\date{today}"); writer.println(""); writer.println("\n%% Plot generated by GroupEval of alignapi"); writer.println("\\begin{tikzpicture}[cap=round]"); writer.println("% Draw grid"); //writer.println("\\draw[step=1cm,very thin,color=gray] (-0.2,-0.2) grid (10.0,9.0);"); writer.println("\\draw[|-|] (-0,0) -- (10,0);"); writer.println("%\\draw[dashed,very thin] (0,0) -- (5,8.66) -- (10,0);"); writer.println("\\draw[dashed,very thin] (10,0) arc (0:60:10cm);"); writer.println("\\draw[dashed,very thin] (0,0) arc (180:120:10cm);"); writer.println("%% Level lines for recall"); writer.println("\\draw[dashed] (10,0) arc (0:60:10cm) node[anchor=south east] {{\\tiny R=1.}};"); writer.println("\\draw[dotted,very thin] (9,0) arc (0:63:9cm) node[anchor=south east] {{\\tiny R=.9}};"); writer.println("\\draw[dotted,very thin] (8,0) arc (0:66:8cm) node[anchor=south east] {{\\tiny R=.8}};"); writer.println("\\draw[dotted,very thin] (7,0) arc (0:70:7cm) node[anchor=south east] {{\\tiny R=.7}};"); writer.println("\\draw[dotted,very thin] (6,0) arc (0:73:6cm) node[anchor=south east] {{\\tiny R=.6}};"); writer.println("\\draw[dotted,very thin] (5,0) arc (0:76:5cm) node[anchor=south east] {{\\tiny R=.5}};"); writer.println("\\draw[dotted,very thin] (4,0) arc (0:78:4cm) node[anchor=south east] {{\\tiny R=.4}};"); writer.println("\\draw[dotted,very thin] (3,0) arc (0:80:3cm) node[anchor=south east] {{\\tiny R=.3}};"); writer.println("\\draw[dotted,very thin] (2,0) arc (0:82:2cm) node[anchor=south east] {{\\tiny R=.2}};"); writer.println("\\draw[dotted,very thin] (1,0) arc (0:84:1cm) node[anchor=south east] {{\\tiny R=.1}};"); writer.println("%% Level lines for precision"); writer.println("\\draw[dashed] (0,0) arc (180:120:10cm) node[anchor=south west] {{\\tiny P=1.}};"); writer.println("\\draw[dotted,very thin] (1,0) arc (180:117:9cm) node[anchor=south west] {{\\tiny P=.9}};"); writer.println("\\draw[dotted,very thin] (2,0) arc (180:114:8cm) node[anchor=south west] {{\\tiny P=.8}};"); writer.println("\\draw[dotted,very thin] (3,0) arc (180:110:7cm) node[anchor=south west] {{\\tiny P=.7}};"); writer.println("\\draw[dotted,very thin] (4,0) arc (180:107:6cm) node[anchor=south west] {{\\tiny P=.6}};"); writer.println("\\draw[dotted,very thin] (5,0) arc (180:105:5cm) node[anchor=south west] {{\\tiny P=.5}};"); writer.println("\\draw[dotted,very thin] (6,0) arc (180:103:4cm) node[anchor=south west] {{\\tiny P=.4}};"); writer.println("\\draw[dotted,very thin] (7,0) arc (180:100:3cm) node[anchor=south west] {{\\tiny P=.3}};"); writer.println("\\draw[dotted,very thin] (8,0) arc (180:96:2cm) node[anchor=south west] {{\\tiny P=.2}};"); writer.println("\\draw[dotted,very thin] (9,0) arc (180:90:1cm) node[anchor=south west] {{\\tiny P=.1}};"); writer.println("%% Level lines for F-measure"); writer.println( "\\draw[very thin,densely dotted] plot[smooth] coordinates { (0.56,3.29) (1.55,3.10) (2.46,2.68) (3.31,2.05) (4.12,1.19) (5.00,0.00) (6.42,1.79) (9.44,3.29)};"); writer.println("\\draw (0.56,3.29) node[anchor=south west] {\\tiny{F=0.5}};"); writer.println( "\\draw[very thin,densely dotted] plot[smooth] coordinates { (0.92,4.19) (1.96,4.05) (2.95,3.78) (3.93,3.48) (5.00,3.32) (6.56,3.63) (9.08,4.19)};"); writer.println("\\draw (0.92,4.19) node[anchor=south west] {\\tiny{F=0.6}};"); writer.println( "\\draw[very thin,densely dotted] plot[smooth] coordinates { (1.45,5.19) (2.59,5.11) (3.74,4.98) (5.00,4.90) (6.73,5.03) (8.55,5.19)};"); writer.println("\\draw (1.45,5.19) node[anchor=south west] {\\tiny{F=0.7}};"); writer.println( "\\draw[very thin,densely dotted] plot[smooth] coordinates { (2.22,6.29) (3.54,6.27) (5.00,6.24) (6.91,6.28) (7.78,6.29)};"); writer.println("\\draw (2.22,6.29) node[anchor=south west] {\\tiny{F=0.8}};"); writer.println( "\\draw[very thin,densely dotted] plot[smooth] coordinates { (3.35,7.47) (5.00,7.48) (6.65,7.47)};"); writer.println("\\draw (3.35,7.47) node[anchor=south west] {\\tiny{F=0.9}};"); writer.println("\\draw (0,-0.3) node {$recall$};"); writer.println("\\draw (10,-0.3) node {$precision$};"); //writer.println("\\draw (0,-0.3) node {0.}; "); //writer.println("\\draw (10,-0.3) node {1.}; "); writer.println("% Plots"); int k = 0; for (String m : listAlgo) { double precision = (double) correctVect[k] / foundVect[k]; double recall = (double) correctVect[k] / expected; double prec2 = precision * precision; double a = ((prec2 - (recall * recall) + 1) / 2); double b = java.lang.Math.sqrt(prec2 - (a * a)); if (b == b) { // Test if b is not NaN! Otherwise, no square root: the point is out of the triangle a = a * 10; b = b * 10; //for printing scale 10. writer.println("\\draw plot[mark=+,] coordinates {(" + a + "," + b + ")};"); writer.println("\\draw (" + (a + .01) + "," + (b + .01) + ") node[anchor=south west] {" + m + "};"); } k++; } writer.println("\\end{tikzpicture}"); writer.println(); writer.println("\\end{document}"); }
From source file:org.sakaiproject.kernel.component.core.test.ComponentClassloaderTest.java
@Test public void testGetResorcesAsStream() throws IOException { Vector<URL> v = new Vector<URL>(); v.add(new URL("http://notareal.com/url")); Exporter mockExporter = EasyMock.createMock(Exporter.class); replay(mockExporter);/*from w w w . jav a2s .c o m*/ Enumeration<URL> urls = componentClassloader.getResources("META-INF/persistance.xml"); assertNotNull(urls); int i = 0; Map<String, String> map = new HashMap<String, String>(); while (urls.hasMoreElements()) { i++; URL u = urls.nextElement(); String url = u.toString(); if (map.containsKey(url)) { fail("Duplicate URL found " + url); } map.put(url, url); } verify(mockExporter); reset(mockExporter); expect(mockExporter.findExportedResources("META-INF/persistance.xml")).andReturn(v.elements()); replay(mockExporter); packageRegistryService.addResource("META-INF", mockExporter); urls = componentClassloader.getResources("META-INF/persistance.xml"); assertNotNull(urls); i = 0; Map<String, String> map2 = new HashMap<String, String>(); while (urls.hasMoreElements()) { i++; URL u = urls.nextElement(); String url = u.toString(); if (map.containsKey(url)) { } else if (map2.containsKey(url)) { fail("Duplicate URL found second time " + url); } else { map2.put(url, url); map.put(url, url); } } verify(mockExporter); }
From source file:com.warfrog.bitmapallthethings.BattEngine.java
private void generateBitmap(String inputName, String outputName) throws Exception { System.out.println("Generating " + outputName); File input = new File(inputName); int size = (int) new FileInputStream(inputName).getChannel().size(); if (size > getMaxFileSize()) { System.err.println(/* ww w .java 2s .co m*/ "ERROR: Skipping " + inputName + " the file size is larger than the maximum size allowed."); return; } int height = (size / (getBytesPerPixel() / 8)) / getWidth(); int fillerBytes = (size / (getBytesPerPixel() / 8)) % getWidth(); //encode (repeat this for each file in a directory) InputStream header = generateBitmapHeader(getWidth(), height, size, fillerBytes); InputStream file = generateFileInputStream(inputName); InputStream filler = generateFillerStream(fillerBytes); Vector<InputStream> inputStreams = new Vector<InputStream>(); inputStreams.add(header); inputStreams.add(file); inputStreams.add(filler); SequenceInputStream inputStream = new SequenceInputStream(inputStreams.elements()); Files.copy(inputStream, new File(outputName).toPath(), StandardCopyOption.REPLACE_EXISTING); }
From source file:plugspud.PluginManager.java
/** * Return an enumeration of all the plugins * //from ww w . j a va2s . c o m * @return enumeration of plugins */ public Enumeration<Plugin> plugins() { Vector<Plugin> v = new Vector<Plugin>(); for (Enumeration<PluginWrapper> e = plugins.elements(); e.hasMoreElements();) { v.addElement(e.nextElement().plugin); } return v.elements(); }
From source file:org.openmrs.module.openhmis.inventory.web.controller.InventoryMessageRenderController.java
@RequestMapping(method = RequestMethod.GET) public ModelAndView render(HttpServletRequest request) { // object to store keys from inventory and backboneforms Vector<String> keys = new Vector<String>(); Locale locale = RequestContextUtils.getLocale(request); ResourceBundle resourceBundle = ResourceBundle.getBundle("messages", locale); // store inventory message keys in the vector object keys.addAll(resourceBundle.keySet()); // retrieve backboneforms messages BackboneMessageRenderController backboneController = new BackboneMessageRenderController(); ModelAndView modelAndView = backboneController.render(request); // store backboneforms message keys in the vector object for (Map.Entry<String, Object> messageKeys : modelAndView.getModel().entrySet()) { Enumeration<String> messageKey = (Enumeration<String>) messageKeys.getValue(); while (messageKey.hasMoreElements()) { String key = messageKey.nextElement(); if (!keys.contains(key)) keys.add(key);//from w w w .j av a 2 s .c o m } } return new ModelAndView(ModuleWebConstants.MESSAGE_PAGE, "keys", keys.elements()); }