List of usage examples for java.util Collections enumeration
public static <T> Enumeration<T> enumeration(final Collection<T> c)
From source file:org.ireland.jnetty.http.HttpServletRequestImpl.java
@Override // OK//from w w w.ja va2 s . c o m public Enumeration<String> getHeaders(String name) { List<String> e = headers.getAll(name); if (e == null) return Collections.enumeration(Collections.<String>emptyList()); return Collections.enumeration(e); }
From source file:org.sakaiproject.entitybroker.util.http.EntityHttpServletRequest.java
public Enumeration getLocales() { if (copy != null) { return copy.getLocales(); } else {// w w w .j a v a2 s .co m ArrayList<Locale> l = new ArrayList<Locale>(); l.add(locale); return Collections.enumeration(l); } }
From source file:net.lightbody.bmp.proxy.jetty.http.HttpContext.java
/** * @return enumaration of names. */ public Enumeration getAttributeNames() { return Collections.enumeration(_attributes.keySet()); }
From source file:org.clothocad.phagebook.controllers.ProjectController.java
@RequestMapping(value = "/editProject", method = RequestMethod.POST) protected void editProject(@RequestParam Map<String, String> params, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { ClothoConnection conn = new ClothoConnection(Args.clothoLocation); Clotho clothoObject = new Clotho(conn); String username = this.backendPhagebookUser; String password = this.backendPhagebookPassword; Map loginMap = new HashMap(); loginMap.put("username", username); loginMap.put("credentials", password); clothoObject.login(loginMap);/* w w w. ja v a 2 s . co m*/ System.out.println("got request in EditProject"); System.out.println(params); // these will be in a cookie? String userID = params.get("userID"); String projectID = params.get("projectID"); Person editor = ClothoAdapter.getPerson(userID, clothoObject); Project project = ClothoAdapter.getProject(projectID, clothoObject); System.out.println(editor.getEmailId()); System.out.println(project.getName()); // get all of the parameters in the request List<String> l = new ArrayList<String>(params.keySet()); Enumeration e = Collections.enumeration(l); // loop through the enumeration to get values from the request and add to // the hashmap HashMap reqHashMap = new HashMap(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = params.get(key); reqHashMap.put(key, value); } Map result = editProjectHelper(project, reqHashMap, clothoObject); System.out.println("resulting map is: " + result); System.out.println(result); // create a result object and send it to the frontend JSONObject json = new JSONObject(result); // System.out.printf( "JSON: %s", json.toString(2) ); if ((int) result.get("success") == 1) { json.put("success", 1); } else if ((int) result.get("success") == 0) { json.put("success", 0); } PrintWriter writer = response.getWriter(); writer.println(json); writer.flush(); writer.close(); clothoObject.logout(); conn.closeConnection(); } }
From source file:org.ireland.jnetty.http.HttpServletRequestImpl.java
@Override public Enumeration<Locale> getLocales() { if (!localesParsed) { parseLocales();//from w w w. j ava2s . co m } if (_locales.size() > 0) { return Collections.enumeration(_locales); } List<Locale> results = new LinkedList<Locale>(); results.add(defaultLocale); return Collections.enumeration(results); }
From source file:org.apache.xmlgraphics.image.codec.png.PNGImageDecoder.java
private void parse_IEND_chunk(final PNGChunk chunk) { // Store text strings final int textLen = this.textKeys.size(); final String[] textArray = new String[2 * textLen]; for (int i = 0; i < textLen; ++i) { final String key = this.textKeys.get(i); final String val = this.textStrings.get(i); textArray[2 * i] = key;// w ww. j a v a2 s .com textArray[2 * i + 1] = val; if (this.emitProperties) { final String uniqueKey = "text_" + i + ':' + key; this.properties.put(uniqueKey.toLowerCase(), val); } } if (this.encodeParam != null) { this.encodeParam.setText(textArray); } // Store compressed text strings final int ztextLen = this.ztextKeys.size(); final String[] ztextArray = new String[2 * ztextLen]; for (int i = 0; i < ztextLen; ++i) { final String key = this.ztextKeys.get(i); final String val = this.ztextStrings.get(i); ztextArray[2 * i] = key; ztextArray[2 * i + 1] = val; if (this.emitProperties) { final String uniqueKey = "ztext_" + i + ':' + key; this.properties.put(uniqueKey.toLowerCase(), val); } } if (this.encodeParam != null) { this.encodeParam.setCompressedText(ztextArray); } // Parse prior IDAT chunks final InputStream seqStream = new SequenceInputStream(Collections.enumeration(this.streamVec)); final InputStream infStream = new InflaterInputStream(seqStream, new Inflater()); this.dataStream = new DataInputStream(infStream); // Create an empty WritableRaster int depth = this.bitDepth; if (this.colorType == PNG_COLOR_GRAY && this.bitDepth < 8 && this.output8BitGray) { depth = 8; } if (this.colorType == PNG_COLOR_PALETTE && this.expandPalette) { depth = 8; } final int bytesPerRow = (this.outputBands * this.width * depth + 7) / 8; final int scanlineStride = depth == 16 ? bytesPerRow / 2 : bytesPerRow; this.theTile = createRaster(this.width, this.height, this.outputBands, scanlineStride, depth); if (this.performGammaCorrection && this.gammaLut == null) { initGammaLut(this.bitDepth); } if (this.postProcess == POST_GRAY_LUT || this.postProcess == POST_GRAY_LUT_ADD_TRANS || this.postProcess == POST_GRAY_LUT_ADD_TRANS_EXP) { initGrayLut(this.bitDepth); } decodeImage(this.interlaceMethod == 1); this.sampleModel = this.theTile.getSampleModel(); if (this.colorType == PNG_COLOR_PALETTE && !this.expandPalette) { if (this.outputHasAlphaPalette) { this.colorModel = new IndexColorModel(this.bitDepth, this.paletteEntries, this.redPalette, this.greenPalette, this.bluePalette, this.alphaPalette); } else { this.colorModel = new IndexColorModel(this.bitDepth, this.paletteEntries, this.redPalette, this.greenPalette, this.bluePalette); } } else if (this.colorType == PNG_COLOR_GRAY && this.bitDepth < 8 && !this.output8BitGray) { final byte[] palette = this.expandBits[this.bitDepth]; this.colorModel = new IndexColorModel(this.bitDepth, palette.length, palette, palette, palette); } else { this.colorModel = createComponentColorModel(this.sampleModel); } }
From source file:org.lwes.db.EventTemplateDB.java
/** * Returns a HTML rendering of the EventTemplateDB * * @return HTML string of the EventTemplateDB *//*from w w w . j a va 2s. co m*/ public String toHtmlString() { StringBuffer sb = new StringBuffer(); sb.append("<table>\n"); sb.append("<tr><th>" + META_EVENT_INFO + "</th><th>Type</th><th>Name</th></tr>\n"); for (String key : reservedWords.keySet()) { BaseType tv = reservedWords.get(key); FieldType type = tv.getType(); sb.append("<tr><td></td><td>").append(type).append("</td><td>").append(key).append("</td></tr>\n"); } for (String EventKey : events.keySet()) { sb.append("<tr><th>").append(EventKey).append("</th><th>Type</th><th>Name</th></tr>\n"); if (EventKey != null) { Map<String, BaseType> event = events.get(EventKey); for (Enumeration<String> att = Collections.enumeration(event.keySet()); att.hasMoreElements();) { String key = att.nextElement(); BaseType tv = event.get(key); FieldType type = tv.getType(); sb.append("<tr><td></td><td>").append(type).append("</td><td>").append(key) .append("</td></tr>\n"); } } } sb.append("</table>\n"); return sb.toString(); }
From source file:org.apache.xmlgraphics.image.codec.png.PNGRed.java
private void parse_IEND_chunk(final PNGChunk chunk) throws IOException { // Store text strings final int textLen = this.textKeys.size(); final String[] textArray = new String[2 * textLen]; for (int i = 0; i < textLen; ++i) { final String key = this.textKeys.get(i); final String val = this.textStrings.get(i); textArray[2 * i] = key;/*from ww w . j a va 2 s. c o m*/ textArray[2 * i + 1] = val; if (this.emitProperties) { final String uniqueKey = "text_" + i + ':' + key; this.properties.put(uniqueKey.toLowerCase(), val); } } if (this.encodeParam != null) { this.encodeParam.setText(textArray); } // Store compressed text strings final int ztextLen = this.ztextKeys.size(); final String[] ztextArray = new String[2 * ztextLen]; for (int i = 0; i < ztextLen; ++i) { final String key = this.ztextKeys.get(i); final String val = this.ztextStrings.get(i); ztextArray[2 * i] = key; ztextArray[2 * i + 1] = val; if (this.emitProperties) { final String uniqueKey = "ztext_" + i + ':' + key; this.properties.put(uniqueKey.toLowerCase(), val); } } if (this.encodeParam != null) { this.encodeParam.setCompressedText(ztextArray); } // Parse prior IDAT chunks final InputStream seqStream = new SequenceInputStream(Collections.enumeration(this.streamVec)); final InputStream infStream = new InflaterInputStream(seqStream, new Inflater()); this.dataStream = new DataInputStream(infStream); // Create an empty WritableRaster int depth = this.bitDepth; if (this.colorType == PNG_COLOR_GRAY && this.bitDepth < 8 && this.output8BitGray) { depth = 8; } if (this.colorType == PNG_COLOR_PALETTE && this.expandPalette) { depth = 8; } final int width = this.bounds.width; final int height = this.bounds.height; final int bytesPerRow = (this.outputBands * width * depth + 7) / 8; final int scanlineStride = depth == 16 ? bytesPerRow / 2 : bytesPerRow; this.theTile = createRaster(width, height, this.outputBands, scanlineStride, depth); if (this.performGammaCorrection && this.gammaLut == null) { initGammaLut(this.bitDepth); } if (this.postProcess == POST_GRAY_LUT || this.postProcess == POST_GRAY_LUT_ADD_TRANS || this.postProcess == POST_GRAY_LUT_ADD_TRANS_EXP) { initGrayLut(this.bitDepth); } decodeImage(this.interlaceMethod == 1); // Free resources associated with compressed data. this.dataStream.close(); infStream.close(); seqStream.close(); this.streamVec = null; final SampleModel sm = this.theTile.getSampleModel(); ColorModel cm; if (this.colorType == PNG_COLOR_PALETTE && !this.expandPalette) { if (this.outputHasAlphaPalette) { cm = new IndexColorModel(this.bitDepth, this.paletteEntries, this.redPalette, this.greenPalette, this.bluePalette, this.alphaPalette); } else { cm = new IndexColorModel(this.bitDepth, this.paletteEntries, this.redPalette, this.greenPalette, this.bluePalette); } } else if (this.colorType == PNG_COLOR_GRAY && this.bitDepth < 8 && !this.output8BitGray) { final byte[] palette = this.expandBits[this.bitDepth]; cm = new IndexColorModel(this.bitDepth, palette.length, palette, palette, palette); } else { cm = createComponentColorModel(sm); } init((CachableRed) null, this.bounds, cm, sm, 0, 0, this.properties); }
From source file:org.opennms.netmgt.config.PollerConfigManager.java
/** * <p>enumeratePackage</p>/*from w ww.java2s. c o m*/ * * @return a {@link java.util.Enumeration} object. */ @Override public Enumeration<Package> enumeratePackage() { try { getReadLock().lock(); return Collections.enumeration(getConfiguration().getPackages()); } finally { getReadLock().unlock(); } }
From source file:UnpackedJarFile.java
public Enumeration entries() { if (isClosed) { throw new IllegalStateException("NestedJarFile is closed"); }// w w w. ja v a 2 s .c o m Collection baseEntries = Collections.list(baseJar.entries()); Collection entries = new LinkedList(); for (Iterator iterator = baseEntries.iterator(); iterator.hasNext();) { JarEntry baseEntry = (JarEntry) iterator.next(); String path = baseEntry.getName(); if (path.startsWith(basePath)) { entries.add(new NestedJarEntry(path.substring(basePath.length()), baseEntry, getManifestSafe())); } } return Collections.enumeration(entries); }