Example usage for java.util LinkedHashSet LinkedHashSet

List of usage examples for java.util LinkedHashSet LinkedHashSet

Introduction

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

Prototype

public LinkedHashSet() 

Source Link

Document

Constructs a new, empty linked hash set with the default initial capacity (16) and load factor (0.75).

Usage

From source file:org.openmrs.module.dataexchange.DataExporter.java

@Transactional
public void exportAllConcepts(String filePath) throws IOException {
    DatabaseConnection connection = getConnection();

    Set<Integer> conceptIds = new LinkedHashSet<Integer>();
    try {/*from   w w w .ja  va2  s  .com*/
        PreparedStatement selectQuery = connection.getConnection()
                .prepareStatement("select concept_id from concept");
        ResultSet resultSet = selectQuery.executeQuery();
        while (resultSet.next()) {
            int id = resultSet.getInt(1);
            conceptIds.add(id);
        }
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }

    exportConcepts(filePath, conceptIds);
}

From source file:com.espertech.esper.epl.named.NamedWindowOnSelectView.java

public void handleMatching(EventBean[] triggerEvents, EventBean[] matchingEvents) {
    EventBean[] newData;//  w  w  w  .jav  a 2 s.c  o m

    // clear state from prior results
    resultSetProcessor.clear();

    // build join result
    // use linked hash set to retain order of join results for last/first/window to work most intuitively
    Set<MultiKey<EventBean>> newEvents = new LinkedHashSet<MultiKey<EventBean>>();
    for (int i = 0; i < triggerEvents.length; i++) {
        EventBean triggerEvent = triggerEvents[0];
        if (matchingEvents != null) {
            for (int j = 0; j < matchingEvents.length; j++) {
                EventBean[] eventsPerStream = new EventBean[2];
                eventsPerStream[0] = matchingEvents[j];
                eventsPerStream[1] = triggerEvent;
                newEvents.add(new MultiKey<EventBean>(eventsPerStream));
            }
        }
    }

    // process matches
    UniformPair<EventBean[]> pair = resultSetProcessor.processJoinResult(newEvents, oldEvents, false);
    newData = (pair != null ? pair.getFirst() : null);

    if (parent.isDistinct()) {
        newData = EventBeanUtility.getDistinctByProp(newData, parent.getEventBeanReader());
    }

    if (parent.getInternalEventRouter() != null) {
        if (newData != null) {
            for (int i = 0; i < newData.length; i++) {
                if (audit) {
                    AuditPath.auditInsertInto(getExprEvaluatorContext().getEngineURI(),
                            getExprEvaluatorContext().getStatementName(), newData[i]);
                }
                parent.getInternalEventRouter().route(newData[i], parent.getStatementHandle(),
                        parent.getInternalEventRouteDest(), getExprEvaluatorContext(), parent.isAddToFront());
            }
        }
    }

    // The on-select listeners receive the events selected
    if ((newData != null) && (newData.length > 0)) {
        // And post only if we have listeners/subscribers that need the data
        if (parent.getStatementResultService().isMakeNatural()
                || parent.getStatementResultService().isMakeSynthetic()) {
            updateChildren(newData, null);
        }
    }
    lastResult = newData;

    // clear state from prior results
    resultSetProcessor.clear();

    // Events to delete are indicated via old data
    if (isDelete) {
        this.rootView.update(null, matchingEvents);
    }
}

From source file:org.paxml.launch.LaunchModel.java

/**
 * Get the selected groups to run./*from  w  ww.j  av a  2s. c  om*/
 * 
 * @return the selected
 */
private Set<Group> getSelectedGroups() {
    Set<Group> set = new LinkedHashSet<Group>();
    for (Matcher groupMatcher : globalSettings.getGroupMatchers()) {
        for (Map.Entry<String, Group> groupEntry : groups.entrySet()) {
            if (groupMatcher.match(groupEntry.getKey())) {
                set.add(groupEntry.getValue());
            }
        }
    }
    return set;
}

From source file:annis.CommonHelper.java

public static List<SNode> getSortedSegmentationNodes(String segName, SDocumentGraph graph) {
    List<SNode> token = new ArrayList<SNode>();

    if (segName == null) {
        // if no segmentation is given just return the sorted token list
        token.addAll(graph.getSortedSTokenByText());
    } else {/*from ww  w.  j a v a 2s . com*/
        // get the very first node of the order relation chain
        Set<SNode> startNodes = new LinkedHashSet<SNode>();

        Map<SNode, SOrderRelation> outRelationForNode = new HashMap<SNode, SOrderRelation>();
        for (SOrderRelation rel : graph.getSOrderRelations()) {
            if (rel.getSTypes() != null && rel.getSTypes().contains(segName)) {
                SNode node = rel.getSSource();
                outRelationForNode.put(node, rel);

                EList<Edge> inEdgesForSource = graph.getInEdges(node.getSId());
                boolean hasInOrderEdge = false;
                for (Edge e : inEdgesForSource) {
                    if (e instanceof SOrderRelation) {
                        hasInOrderEdge = true;
                        break;
                    }
                } // for each ingoing edge

                if (!hasInOrderEdge) {
                    startNodes.add(rel.getSSource());
                }
            } // end if type is segName
        } // end for all order relations of graph

        // add all nodes on the order relation chain beginning from the start node
        for (SNode s : startNodes) {
            SNode current = s;
            while (current != null) {
                token.add(current);
                if (outRelationForNode.containsKey(current)) {
                    current = outRelationForNode.get(current).getSTarget();
                } else {
                    current = null;
                }
            }
        }
    }

    return token;
}

From source file:gov.nih.nci.caintegrator.application.query.CompoundCriterionHandler.java

/**
 * Creates the CompoundCriterionHandler based on the given CompoundCriterion.
 * @param compoundCriterion - compound criterion to create from.
 * @return CompoundCriterionHandler object returned, with the handlers collection filled.
 *///from   www . ja  v  a 2s. c o m
static CompoundCriterionHandler create(CompoundCriterion compoundCriterion, ResultTypeEnum resultType) {
    Collection<AbstractCriterionHandler> handlers = new LinkedHashSet<AbstractCriterionHandler>();
    if (compoundCriterion != null && compoundCriterion.getCriterionCollection() != null) {
        for (AbstractCriterion abstractCriterion : compoundCriterion.getCriterionCollection()) {
            if (abstractCriterion instanceof AbstractAnnotationCriterion) {
                handlers.add(new AnnotationCriterionHandler((AbstractAnnotationCriterion) abstractCriterion));
            } else if (abstractCriterion instanceof CompoundCriterion) {
                handlers.add(
                        CompoundCriterionHandler.create((CompoundCriterion) abstractCriterion, resultType));
            } else if (abstractCriterion instanceof GeneNameCriterion) {
                handlers.add(GeneNameCriterionHandler.create((GeneNameCriterion) abstractCriterion));
            } else if (abstractCriterion instanceof FoldChangeCriterion) {
                handlers.add(FoldChangeCriterionHandler.create((FoldChangeCriterion) abstractCriterion));
            } else if (abstractCriterion instanceof SubjectListCriterion) {
                handlers.add(SubjectListCriterionHandler.create((SubjectListCriterion) abstractCriterion));
            } else if (abstractCriterion instanceof CopyNumberAlterationCriterion) {
                handlers.add(CopyNumberAlterationCriterionHandler
                        .create((CopyNumberAlterationCriterion) abstractCriterion));
            } else if (abstractCriterion instanceof ExpressionLevelCriterion) {
                handlers.add(
                        ExpressionLevelCriterionHandler.create((ExpressionLevelCriterion) abstractCriterion));
            } else {
                throw new IllegalStateException("Unknown AbstractCriterion class: " + abstractCriterion);
            }
        }
    }
    return new CompoundCriterionHandler(handlers, compoundCriterion, resultType);
}

From source file:com.espertech.esper.core.deploy.EPLModuleUtil.java

public static Module parseInternal(String buffer, String resourceName) throws IOException, ParseException {

    List<EPLModuleParseItem> semicolonSegments = EPLModuleUtil.parse(buffer.toString());
    List<ParseNode> nodes = new ArrayList<ParseNode>();
    for (EPLModuleParseItem segment : semicolonSegments) {
        nodes.add(EPLModuleUtil.getModule(segment, resourceName));
    }/*from  w ww .j a v a 2  s  .  co  m*/

    String moduleName = null;
    int count = 0;
    for (ParseNode node : nodes) {
        if (node instanceof ParseNodeComment) {
            continue;
        }
        if (node instanceof ParseNodeModule) {
            if (moduleName != null) {
                throw new ParseException(
                        "Duplicate use of the 'module' keyword for resource '" + resourceName + "'");
            }
            if (count > 0) {
                throw new ParseException(
                        "The 'module' keyword must be the first declaration in the module file for resource '"
                                + resourceName + "'");
            }
            moduleName = ((ParseNodeModule) node).getModuleName();
        }
        count++;
    }

    Set<String> uses = new LinkedHashSet<String>();
    Set<String> imports = new LinkedHashSet<String>();
    count = 0;
    for (ParseNode node : nodes) {
        if ((node instanceof ParseNodeComment) || (node instanceof ParseNodeModule)) {
            continue;
        }
        String message = "The 'uses' and 'import' keywords must be the first declaration in the module file or follow the 'module' declaration";
        if (node instanceof ParseNodeUses) {
            if (count > 0) {
                throw new ParseException(message);
            }
            uses.add(((ParseNodeUses) node).getUses());
            continue;
        }
        if (node instanceof ParseNodeImport) {
            if (count > 0) {
                throw new ParseException(message);
            }
            imports.add(((ParseNodeImport) node).getImported());
            continue;
        }
        count++;
    }

    List<ModuleItem> items = new ArrayList<ModuleItem>();
    for (ParseNode node : nodes) {
        if ((node instanceof ParseNodeComment) || (node instanceof ParseNodeExpression)) {
            boolean isComments = (node instanceof ParseNodeComment);
            items.add(new ModuleItem(node.getItem().getExpression(), isComments, node.getItem().getLineNum(),
                    node.getItem().getStartChar(), node.getItem().getEndChar()));
        }
    }

    return new Module(moduleName, resourceName, uses, imports, items, buffer);
}

From source file:com.fizzed.stork.deploy.Archive.java

public Path unpack(Path unpackDir) throws IOException {
    Files.createDirectories(unpackDir);

    log.info("Unpacking {} to {}", file, unpackDir);

    // we need to know the top-level dir(s) created by unpack
    final Set<Path> firstLevelPaths = new LinkedHashSet<>();
    final AtomicInteger count = new AtomicInteger();

    try (ArchiveInputStream ais = newArchiveInputStream(file)) {
        ArchiveEntry entry;//from  ww  w .j a  va  2s  . c om
        while ((entry = ais.getNextEntry()) != null) {
            try {
                Path entryFile = Paths.get(entry.getName());
                Path resolvedFile = unpackDir.resolve(entryFile);

                firstLevelPaths.add(entryFile.getName(0));

                log.debug("{}", resolvedFile);

                if (entry.isDirectory()) {
                    Files.createDirectories(resolvedFile);
                } else {
                    unpackEntry(ais, resolvedFile);
                    count.incrementAndGet();
                }
            } catch (IOException | IllegalStateException | IllegalArgumentException e) {
                log.error("", e);
                throw new RuntimeException(e);
            }
        }
    }

    if (firstLevelPaths.size() != 1) {
        throw new IOException("Only archives with a single top-level directory are supported!");
    }

    Path assemblyDir = unpackDir.resolve(firstLevelPaths.iterator().next());

    log.info("Unpacked {} files to {}", count, assemblyDir);

    return assemblyDir;
}

From source file:mitm.common.util.StringReplaceUtils.java

/**
 * For each String in the list the non-XML characters are replaced. The returned set is a new instance
 * of LinkedHashSet//w w w.j  a v a2 s. c  o m
 */
public static Set<String> replaceNonXML(Set<String> input, String replaceWith) {
    Check.notNull(replaceWith, "replaceWith");

    if (input == null) {
        return null;
    }

    Set<String> result = new LinkedHashSet<String>();

    for (String s : input) {
        s = StringReplaceUtils.replaceNonXML(s, "#");

        result.add(s);
    }

    return result;
}

From source file:net.sf.jasperreports.engine.part.FillPartPrintOutput.java

public FillPartPrintOutput(BaseReportFiller filler) {
    parts = new TreeMap<Integer, PrintPart>();
    pages = new ArrayList<JRPrintPage>();

    delayedActions = new DelayedFillActions(filler);
    delayedActions.createDelayedEvaluationTime(JREvaluationTime.EVALUATION_TIME_MASTER);
    if (log.isDebugEnabled()) {
        log.debug(this + " created delayed actions " + delayedActions.getId());
    }/*  w w w  . ja v  a2 s  .  c  o  m*/

    if (filler.getFillContext().isCollectingBookmarks()) {
        bookmarkHelper = new BookmarkHelper(true);
    }

    styles = new LinkedHashMap<String, JRStyle>();
    origins = new LinkedHashSet<JROrigin>();
}

From source file:com.anrisoftware.globalpom.reflection.annotations.AnnotationDiscoveryImpl.java

@Override
public Collection<AnnotationBean> call() {
    Set<AnnotationBean> result = new LinkedHashSet<AnnotationBean>();
    result = findFields(result, bean);/*from w  w  w . j av a2s .  c om*/
    result = findMethods(result, bean);
    return result;
}