Example usage for java.util Collections EMPTY_SET

List of usage examples for java.util Collections EMPTY_SET

Introduction

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

Prototype

Set EMPTY_SET

To view the source code for java.util Collections EMPTY_SET.

Click Source Link

Document

The empty set (immutable).

Usage

From source file:org.eclipse.rdf4j.repository.sparql.query.SPARQLOperation.java

protected Set<String> getBindingNames() {
    if (bindings.size() == 0)
        return Collections.EMPTY_SET;
    Set<String> names = new HashSet<String>();
    String qry = operation;//from   w ww.  j a  v a 2s.  c o  m
    int b = qry.indexOf('{');
    String select = qry.substring(0, b);
    for (String name : bindings.getBindingNames()) {
        String replacement = getReplacement(bindings.getValue(name));
        if (replacement != null) {
            String pattern = ".*[\\?\\$]" + name + "\\W.*";
            if (Pattern.compile(pattern, Pattern.MULTILINE | Pattern.DOTALL).matcher(select).matches()) {
                names.add(name);
            }
        }
    }
    return names;
}

From source file:org.mule.module.pubsubhubbub.data.DataStore.java

@SuppressWarnings("unchecked")
public Set<String> getTopicFeedIds(final URI topicUrl) {
    return (Set<String>) retrieve(topicUrl, TOPIC_FEED_IDS_PARTITION, (Serializable) Collections.EMPTY_SET);
}

From source file:net.ontopia.topicmaps.nav2.portlets.pojos.TMRAP.java

/**
 * PUBLIC: Sends a query, returning a model of the result.
 * @param psis a collection of PSIs as strings
 * @return a list of Server objects// w  w w  .ja v  a  2 s.  co m
 */
public Collection query(Collection psis) throws IOException, InvalidQueryException {
    if (psis.isEmpty())
        return Collections.EMPTY_SET;
    String psikey = makeKey(psis);

    Collection model = new ArrayList();
    Iterator it = servers.iterator();
    while (it.hasNext()) {
        String endpoint = (String) it.next();

        // is it in the cache?
        if (cache.containsKey(endpoint + psikey)) {
            CacheEntry entry = (CacheEntry) cache.get(endpoint + psikey);
            model.add(entry.getObject());
            continue;
        }

        // not in cache, so go look it up
        InputSource src = getInputSource(endpoint, psis);
        TMXMLReader reader = new TMXMLReader(src, new URILocator(src.getSystemId()));
        TopicMapIF topicmap = reader.read();
        QueryWrapper qw = new QueryWrapper(topicmap);
        qw.setDeclarations("using tmrap for i\"http://psi.ontopia.net/tmrap/\" ");
        Server server = (Server) qw.queryForObject("instance-of($S, tmrap:server)?", new Factory());
        model.add(server);
        qw.queryForList("instance-of($TM, tmrap:topicmap)?", new Factory(server));

        // process the topic maps
        Iterator it2 = server.getTopicMaps().iterator();
        while (it2.hasNext()) {
            TopicMap tm = (TopicMap) it2.next();
            Map params = qw.makeParams("tm", tm.getTopic());
            qw.queryForList("tmrap:contained-in(%tm% : tmrap:container, $P : tmrap:containee)?",
                    new Factory(tm), params);
        }

        // update the cache
        cache.put(endpoint + psikey, new CacheEntry(server));
    }
    return model;
}

From source file:com.phoenixst.plexus.util.SingletonGraph.java

public Collection nodes(Predicate nodePredicate) {
    return (nodePredicate == null || nodePredicate.evaluate(singleNode)) ? Collections.singleton(singleNode)
            : Collections.EMPTY_SET;
}

From source file:org.sipfoundry.sipxconfig.acd.XmlRpcSettings.java

Set getAll(String className, String key) {
    try {/*  w  w w  .  jav  a 2s . c om*/
        Set uris = new HashSet();
        Hashtable params = new Hashtable();
        setObjectClass(params, className);
        Map results = m_provisioning.get(params);
        boolean result = getResultCode(results);
        if (result) {
            List instances = getObjectClassList(results);
            for (Iterator i = instances.iterator(); i.hasNext();) {
                Map objectData = (Map) i.next();
                uris.add(objectData.get(key));
            }
        }
        return uris;
    } catch (XmlRpcRemoteException e) {
        // server throws exceptions if there are no objects of this class
        // it's should not be considered an error
        return Collections.EMPTY_SET;
    }
}

From source file:net.ontopia.persistence.query.jdo.JDOQuery.java

public Collection getVariableNames() {
    if (variables == null)
        return Collections.EMPTY_SET;
    else//from ww  w  .ja  v  a 2s.c o m
        return variables.keySet();
}

From source file:com.nextep.designer.sqlgen.postgre.generator.PostgreTableGenerator.java

@Override
public IGenerationResult generateFullSQL(Object model) {
    final IBasicTable table = (IBasicTable) model;
    final IPostgreSqlTable postgreTable = (table instanceof IPostgreSqlTable) ? (IPostgreSqlTable) table : null;
    final String tabName = getName(table);
    final String rawName = table.getName();

    @SuppressWarnings("unchecked")
    final Set<IReference> inheritedTableRefs = postgreTable == null ? Collections.EMPTY_SET
            : postgreTable.getInheritances();

    // Verifying consistency
    if (table.getColumns().size() == 0 && inheritedTableRefs.size() == 0) {
        throw new ErrorException("Table <" + tabName + "> has no column defined, cannot generate.");
    }//from  w w w.  j  ava  2s. co  m
    // Initializing our column generation result
    IGenerationResult columnGeneration = generateChildren(table.getColumns(), false);

    // Getting constraint generation result (resolving dependencies)
    List<IKeyConstraint> keys = new ArrayList<IKeyConstraint>(table.getConstraints());
    Collections.sort(keys, NameComparator.getInstance());
    IGenerationResult keyGeneration = generateChildren(keys, true);

    // Getting Check constraint generation result (resolving dependencies)
    IGenerationResult checkGeneration = null;
    if (table instanceof ICheckConstraintContainer) {
        List<ICheckConstraint> checks = new ArrayList<ICheckConstraint>(
                ((ICheckConstraintContainer) table).getCheckConstraints());
        Collections.sort(checks, NameComparator.getInstance());
        checkGeneration = generateChildren(checks, true);
    }

    // Initializing output script
    ISQLScript tableScript = getSqlScript(tabName, table.getDescription(), ScriptType.TABLE);
    tableScript.appendSQL(prompt("Creating table '" + tabName + "'...")); //$NON-NLS-1$ //$NON-NLS-2$
    tableScript.appendSQL(getCreateTable(table)).appendSQL(escape(tabName));

    // Appending columns definition since these are partials
    addCommaSeparatedScripts(tableScript, " ( ", ")", columnGeneration.getAdditions()); //$NON-NLS-1$ //$NON-NLS-2$

    if (inheritedTableRefs.size() > 0) {
        String inheritSQL = " INHERITS FROM " + NEWLINE; //$NON-NLS-1$
        boolean first = true;
        for (IReference tableRef : inheritedTableRefs) {
            final IBasicTable inheritedTable = (IBasicTable) VersionHelper.getReferencedItem(tableRef);
            if (inheritedTable != null) {
                inheritSQL = inheritSQL.concat("    "); //$NON-NLS-1$
                if (!first) {
                    inheritSQL = inheritSQL.concat(","); //$NON-NLS-1$
                } else {
                    inheritSQL = inheritSQL.concat(" "); //$NON-NLS-1$
                    first = false;
                }

                final String inheritedTabName = getName(inheritedTable);
                inheritSQL = inheritSQL.concat(inheritedTabName + NEWLINE);
            } else {
                LOGGER.warn("Inherited table reference not found from PostgreSql table '" + table.getName()
                        + "' : " + tableRef);
            }
        }
        inheritSQL = inheritSQL.concat(")" + NEWLINE);
        tableScript.appendSQL(inheritSQL);
    }

    // Generating physical implementation when supported
    if (table instanceof IPhysicalObject) {
        final IPhysicalObject physTable = (IPhysicalObject) table;
        final IPhysicalProperties props = physTable.getPhysicalProperties();
        ISQLGenerator propGenerator = getGenerator(IElementType.getInstance(ITablePhysicalProperties.TYPE_ID));
        if (propGenerator != null && props != null) {
            // Generating the physical implementation
            IGenerationResult propGeneration = propGenerator.generateFullSQL(props);
            // Aggregating implementation
            if (propGeneration != null) {
                Collection<ISQLScript> generatedScripts = propGeneration.getAdditions();
                for (ISQLScript s : generatedScripts) {
                    tableScript.appendScript(s);
                }
            }
        }
    }
    closeLastStatement(tableScript);

    // Generating results
    IGenerationResult genResult = GenerationFactory.createGenerationResult(rawName);
    genResult.addAdditionScript(new DatabaseReference(table.getType(), rawName), tableScript);
    genResult.integrate(keyGeneration);
    genResult.integrate(checkGeneration);

    return genResult;
}

From source file:org.jboss.dashboard.commons.misc.ReflectionUtils.java

public static List<Field> getClassFields(Class clazz, Class type, boolean isStatic, String[] fieldsToIgnore) {
    List<Field> results = new ArrayList<Field>();
    if (clazz == null)
        return results;
    if (clazz.isPrimitive())
        return results;
    if (clazz.isAnnotation())
        return results;
    if (clazz.isInterface())
        return results;
    if (clazz.isEnum())
        return results;

    Collection<String> toIgnore = fieldsToIgnore != null ? Arrays.asList(fieldsToIgnore)
            : Collections.EMPTY_SET;
    Field[] fields = clazz.getDeclaredFields();

    for (int i = 0; i < fields.length; i++) {
        Field field = fields[i];/*w w  w.  j  av  a2s . com*/
        if (toIgnore.contains(field.getName()))
            continue;
        if (isStatic && !Modifier.isStatic(field.getModifiers()))
            continue;
        if (!isStatic && Modifier.isStatic(field.getModifiers()))
            continue;
        if (type != null && !field.getType().equals(type))
            continue;
        results.add(field);
    }
    return results;
}

From source file:org.vosao.entity.field.PageAttributesField.java

@Override
public Set<java.util.Map.Entry<String, String>> entrySet() {
    return Collections.EMPTY_SET;
}

From source file:com.phoenixst.plexus.examples.EmptyGraph.java

protected Collection createEdgeCollection() {
    return Collections.EMPTY_SET;
}