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:utybo.branchingstorytree.swing.editor.StoryNodesEditor.java

public void checkAllAvailable() {
    ArrayList<StorySingleNodeEditor> seen = new ArrayList<>();
    // Because the algorithm used can mark errors twice we use a set to ensure
    // it only contains each errored element once
    LinkedHashSet<StorySingleNodeEditor> toMarkAsError = new LinkedHashSet<>();
    for (StorySingleNodeEditor ssne : list) {
        for (StorySingleNodeEditor other : seen)
            if (other.matchesId(ssne)) {
                toMarkAsError.add(ssne);
                toMarkAsError.add(other);
                break;
            }// ww w.  jav a2  s . c o  m
        seen.add(ssne);
    }
    // Turn "seen" into the "everything is ok" list by removing all the errors
    seen.removeAll(toMarkAsError);
    seen.forEach(ssne -> {
        ssne.setStatus(Status.OK);
        ssne.getId().notifyOk();
    });
    toMarkAsError.forEach(ssne -> {
        ssne.setStatus(Status.ERROR);
        ssne.getId().notifyError();
    });
    jlist.repaint();
}

From source file:com.alibaba.wasp.plan.parser.druid.DruidDMLParser.java

private LinkedHashSet<String> parseInsertColumns(List<SQLExpr> columns) throws UnsupportedException {
    LinkedHashSet<String> columnsItem = new LinkedHashSet<String>(columns.size());
    for (SQLExpr item : columns) {
        String columnName = parseColumn(item);
        LOG.debug(" SQLInsertItem " + columnName);
        columnsItem.add(columnName);
    }//  w  w  w .j  av a  2s .co  m
    return columnsItem;
}

From source file:at.flack.SMSMainActivity.java

public ArrayList<SMSItem> readSMSContacts(Activity activity) {
    LinkedHashSet<SMSItem> smsList = new LinkedHashSet<SMSItem>();
    Cursor cur = activity.getContentResolver().query(Uri.parse("content://sms"), null, null, null, null);
    if (cur != null && cur.moveToFirst()) {
        SMSItem.initIdx(cur);/*from w ww  . j a  v  a2 s . com*/
        do {
            SMSItem item = new SMSItem(cur);
            smsList.add(item);
        } while (cur.moveToNext());
    }
    return new ArrayList<SMSItem>(smsList);
}

From source file:alma.acs.tmcdb.compare.TestHighLevelNodes.java

/**
 * Searches dao for all potential (nodes containing Name attribute) ComponentInfo nodes.
 * @param dc   dao to be searched.//from  w w  w.ja  v a  2 s. c om
 * @returns list of all potential ComponentInfo nodes.
 */
private String[] retrieveComponentsList(CDBAccess cdbAccess) {
    ArrayList<String> componentList = new ArrayList<String>();

    try {
        DAOProxy dc = cdbAccess.createDAO("MACI/Components");
        LinkedHashSet<String> nodes = new LinkedHashSet<String>();
        // current
        nodes.add("");
        String[] subnodes = cdbAccess.getSubNodes(dc);
        if (subnodes != null)
            for (int i = 0; i < subnodes.length; i++)
                nodes.add(subnodes[i]);

        Iterator<String> iter = nodes.iterator();
        while (iter.hasNext()) {
            String prefix = iter.next().toString();
            if (prefix.length() > 0)
                prefix += "/";
            String attributes = dc.get_field_data(prefix + "_characteristics");

            // convert into array
            StringTokenizer tokenizer = new StringTokenizer(attributes, ",");
            while (tokenizer.hasMoreTokens()) {
                String subname = tokenizer.nextToken().toString();
                String componentName = prefix + subname;

                // check if potentially valid ComponentInfo entry - read name
                /// @todo this could be done better (to check if all attributes exist)
                if (readStringCharacteristics(dc, componentName + "/Name", true) != null)
                    componentList.add(componentName);
            }
        }

    } catch (Throwable th) {
        Exception ce = new Exception("Failed to obtain list of all components.", th);
        logger.log(Level.WARNING, ce.getMessage(), ce);
    }

    String[] retVal = new String[componentList.size()];
    componentList.toArray(retVal);

    //logger.log(Level.INFO,"Found " + retVal.length + " component entries in the configuration database.");

    return retVal;
}

From source file:eionet.cr.web.action.factsheet.FactsheetActionBean.java

/**
 *
 * @return/* ww  w .  j  a  v  a  2s. c  om*/
 */
private static Set<String> createEditableTypes() {

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

    InputStream inputStream = null;
    try {
        inputStream = FactsheetActionBean.class.getClassLoader()
                .getResourceAsStream(FULLY_EDITABLE_TYPES_FILE_NAME);
        List<String> lines = IOUtils.readLines(inputStream, "UTF-8");
        for (String line : lines) {
            result.add(line.trim());
        }
    } catch (IOException e) {
        LOGGER.error("Failed reading lines from " + FULLY_EDITABLE_TYPES_FILE_NAME, e);
    } finally {
        IOUtils.closeQuietly(inputStream);
    }

    LOGGER.debug("Found these fully editable types: " + result);

    return result;
}

From source file:com.alibaba.wasp.plan.parser.druid.DruidDQLParser.java

private LinkedHashSet<String> parseFTable(FTable ftable) throws UnsupportedException {
    LinkedHashSet<String> selectItem = new LinkedHashSet<String>(ftable.getColumns().size());
    for (Field item : ftable.getColumns().values()) {
        selectItem.add(item.getName());
        LOG.debug(" SQLSelectItem " + item.getName());
    }/*from www .  ja v a2 s  .  com*/
    return selectItem;
}

From source file:net.heroicefforts.viable.android.rep.it.GIssueTrackerRepository.java

public SearchResults search(SearchParams params) throws ServiceException {
    final int startIdx = (params.getPage() - 1) * params.getPageSize();
    final int pageSize = params.getPageSize();

    LinkedHashSet<Issue> issues = new LinkedHashSet<Issue>();
    for (int i = startIdx; i < params.getIds().size() && i < startIdx + pageSize + i; i++)
        issues.add(findById(params.getIds().get(i)));

    if (issues.size() <= pageSize) {
        Issue issue = findByHash(params.getHash());
        if (issue != null)
            issues.add(issue);// ww w  .  j a v  a  2s  .c o m
    }

    if (issues.size() <= pageSize) {
        long skip = startIdx;
        long skipped = params.getIds().size() + (params.getHash() != null ? 1 : 0);
        for (int i = 0; i < params.getAffectedVersions().size() && issues.size() <= pageSize; i++) {
            long count = countIssuesByVersion(params.getAffectedVersions().get(i));
            if (skipped + count > skip) {
                int needed = pageSize - issues.size() + 1;
                long startAt = skip - skipped;
                if (startAt < 0)
                    startAt = 0;
                issues.addAll(findIssuesByVersion(params.getAffectedVersions().get(i), startAt, needed));
                skipped = skip;
            } else {
                skipped += count;
            }
        }
    }

    setAppName(issues);

    if (issues.size() > pageSize)
        return new SearchResults(new ArrayList<Issue>(issues).subList(0, pageSize), true);
    else
        return new SearchResults(new ArrayList<Issue>(issues), false);
}

From source file:org.fusesource.hawtjni.generator.HawtJNI.java

@SuppressWarnings("unchecked")
private void collectMatchingClasses(ClassFinder finder, Class annotation, LinkedHashSet<Class<?>> collector) {
    List<Class> annotated = finder.findAnnotatedClasses(annotation);
    for (Class<?> clazz : annotated) {
        if (packages.isEmpty()) {
            collector.add(clazz);
        } else {//from   w w  w  . jav  a2 s.  c o m
            if (packages.contains(clazz.getPackage().getName())) {
                collector.add(clazz);
            }
        }
    }
}

From source file:org.wrml.runtime.schema.SchemaBuilder.java

public SchemaBuilder extend(final Schema baseSchema, final Schema... baseSchemas) {

    extend(baseSchema.getUri());/*from   ww w  . j  av  a 2s.co m*/

    if (baseSchemas != null) {
        final LinkedHashSet<URI> baseSchemaUris = new LinkedHashSet<>(baseSchemas.length);
        for (final Schema schema : baseSchemas) {
            baseSchemaUris.add(schema.getUri());
        }

        _Schema.getBaseSchemaUris().addAll(baseSchemaUris);
    }

    return this;
}

From source file:com.geewhiz.pacify.managers.EntityManager.java

public LinkedHashSet<Defect> initialize() {
    LinkedHashSet<Defect> defects = new LinkedHashSet<Defect>();
    if (initialized) {
        return defects;
    }/* www.ja  va2  s  .  com*/

    pMarkers = new ArrayList<PMarker>();
    for (File markerFile : new PacifyFilesFinder(startPath).getPacifyFiles()) {
        try {
            PMarker pMarker = unmarshal(markerFile);
            pMarker.setFile(markerFile);

            pMarkers.add(pMarker);
        } catch (JAXBException e) {
            defects.add(new XMLValidationDefect(markerFile));
            logger.debug("Error while parsing file [" + markerFile.getAbsolutePath() + "]", e);
        }
    }

    initialized = true;

    return defects;
}