Example usage for java.util LinkedHashSet add

List of usage examples for java.util LinkedHashSet add

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:org.agiso.tempel.core.RecursiveTemplateVerifier.java

/**
 * Weryfikuje poprawno szablonu, szablonu nadrzdnego i rekurencyjne
 * sprawdza wszystkie szablony uywane. Kontroluje, czy drzewie wywoa
 * szablonw nie wystpuje zaptlenie.//from www.java  2  s  .c o m
 * 
 * @param template Szablon do weryfikacji.
 * @param templates Zbir identyfikatorw szablonw gazi. Wykorzystywany
 *     do wykrywania zaptle wywoa.
 */
private void verifyTemplate(Template<?> template, LinkedHashSet<String> templates) {
    String id = template.getKey();

    // Sprawdzanie, czy w gazi wywoa szablonw nie ma zaptlenia:
    if (templates.contains(id)) {
        // Wywietlanie gazi z zaptleniem i wyrzucanie wyjtku:
        Iterator<String> t = templates.iterator();
        System.out.print(t.next());
        while (t.hasNext()) {
            System.out.print("->" + t.next());
        }
        System.out.println("->" + id);

        throw new IllegalStateException("Zaptlenie wywoa szablonu '" + id + "'");
    }

    // Szablon OK. Dodawanie do zbioru szablonw gazi:
    templates.add(id);

    //      // Sprawdzanie kadego z podszablonw szablonu:
    //      if(template.getReferences() != null) {
    //         for(TemplateReference reference : template.getReferences()) {
    //            verifyTemplate(reference, templates);
    //         }
    //      }
}

From source file:ColumnStorage.ColumnProject.java

public ArrayList<String> getFileNameByIndex(ArrayList<Short> idx) {
    if (idx == null) {
        return null;
    }//from w  ww  .j a  v  a  2 s.c  o m

    if (idx.size() == 0) {
        return null;
    }

    if (infos.size() == 0) {
        return null;
    }

    LinkedHashSet<String> result = new LinkedHashSet<String>();
    short foundTimes = 0;
    int size = idx.size();
    int count = 0;
    for (int i = 0; i < size; i++) {
        count = 0;
        while (count < infos.size()) {
            ColumnInfo info = infos.get(count);

            if (!info.idxs.contains(idx.get(i))) {

                count++;
                continue;
            } else {
                foundTimes++;
                result.add(info.name);
                break;
            }
        }
    }

    if (foundTimes == size) {
        ArrayList<String> rrArrayList = new ArrayList<String>();
        Iterator<String> iterator = result.iterator();
        while (iterator.hasNext()) {
            rrArrayList.add(iterator.next());
        }

        return rrArrayList;
    } else {
        return null;
    }
}

From source file:org.pentaho.reporting.engine.classic.extensions.datasources.pmd.SimplePmdDataFactory.java

public String[] getReferencedFields(final String query, final DataRow parameter)
        throws ReportDataFactoryException {
    final String queryRaw = computedQuery(query, parameter);
    if (query == null) {
        return null;
    }//w w  w .  j  a  va2  s.  c  om

    final Query queryObject = parseQuery(queryRaw);
    final List<Parameter> queryParamValues = queryObject.getParameters();
    final LinkedHashSet<String> retval = new LinkedHashSet<String>();
    if (userField != null) {
        retval.add(userField);
    }
    if (passwordField != null) {
        retval.add(passwordField);
    }
    if (queryParamValues != null) {
        for (final Parameter p : queryParamValues) {
            retval.add(p.getName());
        }
    }
    retval.add(DataFactory.QUERY_LIMIT);
    retval.add(DataFactory.QUERY_TIMEOUT);
    return retval.toArray(new String[retval.size()]);
}

From source file:org.opens.referentiel.creator.CodeGeneratorMojo.java

private void extractAvailableLangsFromCsvHeader(String[] csvHeaders) throws I18NLanguageNotFoundException {
    LinkedHashSet<String> themeList = new LinkedHashSet();
    LinkedHashSet<String> critereList = new LinkedHashSet();
    LinkedHashSet<String> testList = new LinkedHashSet();
    for (String header : csvHeaders) {
        if (header.startsWith(THEME_LABEL_COLUMN_NAME)) {
            themeList.add(header.split("_")[1]);
        } else if (header.startsWith(CRITERION_LABEL_COLUMN_NAME)) {
            critereList.add(header.split("_")[1]);
        } else if (header.startsWith(TEST_LABEL_COLUMN_NAME)) {
            testList.add(header.split("_")[1]);
        }/*w ww .  j a  va  2 s .c om*/
    }
    if (isCriterionPresent) {
        if (themeList.equals(critereList) && testList.equals(critereList)) {
            langSet.addAll(themeList);
        } else {
            throw new I18NLanguageNotFoundException("All Label on csv column must have internationalization");
        }
    } else {
        if (themeList.equals(testList)) {
            langSet.addAll(themeList);
        } else {
            throw new I18NLanguageNotFoundException("All Label on csv column must have internationalization");
        }
    }
}

From source file:org.impalaframework.module.definition.DependencyManager.java

/**
 * Returns all {@link ModuleDefinition} known to this {@link DependencyManager} instance, returned in topological sort order.
 *//* w  w w  . j  av  a 2  s.  co  m*/
public Collection<ModuleDefinition> getAllModules() {

    final Collection<Vertex> vertices = this.vertexMap.values();

    List<Vertex> ordered = populatedOrderedVertices(vertices);

    final LinkedHashSet<ModuleDefinition> definitions = new LinkedHashSet<ModuleDefinition>();
    for (Vertex vertex : ordered) {
        definitions.add(vertex.getModuleDefinition());
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Returning all module defintions: "
                + ModuleDefinitionUtils.getModuleNamesFromCollection(definitions));
    }

    return definitions;
}

From source file:net.sourceforge.sqlexplorer.connections.ConnectionsView.java

/**
 * Returns a list of selected sessions; if recurse is true, then it includes indirectly selected sessions (eg a
 * selected user's sessions)/*from ww  w . jav  a  2s. co m*/
 * 
 * @param recurse
 * @return Set of Sessions, never returns null
 */
public Set<SQLConnection> getSelectedConnections(boolean recurse) {
    IStructuredSelection selection = (IStructuredSelection) _treeViewer.getSelection();
    if (selection == null) {
        return EMPTY_CONNECTIONS;
    }

    LinkedHashSet<SQLConnection> result = new LinkedHashSet<SQLConnection>();
    Iterator iter = selection.iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (obj instanceof SQLConnection) {
            result.add((SQLConnection) obj);
        } else if (recurse) {
            if (obj instanceof Alias) {
                Alias alias = (Alias) obj;
                for (User user : alias.getUsers()) {
                    result.addAll(user.getConnections());
                }
            } else if (obj instanceof User) {
                User user = (User) obj;
                result.addAll(user.getConnections());
            }
        }
    }

    return result;
}

From source file:org.openflexo.foundation.sg.implmodel.TechnologyModuleDefinition.java

private void fillRequiredModules(Map<Integer, LinkedHashSet<TechnologyModuleDefinition>> requiredModules,
        int level) {

    // Avoid infinite loop (module1 requires module2 and module2 requires module1)
    for (LinkedHashSet<TechnologyModuleDefinition> set : requiredModules.values()) {
        if (set.contains(this)) {
            return;
        }//from w  ww.ja  v  a 2 s .com
    }

    LinkedHashSet<TechnologyModuleDefinition> set = requiredModules.get(level);
    if (set == null) {
        set = new LinkedHashSet<TechnologyModuleDefinition>();
        requiredModules.put(level, set);
    }
    set.add(this);

    for (TechnologyModuleDefinition moduleDefinition : getRequiredModules()) {
        moduleDefinition.fillRequiredModules(requiredModules, level + 1);
    }
}

From source file:org.asqatasun.referential.creator.CodeGeneratorMojo.java

private void extractAvailableLangsFromCsvHeader(String[] csvHeaders) throws I18NLanguageNotFoundException {
    LinkedHashSet<String> themeList = new LinkedHashSet<>();
    LinkedHashSet<String> critereList = new LinkedHashSet<>();
    LinkedHashSet<String> testList = new LinkedHashSet<>();
    for (String header : csvHeaders) {
        if (header.startsWith(THEME_LABEL_COLUMN_NAME)) {
            themeList.add(header.split("_")[1]);
        } else if (header.startsWith(CRITERION_LABEL_COLUMN_NAME)) {
            critereList.add(header.split("_")[1]);
        } else if (header.startsWith(TEST_LABEL_COLUMN_NAME)) {
            testList.add(header.split("_")[1]);
        }//w w w .ja va  2  s.c  o  m
    }
    if (isCriterionPresent) {
        if (themeList.equals(critereList) && testList.equals(critereList)) {
            langSet.addAll(themeList);
        } else {
            throw new I18NLanguageNotFoundException("All Label on csv column must have internationalization");
        }
    } else {
        if (themeList.equals(testList)) {
            langSet.addAll(themeList);
        } else {
            throw new I18NLanguageNotFoundException("All Label on csv column must have internationalization");
        }
    }
}

From source file:com.yahoo.bard.webservice.data.metric.TemplateDruidQuery.java

/**
 * Transforms a N-pass query into a (N+1)-pass query. The original query is not mutated.
 *
 * @return nested query// w  w w .j a v  a 2s  . co  m
 */
public TemplateDruidQuery nest() {

    /*
     * each aggregation needs to be split into an inner & outer. Sometimes this involves transformation of the
     * aggregation type, name, or field name.
     */
    LinkedHashSet<Aggregation> innerAggregations = new LinkedHashSet<>();
    LinkedHashSet<Aggregation> outerAggregations = new LinkedHashSet<>();
    for (Aggregation agg : aggregations) {
        Pair<Aggregation, Aggregation> split = agg.nest();
        innerAggregations.add(split.getRight());
        outerAggregations.add(split.getLeft());
    }

    // Create the inner query.
    TemplateDruidQuery innerQuery;
    if (isNested()) {
        innerQuery = new TemplateDruidQuery(innerAggregations, Collections.emptySet(), nestedQuery, null);
    } else {
        innerQuery = new TemplateDruidQuery(innerAggregations, Collections.emptySet(), null, null);
    }

    // Create the outer query, floating the post aggregations upward
    return new TemplateDruidQuery(outerAggregations, postAggregations, innerQuery, timeGrain);
}

From source file:org.grouplens.grapht.graph.DAGNode.java

/**
 * Helper mode for {@link #getSortedNodes()}, via {@link TopologicalSortSupplier}.  This method
 * does a depth-first traversal of the nodes, adding each to the {@code visited} set when it is
 * left.  This results in {@code visited} being a topological sort.
 *
 * @param visited The set of nodes seen so far.
 *//*  w w w.  ja v a  2 s.  com*/
private void sortVisit(LinkedHashSet<DAGNode<V, E>> visited) {
    if (!visited.contains(this)) {
        for (DAGEdge<V, E> nbr : outgoingEdges) {
            nbr.getTail().sortVisit(visited);
        }
        // neighbors won't have added this, or we have an impossible cycle
        assert !visited.contains(this);
        visited.add(this);
    }
}