List of usage examples for java.lang String contains
public boolean contains(CharSequence s)
From source file:btrplace.fromEntropy.Converter.java
public static void main(String[] args) { String src, dst = null, output, scriptDC = null, dirScriptsCL = null; if (args.length < 5 || args.length > 6 || !args[args.length - 2].equals("-o")) { usage(1);//w w w .jav a2 s . c om } src = args[0]; output = args[args.length - 1]; if (args.length > 5) { dst = args[1]; } scriptDC = args[args.length - 4]; dirScriptsCL = args[args.length - 3]; OutputStreamWriter out = null; try { // Convert the src file ConfigurationConverter conv = new ConfigurationConverter(src); Instance i = conv.getInstance(); // Read the dst file, deduce and add the states constraints if (dst != null) { i.getSatConstraints().addAll(conv.getNextStates(dst)); } // Read the script files ScriptBuilder scriptBuilder = new ScriptBuilder(i.getModel()); //scriptBuilder.setIncludes(new PathBasedIncludes(scriptBuilder, // new File("src/test/resources"))); // Read the datacenter script file if exists if (scriptDC != null) { String strScriptDC = null; try { strScriptDC = readFile(scriptDC); } catch (IOException e) { e.printStackTrace(); } Script scrDC = null; try { // Build the DC script scrDC = scriptBuilder.build(strScriptDC); } catch (ScriptBuilderException sbe) { System.out.println(sbe); } // Set the DC script as an include BasicIncludes bi = new BasicIncludes(); bi.add(scrDC); scriptBuilder.setIncludes(bi); } // Read all the client script files String scriptCL = null, strScriptCL = null; Script scrCL = null; Iterator it = FileUtils.iterateFiles(new File(dirScriptsCL), null, false); while (it.hasNext()) { scriptCL = dirScriptsCL + "/" + ((File) it.next()).getName(); if (scriptCL != null) { // Read try { strScriptCL = readFile(scriptCL); } catch (IOException e) { e.printStackTrace(); } // Parse try { scrCL = scriptBuilder.build(strScriptCL); } catch (ScriptBuilderException sbe) { System.out.println(sbe); sbe.printStackTrace(); } // Add the resulting constraints if (scrCL.getConstraints() != null) { i.getSatConstraints().addAll(scrCL.getConstraints()); } } } /************** PATCH **************/ // State constraints; for (Node n : i.getModel().getMapping().getOnlineNodes()) { i.getSatConstraints().add(new Online(n)); } for (Node n : i.getModel().getMapping().getOfflineNodes()) { i.getSatConstraints().add(new Offline(n)); } // Remove preserve constraints for (Iterator<SatConstraint> ite = i.getSatConstraints().iterator(); ite.hasNext();) { SatConstraint s = ite.next(); if (s instanceof Preserve && src.contains("nr")) { ite.remove(); } } /************************************/ // Convert to JSON InstanceConverter iConv = new InstanceConverter(); JSONObject o = iConv.toJSON(i); // Check for gzip extension if (output.endsWith(".gz")) { out = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(output))); } else { out = new FileWriter(output); } // Write the output file o.writeJSONString(out); out.close(); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); System.exit(1); } finally { if (out != null) { try { out.close(); } catch (IOException e) { System.err.println(e.getMessage()); System.exit(1); } } } }
From source file:com.peterbochs.PeterBochsDebugger.java
public static void main(String[] args) { WebServiceUtil.log("peter-bochs", "start", null, null, null); try {//from ww w.jav a 2 s .c o m UIManager.setLookAndFeel("com.peterswing.white.PeterSwingWhiteLookAndFeel"); } catch (Exception e) { e.printStackTrace(); } if (args.length == 0) { String errorMessage = "Wrong number of argument\n\n"; errorMessage += "\nIn Linux/Mac : java -jar peter-bochs-debugger.jar bochs -f bochsrc.bxrc"; errorMessage += "\nIn windows : java -jar peter-bochs-debugger.jar c:\\program files\\bochs2.4.3\\bochsdbg.exe -q -f bochsrc.bxrc"; errorMessage += "\n!!! if using peter-bochs in windows, you need to pass the full path of bochs exe and -q to the parameter. (!!! relative path of bochs exe will not work)"; errorMessage += "\n!!! to use \"experimental feature\", please add \"-debug\" to the parameter list"; System.out.println(errorMessage); JOptionPane.showMessageDialog(null, errorMessage); System.exit(1); } else { if (args[0].equals("-version") || args[0].equals("-v")) { System.out.println(Global.version); System.exit(1); } } for (String str : args) { if (str.contains("bochsrc") || str.contains(".bxrc")) { bochsrc = str; } } String osName = System.getProperty("os.name").toLowerCase(); if (osName.toLowerCase().contains("windows")) { os = OSType.win; } else if (osName.toLowerCase().contains("mac")) { os = OSType.mac; } else { os = OSType.linux; } if (os == OSType.mac) { com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication(); // System.setProperty("dock:name", "Your Application Name"); macApp.setDockIconImage(new ImageIcon( PeterBochsDebugger.class.getClassLoader().getResource("com/peterbochs/icons/peter.png")) .getImage()); // java.awt.PopupMenu menu = new java.awt.PopupMenu(); // menu.add(new MenuItem("test")); // macApp.setDockMenu(menu); macApp.addApplicationListener(new MacAboutBoxHandler()); } if (ArrayUtils.contains(args, "-debug")) { Global.debug = true; args = (String[]) ArrayUtils.removeElement(args, "-debug"); } else { Global.debug = false; } try { if (PeterBochsDebugger.class.getProtectionDomain().getCodeSource().getLocation().getFile() .endsWith(".jar")) { JarFile jarFile = new JarFile( PeterBochsDebugger.class.getProtectionDomain().getCodeSource().getLocation().getFile()); if (System.getProperty("os.name").toLowerCase().contains("linux")) { if (System.getProperty("os.arch").contains("64")) { if (Global.debug) { System.out.println("Loading linux 64 bits jogl"); } CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libgluegen-rt.so")), new File("libgluegen-rt.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libjogl_awt.so")), new File("libjogl_awt.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libjogl_cg.so")), new File("libjogl_cg.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libjogl.so")), new File("libjogl.so")); } else { if (Global.debug) { System.out.println("Loading linux 32 bits jogl"); } CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_i586/libgluegen-rt.so")), new File("libgluegen-rt.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_i586/libjogl_awt.so")), new File("libjogl_awt.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_i586/libjogl_cg.so")), new File("libjogl_cg.so")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/linux_i586/libjogl.so")), new File("libjogl.so")); } try { File f = new File("."); Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libjogl.so"); System.out.println("Loading " + f.getAbsolutePath() + File.separator + "libjogl.so"); Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libjogl_awt.so"); Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libjogl_cg.so"); Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libgluegen-rt.so"); } catch (UnsatisfiedLinkError e) { e.printStackTrace(); System.err.println("Native code library failed to load.\n" + e); System.err.println( "Solution : Please add \"-Djava.library.path=.\" to start peter-bochs\n" + e); } } else if (System.getProperty("os.name").toLowerCase().contains("windows")) { CommonLib.writeFile(jarFile.getInputStream(new JarEntry("com/peterbochs/exe/PauseBochs.exe")), new File("PauseBochs.exe")); CommonLib.writeFile(jarFile.getInputStream(new JarEntry("com/peterbochs/exe/StopBochs.exe")), new File("StopBochs.exe")); CommonLib.writeFile(jarFile.getInputStream(new JarEntry("com/peterbochs/exe/ndisasm.exe")), new File("ndisasm.exe")); if (System.getProperty("os.arch").contains("64")) { if (Global.debug) { System.out.println("Loading windows 64 bits jogl"); } CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_amd64/jogl.dll")), new File("jogl.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_amd64/jogl_awt.dll")), new File("jogl_awt.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_amd64/jogl_cg.dll")), new File("jogl_cg.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_amd64/gluegen-rt.dll")), new File("gluegen-rt.dll")); } else { if (Global.debug) { System.out.println("Loading windows 32 bits jogl"); } CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_i586/jogl.dll")), new File("jogl.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_i586/jogl_awt.dll")), new File("jogl_awt.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_i586/jogl_cg.dll")), new File("jogl_cg.dll")); CommonLib.writeFile( jarFile.getInputStream( new JarEntry("com/peterbochs/jogl_dll/windows_i586/gluegen-rt.dll")), new File("gluegen-rt.dll")); } try { File f = new File("."); System.load(f.getAbsolutePath() + File.separator + "jogl.dll"); System.load(f.getAbsolutePath() + File.separator + "jogl_awt.dll"); System.load(f.getAbsolutePath() + File.separator + "jogl_cg.dll"); System.load(f.getAbsolutePath() + File.separator + "gluegen-rt.dll"); } catch (UnsatisfiedLinkError e) { e.printStackTrace(); System.err.println("Native code library failed to load.\n" + e); System.err.println( "Solution : Please add \"-Djava.library.path=.\" to start peter-bochs\n" + e); } } } } catch (IOException e) { e.printStackTrace(); } if (ArrayUtils.contains(args, "-loadBreakpoint")) { Setting.getInstance().setLoadBreakpointAtStartup(true); args = (String[]) ArrayUtils.removeElement(args, "-loadBreakpoint"); } else if (ArrayUtils.contains(args, "-loadbreakpoint")) { Setting.getInstance().setLoadBreakpointAtStartup(true); args = (String[]) ArrayUtils.removeElement(args, "-loadbreakpoint"); } for (int x = 0; x < args.length; x++) { if (args[x].toLowerCase().startsWith("-osdebug")) { Global.osDebug = CommonLib.string2long(args[x].replaceAll("-.*=", "")); args = (String[]) ArrayUtils.removeElement(args, args[x]); x = -1; } else if (args[x].toLowerCase().startsWith("-profilingmemoryport")) { Global.profilingMemoryPort = (int) CommonLib.string2long(args[x].replaceAll("-.*=", "")); args = (String[]) ArrayUtils.removeElement(args, args[x]); x = -1; } else if (args[x].toLowerCase().startsWith("-profilingjmpport")) { Global.profilingJmpPort = (int) CommonLib.string2long(args[x].replaceAll("-.*=", "")); args = (String[]) ArrayUtils.removeElement(args, args[x]); x = -1; } else if (args[x].toLowerCase().startsWith("-loadelf")) { Global.elfPaths = args[x].replaceAll("-loadelf=", "").split(","); Setting.getInstance().setLoadSystemMapAtStartup(true); args = (String[]) ArrayUtils.removeElement(args, args[x]); x = -1; } else if (args[x].toLowerCase().startsWith("-loadmap")) { System.out.println("-loadmap is not deprecated, please use -loadelf."); } } arguments = args; SwingUtilities.invokeLater(new Runnable() { public void run() { PeterBochsDebugger inst = new PeterBochsDebugger(); PeterBochsDebugger.instance = inst; new Thread("preventSetVisibleHang thread") { public void run() { try { Thread.sleep(10000); if (preventSetVisibleHang) { System.out.println( "setVisible(true) cause system hang, this probably a swing bug, so force exit, please restart"); System.exit(-1); } } catch (InterruptedException e) { e.printStackTrace(); } } }.start(); if (Global.debug) { System.out.println("setVisible(true)"); } inst.setVisible(true); preventSetVisibleHang = false; if (Global.debug) { System.out.println("end setVisible(true)"); } } }); }
From source file:Main.java
private static boolean containsSpace(String source) { return source.contains(" "); }
From source file:Main.java
public static boolean isGoogleApp(String ns) { return ns.contains("com.google."); }
From source file:Main.java
public static boolean isHtcApp(String ns) { return ns.contains("com.htc."); }
From source file:Main.java
public static boolean isHLSSource(String src) { return src.contains(".m3u8"); }
From source file:Main.java
public static boolean isSerpUrl(String url) { return url.contains("duckduckgo.com"); }
From source file:Main.java
public static String getExtension(String uri) { return uri.contains(".") ? uri.substring(uri.lastIndexOf(".") + 1) : ""; }
From source file:Main.java
public static boolean isServiceFiles(String str) { if (str.contains("/files/")) return true; return false; }
From source file:Main.java
public static boolean isInStringRep(String in) { return in.contains(STRING_ANNOTATION); }