Example usage for java.util Set iterator

List of usage examples for java.util Set iterator

Introduction

In this page you can find the example usage for java.util Set iterator.

Prototype

Iterator<E> iterator();

Source Link

Document

Returns an iterator over the elements in this set.

Usage

From source file:de.tuttas.servlets.ClientConfig.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//from  w w w  . j  a va 2  s  .  c o  m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
        /* TODO output your page here. You may use following sample code. */
        Config c = Config.getInstance();
        Set set = c.clientConfig.keySet();

        Iterator<?> keys = set.iterator();

        while (keys.hasNext()) {

            String key = (String) keys.next();

            out.println("var " + key + "=\"" + c.clientConfig.get(key) + "\";");

        }
        out.println("var debug=" + c.debug + ";");
        out.println("var servername=\"" + request.getServerName() + "\";");
        out.println("var serverport=" + request.getServerPort() + ";");

    }
}

From source file:com.gemstone.gemfire.management.internal.cli.functions.DataCommandFunction.java

/**
 * Returns a sorted list of all region full paths found in the specified
 * cache./*  w w w. j a va  2 s  .c o m*/
 * @param cache The cache to search.
 * @param recursive recursive search for sub-regions
 * @return Returns a sorted list of all region paths defined in the 
 *         distributed system.  
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static List getAllRegionPaths(Cache cache, boolean recursive) {
    ArrayList list = new ArrayList();
    if (cache == null) {
        return list;
    }

    // get a list of all root regions
    Set regions = cache.rootRegions();
    Iterator itor = regions.iterator();

    while (itor.hasNext()) {
        String regionPath = ((Region) itor.next()).getFullPath();

        Region region = cache.getRegion(regionPath);
        list.add(regionPath);
        Set subregionSet = region.subregions(true);
        if (recursive) {
            for (Iterator subIter = subregionSet.iterator(); subIter.hasNext();) {
                list.add(((Region) subIter.next()).getFullPath());
            }
        }
    }
    Collections.sort(list);
    return list;
}

From source file:it.cavallefano.abstractfactoryspring.factory.ObjFactory.java

@Override
public void setApplicationContext(ApplicationContext ac) throws BeansException {
    mApplicationContext = ac;//from   w w  w. j  a  v  a 2 s. c  om

    Map<String, Car> processorMap = mApplicationContext.getBeansOfType(Car.class);
    if (processorMap.isEmpty()) {
        Error noProcessorError = new Error("No Car configured. Check Spring Context");
        throw noProcessorError;
    }
    Set<Entry<String, Car>> processorEntrySet = processorMap.entrySet();

    Iterator<Entry<String, Car>> iterator = processorEntrySet.iterator();

    while (iterator.hasNext()) {
        Entry<String, Car> entry = iterator.next();

        processorBeanMap.put(entry.getValue().getClass().getSimpleName(), entry.getKey());
    }
}

From source file:edu.wisc.my.stats.web.support.WritableHttpServletRequestWrapper.java

/**
 * @see javax.servlet.ServletRequestWrapper#getParameterNames()
 *///w  w w  . jav a2  s  .c  o  m
@Override
public Enumeration getParameterNames() {
    final Set<String> parameterNames = this.parameters.keySet();
    return new IteratorEnumeration(parameterNames.iterator());
}

From source file:com.hmsinc.epicenter.classifier.regex.RegexClassifier.java

/**
 * @param entry//from  w ww . ja  va  2  s. c  om
 * @return
 */
private static String combineItems(final Entry entry) {

    final Set<String> itemList = new HashSet<String>();

    if (entry.getValue() != null) {
        itemList.add(entry.getValue());
    }

    if (entry.getItems() != null && entry.getItems().size() > 0) {
        for (Item item : entry.getItems()) {
            if (EntryType.SEGMENT.equals(item.getType())) {
                final StringBuilder sb = new StringBuilder();
                sb.append("((\\s+|^)").append(item.getValue()).append("(\\s+|$))");
                itemList.add(sb.toString());
            } else {
                itemList.add(item.getValue());
            }
        }
    }

    final String ret;
    if (itemList.size() == 1) {
        ret = itemList.iterator().next();
    } else if (itemList.size() > 1) {
        final StringBuilder sb = new StringBuilder();
        sb.append("(").append(StringUtils.join(itemList, "|")).append(")");
        ret = sb.toString();
    } else {
        throw new IllegalArgumentException("Invalid entry: " + entry.toString());
    }

    return ret;

}

From source file:io.cloudslang.engine.data.SqlInQueryReader.java

private Set<String> extractAndRemoveUpToLimit(Set<String> source, int limit) {
    Set<String> result = new HashSet<>();
    Iterator<String> iterator = source.iterator();
    while (iterator.hasNext() && result.size() < limit) {
        result.add(iterator.next());//  ww w. ja  v a 2 s. c o  m
        iterator.remove();
    }
    return result;
}

From source file:de.blizzy.documentr.markdown.macro.GroovyMacroScannerTest.java

@Test
public void findGroovyMacros() {
    Set<IMacro> macros = scanner.findGroovyMacros();
    IMacro macro = macros.iterator().next();
    assertEquals(MACRO_CLASS_NAME, macro.getClass().getName());
}

From source file:fr.hoteia.qalingo.core.service.impl.ReferentialDataServiceImpl.java

private Map<String, String> buildMap(final ResourceBundle bundleByLocale) {
    Map<String, String> mapByLocale = new HashMap<String, String>();
    Set<String> keyList = bundleByLocale.keySet();
    for (Iterator<String> iterator = keyList.iterator(); iterator.hasNext();) {
        final String key = (String) iterator.next();
        mapByLocale.put(key, (String) bundleByLocale.getObject(key));
    }//from  w  w  w .j  ava 2s . c  o  m
    return mapByLocale;
}

From source file:org.eclipse.virgo.ide.beans.core.internal.locate.SpringOsgiBeansConfigLocator.java

/**
 * Returns Spring DM-specific config set name.
 */// w  ww. j  a  v  a2 s  .com
public String getBeansConfigSetName(Set<IFile> files) {
    Iterator<IFile> iterator = files.iterator();
    if (iterator.hasNext()) {
        BundleManifest bundleManifest = BundleManifestCorePlugin.getBundleManifestManager()
                .getBundleManifest(JdtUtils.getJavaProject(iterator.next().getProject()));
        if (bundleManifest != null && bundleManifest.getBundleSymbolicName() != null
                && bundleManifest.getBundleSymbolicName().getSymbolicName() != null) {
            return bundleManifest.getBundleSymbolicName().getSymbolicName() + "-context "
                    + getBeansConfigSetNameSuffix();
        }
    }
    return "module-context " + getBeansConfigSetNameSuffix();
}

From source file:com.recomdata.export.ExportRow.java

public ExportRow(String gene, Set<String> columns) {
    values = new LinkedHashMap<String, ExportValue>();
    for (Iterator<String> i = columns.iterator(); i.hasNext();) {
        String columnName = i.next();
        if (columnName.equals("Gene")) {
            values.put(columnName, new ExportValue(gene));
        } else {//from w  ww.j a  v  a 2  s  .c o  m
            values.put(columnName, new ExportValue(""));
        }
    }
}