List of usage examples for java.util Enumeration nextElement
E nextElement();
From source file:com.adito.agent.AgentRequestHandler.java
@SuppressWarnings({ "unchecked" }) private static Map getParameters(RequestHandlerRequest request) { Map parameters = new HashMap(request.getParameters()); for (Enumeration fieldNames = request.getFieldNames(); fieldNames.hasMoreElements();) { String fieldName = (String) fieldNames.nextElement(); Enumeration fieldValues = request.getFieldValues(fieldName); if (fieldValues.hasMoreElements()) parameters.put(fieldName, fieldValues.nextElement()); }//from w w w. j a v a 2s. c o m return parameters; }
From source file:com.google.code.fqueue.util.Config.java
/** * ??// w w w . j a va 2s . co m * * @param path * * @throws FileNotFoundException */ public static synchronized void iniSetting(String path) { File file; file = new File(path); FileInputStream in = null; try { in = new FileInputStream(file); Properties p = new Properties(); p.load(in); // ???Map Enumeration<?> item = p.propertyNames(); while (item.hasMoreElements()) { String key = (String) item.nextElement(); setting.put(key, p.getProperty(key)); } in.close(); } catch (FileNotFoundException e) { log.error("config file not found at" + file.getAbsolutePath()); throw new ConfigException("FileNotFoundException", e); } catch (IOException e) { log.error("config file not found at" + file.getAbsolutePath()); throw new ConfigException("IOException", e); } catch (Exception e) { throw new ConfigException("Exception", e); } }
From source file:de.micromata.genome.logging.LogRequestDumpAttribute.java
/** * Gen http request dump.//from www . j a v a 2s .c o m * * @param req the req * @return the string */ @SuppressWarnings("unchecked") public static String genHttpRequestDump(HttpServletRequest req) { StringBuilder sb = new StringBuilder(); sb.append("method: ").append(req.getMethod()).append('\n')// .append("requestURL: ").append(req.getRequestURL()).append('\n')// .append("servletPath: ").append(req.getServletPath()).append('\n')// .append("requestURI: ").append(req.getRequestURI()).append('\n') // .append("queryString: ").append(req.getQueryString()).append('\n') // .append("pathInfo: ").append(req.getPathInfo()).append('\n')// .append("contextPath: ").append(req.getContextPath()).append('\n') // .append("characterEncoding: ").append(req.getCharacterEncoding()).append('\n') // .append("localName: ").append(req.getLocalName()).append('\n') // .append("contentLength: ").append(req.getContentLength()).append('\n') // ; sb.append("Header:\n"); for (Enumeration<String> en = req.getHeaderNames(); en.hasMoreElements();) { String hn = en.nextElement(); sb.append(" ").append(hn).append(": ").append(req.getHeader(hn)).append("\n"); } sb.append("Attr: \n"); Enumeration en = req.getAttributeNames(); for (; en.hasMoreElements();) { String k = (String) en.nextElement(); Object v = req.getAttribute(k); sb.append(" ").append(k).append(": ").append(Objects.toString(v, StringUtils.EMPTY)).append('\n'); } return sb.toString(); }
From source file:com.willwinder.universalgcodesender.i18n.Localization.java
private static int getKeyCount(ResourceBundle b) { Enumeration<String> keyEnum = b.getKeys(); int ret = 0;/*from w w w . jav a2 s . c o m*/ while (keyEnum.hasMoreElements()) { keyEnum.nextElement(); ret++; } return ret; }
From source file:ke.alphacba.cms.core.util.RequestUtils.java
/** * ????Map.//from ww w . jav a2s. c o m * * @param request * @return */ public static Map<String, String> getParamMap(HttpServletRequest request) { Map<String, String> paramMap = new HashMap<String, String>(); Enumeration<String> enume = request.getParameterNames(); while (enume.hasMoreElements()) { String paramName = enume.nextElement(); paramMap.put(paramName, request.getParameter(paramName)); } return paramMap; }
From source file:Main.java
/** * Check whether the given Enumeration contains the given element. * * @param enumeration the Enumeration to check * @param element the element to look for * @return {@code true} if found, {@code false} else *///from w w w. jav a 2s . com public static boolean contains(Enumeration<?> enumeration, Object element) { if (enumeration != null) { while (enumeration.hasMoreElements()) { Object candidate = enumeration.nextElement(); if (org.springframework.util.ObjectUtils.nullSafeEquals(candidate, element)) { return true; } } } return false; }
From source file:com.dragome.compiler.utils.FileManager.java
private static List<String> findClassesInJar(JarFile jarFile) { ArrayList<String> result = new ArrayList<String>(); final Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { final JarEntry entry = entries.nextElement(); final String entryName = entry.getName(); if (entryName.endsWith(".class")) result.add(entryName.replace('/', File.separatorChar).replace(".class", "")); }//w w w. j av a 2 s.com return result; }
From source file:io.apiman.servers.gateway_h2.Starter.java
/** * Loads properties from a file and puts them into system properties. *///from w w w. j ava2 s. c o m @SuppressWarnings({ "unchecked" }) protected static void loadProperties() { URL configUrl = Starter.class.getClassLoader().getResource("gateway_h2-apiman.properties"); if (configUrl == null) { throw new RuntimeException( "Failed to find properties file (see README.md): gateway_h2-apiman.properties"); } InputStream is = null; try { is = configUrl.openStream(); Properties props = new Properties(); props.load(is); Enumeration<String> names = (Enumeration<String>) props.propertyNames(); while (names.hasMoreElements()) { String name = names.nextElement(); String value = props.getProperty(name); System.setProperty(name, value); } } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(is); } }
From source file:adalid.util.info.JavaInfo.java
public static void printManifestInfo(String extension, boolean details, Enumeration<URL> resources) { URL url;/* w w w.j a va2s . c om*/ while (resources.hasMoreElements()) { try { url = resources.nextElement(); printManifestInfo(extension, details, url); } catch (Exception ex) { logger.error(ex); } } }
From source file:cc.aileron.commons.util.ClassPattrnFinderUtils.java
/** * ??????/*from w w w . j a v a 2 s . c o m*/ * * @param targetPackage * @param pattern * @return * @throws IOException * @throws URISyntaxException * @throws ResourceNotFoundException */ private static final List<Class<?>> tryGetClassNameList(final String targetPackage, final Pattern pattern) throws IOException, URISyntaxException, ResourceNotFoundException { final List<Class<?>> result = new ArrayList<Class<?>>(); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final String path = targetPackage.replace('.', '/') + "/"; final Enumeration<URL> urls = classLoader.getResources(path); while (urls.hasMoreElements()) { final URL url = urls.nextElement(); final Resource resource = ResourceConvertUtils.convertUrl(url); for (final FileObject file : resource.toFileObject().getChildren()) { final String name = file.getName().getBaseName().split("\\.")[0]; if (!file.getType().equals(FileType.FILE) || !file.getName().getExtension().equals("class")) { continue; } if (pattern != null && !pattern.matcher(name).matches()) { continue; } final Class<?> classObject = getClass(targetPackage + "." + name); if (classObject != null) { result.add(classObject); } } } return result; }