Example usage for java.util LinkedHashSet toArray

List of usage examples for java.util LinkedHashSet toArray

Introduction

In this page you can find the example usage for java.util LinkedHashSet toArray.

Prototype

<T> T[] toArray(T[] a);

Source Link

Document

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.

Usage

From source file:com.datatorrent.stram.api.IotDev.java

public static URLClassLoader loadDependencies(LinkedHashSet<URL> launchDependencies) {
    URLClassLoader cl = URLClassLoader
            .newInstance(launchDependencies.toArray(new URL[launchDependencies.size()]));
    Thread.currentThread().setContextClassLoader(cl);
    StringCodecs.check();// ww  w.j  a  va  2s  .  c om
    return cl;
}

From source file:de.andreasschoknecht.LS3.Query.java

/**
 * Calculate term frequencies for the query model. Thereby, the term frequencies for terms not contained in the query model
 * but appearing in other models of the collection are set to 0. Terms which are only part of the query model are not represented.
 * They are left out because the goal is to put the query model in the vector space of the Term-Document Matrix of a document
 * collection./*  w  ww. ja  va  2  s  .  c  om*/
 *
 * @param allTerms The list of all terms contained in the whole model collection
 */
void calculateTermFrequencies(LinkedHashSet<String> allTerms) {
    // allTermsArray contains all the terms of the Term-Document Matrix of the document collection
    String[] allTermsArray = allTerms.toArray(new String[allTerms.size()]);
    termFrequencies = new double[allTermsArray.length];

    for (int i = 0; i < allTermsArray.length; i++) {
        if (this.getTermCollection().contains(allTermsArray[i])) {
            String tmp = allTermsArray[i];
            double count = this.getTermCollection().count(tmp);
            termFrequencies[i] = count;
        } else {
            termFrequencies[i] = 0;
        }
    }
}

From source file:com.adobe.cq.wcm.core.components.internal.models.v2.PageImpl.java

protected void populateClientLibCategoriesJs() {
    if (currentStyle != null) {
        clientLibCategoriesJsHead = currentStyle.get(PN_CLIENTLIBS_JS_HEAD, ArrayUtils.EMPTY_STRING_ARRAY);
        LinkedHashSet<String> categories = new LinkedHashSet<>(Arrays.asList(clientLibCategories));
        categories.removeAll(Arrays.asList(clientLibCategoriesJsHead));
        clientLibCategoriesJsBody = categories.toArray(new String[0]);
    }/*  w w w  . j a  va2  s  . co m*/
}

From source file:jenkins.plugins.ivyreport.IvyAccess.java

String[] expandConfs(String[] requested) {
    if (moduleDescriptor == null) {
        recomputeModuleDescriptor();//w w  w.  j  a  va 2 s . co  m
        if (moduleDescriptor == null) {
            return requested;
        }
    }
    String[] expanded = ConfigurationUtils.replaceWildcards(requested, moduleDescriptor);
    LinkedHashSet<String> result = new LinkedHashSet<String>();
    Collections.addAll(result, expanded);
    result.retainAll(Arrays.asList(moduleDescriptor.getConfigurationsNames()));
    return result.toArray(new String[result.size()]);
}

From source file:net.sf.jasperreports.engine.JRPropertiesMap.java

/**
 * Returns the names of the properties.//from  w ww. ja  va2 s . c o  m
 *  
 * @return the names of the properties
 */
public String[] getPropertyNames() {
    String[] names;
    if (hasOwnProperties()) {
        if (base == null) {
            names = propertiesList.toArray(new String[propertiesList.size()]);
        } else {
            LinkedHashSet<String> namesSet = new LinkedHashSet<String>();
            collectPropertyNames(namesSet);
            names = namesSet.toArray(new String[namesSet.size()]);
        }
    } else if (base != null) {
        names = base.getPropertyNames();
    } else {
        names = new String[0];
    }
    return names;
}

From source file:net.famzangl.minecraft.minebot.ai.command.CommandRegistry.java

public String[] fillTabComplete(MinebotNetHandler minebotNetHandler, String[] serverResponse,
        String lastSendTabComplete) {
    String command = getCommandId(lastSendTabComplete);
    LinkedHashSet<String> res = new LinkedHashSet<String>();
    for (String c : commandTable.keySet()) {
        if (c.startsWith(command)) {
            res.add("/" + c);
        }//from w w  w  .  j av  a2s  . c o  m
    }
    if (res.isEmpty())
        return serverResponse;
    res.addAll(Arrays.asList(serverResponse));

    return res.toArray(new String[0]);
}

From source file:com.act.biointerpretation.cofactorremoval.CofactorRemover.java

/**
 * The function removes similar chemicals from the substrates and products (conenzymes) and remove duplicates
 * within each category.//from w  w w.ja v a2s . c o m
 * @param reaction The reaction being updated.
 */
private void findAndIsolateCoenzymesFromReaction(Reaction reaction) {
    // Build ordered sets of the substrates/products.
    LinkedHashSet<Long> substrates = new LinkedHashSet<>(Arrays.asList(reaction.getSubstrates()));
    LinkedHashSet<Long> products = new LinkedHashSet<>(Arrays.asList(reaction.getProducts()));

    // Compute the intersection between the sets.
    Set<Long> intersection = new HashSet<>(substrates);
    intersection.retainAll(products);

    // A - int(A, B) = A / B
    substrates.removeAll(intersection);
    products.removeAll(intersection);

    // Update the reaction with the new (ordered) substrates/products + coenzymes.
    reaction.setSubstrates(substrates.toArray(new Long[substrates.size()]));
    reaction.setProducts(products.toArray(new Long[products.size()]));

    // Keep any existing coenzymes, but don't use them when computing the difference--they might be there for a reason.
    intersection.addAll(Arrays.asList(reaction.getCoenzymes()));
    reaction.setCoenzymes(intersection.toArray(new Long[intersection.size()]));
}

From source file:jef.tools.reflect.ClassEx.java

/**
 * ?????/* ww  w. jav a2  s. c o m*/
 * 
 * @return
 */
public Class<?>[] getAllInterfaces() {
    LinkedHashSet<Class<?>> intf = new LinkedHashSet<Class<?>>();
    Class<?> c = cls;
    while (c != Object.class) {
        for (Class<?> ic : c.getInterfaces()) {
            intf.add(ic);
        }
        c = c.getSuperclass();
    }
    return intf.toArray(new Class<?>[intf.size()]);
}

From source file:com.rapidminer.gui.plotter.charts.SeriesChartPlotter.java

@Override
protected void updatePlotter() {
    int categoryCount = prepareData();
    String maxClassesProperty = ParameterService
            .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
    int maxClasses = 20;
    try {/*  ww w .j a va 2  s.com*/
        if (maxClassesProperty != null) {
            maxClasses = Integer.parseInt(maxClassesProperty);
        }
    } catch (NumberFormatException e) {
        // LogService.getGlobal().log("Series plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.",
        // LogService.WARNING);
        LogService.getRoot().log(Level.WARNING,
                "com.rapidminer.gui.plotter.charts.SeriesChartPlotter.parsing_property_error");
    }
    boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;

    JFreeChart chart = createChart(this.dataset, createLegend);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // domain axis
    if (axis[INDEX] >= 0) {
        if (!dataTable.isNominal(axis[INDEX])) {
            if (dataTable.isDate(axis[INDEX]) || dataTable.isDateTime(axis[INDEX])) {
                DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[INDEX]));
                domainAxis.setTimeZone(Tools.getPreferredTimeZone());
                chart.getXYPlot().setDomainAxis(domainAxis);
                if (getRangeForDimension(axis[INDEX]) != null) {
                    domainAxis.setRange(getRangeForDimension(axis[INDEX]));
                }
                domainAxis.setLabelFont(LABEL_FONT_BOLD);
                domainAxis.setTickLabelFont(LABEL_FONT);
                domainAxis.setVerticalTickLabels(isLabelRotating());
            }
        } else {
            LinkedHashSet<String> values = new LinkedHashSet<String>();
            for (DataTableRow row : dataTable) {
                String stringValue = dataTable.mapIndex(axis[INDEX], (int) row.getValue(axis[INDEX]));
                if (stringValue.length() > 40) {
                    stringValue = stringValue.substring(0, 40);
                }
                values.add(stringValue);
            }
            ValueAxis categoryAxis = new SymbolAxis(dataTable.getColumnName(axis[INDEX]),
                    values.toArray(new String[values.size()]));
            categoryAxis.setLabelFont(LABEL_FONT_BOLD);
            categoryAxis.setTickLabelFont(LABEL_FONT);
            categoryAxis.setVerticalTickLabels(isLabelRotating());
            chart.getXYPlot().setDomainAxis(categoryAxis);
        }
    }

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
        legend.setItemFont(LABEL_FONT);
    }

    AbstractChartPanel panel = getPlotterPanel();
    if (panel == null) {
        panel = createPanel(chart);
    } else {
        panel.setChart(chart);
    }

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}

From source file:net.sf.maltcms.common.charts.overlay.nodes.OverlayNode.java

@Override
public Action[] getActions(boolean context) {
    List<?> interfaces = getAllInterfaces(getBean().getClass());
    List<?> superClasses = getAllSuperclasses(getBean().getClass());
    LinkedHashSet<Action> containerActions = new LinkedHashSet<>();
    for (Object o : interfaces) {
        Class<?> c = (Class) o;
        containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/" + c.getName()));
        containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/" + c.getSimpleName()));
    }/*from w  w w .  j a  v  a2  s .c om*/
    for (Object o : superClasses) {
        Class<?> c = (Class) o;
        containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/" + c.getName()));
        containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/" + c.getSimpleName()));
    }
    containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/" + getBean().getClass().getName()));
    containerActions
            .addAll(actionsForPath("Actions/OverlayNodeActions/" + getBean().getClass().getSimpleName()));
    containerActions.add(null);
    containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/DefaultActions"));
    containerActions.add(get(PropertiesAction.class));
    return containerActions.toArray(new Action[containerActions.size()]);
}