List of usage examples for java.util LinkedHashMap keySet
public Set<K> keySet()
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"); Set st = lHashMap.keySet(); Iterator itr = st.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); }/*w ww . ja v a2s . c o m*/ st.remove("2"); boolean blnExists = lHashMap.containsKey("2"); System.out.println(blnExists); }
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);/*from w ww .j a va 2 s. c o m*/ 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:unige.cui.meghdad.nlp.mwe1.Collocational_Bidirect_Prob_Corpus.java
public static void main(String[] args) throws UnsupportedEncodingException, FileNotFoundException, IOException, ParseException { //====================================================================== //====================== COMMAND LINE ARGUMENTS ======================= //====================================================================== //use apache commons CLI to parse command line arguments // create Options object Options options = new Options(); //required options: options.addOption("p2corpus", true, "Path 2 POS tagged corpus."); //optional options: options.addOption("rc", true, "Ranking criteria: delta_12, delta_21, or combined."); options.addOption("maxRank", true, "Return MWEs up to this rank."); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); //initialize options to default values and check required options are set if (!cmd.hasOption("p2corpus")) { System.out.println("Path to the POS tagged corpus must be set."); }/*from www . ja va 2s.com*/ String rc = "21"; if (cmd.hasOption("rc")) { rc = cmd.getOptionValue("rc"); } int maxRank = 200; if (cmd.hasOption("maxRank")) { rc = cmd.getOptionValue("maxRank"); } //====================================================================== //====================================================================== String p2corpus = cmd.getOptionValue("p2corpus"); Tools T = new Tools(); System.out.println("Extracting a set of \"nn-nn\" candidates..."); LinkedHashMap<String, Integer> posCandidates = new LinkedHashMap<String, Integer>( T.extractNCs(p2corpus, "nn-nn", true, true, 50)); //TODO keep only the candiddates whose components that have at least one synonym in wordnet System.out.println("Extracting 1-grams..."); HashMap<String, Integer> unigrams = T.ExtractUnigram(p2corpus, 1, true, true).get(0); System.out.println("Extracting 2-grams..."); HashMap<String, Integer> bigrams = T.ExtractNgrams(p2corpus, 1, 2, true, false, true); System.out.println("Calculating bidirectional synset-baset probabilities..."); Collocational_Bidirect_Prob_Corpus cpb = new Collocational_Bidirect_Prob_Corpus(posCandidates, unigrams, bigrams); LinkedHashMap<String, Double[]> r = cpb.calculateSynBasedProbs_v2(false); DecimalFormat df = new DecimalFormat("0.000"); //calculate the score: HashMap<String, Double> scores = new HashMap<String, Double>(); if (rc.equals("12")) { for (String s : r.keySet()) { scores.put(s, (r.get(s)[0] - r.get(s)[2])); } } else if (rc.equals("21")) { for (String s : r.keySet()) { scores.put(s, (r.get(s)[1] - r.get(s)[3])); } } else if (rc.equals("hybrid")) { for (String s : r.keySet()) { scores.put(s, (r.get(s)[0] - r.get(s)[2]) * (r.get(s)[1] - r.get(s)[3])); } } //sort (descending) candidates by their score: List<Entry<String, Double>> entryList = new ArrayList<Entry<String, Double>>(scores.entrySet()); Collections.sort(entryList, new Comparator<Entry<String, Double>>() { @Override public int compare(Entry<String, Double> e1, Entry<String, Double> e2) { return -1 * e1.getValue().compareTo(e2.getValue()); } }); //print the results: System.out.println("Ranking the candidates...\n"); System.out.println("Returning the ranked candidates for which WordNet synsets were available."); int rank = 0; for (Entry<String, Double> e : entryList) { rank++; System.out.println(e.getKey() + " " + df.format(e.getValue())); if (rank >= maxRank) { break; } } }
From source file:unige.cui.meghdad.nlp.mwe1.Collocational_Bidirect_Prob_File.java
public static void main(String[] args) throws UnsupportedEncodingException, FileNotFoundException, IOException, ParseException { //====================================================================== //====================== COMMAND LINE ARGUMENTS ======================= //====================================================================== //use apache commons CLI to parse command line arguments //create Options object Options options = new Options(); //required options: options.addOption("p2bigrams", true, "Path 2 all bigrams extracted from the corpus."); options.addOption("p2unigrams", true, "Path 2 all unigrams extracted from the corpus."); options.addOption("p2POSTaggedCandidates", true, "Path 2 POS tagged candidates."); //optional options: options.addOption("rc", true, "Ranking criteria: delta_12, delta_21, or combined."); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); //initialize options to default values and check required options are set if (!cmd.hasOption("p2bigrams")) { System.out.println("Path to bigrams must be set."); }// w w w .ja va2s.c o m if (!cmd.hasOption("p2unigrams")) { System.out.println("Path to unigrams must be set."); } if (!cmd.hasOption("p2POSTaggedCandidates")) { System.out.println("Path to POS Tagged candidates must be set."); } String rc = "21"; if (cmd.hasOption("rc")) { rc = cmd.getOptionValue("rc"); } //====================================================================== //====================================================================== String p2bigrams = cmd.getOptionValue("p2bigrams"); String p2unigrams = cmd.getOptionValue("p2unigrams"); String p2POSTaggedCandidates = cmd.getOptionValue("p2POSTaggedCandidates"); //read list of candidates System.out.println("Reading candidates..."); BufferedReader candidateFile = new BufferedReader( new InputStreamReader(new FileInputStream(p2POSTaggedCandidates), "UTF8")); //farahmad ///Users/svm/Resources/DATA/WN-Syn-Based/LowerCased/FAR/eval_farahmand/eval_instances_pos_avail.csv //schneider ///Users/svm/Resources/DATA/WN-Syn-Based/LowerCased/SCH/instance_files/filt/instances_filt_pos.csv ///Users/svm/Resources/DATA/VGI/ac.nc.all.pos.txt LinkedHashMap<String, Integer> posCandLinkedMap = new LinkedHashMap<>(); String Entry = ""; Pattern entryETlabel = Pattern.compile("(\\w+_\\w+\\s\\w+_\\w+)\\s?(\\d+)?$"); Matcher entryETlabelM; while ((Entry = candidateFile.readLine()) != null) { entryETlabelM = entryETlabel.matcher(Entry); if (entryETlabelM.find()) { posCandLinkedMap.put(entryETlabelM.group(1), Integer.parseInt(entryETlabelM.group(2))); } } //read unigrams System.out.println("Reading unigrams..."); BufferedReader allunigrams = new BufferedReader( new InputStreamReader(new FileInputStream(p2unigrams), "UTF8")); HashMap<String, Integer> unigramsMap = new HashMap<String, Integer>(); Pattern puni = Pattern.compile("^(\\w+)\\s+(\\d+)$"); Matcher pm1; String uni = ""; while ((uni = allunigrams.readLine()) != null) { pm1 = puni.matcher(uni); if (pm1.find()) { unigramsMap.put(pm1.group(1), Integer.parseInt(pm1.group(2))); } } allunigrams.close(); System.out.println("Reading 2-grams..."); Pattern pbi = Pattern.compile("^(\\w+\\s\\w+)\\s(\\d+)$"); Matcher pm2; BufferedReader allBigrams = new BufferedReader( new InputStreamReader(new FileInputStream(p2bigrams), "UTF8")); HashMap<String, Integer> bigramMap = new HashMap<String, Integer>(); String bi = ""; while ((bi = allBigrams.readLine()) != null) { pm2 = pbi.matcher(bi); if (pm2.find()) { bigramMap.put(pm2.group(1), Integer.parseInt(pm2.group(2))); } } allBigrams.close(); System.out.println("Calculating bidirectional synset-baset probabilities..."); Collocational_Bidirect_Prob_File cpb = new Collocational_Bidirect_Prob_File(posCandLinkedMap, unigramsMap, bigramMap); LinkedHashMap<String, Double[]> r = cpb.calculateSynBasedProbs_v2(false); DecimalFormat df = new DecimalFormat("0.000"); //calculate the score: HashMap<String, Double> scores = new HashMap<String, Double>(); if (rc.equals("12")) { for (String s : r.keySet()) { scores.put(s, (r.get(s)[0] - r.get(s)[2])); } } else if (rc.equals("21")) { for (String s : r.keySet()) { scores.put(s, (r.get(s)[1] - r.get(s)[3])); } } else if (rc.equals("hybrid")) { for (String s : r.keySet()) { scores.put(s, (r.get(s)[0] - r.get(s)[2]) * (r.get(s)[1] - r.get(s)[3])); } } //sort (descending) candidates by their score: List<Entry<String, Double>> entryList = new ArrayList<Entry<String, Double>>(scores.entrySet()); Collections.sort(entryList, new Comparator<Entry<String, Double>>() { @Override public int compare(Entry<String, Double> e1, Entry<String, Double> e2) { return -1 * e1.getValue().compareTo(e2.getValue()); } }); //print the results: System.out.println("Ranking the candidates...\n"); for (Entry<String, Double> e : entryList) { System.out.println(e.getKey() + " " + df.format(e.getValue())); } }
From source file:nl.systemsgenetics.eqtlannotation.EncodeMultipleTfbsOverlap.java
public static void main(String[] args) { // String inputFile = "D:\\OnlineFolders\\AeroFS\\RP3_BIOS_Methylation\\meQTLs\\Trans_Pc22c_CisMeQTLc_meQTLs\\RegressedOut_CisEffects_New\\Permutations\\PermutedEQTLsPermutationRoundX.head.extended.txt"; // String outputFile = "D:\\OnlineFolders\\AeroFS\\RP3_BIOS_Methylation\\meQTLs\\Trans_Pc22c_CisMeQTLc_meQTLs\\RegressedOut_CisEffects_New\\Permutations\\PermutedEQTLsPermutationRoundX.head.extended.txtall_probeWindow_Test.txt"; String inputFile = "D:\\OnlineFolders\\AeroFS\\RP3_BIOS_Methylation\\meQTLs\\Trans_Pc22c_CisMeQTLc_meQTLs\\RegressedOut_CisEffects_New\\eQTLsFDR0.05-ProbeLevel_Filtered.txt"; String outputFile = "D:\\OnlineFolders\\AeroFS\\RP3_BIOS_Methylation\\meQTLs\\Trans_Pc22c_CisMeQTLc_meQTLs\\RegressedOut_CisEffects_New\\TFBS\\Test.txt"; // String inputFile = "E:\\LL+RS+CODAM+LLS_eqtls_genes_allLevels_18122014_LD_99_TF_input.txt"; // String outputFile = "E:\\LL+RS+CODAM+LLS_eqtls_genes_allLevels_18122014_LD_99_TF_input_all.txt"; String snpToCheck = ""; // String inputFolderTfbsData = "E:\\OnlineFolders\\BitSync\\UMCG\\Data\\ENCODE_TFBS\\"; String inputFolderTfbsData = "D:\\UMCG\\Data\\ENCODE_TFBS\\"; int window = 1; boolean perm = false; LinkedHashMap<String, HashMap<String, ArrayList<EncodeNarrowPeak>>> peakData = null; ArrayList<EQTL> qtls = new ArrayList<>(); try {//w w w .j a v a2 s. co m if (perm) { TextFile t = new TextFile(inputFile, TextFile.R); String row = t.readLine(); while ((row = t.readLine()) != null) { String[] parts = row.split("\t"); EQTL e = new EQTL(); // System.out.println(row); e.setRsName(parts[1]); e.setRsChr(ChrAnnotation.parseChr(parts[2])); e.setRsChrPos(Integer.parseInt(parts[3])); e.setProbe(parts[4]); e.setProbeChr(ChrAnnotation.parseChr(parts[5])); e.setProbeChrPos(Integer.parseInt(parts[6])); qtls.add(e); } t.close(); } else { QTLTextFile e = new QTLTextFile(inputFile, QTLTextFile.R); qtls.addAll(Arrays.asList(e.read())); e.close(); } // peakData = processOverlappingPeaks(readTfbsInformation(inputFolderTfbsData)); peakData = readMultipleTfbsInformation(inputFolderTfbsData); } catch (IOException ex) { Logger.getLogger(EncodeMultipleTfbsOverlap.class.getName()).log(Level.SEVERE, null, ex); } try { TextFile outWriter = new TextFile(outputFile, TextFile.W); StringBuilder extraHeaderInfo = new StringBuilder(); for (String keys : peakData.keySet()) { extraHeaderInfo.append('\t').append(keys).append('\t').append("totalOverlaps").append('\t') .append("bindingLocations").append('\t').append("fileNames"); } outWriter.writeln(QTLTextFile.header + extraHeaderInfo.toString()); for (EQTL e : qtls) { // System.out.println(e); if (e.getRsName().equals(snpToCheck) || snpToCheck.equals("")) { outWriter.writeln(e.toString() + determineContacts(e, peakData, window)); } } outWriter.close(); } catch (IOException ex) { Logger.getLogger(EncodeMultipleTfbsOverlap.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:AndroidUninstallStock.java
@SuppressWarnings("static-access") public static void main(String[] args) { try {/*from ww w. j a v a 2 s . c o m*/ String lang = Locale.getDefault().getLanguage(); GnuParser cmdparser = new GnuParser(); Options cmdopts = new Options(); for (String fld : Arrays.asList("shortOpts", "longOpts", "optionGroups")) { // hack for printOptions java.lang.reflect.Field fieldopt = cmdopts.getClass().getDeclaredField(fld); fieldopt.setAccessible(true); fieldopt.set(cmdopts, new LinkedHashMap<>()); } cmdopts.addOption("h", "help", false, "Help"); cmdopts.addOption("t", "test", false, "Show only report"); cmdopts.addOption(OptionBuilder.withLongOpt("adb").withArgName("file").hasArg() .withDescription("Path to ADB from Android SDK").create("a")); cmdopts.addOption(OptionBuilder.withLongOpt("dev").withArgName("device").hasArg() .withDescription("Select device (\"adb devices\")").create("d")); cmdopts.addOption(null, "restore", false, "If packages have not yet removed and are disabled, " + "you can activate them again"); cmdopts.addOption(null, "google", false, "Delete packages are in the Google section"); cmdopts.addOption(null, "unapk", false, "Delete /system/app/ *.apk *.odex *.dex" + System.lineSeparator() + "(It is required to repeat command execution)"); cmdopts.addOption(null, "unlib", false, "Delete /system/lib/[libs in apk]"); //cmdopts.addOption(null, "unfrw", false, "Delete /system/framework/ (special list)"); cmdopts.addOption(null, "scanlibs", false, "(Dangerous!) Include all the libraries of selected packages." + " Use with --unlib"); cmdopts.addOptionGroup(new OptionGroup() { { addOption(OptionBuilder.withLongOpt("genfile").withArgName("file").hasArg().isRequired() .withDescription("Create file with list packages").create()); addOption(OptionBuilder.withLongOpt("lang").withArgName("ISO 639").hasArg().create()); } }); cmdopts.getOption("lang").setDescription( "See hl= in Google URL (default: " + lang + ") " + "for description from Google Play Market"); CommandLine cmd = cmdparser.parse(cmdopts, args); if (args.length == 0 || cmd.hasOption("help")) { PrintWriter console = new PrintWriter(System.out); HelpFormatter cmdhelp = new HelpFormatter(); cmdhelp.setOptionComparator(new Comparator<Option>() { @Override public int compare(Option o1, Option o2) { return 0; } }); console.println("WARNING: Before use make a backup with ClockworkMod Recovery!"); console.println(); console.println("AndroidUninstallStock [options] [AndroidListSoft.xml]"); cmdhelp.printOptions(console, 80, cmdopts, 3, 2); console.flush(); return; } String adb = cmd.getOptionValue("adb", "adb"); try { run(adb, "start-server"); } catch (IOException e) { System.out.println("Error: Not found ADB! Use -a or --adb"); return; } final boolean NotTest = !cmd.hasOption("test"); String deverror = getDeviceStatus(adb, cmd.getOptionValue("dev")); if (!deverror.isEmpty()) { System.out.println(deverror); return; } System.out.println("Getting list packages:"); LinkedHashMap<String, String> apklist = new LinkedHashMap<String, String>(); for (String ln : run(adb, "-s", lastdevice, "shell", "pm list packages -s -f")) { // "pm list packages" give list sorted by packages ;) String pckg = ln.substring("package:".length()); String pckgname = ln.substring(ln.lastIndexOf('=') + 1); pckg = pckg.substring(0, pckg.length() - pckgname.length() - 1); if (!pckgname.equals("android") && !pckgname.equals("com.android.vending")/*Google Play Market*/) { apklist.put(pckg, pckgname); } } for (String ln : run(adb, "-s", lastdevice, "shell", "ls /system/app/")) { String path = "/system/app/" + ln.replace(".odex", ".apk").replace(".dex", ".apk"); if (!apklist.containsKey(path)) { apklist.put(path, ""); } } apklist.remove("/system/app/mcRegistry"); for (Map.Entry<String, String> info : sortByValues(apklist).entrySet()) { System.out.println(info.getValue() + " = " + info.getKey()); } String genfile = cmd.getOptionValue("genfile"); if (genfile != null) { Path genpath = Paths.get(genfile); try (BufferedWriter gen = Files.newBufferedWriter(genpath, StandardCharsets.UTF_8, new StandardOpenOption[] { StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE })) { if (cmd.getOptionValue("lang") != null) { lang = cmd.getOptionValue("lang"); } LinkedHashSet<String> listsystem = new LinkedHashSet<String>() { { add("com.android"); add("com.google.android"); //add("com.sec.android.app"); add("com.monotype.android"); add("eu.chainfire.supersu"); } }; // \r\n for Windows Notepad gen.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); gen.write("<!-- & raplace with & or use <![CDATA[ ]]> -->\r\n"); gen.write("<AndroidUninstallStock>\r\n\r\n"); gen.write("<Normal>\r\n"); System.out.println(); System.out.println("\tNormal:"); writeInfo(gen, apklist, lang, listsystem, true); gen.write("\t<apk name=\"Exclude Google and etc\">\r\n"); for (String exc : listsystem) { gen.write("\t\t<exclude global=\"true\" in=\"package\" pattern=\"" + exc + "\" />\r\n"); } gen.write("\t</apk>\r\n"); gen.write("</Normal>\r\n\r\n"); gen.write("<Google>\r\n"); System.out.println(); System.out.println("\tGoogle:"); writeInfo(gen, apklist, lang, listsystem, false); gen.write("</Google>\r\n\r\n"); gen.write("</AndroidUninstallStock>\r\n"); System.out.println("File " + genpath.toAbsolutePath() + " created."); } return; } String[] FileName = cmd.getArgs(); if (!(FileName.length > 0 && Files.isReadable(Paths.get(FileName[0])))) { System.out.println("Error: File " + FileName[0] + " not found!"); return; } DocumentBuilderFactory xmlfactory = getXmlDocFactory(); // DocumentBuilder.setErrorHandler() for print errors Document xml = xmlfactory.newDocumentBuilder().parse(new File(FileName[0])); LinkedList<AusInfo> Normal = new LinkedList<AusInfo>(); LinkedList<AusInfo> Google = new LinkedList<AusInfo>(); NodeList ndaus = xml.getElementsByTagName("AndroidUninstallStock").item(0).getChildNodes(); for (int ndausx = 0, ndausc = ndaus.getLength(); ndausx < ndausc; ndausx++) { Node ndnow = ndaus.item(ndausx); NodeList nd = ndnow.getChildNodes(); String ndname = ndnow.getNodeName(); for (int ndx = 0, ndc = nd.getLength(); ndx < ndc; ndx++) { if (!nd.item(ndx).getNodeName().equalsIgnoreCase("apk")) { continue; } if (ndname.equalsIgnoreCase("Normal")) { Normal.add(getApkInfo(nd.item(ndx))); } else if (ndname.equalsIgnoreCase("Google")) { Google.add(getApkInfo(nd.item(ndx))); } } } // FIXME This part must be repeated until the "pm uninstall" will not issue "Failure" on all packages. // Now requires a restart. System.out.println(); System.out.println("Include and Exclude packages (Normal):"); LinkedHashMap<String, String> apkNormal = getApkFromPattern(apklist, Normal, false); System.out.println(); System.out.println("Global Exclude packages (Normal):"); apkNormal = getApkFromPattern(apkNormal, Normal, true); System.out.println(); System.out.println("Final list packages (Normal):"); for (Map.Entry<String, String> info : sortByValues(apkNormal).entrySet()) { System.out.println(info.getValue() + " = " + info.getKey()); } LinkedHashMap<String, String> apkGoogle = new LinkedHashMap<String, String>(); if (cmd.hasOption("google")) { System.out.println(); System.out.println("Include and Exclude packages (Google):"); apkGoogle = getApkFromPattern(apklist, Google, false); System.out.println(); System.out.println("Global Exclude packages (Google):"); apkGoogle = getApkFromPattern(apkGoogle, Google, true); System.out.println(); System.out.println("Final list packages (Google):"); for (Map.Entry<String, String> info : sortByValues(apkGoogle).entrySet()) { System.out.println(info.getValue() + " = " + info.getKey()); } } if (NotTest) { if (!hasRoot(adb)) { System.out.println("No Root"); System.out.println(); System.out.println("FINISH :)"); return; } } if (cmd.hasOption("restore")) { System.out.println(); System.out.println("Enable (Restore) packages (Normal):"); damage(adb, "pm enable ", NotTest, apkNormal, 2); if (cmd.hasOption("google")) { System.out.println(); System.out.println("Enable (Restore) packages (Google):"); damage(adb, "pm enable ", NotTest, apkGoogle, 2); } System.out.println(); System.out.println("FINISH :)"); return; } else { System.out.println(); System.out.println("Disable packages (Normal):"); damage(adb, "pm disable ", NotTest, apkNormal, 2); if (cmd.hasOption("google")) { System.out.println(); System.out.println("Disable packages (Google):"); damage(adb, "pm disable ", NotTest, apkGoogle, 2); } } if (!cmd.hasOption("unapk") && !cmd.hasOption("unlib")) { System.out.println(); System.out.println("FINISH :)"); return; } // Reboot now not needed /*if (NotTest) { reboot(adb, "-s", lastdevice, "reboot"); if (!hasRoot(adb)) { System.out.println("No Root"); System.out.println(); System.out.println("FINISH :)"); return; } }*/ if (cmd.hasOption("unlib")) { // "find" not found System.out.println(); System.out.println("Getting list libraries:"); LinkedList<String> liblist = new LinkedList<String>(); liblist.addAll(run(adb, "-s", lastdevice, "shell", "ls -l /system/lib/")); String dircur = "/system/lib/"; for (int x = 0; x < liblist.size(); x++) { if (liblist.get(x).startsWith("scan:")) { dircur = liblist.get(x).substring("scan:".length()); liblist.remove(x); x--; } else if (liblist.get(x).startsWith("d")) { String dir = liblist.get(x).substring(liblist.get(x).lastIndexOf(':') + 4) + "/"; liblist.remove(x); x--; liblist.add("scan:/system/lib/" + dir); liblist.addAll(run(adb, "-s", lastdevice, "shell", "ls -l /system/lib/" + dir)); continue; } liblist.set(x, dircur + liblist.get(x).substring(liblist.get(x).lastIndexOf(':') + 4)); System.out.println(liblist.get(x)); } final boolean scanlibs = cmd.hasOption("scanlibs"); LinkedHashMap<String, String> libNormal = getLibFromPatternInclude(adb, liblist, apkNormal, Normal, "Normal", scanlibs); libNormal = getLibFromPatternGlobalExclude(libNormal, Normal, "Normal"); System.out.println(); System.out.println("Final list libraries (Normal):"); for (Map.Entry<String, String> info : sortByValues(libNormal).entrySet()) { System.out.println(info.getKey() + " = " + info.getValue()); } LinkedHashMap<String, String> libGoogle = new LinkedHashMap<String, String>(); if (cmd.hasOption("google")) { libGoogle = getLibFromPatternInclude(adb, liblist, apkGoogle, Google, "Google", scanlibs); libGoogle = getLibFromPatternGlobalExclude(libGoogle, Google, "Google"); System.out.println(); System.out.println("Final list libraries (Google):"); for (Map.Entry<String, String> info : sortByValues(libGoogle).entrySet()) { System.out.println(info.getKey() + " = " + info.getValue()); } } LinkedHashMap<String, String> apkExclude = new LinkedHashMap<String, String>(apklist); for (String key : apkNormal.keySet()) { apkExclude.remove(key); } for (String key : apkGoogle.keySet()) { apkExclude.remove(key); } System.out.println(); System.out.println("Include libraries from Exclude packages:"); LinkedHashMap<String, String> libExclude = getLibFromPackage(adb, liblist, apkExclude); System.out.println(); System.out.println("Enclude libraries from Exclude packages (Normal):"); for (Map.Entry<String, String> info : sortByValues(libNormal).entrySet()) { if (libExclude.containsKey(info.getKey())) { System.out.println("exclude: " + info.getKey() + " = " + libExclude.get(info.getKey())); libNormal.remove(info.getKey()); } } System.out.println(); System.out.println("Enclude libraries from Exclude packages (Google):"); for (Map.Entry<String, String> info : sortByValues(libGoogle).entrySet()) { if (libExclude.containsKey(info.getKey())) { System.out.println("exclude: " + info.getKey() + " = " + libExclude.get(info.getKey())); libGoogle.remove(info.getKey()); } } System.out.println(); System.out.println("Delete libraries (Normal):"); damage(adb, "rm ", NotTest, libNormal, 1); if (cmd.hasOption("google")) { System.out.println(); System.out.println("Delete libraries (Google):"); damage(adb, "rm ", NotTest, libGoogle, 1); } } if (cmd.hasOption("unapk")) { System.out.println(); System.out.println("Cleaning data packages (Normal):"); damage(adb, "pm clear ", NotTest, apkNormal, 2); if (cmd.hasOption("google")) { System.out.println(); System.out.println("Cleaning data packages (Google):"); damage(adb, "pm clear ", NotTest, apkGoogle, 2); } System.out.println(); System.out.println("Uninstall packages (Normal):"); damage(adb, "pm uninstall ", NotTest, apkNormal, 2); if (cmd.hasOption("google")) { System.out.println(); System.out.println("Uninstall packages (Google):"); damage(adb, "pm uninstall ", NotTest, apkGoogle, 2); } } if (cmd.hasOption("unapk")) { System.out.println(); System.out.println("Delete packages (Normal):"); LinkedHashMap<String, String> dexNormal = new LinkedHashMap<String, String>(); for (Map.Entry<String, String> apk : apkNormal.entrySet()) { dexNormal.put(apk.getKey(), apk.getValue()); dexNormal.put(apk.getKey().replace(".apk", ".dex"), apk.getValue()); dexNormal.put(apk.getKey().replace(".apk", ".odex"), apk.getValue()); } damage(adb, "rm ", NotTest, dexNormal, 1); if (cmd.hasOption("google")) { System.out.println(); System.out.println("Delete packages (Google):"); LinkedHashMap<String, String> dexGoogle = new LinkedHashMap<String, String>(); for (Map.Entry<String, String> apk : apkGoogle.entrySet()) { dexGoogle.put(apk.getKey(), apk.getValue()); dexGoogle.put(apk.getKey().replace(".apk", ".dex"), apk.getValue()); dexGoogle.put(apk.getKey().replace(".apk", ".odex"), apk.getValue()); } damage(adb, "rm ", NotTest, dexGoogle, 1); } } if (NotTest) { run(adb, "-s", lastdevice, "reboot"); } System.out.println(); System.out.println("FINISH :)"); } catch (SAXException e) { System.out.println("Error parsing list: " + e); } catch (Throwable e) { e.printStackTrace(); } }
From source file:Main.java
@SuppressWarnings("unchecked") static public LinkedHashMap invertOrdering(LinkedHashMap passedMap) { LinkedHashMap result = new LinkedHashMap(); Object[] keys = passedMap.keySet().toArray(); for (int i = keys.length - 1; i >= 0; i--) result.put(keys[i], passedMap.get(keys[i])); return result; }
From source file:Main.java
/** * Returns the keys from the map as a list. Most useful if the map's keys * are ordered, for instance if it is a <code>LinkedHashMap</code>. * /*w w w . j a va 2 s . c o m*/ * @param map * @return */ public static <T, U> List<T> getKeyList(LinkedHashMap<T, U> linkedMap) { List<T> keyList = new ArrayList<T>(); for (T key : linkedMap.keySet()) { keyList.add(key); } return keyList; }
From source file:max.hubbard.Factoring.Graphing.java
private static XYDataset createDataset(LinkedList<LinkedHashMap<Float, Integer>> list, String orig) { final XYSeries series1 = new XYSeries(orig); for (double i = -10; i < 11; i++) { float v = 0; for (LinkedHashMap<Float, Integer> map : list) { for (Float f : map.keySet()) { if (map.get(f) != 0) { v = v + f * (float) Math.pow(i, map.get(f)); } else { v = v + f;//from ww w.j a v a 2 s . co m } } } series1.add(i, v); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); return dataset; }
From source file:ru.crazycoder.plugins.tabdir.TitleFormatter.java
private static String joinPrefixesWithRemoveDuplication(LinkedHashMap<String, Set<String>> prefixes, FolderConfiguration configuration) { List<String> keys = new LinkedList<String>(prefixes.keySet()); keys = getPrefixesSublist(keys, configuration); List<String> resultPrefixes = new ArrayList<String>(keys.size()); for (String key : keys) { resultPrefixes.add(removeDuplicates(key, prefixes.get(key))); }//from ww w . j a v a 2 s .co m StringBuilder buffer = join(resultPrefixes, configuration); return removeEnd(buffer.toString(), configuration.getDirSeparator()); }