/** * Prompt to confirm that the user wants to delete the JShellItem from the file system. If so, * remove it. If -f is supplied, do not prompt and confirm. If the root directory is specified, * its contents but not itself will be subject to deletion. * * @param paths the JShellItem to be removed. */ public void rm(List<String> paths) throws Exception { // Loop through the user inputs. for (String path : paths) { // Initialize the current JShellItem. JShellItem item = getItemAtPath(path, 0); if (item == null) { System.out.printf("%s: does not exist.\n", path); } else { // Keep track of the size of that JShellItem. int size = item.getSize(); if (size > 0) { List<String> recursiveList = recurseOnPath(path, true); rm(recursiveList.subList(0, size + 1)); if (item.getSize() == 0) { rm(recursiveList.subList(size + 1, size + 2)); } } else { if (item.getPath().equals("/")) { return; } // Check the -f option. if (!currentOptions_.equals("f")) { System.out.printf( "Really remove %s from %s? (y/n) ", item.getName(), item.getParentDirectory().getPath()); // Read the user input. ArrayList<String> in = readInput(); // If 'y' if (in.toString().equals("[y]")) { item.getParentDirectory().removeItem(item); // if not 'n', ask again. } else if (!in.toString().equals("[n]")) { List<String> tempStore = new ArrayList<String>(); tempStore.add(path); rm(tempStore); } // If -f is specified. } else { item.getParentDirectory().removeItem(item); } } } } }
/** * Converts a map of results to a String JSON representation for it * * @param map a map that matches properties with an ArrayList of values * @return the JSON representation for the map, as a String */ private String mapToString(Map<String, ArrayList<String>> map) { StringBuilder result = new StringBuilder("{"); for (Map.Entry<String, ArrayList<String>> entry : map.entrySet()) { ArrayList<String> value = entry.getValue(); if (value.size() == 1) result.append(String.format("\"%s\" : %s,\n", entry.getKey(), value.get(0))); else result.append(String.format("\"%s\" : %s,\n", entry.getKey(), value.toString())); } result.setCharAt(result.length() - 2, '}'); return result.toString(); }
public static String pSet(Integer n) { String str1 = ""; for (int i = 1; i <= n; i++) { str1 += i; } char[] array1 = str1.toCharArray(); ArrayList list = new ArrayList(); int length = array1.length; int totalElements = (int) Math.pow(2, length); for (int i = 0; i < totalElements; i++) { String binString = Integer.toBinaryString(i); int stringValue = binString.length(); String subset = binString; for (int j = stringValue; j < length; j++) { subset = "0" + subset; } ArrayList innerSet = new ArrayList(); for (int k = 0; k < subset.length(); k++) { if (subset.charAt(k) == '1') innerSet.add(array1[k]); } list.add(innerSet); } return list.toString(); }
public void addObjectValue(String name, String[] al) { ArrayList al1 = new ArrayList(); for (int i = 0; i < al.length; i++) { // this.theArrayAdapter.add(name + ":" + al[i]); al1.add(al[i]); } String f = al1.toString().replace('[', '{'); String f2 = f.replace(']', '}'); this.theArrayAdapter.add(name + ":" + f2); }
private int vita_sociale(FileAccess file_acc, ArrayList<InetAddress> l_peers) { int contattato_ok = 0; int problemi = 0; System.out.println("@ vista sociale attivata con lista !" + l_peers.toString()); for (InetAddress i : l_peers) if (!i.getHostAddress().equals("192.168.0.10")) { System.out.println("@ confronto gli ip di: " + i.getHostAddress() + " con 192.168.0.10"); contattato_ok = contatta_Peer(file_acc, i, 4000); if (contattato_ok != 0) { System.out.println( "# il tentativo di creazione di connessione con il peer " + i.getHostAddress() + " ha fallito"); problemi = 1; } } else System.out.println("Evito di contattare il mio stesso indirizzo"); // TODO togliere questo return problemi; }
private List<String> getIgnoreSignFieldNames(Class<? extends RopRequest> requestType) { if (logger.isDebugEnabled()) { logger.debug("获取" + requestType.getCanonicalName() + "需要签名的属性"); } final ArrayList<String> igoreSignFieldNames = new ArrayList<String>(10); ReflectionUtils.doWithFields( requestType, new ReflectionUtils.FieldCallback() { public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { igoreSignFieldNames.add(field.getName()); } }, new ReflectionUtils.FieldFilter() { public boolean matches(Field field) { IgnoreSign ignoreSign = field.getAnnotation(IgnoreSign.class); return ignoreSign != null; } }); if (logger.isDebugEnabled()) { logger.debug(requestType.getCanonicalName() + "需要签名的属性:" + igoreSignFieldNames.toString()); } return igoreSignFieldNames; }
public Allele getLikelihoods( RefMetaDataTracker tracker, ReferenceContext ref, Map<String, AlignmentContext> contexts, AlignmentContextUtils.ReadOrientation contextType, GenotypePriors priors, Map<String, MultiallelicGenotypeLikelihoods> GLs, Allele alternateAlleleToUse, boolean useBAQedPileup) { if (tracker == null) return null; GenomeLoc loc = ref.getLocus(); Allele refAllele, altAllele; VariantContext vc = null; if (!ref.getLocus().equals(lastSiteVisited)) { // starting a new site: clear allele list alleleList.clear(); lastSiteVisited = ref.getLocus(); indelLikelihoodMap.set(new HashMap<PileupElement, LinkedHashMap<Allele, Double>>()); haplotypeMap.clear(); if (getAlleleListFromVCF) { for (final VariantContext vc_input : tracker.getValues(UAC.alleles, loc)) { if (vc_input != null && allowableTypes.contains(vc_input.getType()) && ref.getLocus().getStart() == vc_input.getStart()) { vc = vc_input; break; } } // ignore places where we don't have a variant if (vc == null) return null; alleleList.clear(); if (ignoreSNPAllelesWhenGenotypingIndels) { // if there's an allele that has same length as the reference (i.e. a SNP or MNP), ignore // it and don't genotype it for (Allele a : vc.getAlleles()) if (a.isNonReference() && a.getBases().length == vc.getReference().getBases().length) continue; else alleleList.add(a); } else { for (Allele a : vc.getAlleles()) alleleList.add(a); } } else { alleleList = computeConsensusAlleles(ref, contexts, contextType); if (alleleList.isEmpty()) return null; } } // protect against having an indel too close to the edge of a contig if (loc.getStart() <= HAPLOTYPE_SIZE) return null; // check if there is enough reference window to create haplotypes (can be an issue at end of // contigs) if (ref.getWindow().getStop() < loc.getStop() + HAPLOTYPE_SIZE) return null; if (!(priors instanceof DiploidIndelGenotypePriors)) throw new StingException( "Only diploid-based Indel priors are supported in the DINDEL GL model"); if (alleleList.isEmpty()) return null; refAllele = alleleList.get(0); altAllele = alleleList.get(1); // look for alt allele that has biggest length distance to ref allele int maxLenDiff = 0; for (Allele a : alleleList) { if (a.isNonReference()) { int lenDiff = Math.abs(a.getBaseString().length() - refAllele.getBaseString().length()); if (lenDiff > maxLenDiff) { maxLenDiff = lenDiff; altAllele = a; } } } final int eventLength = altAllele.getBaseString().length() - refAllele.getBaseString().length(); final int hsize = (int) ref.getWindow().size() - Math.abs(eventLength) - 1; final int numPrefBases = ref.getLocus().getStart() - ref.getWindow().getStart() + 1; haplotypeMap = Haplotype.makeHaplotypeListFromAlleles( alleleList, loc.getStart(), ref, hsize, numPrefBases); // For each sample, get genotype likelihoods based on pileup // compute prior likelihoods on haplotypes, and initialize haplotype likelihood matrix with // them. // initialize the GenotypeLikelihoods GLs.clear(); for (Map.Entry<String, AlignmentContext> sample : contexts.entrySet()) { AlignmentContext context = AlignmentContextUtils.stratify(sample.getValue(), contextType); ReadBackedPileup pileup = null; if (context.hasExtendedEventPileup()) pileup = context.getExtendedEventPileup(); else if (context.hasBasePileup()) pileup = context.getBasePileup(); if (pileup != null) { final double[] genotypeLikelihoods = pairModel.computeReadHaplotypeLikelihoods( pileup, haplotypeMap, ref, eventLength, getIndelLikelihoodMap()); GLs.put( sample.getKey(), new MultiallelicGenotypeLikelihoods( sample.getKey(), alleleList, genotypeLikelihoods, getFilteredDepth(pileup))); if (DEBUG) { System.out.format("Sample:%s Alleles:%s GL:", sample.getKey(), alleleList.toString()); for (int k = 0; k < genotypeLikelihoods.length; k++) System.out.format("%1.4f ", genotypeLikelihoods[k]); System.out.println(); } } } return refAllele; }
/** * Assign a {@link FloatingIP} from the given {@link FloatingNetwork} to the given {@link Port}. * It will either assign an existing floating IP or it will create and assign a new floating IP. * * @param port the {@link Port} to which a floating IP to be assigned. * @param floatingNetworkUuid the network uuid of the floating network from which a floating IP to * be chosen/created * @return the assigned Floating IP */ private FloatingIP assignFloatingIP(Port port, String floatingNetworkUuid) { // checking whether if there are any available floating IPs in the external network // if there are any we don't need to create a new one ArrayList<FloatingIP> unassignedFloatingIPs = getUnassignedFloatingIPsByNetworkUuid(floatingNetworkUuid); // we should remove all predefined floating IPs from unassigned list // otherwise, these predefined floating IPs can be associated to some other interfaces if (unassignedFloatingIPs != null) { if (log.isDebugEnabled()) { String msg = String.format( "Unassigned floating IPs from the network %s - %s", floatingNetworkUuid, unassignedFloatingIPs.toString()); log.debug(msg); } Iterator<FloatingIP> unassginedFloatingIPsIterator = unassignedFloatingIPs.iterator(); while (unassginedFloatingIPsIterator.hasNext()) { FloatingIP floatingIP = unassginedFloatingIPsIterator.next(); List<String> allPredefinedFloatingIPs = getAllPredefinedFloatingIPs(iaasProvider.getNetworkInterfaces()); if (allPredefinedFloatingIPs != null && !allPredefinedFloatingIPs.isEmpty()) { if (log.isDebugEnabled()) { String msg = String.format( "Predefined floating IPs - %s found in cartridge", allPredefinedFloatingIPs.toString()); log.debug(msg); } Iterator<String> predefinedFloatingIPsIterator = allPredefinedFloatingIPs.iterator(); while (predefinedFloatingIPsIterator.hasNext()) { String floatingIPAddress = predefinedFloatingIPsIterator.next(); if (floatingIP.getFloatingIpAddress() != null && floatingIP.getFloatingIpAddress().equals(floatingIPAddress)) { unassginedFloatingIPsIterator.remove(); if (log.isDebugEnabled()) { String msg = String.format( "Removed predefined floating IP %s from available floating IPs", floatingIPAddress); log.debug(msg); } } } } } } if (unassignedFloatingIPs == null || unassignedFloatingIPs.isEmpty()) { return createAndAssignFloatingIP(port, floatingNetworkUuid); } if (log.isDebugEnabled()) { String msg = String.format( "Available floating IPs from the network %s - %s", floatingNetworkUuid, unassignedFloatingIPs.toString()); log.debug(msg); } // shuffle and get the last for randomness Collections.shuffle(unassignedFloatingIPs); FloatingIP selectedFloatingIP = Iterables.getLast(unassignedFloatingIPs); if (log.isDebugEnabled()) { String msg = String.format( "Floating IP %s is selected among %s from the network %s", selectedFloatingIP.getFloatingIpAddress(), unassignedFloatingIPs.toString(), floatingNetworkUuid); log.debug(msg); } return updateFloatingIP(selectedFloatingIP, port); }
public String toString() { return historia.toString(); }
@Override public String toString() { return original.toString(); }
public void onMessage( String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("!goaway")) { if (sender.equals(BotOP) || sender.equals(BotOP2)) { partChannel(channel, "Fine, I'll leave quietly."); } else { sendMessage(channel, "Only the main operator can use this command."); } } if (message.contains("!game")) { String[] parts = message.split(" "); if (parts[1].equalsIgnoreCase("genesis")) { if (parts[2].equals("1")) { sendMessage(channel, "Name: Sonic the Hedgehog; Release date: 1991-06-23;"); } if (parts[2].equals("2")) { sendMessage(channel, "Name: Sonic the Hedgehog 2; Release date: 1992-11-24;"); } if (parts[2].equals("3")) { sendMessage( channel, "Name: Sonic the Hedgehog 3 (and Knuckles); Release date: 1994-02-02 (1994-08-18)"); } if (parts[2].equalsIgnoreCase("spinball")) { sendMessage(channel, "Name: Sonic Spinball; Initial US Release date: 1993-11-23;"); } if (parts[2].equalsIgnoreCase("3dblast")) { sendMessage(channel, "Name: Sonic 3D Blast; Genesis release date: 1996-11-12;"); } } if (parts[1].equalsIgnoreCase("saturn")) { if (parts[2].equalsIgnoreCase("r")) { sendMessage(channel, "Name: Sonic R; Release date: 1997-11-18;"); } if (parts[2].equalsIgnoreCase("3dblast")) { sendMessage(channel, "Name: Sonic 3D Blast; Saturn release date: 1996-11-20;"); } } if (parts[1].equalsIgnoreCase("dreamcast")) { if (parts[2].equalsIgnoreCase("adventure")) { if (parts.length == 4) { if (parts[3].equals("2")) { sendMessage(channel, "Name: Sonic Adventure 2; Release date: 2001-06-19;"); } } else { sendMessage(channel, "Name: Sonic Adventure; Release date: 1998-12-23;"); } } if (parts[2].equalsIgnoreCase("shuffle")) { sendMessage(channel, "Name: Sonic Shuffle; Release date: 2000-11-14;"); } } } if (message.equalsIgnoreCase("!didit")) { if (jokesPub) { sendMessage(channel, "I DID IT! \\o/"); } else { if (sender.equals(BotOP) || sender.equalsIgnoreCase(BotOP2) || checkMod(sender)) { sendMessage(channel, "I DID IT! \\o/"); } else { return; } } } if (message.equalsIgnoreCase("!isayhey")) { if (channel.equals("")) { return; } else { if (jokesPub) { sendMessage(channel, "What's going on?"); } else { if (sender.equals(BotOP) || sender.equals("BotOP2") || checkMod(sender)) { sendMessage(channel, "What's going on?"); } else { return; } } } } if (message.equals("!jokes")) { if (sender.equals(BotOP) || sender.equals(BotOP2) || checkMod(sender)) { jokesPub = !jokesPub; sendMessage(channel, "Joke commands toggled!"); } else { sendMessage(channel, "Only the current operator can toggle joke commands!"); } } if (message.equalsIgnoreCase("!source")) { sendMessage( channel, sender + ": My source code is at http://www.github.com/MineRobber9000/KintoBot"); sendMessage( channel, sender + ": It may not be up to date though, my creator works on my code a lot."); } if (message.contains("!kb")) { if (sender.equals(BotOP)) { String[] parts = message.split(" "); if (parts[1].equalsIgnoreCase("dumpvars")) { sendMessage( channel, "The sender is " + sender + ", the channel was " + channel + ", the login variable was " + login + ", the hostname is " + hostname + ", and the message was " + message + "."); } if (parts[1].equalsIgnoreCase("botop2")) { if (parts[2].equalsIgnoreCase("clear")) { BotOP2 = ""; } else { BotOP2 = parts[2]; } } if (parts[1].equalsIgnoreCase("mods")) { if (parts.length == 4) { switch (parts[2]) { case "add": mods.add(parts[3]); break; case "rm": mods.remove(parts[3]); break; } } else { if (parts[2].equalsIgnoreCase("wipe")) { mods = new ArrayList<String>(); } else { sendMessage(channel, "Mods: " + mods.toString()); } } if (parts[2].equalsIgnoreCase("check")) { if (checkMod(parts[3])) { sendMessage(channel, BotOP + ": Yes, " + parts[3] + " is a mod."); } else { sendMessage(channel, BotOP + ": No, " + parts[3] + " is not a mod."); } } } if (parts[1].equalsIgnoreCase("passop")) { BotOP = parts[2]; } } else { sendMessage(channel, "Only the current main operator can configure KintoBot."); } } }
public String toString() { return "[" + this.weight + "]: " + traversals.toString(); }
private ArrayList<InetAddress> contatta_Tracker(Descrittore descr) { InetAddress server = null; ObjectInputStream data_in; ObjectOutputStream data_out; InputStream in; OutputStream out; ArrayList<InetAddress> lista = null; /* socket per la comunicazione TCP */ SSLSocketFactory factory = null; SSLSocket socket = null; // ###### preparo l'indirizzo try { server = InetAddress.getByName("192.168.0.10"); } catch (UnknownHostException e1) { e1.printStackTrace(); } // ###### creo il socket if (descr == null) { System.out.println("## contatta_tracker di Download ha ricevuto parametro null ! "); return null; } System.out.println( "@ provo a contattare via TCP il Tracker a " + server.toString() + " porta " + descr.getTcp()); try { factory = (SSLSocketFactory) SSLSocketFactory.getDefault(); socket = (SSLSocket) factory.createSocket(server, descr.getTcp()); } catch (IOException e1) { System.out.println("# eccezione nella creazione socket verso il Tracker TCP"); e1.printStackTrace(); } System.out.println("@ socket creato "); if (factory == null || socket == null) { System.out.println("## la connessione ssl di Download ha ritornato null ! "); return null; } try { System.out.println("@ out_stream "); out = socket.getOutputStream(); System.out.println("@ out "); data_out = new ObjectOutputStream(out); System.out.println("@ in_stream "); in = socket.getInputStream(); System.out.println("@ in "); data_in = new ObjectInputStream(in); System.out.println("@ Downloader: streams ok "); data_out.writeObject(descr); // TODO Perchè ? data_out.flush(); System.out.println("@ descrittore mandato "); lista = (ArrayList<InetAddress>) data_in.readObject(); if (lista == null) System.out.println( "@ ritornata lista vuota dal tracker riguardo : " + descr.nome); // TODO sarebbe un caso plausibile else System.out.println("@ lista ricevuta : " + lista.toString()); } catch (IOException e) { System.out.println("# eccezione I/O nella creazione socket verso il Tracker TCP"); e.printStackTrace(); } catch (ClassNotFoundException e) { System.out.println("# eccezione C N F nella creazione socket verso il Tracker TCP"); e.printStackTrace(); } return lista; }