List of usage examples for java.util Collections enumeration
public static <T> Enumeration<T> enumeration(final Collection<T> c)
From source file:org.sakaiproject.tool.messageforums.FileUploadFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!(request instanceof HttpServletRequest)) { chain.doFilter(request, response); return;//from w w w .j a va 2 s . co m } HttpServletRequest httpRequest = (HttpServletRequest) request; boolean isMultipartContent = FileUpload.isMultipartContent(httpRequest); if (!isMultipartContent) { chain.doFilter(request, response); return; } DiskFileUpload upload = new DiskFileUpload(); if (repositoryPath != null) { upload.setRepositoryPath(repositoryPath); } try { List list = upload.parseRequest(httpRequest); final Map map = new HashMap(); for (int i = 0; i < list.size(); i++) { FileItem item = (FileItem) list.get(i); String str = item.getString(); if (item.isFormField()) { map.put(item.getFieldName(), new String[] { str }); } else { httpRequest.setAttribute(item.getFieldName(), item); } } chain.doFilter(new HttpServletRequestWrapper(httpRequest) { public Map getParameterMap() { return map; } public String[] getParameterValues(String name) { Map map = getParameterMap(); return (String[]) map.get(name); } public String getParameter(String name) { String[] params = getParameterValues(name); if (params == null) { return null; } return params[0]; } public Enumeration getParameterNames() { Map map = getParameterMap(); return Collections.enumeration(map.keySet()); } }, response); } catch (FileUploadException ex) { ServletException servletEx = new ServletException(); servletEx.initCause(ex); throw servletEx; } }
From source file:com.idega.slide.util.WebdavLocalResource.java
@Override public Enumeration<LocalResponse> propfindMethod(String path, int depth, @SuppressWarnings("rawtypes") Vector presetProperties) throws HttpException, IOException { if (properties == null) { String resourcePath = getPath(); if (resourcePath.startsWith(CoreConstants.WEBDAV_SERVLET_URI)) { resourcePath = resourcePath.substring(CoreConstants.WEBDAV_SERVLET_URI.length()); }/* ww w. j ava 2s . c o m*/ try { if (!getSlideAPI().checkExistance(resourcePath)) { return Collections.enumeration(new ArrayList<LocalResponse>()); } } catch (Exception e) { } try { NodeRevisionDescriptor rev = getSlideAPI().getRevisionDescriptor(resourcePath); properties = propfindMethod(rev); } catch (Exception e) { if (e instanceof ObjectNotFoundException) { getSlideAPI().deletetDefinitionFile(((ObjectNotFoundException) e).getObjectUri()); } else if (e instanceof RevisionDescriptorNotFoundException) { getSlideAPI().deletetDefinitionFile(((RevisionDescriptorNotFoundException) e).getObjectUri()); } } } return properties; }
From source file:de.jbellmann.tomcat.cassandra.CassandraSession.java
@Override public Enumeration<String> getAttributeNames() { return Collections.enumeration(Arrays.asList(keys())); }
From source file:randori.plugin.compiled.RblFileDecompiler.java
/** * Extract the library for each declared bundle in the RBL. * It doesn't extract it from the rblFile itself but from its content. * * @param rblFile The RBL file.//from w w w .j av a 2s.c o m * @param content The content of the RBL file. * @return An InputStream sequence of the extracted libraries. * @throws IOException * @throws XMLStreamException */ public static InputStream extractLibraries(VirtualFile rblFile, byte[] content) throws IOException, XMLStreamException { final List<InputStream> libraries = new ArrayList<InputStream>(); SequenceInputStream librariesInputStream = null; InputStream swcInputStream; byte[] swcBytes; ZipFile swc; InputStream library; ZipEntry entry; final Bundle bundle = new Bundle(new File(rblFile.getPath())); final ByteArrayReadOnlyFile rof = new ByteArrayReadOnlyFile(content); final ZipFile rbl = new ZipFile(rof); readCatalog(rbl, bundle); for (IBundleLibrary iBundleLibrary : bundle.getLibraries()) { entry = rbl.getEntry(iBundleLibrary.getName() + "/bin/swc/" + iBundleLibrary.getName() + ".swc"); swcInputStream = rbl.getInputStream(entry); if (swcInputStream != null) { swcBytes = IOUtils.toByteArray(swcInputStream); if (swcBytes != null && swcBytes.length > 0) { swc = new ZipFile(new ByteArrayReadOnlyFile(swcBytes)); library = swc.getInputStream("library.swf"); libraries.add(library); libraries.add(new ByteArrayInputStream(libSeparator.getBytes())); } } } if (libraries.size() > 0) librariesInputStream = new SequenceInputStream(Collections.enumeration(libraries)); return librariesInputStream; }
From source file:org.apache.xmlgraphics.image.loader.impl.PNGFile.java
public ImageRawPNG getImageRawPNG(final ImageInfo info) throws ImageException, IOException { try (final InputStream seqStream = new SequenceInputStream(Collections.enumeration(this.streamVec))) { switch (this.colorType) { case PNG_COLOR_GRAY: if (this.hasPalette) { throw new ImageException("Corrupt PNG: color palette is not allowed!"); }/*from w w w.j av a2 s. co m*/ this.colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); break; case PNG_COLOR_RGB: // actually a check of the sRGB chunk would be necessary to // confirm // if it's really sRGB this.colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); break; case PNG_COLOR_PALETTE: if (this.hasAlphaPalette) { 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); } break; case PNG_COLOR_GRAY_ALPHA: if (this.hasPalette) { throw new ImageException("Corrupt PNG: color palette is not allowed!"); } this.colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); break; case PNG_COLOR_RGB_ALPHA: // actually a check of the sRGB chunk would be necessary to // confirm // if it's really sRGB this.colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); break; default: throw new ImageException("Unsupported color type: " + this.colorType); } // the iccProfile is still null for now final ImageRawPNG rawImage = new ImageRawPNG(info, seqStream, this.colorModel, this.bitDepth, this.iccProfile); if (this.isTransparent) { if (this.colorType == PNG_COLOR_GRAY) { rawImage.setGrayTransparentAlpha(this.grayTransparentAlpha); } else if (this.colorType == PNG_COLOR_RGB) { rawImage.setRGBTransparentAlpha(this.redTransparentAlpha, this.greenTransparentAlpha, this.blueTransparentAlpha); } else if (this.colorType == PNG_COLOR_PALETTE) { rawImage.setTransparent(); } else { // } } return rawImage; } }
From source file:org.opennms.netmgt.xml.eventconf.Mask.java
/** * Method enumerateMaskelement.// w ww . ja v a 2 s .com * * @return an Enumeration over all possible elements of this * collection */ public Enumeration<Maskelement> enumerateMaskelement() { return Collections.enumeration(this.m_maskelementList); }
From source file:UnpackedJarFile.java
public Enumeration entries() { Collection files = DeploymentUtil.listRecursiveFiles(baseDir); Manifest manifest = getManifestSafe(); LinkedList entries = new LinkedList(); URI baseURI = baseDir.getAbsoluteFile().toURI(); for (Iterator iterator = files.iterator(); iterator.hasNext();) { File entryFile = ((File) iterator.next()).getAbsoluteFile(); URI entryURI = entryFile.toURI(); URI relativeURI = baseURI.relativize(entryURI); entries.add(new UnpackedJarEntry(relativeURI.getPath(), entryFile, manifest)); }/*from w ww . j ava2 s . c o m*/ return Collections.enumeration(entries); }
From source file:org.opennms.netmgt.xml.eventconf.Events.java
/** * Method enumerateEventFile.// www .j a v a 2 s.c o m * * @return an Enumeration over all possible elements of this * collection */ public Enumeration<String> enumerateEventFile() { return Collections.enumeration(this.m_eventFileList); }
From source file:com.google.gerrit.util.http.testutil.FakeHttpServletRequest.java
@Override public Enumeration<String> getParameterNames() { return Collections.enumeration(parameters.keySet()); }
From source file:org.dspace.app.webui.util.FileUploadRequest.java
public Enumeration<String> getFileParameterNames() { Collection<String> c = fileitems.keySet(); return Collections.enumeration(c); }