List of usage examples for java.util LinkedHashMap values
public Collection<V> values()
From source file:Main.java
public static void main(String[] args) { LinkedHashMap<String, String> lHashMap = new LinkedHashMap<String, String>(); lHashMap.put("1", "One"); lHashMap.put("2", "Two"); lHashMap.put("3", "Three"); Collection c = lHashMap.values(); Iterator itr = c.iterator();/*from w ww . j ava2 s. co m*/ while (itr.hasNext()) { System.out.println(itr.next()); } }
From source file:CollectionAll.java
public static void main(String[] args) { List list1 = new LinkedList(); list1.add("list"); list1.add("dup"); list1.add("x"); list1.add("dup"); traverse(list1);/*w w w . j a v a 2s . c om*/ List list2 = new ArrayList(); list2.add("list"); list2.add("dup"); list2.add("x"); list2.add("dup"); traverse(list2); Set set1 = new HashSet(); set1.add("set"); set1.add("dup"); set1.add("x"); set1.add("dup"); traverse(set1); SortedSet set2 = new TreeSet(); set2.add("set"); set2.add("dup"); set2.add("x"); set2.add("dup"); traverse(set2); LinkedHashSet set3 = new LinkedHashSet(); set3.add("set"); set3.add("dup"); set3.add("x"); set3.add("dup"); traverse(set3); Map m1 = new HashMap(); m1.put("map", "Java2s"); m1.put("dup", "Kava2s"); m1.put("x", "Mava2s"); m1.put("dup", "Lava2s"); traverse(m1.keySet()); traverse(m1.values()); SortedMap m2 = new TreeMap(); m2.put("map", "Java2s"); m2.put("dup", "Kava2s"); m2.put("x", "Mava2s"); m2.put("dup", "Lava2s"); traverse(m2.keySet()); traverse(m2.values()); LinkedHashMap /* from String to String */ m3 = new LinkedHashMap(); m3.put("map", "Java2s"); m3.put("dup", "Kava2s"); m3.put("x", "Mava2s"); m3.put("dup", "Lava2s"); traverse(m3.keySet()); traverse(m3.values()); }
From source file:no.uio.medisin.bag.biojavagb.GBRead.java
public static void main(String[] args) throws Exception { logger.info("\n\n" + StringUtils.repeat("*", 80) + "\n"); logger.info(" GenBank parse"); logger.info("\n\n" + StringUtils.repeat("*", 80) + "\n"); // String ax = StringUtils.repeat("*", 80); // String gx = Strings.repeat("*", 3); /*//from ww w .j a v a2s.c o m * Method 1: With the GenbankProxySequenceReader */ //Try with the GenbankProxySequenceReader GenbankProxySequenceReader<AminoAcidCompound> genbankProteinReader = new GenbankProxySequenceReader<AminoAcidCompound>( "/tmp", "NP_000257", AminoAcidCompoundSet.getAminoAcidCompoundSet()); ProteinSequence proteinSequence = new ProteinSequence(genbankProteinReader); genbankProteinReader.getHeaderParser().parseHeader(genbankProteinReader.getHeader(), proteinSequence); logger.info("Sequence" + "(" + proteinSequence.getAccession() + "," + proteinSequence.getLength() + ")=" + proteinSequence.getSequenceAsString().substring(0, 10) + "...\n\n"); GenbankProxySequenceReader<NucleotideCompound> genbankDNAReader = new GenbankProxySequenceReader<NucleotideCompound>( "/tmp", "NM_001126", DNACompoundSet.getDNACompoundSet()); DNASequence dnaSequence = new DNASequence(genbankDNAReader); genbankDNAReader.getHeaderParser().parseHeader(genbankDNAReader.getHeader(), dnaSequence); logger.info("Sequence" + "(" + dnaSequence.getAccession() + "," + dnaSequence.getLength() + ")=" + dnaSequence.getSequenceAsString().substring(0, 10) + "...\n\n"); /* * Method 2: With the GenbankReaderHelper */ //Try with the GenbankReaderHelper File dnaFile = new File("src/test/resources/NM_000266.gb"); File protFile = new File("src/test/resources/BondFeature.gb"); logger.info("\n\nREAD dna file " + dnaFile + "\n\n"); LinkedHashMap<String, DNASequence> dnaSequences = GenbankReaderHelper.readGenbankDNASequence(dnaFile); for (DNASequence sequence : dnaSequences.values()) { //logger.info( sequence.getSequenceAsString() ); String notes = sequence.getOriginalHeader(); sequence.getDescription(); List fr = sequence.getFeaturesByType("source"); // List<FeatureInterface<AbstractSequence<NucleotideCompound>, NucleotideCompound>> fr = sequence.getFeaturesByType("SOURCE"); // for (FeatureInterface fi : fr) { // logger.info("DESCRIPTION\t" + fi.getDescription()); // } logger.info(sequence.getDatabaseReferences()); logger.info(sequence.getDescription()); List<FeatureInterface<AbstractSequence<NucleotideCompound>, NucleotideCompound>> fl = sequence .getFeatures(); for (FeatureInterface fi : fl) { logger.info("DESCRIPTION\t" + fi.getDescription()); logger.info("CHILDREN\t" + fi.getChildrenFeatures()); logger.info("LOCATIONS\t" + fi.getLocations()); logger.info("PARENT\t" + fi.getParentFeature()); logger.info("QUALIFIERS"); HashMap<String, Qualifier> quals = fi.getQualifiers(); for (Map.Entry<String, Qualifier> entry : quals.entrySet()) { logger.info("--\t" + entry.getKey() + "\t|\t" + entry.getValue().getName() + " / " + entry.getValue().getValue() + "\\" + entry.getValue().toString()); } logger.info("\n"); logger.info("SHORT\t" + fi.getShortDescription()); logger.info("SOURCE\t" + fi.getSource()); logger.info("TYPE\t" + fi.getType()); logger.info("HASHCODE\t" + fi.hashCode()); logger.info("-"); } // Annotation seqAn = seq.getAnnotation(); // for (Iterator i = seqAn.keys().iterator(); i.hasNext(); ) { // Object key = i.next(); // Object value = seqAn.getProperty(key); // logger.info(key.toString() + ": " + value.toString()); // } } LinkedHashMap<String, ProteinSequence> protSequences = GenbankReaderHelper .readGenbankProteinSequence(protFile); for (ProteinSequence sequence : protSequences.values()) { logger.info(sequence.getSequenceAsString()); } /* * Method 3: With the GenbankReader Object */ //Try reading with the GanbankReader FileInputStream is = new FileInputStream(dnaFile); GenbankReader<DNASequence, NucleotideCompound> dnaReader = new GenbankReader<DNASequence, NucleotideCompound>( is, new GenericGenbankHeaderParser<DNASequence, NucleotideCompound>(), new DNASequenceCreator(DNACompoundSet.getDNACompoundSet())); dnaSequences = dnaReader.process(); is.close(); logger.info(dnaSequences); is = new FileInputStream(protFile); GenbankReader<ProteinSequence, AminoAcidCompound> protReader = new GenbankReader<ProteinSequence, AminoAcidCompound>( is, new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())); protSequences = protReader.process(); is.close(); logger.info(protSequences); }
From source file:net.itransformers.idiscover.v2.core.Main.java
public static void main(String[] args) throws MalformedURLException { logger.debug("iDiscover v2. gearing up"); Map<String, String> params = CmdLineParser.parseCmdLine(args); // String connectionDetailsFileName = params.get("-f"); // if (connectionDetailsFileName == null) { // printUsage("fileName"); return; // }//w ww .ja v a 2 s . c o m String depthCmdArg = params.get("-d"); // if (depthCmdArg == null) { // printUsage("depth"); return; // } String projectPath = params.get("-p"); if (projectPath == null) { File cwd = new File("."); System.out.println("Project path is not specified. Will use current dir: " + cwd.getAbsolutePath()); projectPath = cwd.getAbsolutePath(); } File workingDir = new File(projectPath); if (!workingDir.exists()) { System.out.println("Invalid project path!"); return; } System.out.println("Loading beans!!"); File conDetails = new File(projectPath, "iDiscover/conf/txt/connection-details.txt"); File generic = new File(projectPath, "iDiscover/conf/xml/generic.xml"); String genericContextPath = generic.toURI().toURL().toString(); File snmpDiscovery = new File(projectPath, "iDiscover/conf/xml/snmpNetworkDiscovery.xml"); String snmpDiscoveryContextPath = snmpDiscovery.toURI().toURL().toString(); File connectionsDetails = new File(projectPath, "iDiscover/conf/xml/connectionsDetails.xml"); String connectionsDetailsContextPath = connectionsDetails.toURI().toURL().toString(); DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); BeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(String.class) .addConstructorArgValue(projectPath).getBeanDefinition(); String labelDirName = autolabel(projectPath); BeanDefinition beanDefinition2 = BeanDefinitionBuilder.rootBeanDefinition(String.class) .addConstructorArgValue(labelDirName).getBeanDefinition(); beanFactory.registerBeanDefinition("projectPath", beanDefinition); beanFactory.registerBeanDefinition("labelDirName", beanDefinition2); GenericApplicationContext cmdArgCxt = new GenericApplicationContext(beanFactory); // Must call refresh to initialize context cmdArgCxt.refresh(); String[] paths = new String[] { genericContextPath, snmpDiscoveryContextPath, connectionsDetailsContextPath }; // ,project.getAbsolutePath()+project.getAbsolutePath()+File.separator+"iDiscover/conf/xml/snmpNetworkDiscovery.xml", project.getAbsolutePath()+File.separator+"iDiscover/src/main/resources/connectionsDetails.xml" FileSystemXmlApplicationContext applicationContext = new FileSystemXmlApplicationContext(paths, cmdArgCxt); // ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(workingDir+File.separator+"iDiscover/conf/xml/generic.xml",workingDir+File.separator+"/iDiscover/conf/xml/snmpNetworkDiscovery.xml","connectionsDetails.xml"); // NetworkDiscoverer discoverer = fileApplicationContext.getBean("bgpPeeringMapDiscovery", NetworkDiscoverer.class); //NetworkDiscoverer discoverer = fileApplicationContext.getBean("floodLightNodeDiscoverer", NetworkDiscoverer.class); NetworkDiscoverer discoverer = applicationContext.getBean("snmpDiscovery", NetworkDiscoverer.class); LinkedHashMap<String, ConnectionDetails> connectionList = (LinkedHashMap) applicationContext .getBean("connectionList", conDetails); int depth = (Integer) applicationContext.getBean("discoveryDepth", depthCmdArg == null ? "-1" : depthCmdArg); NetworkDiscoveryResult result = discoverer .discoverNetwork(new ArrayList<ConnectionDetails>(connectionList.values()), depth); if (result != null) { for (String s : result.getNodes().keySet()) { System.out.println("\nNode: " + s); } } // }
From source file:org.countandra.unittests.CountandraTestUtils.java
public static Long httpGet(String query) { URL url;//w w w . ja v a 2s .c om try { url = new URL(query); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.connect(); InputStream in = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String jsonText = reader.readLine(); JSONParser parser = new JSONParser(); ContainerFactory containerFactory = new ContainerFactory() { public List creatArrayContainer() { return new LinkedList(); } public Map createObjectContainer() { return new LinkedHashMap(); } }; try { Map json = (Map) parser.parse(jsonText, containerFactory); Iterator iter = json.entrySet().iterator(); while (iter.hasNext()) { Map.Entry result = (Map.Entry) iter.next(); if (result.getKey().equals("Results")) { LinkedHashMap resultHashMap = (LinkedHashMap) result.getValue(); LinkedHashMap dataHashMap = (LinkedHashMap) resultHashMap.get("Data"); Collection values = dataHashMap.values(); Iterator valueItr = values.iterator(); Long sum = 0L; while (valueItr.hasNext()) { sum = +(Long) valueItr.next(); } return sum; } else { return 0L; } } } catch (ParseException pe) { System.out.println(pe); } conn.disconnect(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return 0L; }
From source file:ca.sfu.federation.utils.IContextUtils.java
/** * Get elements in topological order./* ww w .j ava2 s.co m*/ * @param Named Named object. * @param Sorted List of elements in topological order. * @throws GraphCycleException Graph contains a cycle and can not be updated. */ private static void getElementsInTopologicalOrder(INamed Named, ArrayList Sorted) throws GraphCycleException { // if the NamedObject is already in the list, then we expect that its dependancies // are also already represented there and therefore we don't need to do anything if (Named instanceof IGraphable && !Sorted.contains(Named)) { IGraphable graphobject = (IGraphable) Named; // add nodes upon which the object is dependant first LinkedHashMap deps = (LinkedHashMap) graphobject.getDependancies(); Iterator iter = deps.values().iterator(); while (iter.hasNext()) { INamed namedDep = (INamed) iter.next(); getElementsInTopologicalOrder(namedDep, Sorted); } // add myself if (!Sorted.contains(Named)) { Sorted.add(Named); } else { // graph has a cycle throw new GraphCycleException(); } } }
From source file:org.sonatype.nexus.repository.r.internal.RPackagesUtils.java
static List<Map<String, String>> merge(List<List<Map<String, String>>> parts) { final LinkedHashMap<String, Map<String, String>> merged = new LinkedHashMap<>(); for (List<Map<String, String>> part : parts) { for (Map<String, String> thisEntry : part) { merged.putIfAbsent(thisEntry.get(P_PACKAGE), thisEntry); }// w w w. ja v a2 s. co m } return new ArrayList<>(merged.values()); }
From source file:hudson.plugins.parameterizedtrigger.ParameterizedTriggerUtils.java
public static ParametersAction mergeParameters(ParametersAction base, ParametersAction overlay) { LinkedHashMap<String, ParameterValue> params = new LinkedHashMap<String, ParameterValue>(); for (ParameterValue param : base.getParameters()) params.put(param.getName(), param); for (ParameterValue param : overlay.getParameters()) params.put(param.getName(), param); return new ParametersAction(params.values().toArray(new ParameterValue[params.size()])); }
From source file:ca.sfu.federation.utils.IContextUtils.java
public static ArrayList<INamed> getElementsInTopologicalOrder(Map<String, INamed> ElementMap) throws GraphCycleException { ArrayList<INamed> sorted = new ArrayList<INamed>(); Iterator iter = ElementMap.values().iterator(); while (iter.hasNext()) { INamed named = (INamed) iter.next(); if (named instanceof IGraphable) { IGraphable graphobject = (IGraphable) named; // get dependancies for the node LinkedHashMap deps = (LinkedHashMap) graphobject.getDependancies(); // for each dependancy, do a topological sort on its subgraph Iterator it = deps.values().iterator(); while (it.hasNext()) { INamed namedDep = (INamed) it.next(); getElementsInTopologicalOrder(namedDep, sorted); }/*from w w w . j a v a 2 s . c o m*/ // insert self into list if (!sorted.contains(named)) { sorted.add(named); } } else { // what should we do with an object that does not have dependancies? } } // return result return sorted; }
From source file:gov.llnl.lc.smt.command.route.SmtMulticast.java
public static SBN_MulticastGroup[] getGroupsWithMembers(LinkedHashMap<String, SBN_MulticastGroup> mcGroups, int minimumNumber) { java.util.ArrayList<SBN_MulticastGroup> gMems = new java.util.ArrayList<SBN_MulticastGroup>(); for (SBN_MulticastGroup g : mcGroups.values()) { // if this has the minimum number of members, then add it to the return list if (g.port_guids.length >= minimumNumber) gMems.add(g);/*from www . ja va 2 s. c o m*/ } SBN_MulticastGroup list[] = new SBN_MulticastGroup[gMems.size()]; return gMems.toArray(list); }