Tabnine Logo
Enumeration
Code IndexAdd Tabnine to your IDE (free)

How to use
Enumeration
in
java.util

Best Java code snippets using java.util.Enumeration (Showing top 20 results out of 70,335)

Refine searchRefine arrow

  • Vector
  • Properties
  • Hashtable
  • URL
  • HttpServletRequest
  • Call
  • JarFile
  • InputStream
  • JarEntry
origin: alibaba/druid

private static void loadFilterConfig(Properties filterProperties, ClassLoader classLoader) throws IOException {
  if (classLoader == null) {
    return;
  }
  
  for (Enumeration<URL> e = classLoader.getResources("META-INF/druid-filter.properties"); e.hasMoreElements();) {
    URL url = e.nextElement();
    Properties property = new Properties();
    InputStream is = null;
    try {
      is = url.openStream();
      property.load(is);
    } finally {
      JdbcUtils.close(is);
    }
    filterProperties.putAll(property);
  }
}
origin: spring-projects/spring-framework

private static HttpHeaders createDefaultHttpHeaders(HttpServletRequest request) {
  HttpHeaders headers = new HttpHeaders();
  for (Enumeration<?> names = request.getHeaderNames(); names.hasMoreElements(); ) {
    String name = (String) names.nextElement();
    for (Enumeration<?> values = request.getHeaders(name); values.hasMoreElements(); ) {
      headers.add(name, (String) values.nextElement());
    }
  }
  return headers;
}
origin: spring-projects/spring-framework

/**
 * Copy the configured output {@link Properties}, if any, into the
 * {@link Transformer#setOutputProperty output property set} of the supplied
 * {@link Transformer}.
 * @param transformer the target transformer
 */
protected final void copyOutputProperties(Transformer transformer) {
  if (this.outputProperties != null) {
    Enumeration<?> en = this.outputProperties.propertyNames();
    while (en.hasMoreElements()) {
      String name = (String) en.nextElement();
      transformer.setOutputProperty(name, this.outputProperties.getProperty(name));
    }
  }
}
origin: google/guava

@Override
protected void scanJarFile(ClassLoader classloader, JarFile file) {
 Enumeration<JarEntry> entries = file.entries();
 while (entries.hasMoreElements()) {
  JarEntry entry = entries.nextElement();
  if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) {
   continue;
  }
  resources.get(classloader).add(entry.getName());
 }
}
origin: netty/netty

Properties props = new Properties();
try {
  Enumeration<URL> resources = classLoader.getResources("META-INF/io.netty.versions.properties");
  while (resources.hasMoreElements()) {
    URL url = resources.nextElement();
    InputStream in = url.openStream();
    try {
      props.load(in);
    } finally {
      try {
        in.close();
      } catch (Exception ignore) {
for (Object o: props.keySet()) {
  String k = (String) o;
origin: spring-projects/spring-framework

Properties props = new Properties();
while (urls.hasMoreElements()) {
  URL url = urls.nextElement();
  URLConnection con = url.openConnection();
  ResourceUtils.useCachesIfNecessary(con);
  InputStream is = con.getInputStream();
  try {
    if (resourceName.endsWith(XML_FILE_EXTENSION)) {
      props.loadFromXML(is);
      props.load(is);
    is.close();
origin: eclipse-vertx/vert.x

protected String getCommandFromManifest() {
 try {
  Enumeration<URL> resources = RunCommand.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
  while (resources.hasMoreElements()) {
   InputStream stream = resources.nextElement().openStream();
   Manifest manifest = new Manifest(stream);
   Attributes attributes = manifest.getMainAttributes();
   String mainClass = attributes.getValue("Main-Class");
   if (main.getClass().getName().equals(mainClass)) {
    String command = attributes.getValue("Main-Command");
    if (command != null) {
     stream.close();
     return command;
    }
   }
   stream.close();
  }
 } catch (IOException e) {
  throw new IllegalStateException(e.getMessage());
 }
 return null;
}
origin: log4j/log4j

Hashtable filters = new Hashtable();
Enumeration e = props.keys();
String name = "";
while (e.hasMoreElements()) {
 String key = (String) e.nextElement();
 if (key.startsWith(filterPrefix)) {
  int dotIdx = key.indexOf('.', fIdx);
   name = key.substring(dotIdx+1);
   filterOpts.add(new NameValue(name, value));
while (g.hasMoreElements()) {
 String key = (String) g.nextElement();
 String clazz = props.getProperty(key);
 if (clazz != null) {
  LogLog.debug("Filter key: ["+key+"] class: ["+props.getProperty(key) +"] props: "+filters.get(key));
  Filter filter = (Filter) OptionConverter.instantiateByClassName(clazz, Filter.class, null);
  if (filter != null) {
   PropertySetter propSetter = new PropertySetter(filter);
   Vector v = (Vector)filters.get(key);
   Enumeration filterProps = v.elements();
   while (filterProps.hasMoreElements()) {
    NameValue kv = (NameValue)filterProps.nextElement();
    propSetter.setProperty(kv.key, kv.value);
origin: apache/flink

jar = new JarFile(new File(jarFile.toURI()));
final List<JarEntry> containedJarFileEntries = new ArrayList<JarEntry>();
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
  JarEntry entry = entries.nextElement();
  String name = entry.getName();
    for (int i = 0; i < containedJarFileEntries.size(); i++) {
      final JarEntry entry = containedJarFileEntries.get(i);
      String name = entry.getName();
        throw new ProgramInvocationException(
          "An I/O error occurred while creating temporary file to extract nested library '" +
              entry.getName() + "'.", e);
        in = new BufferedInputStream(jar.getInputStream(entry));
        while ((numRead = in.read(buffer)) != -1) {
          out.write(buffer, 0, numRead);
          in.close();
origin: git-commit-id/maven-git-commit-id-plugin

@Override
public Enumeration keys() {
 Enumeration keysEnum = super.keys();
 Vector<String> keyList = new Vector<>();
 while (keysEnum.hasMoreElements()) {
  keyList.add((String)keysEnum.nextElement());
 }
 Collections.sort(keyList);
 return keyList.elements();
}
origin: spring-projects/spring-framework

@Override
public Map<String, String[]> getParameterMap() {
  Map<String, String[]> result = new LinkedHashMap<>();
  Enumeration<String> names = getParameterNames();
  while (names.hasMoreElements()) {
    String name = names.nextElement();
    result.put(name, getParameterValues(name));
  }
  return result;
}
origin: alibaba/druid

public void setColumnMargin(int margin) {
  this.margin = margin;
  Enumeration<Object> enumeration = vector.elements();
  while (enumeration.hasMoreElements()) {
    Object obj = enumeration.nextElement();
    if (obj instanceof ColumnGroup) {
      ((ColumnGroup) obj).setColumnMargin(margin);
    }
  }
}
origin: androidannotations/androidannotations

JarFile jar = null;
try {
  jarURL = new URL("file:/" + file.getCanonicalPath());
  jarURL = new URL("jar:" + jarURL.toExternalForm() + "!/");
  JarURLConnection conn = (JarURLConnection) jarURL.openConnection();
  jar = conn.getJarFile();
Enumeration<JarEntry> e = jar.entries();
while (e.hasMoreElements()) {
  JarEntry entry = e.nextElement();
  if (entry.isDirectory()) {
    if (entry.getName().toUpperCase().equals("META-INF/")) {
      continue;
      map.put(new URL(jarURL.toExternalForm() + entry.getName()), packageNameFor(entry));
    } catch (MalformedURLException murl) {
origin: skylot/jadx

  public static String getVersion() {
    try {
      ClassLoader classLoader = Jadx.class.getClassLoader();
      if (classLoader != null) {
        Enumeration<URL> resources = classLoader.getResources("META-INF/MANIFEST.MF");
        while (resources.hasMoreElements()) {
          Manifest manifest = new Manifest(resources.nextElement().openStream());
          String ver = manifest.getMainAttributes().getValue("jadx-version");
          if (ver != null) {
            return ver;
          }
        }
      }
    } catch (Exception e) {
      LOG.error("Can't get manifest file", e);
    }
    return "dev";
  }
}
origin: spring-projects/spring-framework

/**
 * Set the mappings of bean keys to a comma-separated list of method names.
 * The property key should match the bean key and the property value should match
 * the list of method names. When searching for method names for a bean, Spring
 * will check these mappings first.
 * @param mappings the mappings of bean keys to method names
 */
public void setMethodMappings(Properties mappings) {
  this.methodMappings = new HashMap<>();
  for (Enumeration<?> en = mappings.keys(); en.hasMoreElements();) {
    String beanKey = (String) en.nextElement();
    String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey));
    this.methodMappings.put(beanKey, new HashSet<>(Arrays.asList(methodNames)));
  }
}
origin: apache/incubator-dubbo

@Override
public void handle(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  String uri = request.getRequestURI();
  HessianSkeleton skeleton = skeletonMap.get(uri);
  if (!request.getMethod().equalsIgnoreCase("POST")) {
    response.setStatus(500);
  } else {
    RpcContext.getContext().setRemoteAddress(request.getRemoteAddr(), request.getRemotePort());
    Enumeration<String> enumeration = request.getHeaderNames();
    while (enumeration.hasMoreElements()) {
      String key = enumeration.nextElement();
      if (key.startsWith(Constants.DEFAULT_EXCHANGER)) {
        RpcContext.getContext().setAttachment(key.substring(Constants.DEFAULT_EXCHANGER.length()),
            request.getHeader(key));
      }
    }
    try {
      skeleton.invoke(request.getInputStream(), response.getOutputStream());
    } catch (Throwable e) {
      throw new ServletException(e);
    }
  }
}
origin: lets-blade/blade

List<FileMeta> getResourceListing(URL dirURL, String path) throws IOException {
  List<FileMeta> listFiles = new ArrayList<>();
  if (null == CACHE_JAR_FILE) {
    //strip out only the JAR file
    String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!"));
    CACHE_JAR_FILE = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
  }
  Enumeration<JarEntry> entries = CACHE_JAR_FILE.entries();
  while (entries.hasMoreElements()) {
    JarEntry jarEntry = entries.nextElement();
    String   name     = jarEntry.getName();
    if (!name.startsWith(path) || name.equals(path + "/")) {
      continue;
    }
    FileMeta fileMeta = new FileMeta();
    fileMeta.name = name.substring(path.length() + 1);
    fileMeta.isDirectory = jarEntry.isDirectory();
    if (!fileMeta.isDirectory) {
      fileMeta.length = jarEntry.getSize();
    }
    listFiles.add(fileMeta);
  }
  return listFiles;
}
origin: spring-projects/spring-framework

  throws IOException {
URLConnection con = rootDirURL.openConnection();
JarFile jarFile;
String jarFileUrl;
  ResourceUtils.useCachesIfNecessary(jarCon);
  jarFile = jarCon.getJarFile();
  jarFileUrl = jarCon.getJarFileURL().toExternalForm();
  JarEntry jarEntry = jarCon.getJarEntry();
  rootEntryPath = (jarEntry != null ? jarEntry.getName() : "");
  closeJarFile = !jarCon.getUseCaches();
  String urlFile = rootDirURL.getFile();
  try {
    int separatorIndex = urlFile.indexOf(ResourceUtils.WAR_URL_SEPARATOR);
      jarFile = new JarFile(urlFile);
      jarFileUrl = urlFile;
      rootEntryPath = "";
  for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
    JarEntry entry = entries.nextElement();
    String entryPath = entry.getName();
    if (entryPath.startsWith(rootEntryPath)) {
      String relativePath = entryPath.substring(rootEntryPath.length());
    jarFile.close();
origin: loklak/loklak_server

private static void extractContents() {
  // Check if we're running inside a JAR file
  if(!LoklakServer.class.getResource("LoklakServer.class").getPath().startsWith("file:"))
    return;
  try {
    JarFile jar =
        new JarFile(LoklakServer.class.getProtectionDomain().getCodeSource().getLocation().getPath());
    Enumeration entries = jar.entries();
    while (entries.hasMoreElements()) {
      JarEntry file = (JarEntry) entries.nextElement();
      for (String s : FOLDER_TO_EXTRACT) {
        if (file.getName().startsWith(s + File.separator)) {
          extract(jar, file);
          continue;
        }
      }
    }
  } catch (IOException e) {
    DAO.severe("An exception has occurred while extracting contents from JAR File", e);
    DAO.log("Exiting due to fatal error ...");
    System.exit(1);
  }
}
origin: redisson/redisson

/**
 * This method is periodically invoked so that memory
 * footprint will be minimized.
 */
void compress() {
  if (compressCount++ > COMPRESS_THRESHOLD) {
    compressCount = 0;
    Enumeration e = classes.elements();
    while (e.hasMoreElements())
      ((CtClass)e.nextElement()).compress();
  }
}
java.utilEnumeration

Javadoc

A legacy iteration interface.

New code should use Iterator instead. Iterator replaces the enumeration interface and adds a way to remove elements from a collection.

If you have an Enumeration and want a Collection, you can use Collections#list to get a List.

If you need an Enumeration for a legacy API and have a Collection, you can use Collections#enumeration.

Most used methods

  • nextElement
    Returns the next element in this Enumeration.
  • hasMoreElements
    Tests if this enumeration contains more elements.

Popular in Java

  • Making http requests using okhttp
  • onCreateOptionsMenu (Activity)
  • getContentResolver (Context)
  • getResourceAsStream (ClassLoader)
  • Menu (java.awt)
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now