List of usage examples for java.util Collections unmodifiableCollection
public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> c)
From source file:com.hs.mail.dns.DnsServer.java
/** * <p>/*ww w. j a v a2 s . c om*/ * Return a prioritized unmodifiable list of host handling mail for the * domain. * </p> * * <p> * First lookup MX hosts, then MX hosts of the CNAME adress, and if no * server is found return the IP of the hostname * </p> * * @param hostname * domain name to look up * * @return a unmodifiable list of handling servers corresponding to this * mail domain name */ public Collection<String> findMXRecords(String hostname) { List<String> servers = new ArrayList<String>(); try { servers = findMXRecordsRaw(hostname); return Collections.unmodifiableCollection(servers); } finally { // If we found no results, we'll add the original domain name if // it's a valid DNS entry if (servers.size() == 0) { StringBuffer logBuffer = new StringBuffer(128).append("Couldn't resolve MX records for domain ") .append(hostname).append("."); logger.info(logBuffer.toString()); Record cnames[] = lookup(hostname, Type.CNAME); Collection<String> cnameMXrecords = null; if (cnames != null && cnames.length > 0) { cnameMXrecords = findMXRecordsRaw(((CNAMERecord) cnames[0]).getTarget().toString()); } else { logBuffer = new StringBuffer(128).append("Couldn't find CNAME records for domain ") .append(hostname).append("."); logger.info(logBuffer.toString()); } if (cnameMXrecords == null) { try { getByName(hostname); servers.add(hostname); } catch (UnknownHostException uhe) { // The original domain name is not a valid host, // so we can't add it to the server list. In this // case we return an empty list of servers logBuffer = new StringBuffer(128).append("Couldn't resolve IP address for host ") .append(hostname).append("."); logger.error(logBuffer.toString()); } } else { servers.addAll(cnameMXrecords); } } } }
From source file:dk.netarkivet.common.distribute.arcrepository.Replica.java
/** * Get all known replicas./*from ww w . j a v a2 s . c om*/ * @return A unmodifiable view of the currently known replicas. */ public static Collection<Replica> getKnown() { initializeKnownReplicasList(); return Collections.unmodifiableCollection(knownReplicas.values()); }
From source file:net.krotscheck.stk.filterColumn.FilterColumnBolt.java
/** * Whenever the provided streams are changed, this method is invoked to * trigger the component to recalculate the emitted streams. * * @param providedStreams The number of streams provided to this component. * @return A set of emitted streams./*from w ww . ja va 2 s. co m*/ */ @Override protected Collection<Stream> calculateEmittedStreams(final Collection<Stream> providedStreams) { List<Stream> emitted = new ArrayList<>(); for (Stream provided : providedStreams) { Stream.Builder streamBuilder = new Stream.Builder(provided.getStreamId()); // Filter out whatever we don't have. Map<String, Type> filtered = provided.getSchema().entrySet().stream() .filter(p -> requestedColumns.contains(p.getKey())) .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); // Insert everything we don't have... for (String key : requestedColumns) { if (!filtered.containsKey(key)) { filtered.put(key, Type.STRING); } } streamBuilder.addSchemaFields(filtered); emitted.add(streamBuilder.build()); } return Collections.unmodifiableCollection(emitted); }
From source file:edu.uci.ics.jung.graph.DirectedSparseGraph.java
public Collection<V> getNeighbors(V vertex) { if (!containsVertex(vertex)) return null; Collection<V> neighbors = new HashSet<V>(); neighbors.addAll(getPreds_internal(vertex)); neighbors.addAll(getSuccs_internal(vertex)); return Collections.unmodifiableCollection(neighbors); }
From source file:edu.vt.middleware.gator.log4j.SocketServer.java
/** * Gets a collection of all registered logging event handlers. * * @return Immutable collection of logging event handlers. *//*from w ww . j a va 2 s. com*/ public Collection<LoggingEventHandler> getLoggingEventHandlers() { return Collections.unmodifiableCollection(eventHandlerMap.values()); }
From source file:biz.wolschon.fileformats.gnucash.jwsdpimpl.GnucashFileImpl.java
/** * * @return a read-only collection of all accounts *///from ww w. jav a 2 s .c om public Collection<GnucashAccount> getAccounts() { if (accountid2account == null) { throw new IllegalStateException("no root-element loaded"); } return Collections.unmodifiableCollection(new TreeSet<GnucashAccount>(accountid2account.values())); }
From source file:com.willwinder.universalgcodesender.utils.Settings.java
public Collection<String> getRecentDirectories() { return Collections.unmodifiableCollection(dirHistory); }
From source file:com.hp.autonomy.aci.content.identifier.stateid.StateIdsBuilder.java
@Override public Iterator<StateId> iterator() { // We may later decide to make StateIdsBuilder a full Collection but for now we need to avoid allowing removal // via Iterator, so wrap our collection return Collections.unmodifiableCollection(stateIds).iterator(); }
From source file:edu.ksu.cis.indus.staticanalyses.concurrency.escape.LockAcquisitionBasedEquivalence.java
/** * Retrieves the lock acquisitions that belong to the same equivalence class as the given lock acquisition. * //from ww w . java2 s . c o m * @param pair of interest. * @return a collection of lock acquisition. * @pre pair.oclIsKindOf(Pair(InvokeStmt, SootMethod)) or pair.oclIsKindOf(Pair(EnterMonitorStmt, SootMethod)) * @post result != null * @post * @post result->forall(o | o.oclIsKindOf(Pair(InvokeStmt, SootMethod)) or o.oclIsKindOf(Pair(EnterMonitorStmt, * SootMethod))) */ public Collection<Pair<? extends Stmt, SootMethod>> getLockAcquisitionsInEquivalenceClassOf( final Pair<Stmt, SootMethod> pair) { return Collections.unmodifiableCollection(MapUtils.getEmptyCollectionFromMap(locking2lockings, pair)); }
From source file:edu.ksu.cis.indus.staticanalyses.concurrency.escape.SharedWriteBasedEquivalence.java
/** * Retrieves the shared writes that belong to a non-singleton equivalence class. * // w w w .jav a2 s. c om * @return a collection of lock acquisition. * @post result.getFirst().oclIsKindOf(AssignStmt) * @post result.getFirst().getLeftOp().oclIsKindOf(InstanceFieldRef) or * result.getFirst().getLeftOp().oclIsKindOf(StaticFieldRef) or result.getFirst().getLeftOp().oclIsKindOf(ArrayRef) * @post result != null */ public Collection<Pair<AssignStmt, SootMethod>> getSharedWritesInNonSingletonEquivalenceClass() { return Collections.unmodifiableCollection(write2writes.keySet()); }