List of usage examples for java.util Collections emptySet
@SuppressWarnings("unchecked") public static final <T> Set<T> emptySet()
From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.NavigationController.java
protected Set<ValueFactory> getValueFactory(RDFNode valueNode, OntModel displayOntModel) { //maybe use jenabean or owl2java for this? if (valueNode.isResource()) { Resource res = (Resource) valueNode.as(Resource.class); Statement stmt = res.getProperty(DisplayVocabulary.JAVA_CLASS_NAME); if (stmt == null || !stmt.getObject().isLiteral()) { log.debug("Cannot build value factory: java class was " + stmt.getObject()); return Collections.emptySet(); }/*from w ww . j a va2 s. c om*/ String javaClassName = ((Literal) stmt.getObject().as(Literal.class)).getLexicalForm(); if (javaClassName == null || javaClassName.length() == 0) { log.debug("Cannot build value factory: no java class was set."); return Collections.emptySet(); } Class<?> clazz; Object newObj; try { clazz = Class.forName(javaClassName); } catch (ClassNotFoundException e) { log.debug("Cannot build value factory: no class found for " + javaClassName); return Collections.emptySet(); } try { newObj = clazz.newInstance(); } catch (Exception e) { log.debug("Cannot build value factory: exception while creating object of java class " + javaClassName + " " + e.getMessage()); return Collections.emptySet(); } if (newObj instanceof ValueFactory) { ValueFactory valueFactory = (ValueFactory) newObj; return Collections.singleton(valueFactory); } else { log.debug("Cannot build value factory: " + javaClassName + " does not implement " + ValueFactory.class.getName()); return Collections.emptySet(); } } else { log.debug("Cannot build value factory for " + valueNode); return Collections.emptySet(); } }
From source file:ru.org.linux.group.GroupController.java
private List<TopicsListItem> getTopics(Group group, int messagesInPage, boolean lastmod, Integer year, Integer month, int topics, int offset, boolean showDeleted, boolean showIgnored, @Nullable User currentUser) {/*w w w . j a v a 2 s.co m*/ Set<Integer> ignoreList; if (currentUser != null) { ignoreList = ignoreListDao.get(currentUser); } else { ignoreList = Collections.emptySet(); } String delq = showDeleted ? "" : " AND NOT deleted "; String q = "SELECT topics.title as subj, lastmod, userid, topics.id as msgid, deleted, topics.stat1, topics.stat3, topics.stat4, topics.sticky, topics.resolved " + "FROM topics WHERE NOT sticky AND topics.groupid=" + group.getId() + delq; if (year != null) { q += " AND postdate>='" + year + '-' + month + "-01'::timestamp AND (postdate<'" + year + '-' + month + "-01'::timestamp+'1 month'::interval)"; } String ignq = ""; if (!showIgnored && currentUser != null) { int currentUserId = currentUser.getId(); if (!ignoreList.isEmpty()) { ignq = " AND topics.userid NOT IN (SELECT ignored FROM ignore_list WHERE userid=" + currentUserId + ')'; } if (!currentUser.isModerator()) { ignq += " AND topics.id NOT IN (select distinct tags.msgid from tags, user_tags " + "where tags.tagid=user_tags.tag_id and user_tags.is_favorite = false and user_id=" + currentUserId + ") "; } } SqlRowSet rs; if (!lastmod) { if (year == null) { if (offset == 0) { q += " AND postdate>CURRENT_TIMESTAMP-'3 month'::interval "; } rs = jdbcTemplate .queryForRowSet(q + ignq + " ORDER BY msgid DESC LIMIT " + topics + " OFFSET " + offset); } else { rs = jdbcTemplate .queryForRowSet(q + ignq + " ORDER BY msgid DESC LIMIT " + topics + " OFFSET " + offset); } } else { rs = jdbcTemplate .queryForRowSet(q + ignq + " ORDER BY lastmod DESC LIMIT " + topics + " OFFSET " + offset); } return prepareTopic(rs, messagesInPage); }
From source file:grakn.core.graql.analytics.MedianVertexProgram.java
@Override public Set<MessageScope> getMessageScopes(final Memory memory) { switch (memory.getIteration()) { case 0:// ww w .ja v a 2 s . c o m return Sets.newHashSet(messageScopeShortcutIn, messageScopeResourceOut); case 1: return Collections.singleton(messageScopeShortcutOut); default: return Collections.emptySet(); } }
From source file:com.hortonworks.streamline.registries.dashboard.service.DashboardCatalogService.java
public Set<Long> getWidgetDatasourceMapping(Widget widget) { List<QueryParam> queryParams = Collections .singletonList(new QueryParam(WidgetDatasourceMapping.WIDGET_ID, widget.getId().toString())); Collection<WidgetDatasourceMapping> mappings = dao.find(WIDGET_DATASOURCE_MAPPING_NAMESPACE, queryParams); if (mappings != null) { return mappings.stream().map(WidgetDatasourceMapping::getWidgetId).collect(Collectors.toSet()); }/*from ww w .j a v a 2s.c o m*/ return Collections.emptySet(); }
From source file:com.boundlessgeo.wps.grass.GrassProcesses.java
@Override public Set<Name> getNames() { if (EXEC == null) { // do not advertise grass processes if executable is not available return Collections.emptySet(); }/*from w w w . j a v a 2s . c o m*/ return super.getNames(); }
From source file:de.tudarmstadt.ukp.dkpro.lexsemresource.wikipedia.WikipediaArticleResource.java
public Set<Entity> getChildren(Entity entity) throws LexicalSemanticResourceException { if (!this.containsEntity(entity)) { return Collections.emptySet(); }//from w w w.j a v a 2 s .c o m Page p = WikipediaArticleUtils.entityToPage(wiki, entity, isCaseSensitive); return WikipediaArticleUtils.pagesToEntities(wiki, p.getOutlinks(), isCaseSensitive); }
From source file:jp.co.tis.gsp.tools.dba.s2jdbc.gen.DbTableMetaReaderWithView.java
@Override protected Set<String> getPrimaryKeySet(DatabaseMetaData metaData, DbTableMeta tableMeta) { Set<String> result = new HashSet<String>(); Dialect gspDialect = DialectUtil.getDialect(); try {// w ww .j a v a 2 s . c o m String typeName = getObjectTypeName(metaData, tableMeta); String tableName = tableMeta.getName(); ViewAnalyzer viewAnalyzer = null; if (StringUtils.equals(typeName, "VIEW")) { String sql = gspDialect.getViewDefinition(metaData.getConnection(), tableName, tableMeta); viewAnalyzer = new ViewAnalyzer(); viewAnalyzer.parse(sql); if (viewAnalyzer.isSimple()) { tableName = viewAnalyzer.getTableName().toUpperCase(); } else { return Collections.emptySet(); } } ResultSet rs = metaData.getPrimaryKeys(tableMeta.getCatalogName(), tableMeta.getSchemaName(), tableName); try { while (rs.next()) { result.add(rs.getString("COLUMN_NAME")); } } finally { ResultSetUtil.close(rs); } if (viewAnalyzer != null && !result.isEmpty()) { Set<String> viewPKs = new TreeSet<String>(); for (String pkColumn : result) { if (viewAnalyzer.getColumnNames().contains(pkColumn.toUpperCase())) { String alias = viewAnalyzer.getAlias((pkColumn.toUpperCase())); viewPKs.add(StringUtils.isEmpty(alias) ? pkColumn : alias); } } System.out.println("View Pks" + viewPKs); if (viewPKs.size() == result.size()) return viewPKs; else return Collections.emptySet(); } return result; } catch (SQLException ex) { throw new SQLRuntimeException(ex); } }
From source file:org.jasig.portlet.blackboardvcportlet.service.impl.LdapUserServiceImpl.java
@Override public Set<BasicUser> searchForUserByEmail(String email) { email = StringUtils.trimToNull(email); if (email == null) { return Collections.emptySet(); }// w w w . j a v a 2s . c o m final AndFilter andFilter = createBaseFilter(); andFilter.and(new LikeFilter(mailAttributeName, email + "*")); final String searchFilter = andFilter.encode(); @SuppressWarnings("unchecked") final List<BasicUser> results = ldapOperations.search("", searchFilter, basicUserAttributeMapper); return Collections.unmodifiableSet(new LinkedHashSet<BasicUser>(results)); }
From source file:net.big_oh.algorithms.graph.clique.BronKerboschMaximalCliqueFinder.java
private Set<Set<V>> bronKerbosch1(Set<V> r, Set<V> p, Set<V> x, Graph<V> g, int minCliqueSize, int searchDepth) { if (logger.isDebugEnabled()) { logger.debug("Depth:" + searchDepth + " - R:" + r.size() + " - P:" + p.size() + " - X:" + x.size()); }/*from w ww. j a v a 2s .c om*/ // base case ... // if P and X are both empty, then we're done if (p.isEmpty() && x.isEmpty()) { if (r.size() >= minCliqueSize) { // the maximal clique contained in r is big enough to report return Collections.singleton(r); } else { // the maximal clique contained in r is too small return Collections.emptySet(); } } // recursive case ... Set<Set<V>> maximalCliques = new HashSet<Set<V>>(); Set<V> pCopy = new HashSet<V>(p); for (V v : pCopy) { // rPrime = R {v} Set<V> rPrime = new HashSet<V>(r); rPrime.add(v); // pPrime = P N(v) Set<V> pPrime = new HashSet<V>(p); pPrime.retainAll(g.getAllNeighbors(v)); // xPrime = X N(v) Set<V> xPrime = new HashSet<V>(x); xPrime.retainAll(g.getAllNeighbors(v)); maximalCliques.addAll(bronKerbosch1(rPrime, pPrime, xPrime, g, minCliqueSize, searchDepth + 1)); // P := P \ {v} p.remove(v); // X := X {v} x.add(v); } return maximalCliques; }
From source file:com.netty.file.HttpUploadServerHandler.java
@Override public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { if (msg instanceof HttpRequest) { HttpRequest request = this.request = (HttpRequest) msg; URI uri = new URI(request.uri()); if (!uri.getPath().startsWith("/form")) { // Write Menu writeMenu(ctx);/*from w ww . j a v a 2s . com*/ return; } responseContent.setLength(0); responseContent.append("WELCOME TO THE WILD WILD WEB SERVER\r\n"); responseContent.append("===================================\r\n"); responseContent.append("VERSION: " + request.protocolVersion().text() + "\r\n"); responseContent.append("REQUEST_URI: " + request.uri() + "\r\n\r\n"); responseContent.append("\r\n\r\n"); // new getMethod for (Entry<String, String> entry : request.headers()) { responseContent.append("HEADER: " + entry.getKey() + '=' + entry.getValue() + "\r\n"); } responseContent.append("\r\n\r\n"); System.out.println("Helllllllllllllllllloooooooooooooo"); // new getMethod Set<Cookie> cookies; String value = request.headers().get(HttpHeaderNames.COOKIE); if (value == null) { cookies = Collections.emptySet(); } else { cookies = ServerCookieDecoder.STRICT.decode(value); } for (Cookie cookie : cookies) { responseContent.append("COOKIE: " + cookie + "\r\n"); } responseContent.append("\r\n\r\n"); QueryStringDecoder decoderQuery = new QueryStringDecoder(request.uri()); Map<String, List<String>> uriAttributes = decoderQuery.parameters(); for (Entry<String, List<String>> attr : uriAttributes.entrySet()) { for (String attrVal : attr.getValue()) { responseContent.append("URI: " + attr.getKey() + '=' + attrVal + "\r\n"); } } responseContent.append("\r\n\r\n"); // if GET Method: should not try to create a HttpPostRequestDecoder if (request.method().equals(HttpMethod.GET)) { // GET Method: should not try to create a HttpPostRequestDecoder // So stop here responseContent.append("\r\n\r\nEND OF GET CONTENT\r\n"); // Not now: LastHttpContent will be sent writeResponse(ctx.channel()); return; } try { decoder = new HttpPostRequestDecoder(factory, request); } catch (ErrorDataDecoderException e1) { e1.printStackTrace(); responseContent.append(e1.getMessage()); writeResponse(ctx.channel()); ctx.channel().close(); return; } readingChunks = HttpUtil.isTransferEncodingChunked(request); responseContent.append("Is Chunked: " + readingChunks + "\r\n"); responseContent.append("IsMultipart: " + decoder.isMultipart() + "\r\n"); if (readingChunks) { // Chunk version responseContent.append("Chunks: "); readingChunks = true; } } // check if the decoder was constructed before // if not it handles the form get if (decoder != null) { if (msg instanceof HttpContent) { // New chunk is received HttpContent chunk = (HttpContent) msg; try { decoder.offer(chunk); } catch (ErrorDataDecoderException e1) { e1.printStackTrace(); responseContent.append(e1.getMessage()); writeResponse(ctx.channel()); ctx.channel().close(); return; } responseContent.append('o'); // example of reading chunk by chunk (minimize memory usage due to // Factory) readHttpDataChunkByChunk(); // example of reading only if at the end if (chunk instanceof LastHttpContent) { writeResponse(ctx.channel()); readingChunks = false; reset(); } } } else { writeResponse(ctx.channel()); } }