当前位置: 首页>>代码示例>>Java>>正文


Java Enumeration类代码示例

本文整理汇总了Java中java.util.Enumeration的典型用法代码示例。如果您正苦于以下问题:Java Enumeration类的具体用法?Java Enumeration怎么用?Java Enumeration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Enumeration类属于java.util包,在下文中一共展示了Enumeration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseDescriptionFile

import java.util.Enumeration; //导入依赖的package包/类
/**
 * Parses metadata stored in a Debian Control File-like format.
 *
 * @see <a href="https://cran.r-project.org/doc/manuals/r-release/R-exts.html#The-DESCRIPTION-file">Description File</a>
 */
public static Map<String, String> parseDescriptionFile(final InputStream in) {
  checkNotNull(in);
  try {
    LinkedHashMap<String, String> results = new LinkedHashMap<>();
    InternetHeaders headers = new InternetHeaders(in);
    Enumeration headerEnumeration = headers.getAllHeaders();
    while (headerEnumeration.hasMoreElements()) {
      Header header = (Header) headerEnumeration.nextElement();
      String name = header.getName();
      String value = header.getValue()
          .replace("\r\n", "\n")
          .replace("\r", "\n"); // TODO: "should" be ASCII only, otherwise need to know encoding?
      results.put(name, value); // TODO: Supposedly no duplicates, is this true?
    }
    return results;
  } catch (MessagingException e) {
    throw new RException(null, e);
  }
}
 
开发者ID:sonatype-nexus-community,项目名称:nexus-repository-r,代码行数:25,代码来源:RMetadataUtils.java

示例2: splitFrom

import java.util.Enumeration; //导入依赖的package包/类
/**
 * This method creates a new Vector which does not contain the first
 * element up to the specified limit.
 *
 * @param original The original vector.
 * @param limit The limit.
 */
private Vector<SnmpVarBind> splitFrom(Vector<SnmpVarBind> original, int limit) {

    int max= original.size();
    Vector<SnmpVarBind> result= new Vector<>(max - limit);
    int i= limit;

    // Ok the loop looks a bit strange. But in order to improve the
    // perf, we try to avoid reference to the limit variable from
    // within the loop ...
    //
    for(Enumeration<SnmpVarBind> e= original.elements(); e.hasMoreElements(); --i) {
        SnmpVarBind var= e.nextElement();
        if (i >0)
            continue;
        result.addElement(new SnmpVarBind(var.oid, var.value));
    }
    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:SnmpMibAgent.java

示例3: getGenericRules

import java.util.Enumeration; //导入依赖的package包/类
/**
 * Gets the genericRules attribute of the YassLanguageFilter object
 *
 * @param data Description of the Parameter
 * @return The genericRules value
 */
public String[] getGenericRules(Vector<YassSong> data) {
    Vector<String> langs = new Vector<>();
    for (Enumeration<?> e = data.elements(); e.hasMoreElements(); ) {
        YassSong s = (YassSong) e.nextElement();
        String lang = s.getLanguage();
        if (lang == null || lang.length() < 1) {
            continue;
        }
        if (!langs.contains(lang)) {
            langs.addElement(lang);

        }
    }
    Collections.sort(langs);

    return langs.toArray(new String[langs.size()]);
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:24,代码来源:YassLanguageFilter.java

示例4: replaceIdsWithShortcodes

import java.util.Enumeration; //导入依赖的package包/类
private void replaceIdsWithShortcodes(Vector<Hashtable<String, String>> materials) {
  xLogger.fine("Entered replaceIdsWithShortcodes");
  if (materials == null || materials.isEmpty()) {
    return;
  }
  Enumeration<Hashtable<String, String>> en = materials.elements();
  while (en.hasMoreElements()) {
    Hashtable<String, String> ht = en.nextElement();
    Long materialId = Long.valueOf(ht.get(JsonTagsZ.MATERIAL_ID));
    try {
      IMaterial m = mcs.getMaterial(materialId);
      String shortCode = m.getShortCode();
      String shortName = m.getShortName();
      if (shortCode != null) {
        ht.put(JsonTagsZ.MATERIAL_ID, shortCode);
        xLogger.fine("replaceIdsWithShortcodes: replaced {0} with {1}", materialId, shortCode);
      }
      if (shortName != null && !shortName.isEmpty()) {
        ht.put(JsonTagsZ.NAME, shortName);
      }
    } catch (ServiceException e) {
      xLogger.warn("Unable to get material with ID: {0}", materialId);
    }
  }
  xLogger.fine("Exiting replaceIdsWithShortcodes");
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:27,代码来源:MachineProtocolMessageHandler.java

示例5: isSigned

import java.util.Enumeration; //导入依赖的package包/类
private boolean isSigned(final JarFile jar) throws IOException {
    Enumeration<JarEntry> entries = jar.entries();
    boolean signatureInfoPresent = false;
    boolean signatureFilePresent = false;
    while (entries.hasMoreElements()) {
        String entryName = entries.nextElement().getName();
        if (entryName.startsWith("META-INF/")) {
            if (entryName.endsWith(".RSA") || entryName.endsWith(".DSA")) {
                signatureFilePresent = true;
                if (signatureInfoPresent) {
                    break;
                }
            } else if (entryName.endsWith(".SF")) {
                signatureInfoPresent = true;
                if (signatureFilePresent) {
                    break;
                }
            }
        }
    }
    return signatureFilePresent && signatureInfoPresent;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:MakeNBM.java

示例6: getHeaders

import java.util.Enumeration; //导入依赖的package包/类
/**
 * Fetches MIME header information from HTTP request object.
 *
 * @param req HTTP request object
 * @return MimeHeaders that were extracted from the HTTP request
 */
public static MimeHeaders getHeaders(HttpServletRequest req) {
    Enumeration enumeration = req.getHeaderNames();
    MimeHeaders headers = new MimeHeaders();

    while (enumeration.hasMoreElements()) {
        String name = (String) enumeration.nextElement();
        String value = req.getHeader(name);

        StringTokenizer values = new StringTokenizer(value, ",");
        while (values.hasMoreTokens()) {
            headers.addHeader(name, values.nextToken().trim());
        }
    }
    return headers;
}
 
开发者ID:vrk-kpa,项目名称:xrd4j,代码行数:22,代码来源:AdapterUtils.java

示例7: readCredentials

import java.util.Enumeration; //导入依赖的package包/类
/**
 * Parses the password file to read the credentials.
 * Returns an ArrayList of arrays of 2 string:
 * {<subject>, <password>}.
 * If the password file does not exists, return an empty list.
 * (File not found = empty file).
 **/
private ArrayList readCredentials(String passwordFileName)
    throws IOException {
    final Properties pws = new Properties();
    final ArrayList  result = new ArrayList();
    final File f = new File(passwordFileName);
    if (!f.exists()) return result;
    FileInputStream fin = new FileInputStream(passwordFileName);
    try {pws.load(fin);}finally{fin.close();}
    for (Enumeration en=pws.propertyNames();en.hasMoreElements();) {
        final String[] cred = new String[2];
        cred[0]=(String)en.nextElement();
        cred[1]=pws.getProperty(cred[0]);
        result.add(cred);
    }
    return result;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:RmiBootstrapTest.java

示例8: X509Extensions

import java.util.Enumeration; //导入依赖的package包/类
/**
 * Constructor from two vectors
 *
 * @param objectIDs a vector of the object identifiers.
 * @param values a vector of the extension values.
 */
public X509Extensions(
    Vector      objectIDs,
    Vector      values)
{
    Enumeration e = objectIDs.elements();

    while (e.hasMoreElements())
    {
        this.ordering.addElement(e.nextElement());
    }

    int count = 0;

    e = this.ordering.elements();

    while (e.hasMoreElements())
    {
        DERObjectIdentifier     oid = (DERObjectIdentifier)e.nextElement();
        X509Extension           ext = (X509Extension)values.elementAt(count);

        this.extensions.put(oid, ext);
        count++;
    }
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:31,代码来源:X509Extensions.java

示例9: searchBuildNumber

import java.util.Enumeration; //导入依赖的package包/类
/** @param en enumeration of URLs */
private static String searchBuildNumber(Enumeration<URL> en) {
    String value = null;
    try {
        java.util.jar.Manifest mf;
        URL u = null;
        while(en.hasMoreElements()) {
            u = en.nextElement();
            InputStream is = u.openStream();
            mf = new java.util.jar.Manifest(is);
            is.close();
            // #251035: core-base now allows impl dependencies, with manually added impl version. Prefer Build-Version.
            value = mf.getMainAttributes().getValue("OpenIDE-Module-Build-Version"); // NOI18N
            if (value == null) {
                value = mf.getMainAttributes().getValue("OpenIDE-Module-Implementation-Version"); // NOI18N
            }
            if (value != null) {
                break;
            }
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    return value;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:MainImpl.java

示例10: execute

import java.util.Enumeration; //导入依赖的package包/类
public void execute() throws BuildException {
    // execute all nested tasks
    for ( Enumeration e = tasks.elements(); e.hasMoreElements(); ) {
        Task task = ( Task ) e.nextElement();
        if ( task instanceof Breakable ) {
            task.perform();
            if ( ( ( Breakable ) task ).doBreak() ) {
                setBreak( true );
                return ;
            }
        }
        else {
            task.perform();
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:ElseTask.java

示例11: getCodeSources

import java.util.Enumeration; //导入依赖的package包/类
CodeSource[] getCodeSources(URL url) {
    ensureInitialization();
    if (jv != null) {
        return jv.getCodeSources(this, url);
    }

    /*
     * JAR file has no signed content. Is there a non-signing
     * code source?
     */
    Enumeration<String> unsigned = unsignedEntryNames();
    if (unsigned.hasMoreElements()) {
        return new CodeSource[]{JarVerifier.getUnsignedCS(url)};
    } else {
        return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:JarFile.java

示例12: writeZipEntriesToFile

import java.util.Enumeration; //导入依赖的package包/类
public static void writeZipEntriesToFile(String zipFileName, String outputFileName) {
    Charset charset = StandardCharsets.UTF_8;
    Path outputFilePath = Paths.get(outputFileName);

    try {
        try (
                ZipFile zip = new ZipFile(zipFileName);
                BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset);
        ) {

            String newLine = System.getProperty("line.separator");
            for (Enumeration entries = zip.entries(); entries.hasMoreElements(); ) {
                // Берем имя файла из архива и записываем его в результирующий файл
                // Get the entry name and write it to the output file
                String zipEntryName = ((ZipEntry) entries.nextElement()).getName() + newLine;
                writer.write(zipEntryName, 0, zipEntryName.length());
            }
        }

    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:avedensky,项目名称:JavaRushTasks,代码行数:24,代码来源:Solution.java

示例13: writeStyles

import java.util.Enumeration; //导入依赖的package包/类
/**
 * Outputs the styles as a single element. Styles are not stored as
 * elements, but part of the document. For the time being styles are
 * written out as a comment, inside a style tag.
 */
void writeStyles(StyleSheet sheet) throws IOException {
    if (sheet != null) {
        Enumeration styles = sheet.getStyleNames();
        if (styles != null) {
            boolean outputStyle = false;
            while (styles.hasMoreElements()) {
                String name = (String) styles.nextElement();
                // Don't write out the default style.
                if (!StyleContext.DEFAULT_STYLE.equals(name)
                    && writeStyle(name, sheet.getStyle(name), outputStyle)) {
                    outputStyle = true;
                }
            }
            if (outputStyle) {
                writeStyleEndTag();
            }
        }
    }
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:25,代码来源:AltHTMLWriter.java

示例14: writeForwardReferences

import java.util.Enumeration; //导入依赖的package包/类
/**
 * Write forward references for referenced interfaces and valuetypes
 * ...but not if the reference is to a boxed IDLEntity,
 * @param refHash Hashtable loaded with referenced types
 * @param p The output stream.
 */
protected void writeForwardReferences(
                                      Hashtable refHash,
                                      IndentingWriter p )
    throws IOException {
    Enumeration refEnum = refHash.elements();
    nextReference:
    while ( refEnum.hasMoreElements() ) {
        Type t = (Type)refEnum.nextElement();
        if ( t.isCompound() ) {
            CompoundType ct = (CompoundType)t;
            if ( ct.isIDLEntity() )
                continue nextReference;                  //ignore IDLEntity reference
        }
        writeForwardReference( t,p );
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:IDLGenerator.java

示例15: doGet

import java.util.Enumeration; //导入依赖的package包/类
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

    ServletOutputStream out = response.getOutputStream();
    response.setContentType("text/plain");

    Enumeration e = ((HttpServletRequest)request).getHeaders("Accept-Encoding");
    while (e.hasMoreElements()) {
        String name = (String)e.nextElement();
        out.println(name);
        if (name.indexOf("gzip") != -1) {
            out.println("gzip supported -- able to compress");
        }
        else {
            out.println("gzip not supported");
        }
    }


    out.println("Compression Filter Test Servlet");
    out.close();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:CompressionFilterTestServlet.java


注:本文中的java.util.Enumeration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。