Java Code Examples for java.util.Enumeration

The following are top voted examples for showing how to use java.util.Enumeration. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: nexus-repository-r   File: RMetadataUtils.java   View source code 8 votes vote down vote up
/**
 * 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);
  }
}
 
Example 2
Project: OpenJSharp   File: SnmpMibAgent.java   View source code 8 votes vote down vote up
/**
 * 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;
}
 
Example 3
Project: Yass   File: YassLanguageFilter.java   View source code 8 votes vote down vote up
/**
 * 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()]);
}
 
Example 4
Project: logistimo-web-service   File: MachineProtocolMessageHandler.java   View source code 7 votes vote down vote up
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");
}
 
Example 5
Project: incubator-netbeans   File: MakeNBM.java   View source code 6 votes vote down vote up
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;
}
 
Example 6
Project: xrd4j   File: AdapterUtils.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Project: jdk8u-jdk   File: RmiBootstrapTest.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 8
Project: BiglyBT   File: X509Extensions.java   View source code 6 votes vote down vote up
/**
 * 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++;
    }
}
 
Example 9
Project: incubator-netbeans   File: MainImpl.java   View source code 6 votes vote down vote up
/** @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;
}
 
Example 10
Project: parabuild-ci   File: ElseTask.java   View source code 6 votes vote down vote up
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();
        }
    }
}
 
Example 11
Project: openjdk-jdk10   File: JarFile.java   View source code 6 votes vote down vote up
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;
    }
}
 
Example 12
Project: JavaRushTasks   File: Solution.java   View source code 6 votes vote down vote up
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();
    }
}
 
Example 13
Project: Dahlem_SER316   File: AltHTMLWriter.java   View source code 6 votes vote down vote up
/**
 * 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();
            }
        }
    }
}
 
Example 14
Project: OpenJSharp   File: IDLGenerator.java   View source code 6 votes vote down vote up
/**
 * 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 );
    }
}
 
Example 15
Project: tomcat7   File: CompressionFilterTestServlet.java   View source code 6 votes vote down vote up
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();
}
 
Example 16
Project: FSTestTools   File: InitLog4jLoggingRule.java   View source code 6 votes vote down vote up
/**
 * Returns true if it appears that log4j have been previously configured. This code checks to see if there are any appenders defined for log4j
 * which is the definitive way to tell if log4j is already initialized. See http://wiki.apache.org/logging-log4j/UsefulCode
 *
 * @return true if Log4J is configured, false otherwise.
 */
private static boolean isLog4JConfigured() {
    final Enumeration<?> appenders = Logger.getRootLogger().getAllAppenders();
    if (appenders.hasMoreElements()) {
        return true;
    } else {
        final Enumeration<?> loggers = LogManager.getCurrentLoggers();
        while (loggers.hasMoreElements()) {
            final Logger c = (Logger) loggers.nextElement();
            if (c.getAllAppenders().hasMoreElements()) {
                return true;
            }
        }
    }
    return false;
}
 
Example 17
Project: tomcat7   File: ImplicitObjectELResolver.java   View source code 6 votes vote down vote up
public Map<String,String> getParam() {
    if (this.param == null) {
        this.param = new ScopeMap<String>() {
            @Override
            protected Enumeration<String> getAttributeNames() {
                return page.getRequest().getParameterNames();
            }

            @Override
            protected String getAttribute(String name) {
                return page.getRequest().getParameter(name);
            }
        };
    }
    return this.param;
}
 
Example 18
Project: Java_Certificado   File: CertificadoService.java   View source code 6 votes vote down vote up
/**
 * Metodo Que retorna um Certificado do Tipo A3
 *
 * @param marca
 * @param dll
 * @param senha
 * @return
 * @throws CertificadoException
 */
public static Certificado certificadoA3(String marca, String dll, String senha) throws CertificadoException {

    Certificado certificado = new Certificado();
    try {
        certificado.setMarcaA3(marca);
        certificado.setSenha(senha);
        certificado.setDllA3(dll);
        certificado.setTipo(Certificado.A3);

        Enumeration<String> aliasEnum = getKeyStore(certificado).aliases();

        certificado.setNome(aliasEnum.nextElement());
        certificado.setVencimento(DataValidade(certificado).toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
        certificado.setDiasRestantes(diasRestantes(certificado));
        certificado.setValido(valido(certificado));
    } catch (KeyStoreException e) {
        throw new CertificadoException("Erro ao carregar informações do certificado:" + e.getMessage());
    }

    return certificado;

}
 
Example 19
Project: dxram   File: ManifestHelper.java   View source code 6 votes vote down vote up
/**
 * Get the value of a property within the manifest file.
 *
 * @param p_class
 *     Target class within the jar package.
 * @param p_key
 *     Key for the value to get.
 * @return If value is found it is returned as a string, null otherwise.
 */
public static String getProperty(final Class<?> p_class, final String p_key) {
    String value = null;
    try {
        Enumeration<URL> resources = p_class.getClassLoader().getResources("META-INF/MANIFEST.MF");
        while (resources.hasMoreElements()) {
            Manifest manifest = new Manifest(resources.nextElement().openStream());
            // check that this is your manifest and do what you need or get the next one

            Attributes attr = manifest.getMainAttributes();
            value = attr.getValue(p_key);

            if (value != null) {
                break;
            }
        }
    } catch (final IOException e) {
        e.printStackTrace();
    }
    return value;
}
 
Example 20
Project: tomcat7   File: ApplicationContext.java   View source code 6 votes vote down vote up
/**
 * List resource paths (recursively), and store all of them in the given
 * Set.
 */
private static void listCollectionPaths(Set<String> set,
        DirContext resources, String path) throws NamingException {

    Enumeration<Binding> childPaths = resources.listBindings(path);
    while (childPaths.hasMoreElements()) {
        Binding binding = childPaths.nextElement();
        String name = binding.getName();
        StringBuilder childPath = new StringBuilder(path);
        if (!"/".equals(path) && !path.endsWith("/"))
            childPath.append("/");
        childPath.append(name);
        Object object = binding.getObject();
        if (object instanceof DirContext) {
            childPath.append("/");
        }
        set.add(childPath.toString());
    }

}
 
Example 21
Project: ChronoBike   File: CObjectCatalog.java   View source code 6 votes vote down vote up
public CEntityFileDescriptor getFileDescriptor(String name)
{
	CEntityFileDescriptor eFD = m_tabFileDescriptor.get(name) ;
	if (eFD != null)
	{
		return  eFD ;
	}
	
	CDataEntity record = GetDataEntity(name, "") ;
	if (record != null)
	{
		Enumeration<CEntityFileDescriptor> enm = m_tabFileDescriptor.elements() ;
		while (enm.hasMoreElements())
		{
			eFD = enm.nextElement() ;
			CDataEntity r = eFD.GetRecord() ;
			if (r == record)
			{
				return eFD ;
			}
		}
	}
	return null ;
}
 
Example 22
Project: org.alloytools.alloy   File: Version.java   View source code 6 votes vote down vote up
private static Manifest getManifest() {
	try {
		Enumeration<URL> resources = Version.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
		while (resources.hasMoreElements()) {
			URL url = resources.nextElement();
			Manifest m = new Manifest(url.openStream());
			String value = m.getMainAttributes().getValue("Bundle-SymbolicName");
			if (value != null && value.equals("org.alloytools.alloy.dist")) {
				return m;
			}
		}
	} catch (IOException e) {
		// we ignore
	}

	return null;
}
 
Example 23
Project: Yass   File: YassSheet.java   View source code 6 votes vote down vote up
/**
 * Description of the Method
 *
 * @param g2 Description of the Parameter
 */
public void paintVersionsText(Graphics2D g2) {
    if (!versionTextPainted) {
        return;
    }

    int off = 1;
    Enumeration<Vector<YassRectangle>> er = rects.elements();
    for (Enumeration<YassTable> e = tables.elements(); e.hasMoreElements()
            && er.hasMoreElements(); ) {
        YassTable t = e.nextElement();
        Vector<?> r = er.nextElement();
        if (t == table) {
            continue;
        }
        Color c = t.getTableColor();
        paintTableText(g2, t, r, c.darker(), c, off, 0, false);
        off++;
    }
}
 
Example 24
Project: istio-ola   File: OlaController.java   View source code 6 votes vote down vote up
@CrossOrigin
@RequestMapping(method = RequestMethod.GET, value = "/ola", produces = "text/plain")
@ApiOperation("Returns the greeting in Portuguese")
public String ola(HttpServletRequest request) {
  String hostname = System.getenv().getOrDefault("HOSTNAME", "Unknown");
  Enumeration<String> headerNames = request.getHeaderNames();

  StringBuffer headerMsg = new StringBuffer("{");

  while (headerNames.hasMoreElements()) {
    String headerName = headerNames.nextElement();
    String headerValue = request.getHeader(headerName);
    if (headerValue != null) {
      headerMsg.append(String.format("{\"%s\":\"%s\"}", headerName, headerValue));
      headerMsg.append(",");
    }
  }

  headerMsg.append("}");

  log.info("Request Headers:{}", headerMsg);
  return String.format("Olá de %s", hostname);
}
 
Example 25
Project: SER316-Aachen   File: AltHTMLWriter.java   View source code 6 votes vote down vote up
/**
 * 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();
            }
        }
    }
}
 
Example 26
Project: gemini.blueprint   File: MockServiceReference.java   View source code 5 votes vote down vote up
public String[] getPropertyKeys() {
	String[] keys = new String[this.properties.size()];
	Enumeration ks = this.properties.keys();

	for (int i = 0; i < keys.length && ks.hasMoreElements(); i++) {
		keys[i] = (String) ks.nextElement();
	}

	return keys;
}
 
Example 27
Project: OpenJSharp   File: DatatypeLibraryLoader.java   View source code 5 votes vote down vote up
Enumeration getResources(String resName) {
  try {
    return cl.getResources(resName);
  }
  catch (IOException e) {
    return new Singleton(null);
  }
}
 
Example 28
Project: dacapobench   File: JavaCodeGenerator.java   View source code 5 votes vote down vote up
/**Generate the parser, lexer, treeparser, and token types in Java */
public void gen() {
    // Do the code generation
    try {
        // Loop over all grammars
        Enumeration grammarIter = behavior.grammars.elements();
        while (grammarIter.hasMoreElements()) {
            Grammar g = (Grammar)grammarIter.nextElement();
            // Connect all the components to each other
            g.setGrammarAnalyzer(analyzer);
            g.setCodeGenerator(this);
            analyzer.setGrammar(g);
            // To get right overloading behavior across hetrogeneous grammars
            setupGrammarParameters(g);
            g.generate();
            // print out the grammar with lookahead sets (and FOLLOWs)
            // System.out.print(g.toString());
            exitIfError();
        }

        // Loop over all token managers (some of which are lexers)
        Enumeration tmIter = behavior.tokenManagers.elements();
        while (tmIter.hasMoreElements()) {
            TokenManager tm = (TokenManager)tmIter.nextElement();
            if (!tm.isReadOnly()) {
                // Write the token manager tokens as Java
                // this must appear before genTokenInterchange so that
                // labels are set on string literals
                genTokenTypes(tm);
                // Write the token manager tokens as plain text
                genTokenInterchange(tm);
            }
            exitIfError();
        }
    }
    catch (IOException e) {
        antlrTool.reportException(e, null);
    }
}
 
Example 29
Project: dacapobench   File: Grammar.java   View source code 5 votes vote down vote up
/** Print out the grammar without actions */
public String toString() {
    StringBuffer buf = new StringBuffer(20000);
    Enumeration ids = rules.elements();
    while (ids.hasMoreElements()) {
        RuleSymbol rs = (RuleSymbol)ids.nextElement();
        if (!rs.id.equals("mnextToken")) {
            buf.append(rs.getBlock().toString());
            buf.append("\n\n");
        }
    }
    return buf.toString();
}
 
Example 30
Project: NBANDROID-V2   File: MavenDownloader.java   View source code 5 votes vote down vote up
public static void unzip(File zipFile, File destination)
        throws IOException {
    ZipFile zip = new ZipFile(zipFile);
    try {
        Enumeration<ZipArchiveEntry> e = zip.getEntries();
        while (e.hasMoreElements()) {
            ZipArchiveEntry entry = e.nextElement();
            File file = new File(destination, entry.getName());
            if (entry.isDirectory()) {
                file.mkdirs();
            } else {
                InputStream is = zip.getInputStream(entry);
                File parent = file.getParentFile();
                if (parent != null && parent.exists() == false) {
                    parent.mkdirs();
                }
                FileOutputStream os = new FileOutputStream(file);
                try {
                    IOUtils.copy(is, os);
                } finally {
                    os.close();
                    is.close();
                }
                file.setLastModified(entry.getTime());
                int mode = entry.getUnixMode();
                if ((mode & EXEC_MASK) != 0) {
                    if (!file.setExecutable(true)) {
                    }
                }
            }
        }
    } finally {
        ZipFile.closeQuietly(zip);
    }
}
 
Example 31
Project: sstore-soft   File: HsqlDatabaseProperties.java   View source code 5 votes vote down vote up
void filterLoadedProperties() {

        Enumeration en = stringProps.propertyNames();

        while (en.hasMoreElements()) {
            String  key    = (String) en.nextElement();
            boolean accept = meta.containsKey(key);

            if (!accept) {
                stringProps.remove(key);
            }
        }
    }
 
Example 32
Project: android-apkbox   File: ApkNative.java   View source code 5 votes vote down vote up
/**
 * getLibFiles
 *
 * @param zipFile   zipFile
 * @param targetDir targetDir
 */
private final static Map<String, Map<String, String>> getLibFiles(String zipFile, String targetDir) {
    Map<String, Map<String, String>> entryFiles = new HashMap<String, Map<String, String>>();
    try {
        ZipFile zf = new ZipFile(zipFile);
        Enumeration<?> entries = zf.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = ((ZipEntry) entries.nextElement());
            if (entry.getName().startsWith("lib/")) {
                String[] entrys = entry.getName().split("/");
                if (entrys.length >= 3) {
                    String abi = entrys[1];
                    String targetEntry = entrys[entrys.length - 1];
                    String libraryEntry = targetDir + "/" + targetEntry;
                    if (entryFiles.containsKey(abi)) {
                        entryFiles.get(abi).put(entry.getName(), libraryEntry);
                    } else {
                        Map<String, String> libs = new HashMap<String, String>();
                        libs.put(entry.getName(), libraryEntry);
                        entryFiles.put(abi, libs);
                    }
                }
            }
        }
        zf.close();
    } catch (Exception e) {
    }
    return entryFiles;
}
 
Example 33
Project: ramus   File: Response.java   View source code 5 votes vote down vote up
public java.io.PrintStream writeHead() throws IOException {
    final java.io.PrintStream out = new java.io.PrintStream(stream, false, HTTPParser.ENCODING);
    writer = out;
    out.println("HTTP/1.1 200 OK");
    out.println("Server: RamusLightServer");
    out.println("Expires: Mon, 01 Jan 1990 00:00:00 GMT");
    if (contentType != null)
        out.println("Content-type: " + contentType);
    if (contentDisposition != null) {
        out.println("Content-disposition: " + contentDisposition);
    }
    if (ramusContentDisposition != null)
        out.println("Ramus-content-disposition: " + ramusContentDisposition);
    if (cookies.size() > 0) {
        String s = "";
        final Enumeration<String> e = cookies.keys();
        while (e.hasMoreElements()) {
            final String key = e.nextElement();
            s += key + "=" + cookies.get(key) + ";";
            if (e.hasMoreElements())
                s += " ";
        }
        out.println("Set-Cookie: " + s);
    }
    out.println();
    return out;
}
 
Example 34
Project: T0rlib4j   File: InetRange.java   View source code 5 votes vote down vote up
private boolean checkHostEnding(final String host) {
	final Enumeration<String> enumx = end_names.elements();
	while (enumx.hasMoreElements()) {
		if (host.endsWith(enumx.nextElement())) {
			return true;
		}
	}
	return false;
}
 
Example 35
Project: openjdk-jdk10   File: ReasonFlags.java   View source code 5 votes vote down vote up
/**
 * Return an enumeration of names of attributes existing within this
 * attribute.
 */
public Enumeration<String> getElements () {
    AttributeNameEnumeration elements = new AttributeNameEnumeration();
    for( int i=0; i<NAMES.length; i++ ) {
        elements.addElement(NAMES[i]);
    }
    return (elements.elements());
}
 
Example 36
Project: ipack   File: RSAPublicKeyStructure.java   View source code 5 votes vote down vote up
public RSAPublicKeyStructure(
    ASN1Sequence  seq)
{
    if (seq.size() != 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
                + seq.size());
    }

    Enumeration e = seq.getObjects();

    modulus = ASN1Integer.getInstance(e.nextElement()).getPositiveValue();
    publicExponent = ASN1Integer.getInstance(e.nextElement()).getPositiveValue();
}
 
Example 37
Project: myfaces-trinidad   File: ModifiableAbstractAttributeMap.java   View source code 5 votes vote down vote up
@Override
public void clear()
{
  final List<K> names = new ArrayList<K>();

  for (final Enumeration<K> e = getAttributeNames(); e.hasMoreElements();)
  {
    names.add(e.nextElement());
  }

  for (final K val : names)
  {
    removeAttribute(val);
  }
}
 
Example 38
Project: jdk8u-jdk   File: BasicTableUI.java   View source code 5 votes vote down vote up
/**
 * Return the maximum size of the table. The maximum height is the
 * row heighttimes the number of rows.
 * The maximum width is the sum of the maximum widths of each column.
 */
public Dimension getMaximumSize(JComponent c) {
    long width = 0;
    Enumeration enumeration = table.getColumnModel().getColumns();
    while (enumeration.hasMoreElements()) {
        TableColumn aColumn = (TableColumn)enumeration.nextElement();
        width = width + aColumn.getMaxWidth();
    }
    return createTableSize(width);
}
 
Example 39
Project: jdk8u-jdk   File: AquaTableHeaderUI.java   View source code 5 votes vote down vote up
/**
 * Return the minimum size of the header. The minimum width is the sum of the minimum widths of each column (plus
 * inter-cell spacing).
 */
public Dimension getMinimumSize(final JComponent c) {
    long width = 0;
    final Enumeration<TableColumn> enumeration = header.getColumnModel().getColumns();
    while (enumeration.hasMoreElements()) {
        final TableColumn aColumn = enumeration.nextElement();
        width = width + aColumn.getMinWidth();
    }
    return createHeaderSizeAqua(width);
}
 
Example 40
Project: incubator-netbeans   File: FilesystemBugsTest.java   View source code 5 votes vote down vote up
/** #8124 When attributes are deleted from file objects, so that no attributes remain set
 *  on any file objects in a folder, the .nbattrs file should be deleted. When no
 *   attributes remain on a particular file object, that <fileobject> tag should be
 *   deleted from the .nbattrs even if others remain.
 */
public void testDeleteAttrsFileAfterDeleteAttrib() throws Exception {
    FileObject folder = getWriteFolder();
    FileObject fo = folder.getFileObject("testAttr");
    if (fo == null) {
        fo = folder.createData("testAttr");
    }
    // set any attribute
    fo.setAttribute("blbost", "blbost");
    // flush
    System.gc();
    System.gc();
    // delete all attributes
    FileObject fos[] = folder.getChildren();
    for (int i = 0; i < fos.length; i++) {
        Enumeration keys = fos[i].getAttributes();
        while (keys.hasMoreElements()) {
            fos[i].setAttribute((String) keys.nextElement(), null);
        }
    }
    // flush
    System.gc();
    System.gc();
    // test if exists .nbattrs
    File nbattrs = new File(FileUtil.toFile(folder), ".nbattrs");
    assertTrue("Empty nbattrs exists in folder:" + FileUtil.toFile(folder), nbattrs.exists() == false);


}