List of usage examples for java.util Collections unmodifiableCollection
public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> c)
From source file:org.dasein.cloud.ibm.sce.compute.vm.SCEVirtualMachine.java
@Override public Iterable<VirtualMachineProduct> listProducts(Architecture architecture) throws InternalException, CloudException { if (products == null) { ProviderContext ctx = provider.getContext(); if (ctx == null) { throw new SCEConfigException("No context was configured for this request"); }/*from w w w . jav a2 s. c o m*/ SCEMethod method = new SCEMethod(provider); Document xml = method.getAsXML("offerings/image"); if (xml == null) { return Collections.emptyList(); } HashMap<String, VirtualMachineProduct> t = new HashMap<String, VirtualMachineProduct>(); HashMap<String, VirtualMachineProduct> s = new HashMap<String, VirtualMachineProduct>(); NodeList items = xml.getElementsByTagName("Image"); for (int i = 0; i < items.getLength(); i++) { HashMap<String, VirtualMachineProduct> prdMap = new HashMap<String, VirtualMachineProduct>(); NodeList attrs = items.item(i).getChildNodes(); Architecture a = null; for (int j = 0; j < attrs.getLength(); j++) { Node attr = attrs.item(j); if (attr.getNodeName().equalsIgnoreCase("Architecture") && attr.hasChildNodes()) { String val = attr.getFirstChild().getNodeValue().trim(); if (val.equals("i386")) { a = Architecture.I32; } else if (val.startsWith("x86")) { a = Architecture.I64; } else { System.out.println("DEBUG: Unknown architecture: " + val); a = Architecture.I32; } } else if (attr.getNodeName().equalsIgnoreCase("SupportedInstanceTypes") && attr.hasChildNodes()) { NodeList types = attr.getChildNodes(); for (int k = 0; k < types.getLength(); k++) { Node type = types.item(k); if (type.getNodeName().equalsIgnoreCase("InstanceType") && type.hasChildNodes()) { VirtualMachineProduct prd = new VirtualMachineProduct(); NodeList nodes = type.getChildNodes(); for (int l = 0; l < nodes.getLength(); l++) { Node node = nodes.item(l); if (node.getNodeName().equals("ID") && node.hasChildNodes()) { prd.setProviderProductId(node.getFirstChild().getNodeValue().trim()); } else if (node.getNodeName().equals("Label") && node.hasChildNodes()) { prd.setName(node.getFirstChild().getNodeValue().trim()); } else if (node.getNodeName().equals("Detail") && node.hasChildNodes()) { prd.setDescription(node.getFirstChild().getNodeValue().trim()); } } if (prd.getProviderProductId() != null) { String[] parts = prd.getProviderProductId().split("/"); if (parts.length == 3) { String[] sub = parts[0].split("\\."); if (sub.length > 0) { parts[0] = sub[sub.length - 1]; } try { prd.setCpuCount(Integer.parseInt(parts[0])); } catch (NumberFormatException ignore) { // ignore } try { prd.setRamSize(new Storage<Megabyte>(Integer.parseInt(parts[1]), Storage.MEGABYTE)); } catch (NumberFormatException ignore) { // ignore } try { int idx = parts[2].indexOf("*"); if (idx < 1) { prd.setRootVolumeSize(new Storage<Gigabyte>( Integer.parseInt(parts[2]), Storage.GIGABYTE)); } else { prd.setRootVolumeSize(new Storage<Gigabyte>( Integer.parseInt(parts[2].substring(0, idx)), Storage.GIGABYTE)); } } catch (NumberFormatException ignore) { // ignore } } prdMap.put(prd.getProviderProductId(), prd); } } } } } if (a != null) { if (a.equals(Architecture.I32)) { t.putAll(prdMap); } else if (a.equals(Architecture.I64)) { s.putAll(prdMap); } } } HashMap<Architecture, Collection<VirtualMachineProduct>> tmp = new HashMap<Architecture, Collection<VirtualMachineProduct>>(); tmp.put(Architecture.I32, Collections.unmodifiableCollection(t.values())); tmp.put(Architecture.I64, Collections.unmodifiableCollection(s.values())); products = tmp; } return products.get(architecture); }
From source file:edu.uci.ics.jung.graph.OrderedKAryTree.java
/** * @see edu.uci.ics.jung.graph.Hypergraph#getNeighbors(java.lang.Object) *//*from w w w . j ava 2 s. c o m*/ public Collection<V> getNeighbors(V vertex) { if (!containsVertex(vertex)) return null; ArrayList<V> vertices = new ArrayList<V>(order + 1); VertexData v_data = vertex_data.get(vertex); if (v_data.parent_edge != null) vertices.add(edge_vpairs.get(v_data.parent_edge).getFirst()); if (v_data.child_edges != null) { for (E edge : v_data.child_edges) if (edge != null) vertices.add(edge_vpairs.get(edge).getSecond()); } if (vertices.isEmpty()) return Collections.emptySet(); return Collections.unmodifiableCollection(vertices); }
From source file:edu.ksu.cis.indus.staticanalyses.concurrency.escape.AliasSet.java
/** * Retrieves the threads that read fields of the associated object. * /*from w w w.j a v a 2 s. c o m*/ * @return the reading threads. */ Collection<Triple<InvokeStmt, SootMethod, SootClass>> getReadThreads() { final Collection<Triple<InvokeStmt, SootMethod, SootClass>> _collection = find().readThreads; final Collection<Triple<InvokeStmt, SootMethod, SootClass>> _result; if (_collection != null) { _result = Collections.unmodifiableCollection(_collection); } else { _result = Collections.emptySet(); } return _result; }
From source file:edu.ksu.cis.indus.staticanalyses.concurrency.escape.AliasSet.java
/** * Retrieves the shared entities of this object. * //www.ja v a 2 s. c o m * @return a collection of objects. */ Collection<Object> getReadWriteShareEntities() { final Collection<Object> _collection = find().readwriteEntities; final Collection<Object> _result; if (_collection != null) { _result = Collections.unmodifiableCollection(_collection); } else { _result = null; } return _result; }
From source file:edu.ksu.cis.indus.staticanalyses.concurrency.escape.AliasSet.java
/** * Retrieves the ready entity object of this alias set. * // ww w . jav a 2 s .c om * @return the associated readyentity object. * @post result == self.find().readyEntity */ Collection<Object> getReadyEntities() { final Collection<Object> _collection = find().readyEntities; final Collection<Object> _result; if (_collection != null) { _result = Collections.unmodifiableCollection(_collection); } else { _result = null; } return _result; }
From source file:edu.ksu.cis.indus.staticanalyses.concurrency.escape.AliasSet.java
/** * Retrieves the threads that write fields of the associated object. * //from w w w.j a va2s .c om * @return the writing threads. */ Collection<Triple<InvokeStmt, SootMethod, SootClass>> getWriteThreads() { final Collection<Triple<InvokeStmt, SootMethod, SootClass>> _collection = find().writeThreads; final Collection<Triple<InvokeStmt, SootMethod, SootClass>> _result; if (_collection != null) { _result = Collections.unmodifiableCollection(_collection); } else { _result = Collections.emptySet(); } return _result; }
From source file:edu.ksu.cis.indus.staticanalyses.concurrency.escape.AliasSet.java
/** * Retrieves the shared entities pertaining to write-write sharing of the associated object. * // w ww . j av a2 s. c o m * @return a collection of objects. */ Collection<Object> getWriteWriteShareEntities() { final Collection<Object> _collection = find().writewriteEntities; final Collection<Object> _result; if (_collection != null) { _result = Collections.unmodifiableCollection(_collection); } else { _result = null; } return _result; }
From source file:info.guardianproject.onionkit.trust.StrongTrustManager.java
/** * Returns the JID representation of an XMPP entity contained as a * SubjectAltName extension in the certificate. If none was found then * return <tt>null</tt>./*from w w w .ja v a 2 s . c o m*/ * * @param certificate the certificate presented by the remote entity. * @return the JID representation of an XMPP entity contained as a * SubjectAltName extension in the certificate. If none was found * then return <tt>null</tt>. */ static Collection<String> getSubjectAlternativeNames(X509Certificate certificate) { List<String> identities = new ArrayList<String>(); try { byte[] extVal = certificate.getExtensionValue(X509Extensions.SubjectAlternativeName.getId()); // Check that the certificate includes the SubjectAltName extension if (extVal == null) { return Collections.emptyList(); } ASN1OctetString octs = (ASN1OctetString) ASN1Primitive.fromByteArray(extVal); @SuppressWarnings("rawtypes") Enumeration it = DERSequence.getInstance(ASN1Primitive.fromByteArray(octs.getOctets())).getObjects(); while (it.hasMoreElements()) { GeneralName genName = GeneralName.getInstance(it.nextElement()); switch (genName.getTagNo()) { case GeneralName.dNSName: identities.add(((ASN1String) genName.getName()).getString()); break; } } return Collections.unmodifiableCollection(identities); } catch (Exception e) { Log.e(TAG, "getSubjectAlternativeNames()", e); } return identities; }
From source file:com.vmware.identity.idm.server.ServerUtils.java
public static Collection<String> getConnectionStringFromUris(Collection<URI> uris) { List<String> connectionStrs = new ArrayList<String>(); for (URI uri : uris) { connectionStrs.add(uri.toString()); }//from www . jav a 2 s. c o m return Collections.unmodifiableCollection(connectionStrs); }
From source file:com.vmware.identity.idm.server.ServerUtils.java
public static Collection<URI> toURIObjects(Collection<String> uriStrings) { List<URI> result = new ArrayList<URI>(); for (String uriStr : uriStrings) { try {// ww w . j av a 2 s. c o m result.add(new URI(uriStr)); } catch (URISyntaxException e) { logger.warn(String.format("bad uri: [%s]", uriStr)); } } return Collections.unmodifiableCollection(result); }