List of usage examples for java.lang String contentEquals
public boolean contentEquals(CharSequence cs)
From source file:org.orbisgis.framework.Main.java
private static void parseCommandLine(String[] args) { //Read parameters Stack<String> sargs = new Stack<String>(); for (String arg : args) { sargs.insertElementAt(arg, 0);/*www. j a v a2s .c o m*/ } while (!sargs.empty()) { String argument = sargs.pop(); if (argument.contentEquals("--debug")) { debugMode = true; } else if (argument.contentEquals("--nofailmode")) { noFailMode = true; } } }
From source file:Main.java
private static String executeTop() { Process p = null;/*from ww w .j a v a2s. com*/ BufferedReader in = null; String returnString = null; try { p = Runtime.getRuntime().exec("top -n 1"); in = new BufferedReader(new InputStreamReader(p.getInputStream())); while (returnString == null || returnString.contentEquals("")) { returnString = in.readLine(); } } catch (IOException e) { Log.e("executeTop", "error in getting first line of top"); e.printStackTrace(); } finally { try { in.close(); p.destroy(); } catch (IOException e) { Log.e("executeTop", "error in closing and destroying top process"); e.printStackTrace(); } } return returnString; }
From source file:main.java.com.skillselector.client.root.Neo4JRequest.java
public static JSONObject calculateScoresFromJsonNeo4J(Skill requestedSkills[], int requestedSkillsNumber, double power, Map<String, HashMap<String, String>> content) { System.out.print("Enter calculateScoresFromJsonNeo4J "); int nbConsultant = 0; Iterator it1c = content.entrySet().iterator(); while (it1c.hasNext()) { Map.Entry pair = (Map.Entry) it1c.next(); nbConsultant++;/*from w w w.ja v a 2 s .c om*/ } System.out.print("nbConsultant " + nbConsultant);//skill double totalScore = 0.0; DecimalFormat df = new DecimalFormat("00.00"); int nbConsultants = 0; JSONObject jsonReturn = new JSONObject(); int nbskillsConsultant = 0; Iterator it1 = content.entrySet().iterator(); while (it1.hasNext()) { Map.Entry pair = (Map.Entry) it1.next(); String key = (String) pair.getKey(); HashMap<String, String> map = (HashMap<String, String>) pair.getValue(); Iterator it2 = map.entrySet().iterator(); nbskillsConsultant = 0; while (it2.hasNext()) { Map.Entry submap = (Map.Entry) it2.next(); nbskillsConsultant++; } String[][] skillsTab = new String[nbskillsConsultant][2]; Iterator it3 = map.entrySet().iterator(); int it3Number = -1; while (it3.hasNext()) { it3Number++; Map.Entry submap = (Map.Entry) it3.next(); String subkey = (String) submap.getKey(); String subvalue = (String) submap.getValue(); skillsTab[it3Number][0] = subkey; skillsTab[it3Number][1] = subvalue; } it3Number = -1; // Test if skills in consultant and calculate score for (int j = 0; j < requestedSkillsNumber; j++) { totalScore += SkillsRequest.matchedSkill(requestedSkills[j], skillsTab, nbskillsConsultant - 1, power); } nbskillsConsultant = 0; System.out.print("\nConsultant " + key + " score " + totalScore);//consultant int ts = (int) totalScore; String chTotalScore = String.valueOf(ts); if (!chTotalScore.contentEquals("0")) { jsonReturn.append(key, (String) chTotalScore); } totalScore = 0; } return jsonReturn; }
From source file:com.ibm.rpe.web.service.docgen.impl.GenerateBaseTemplate.java
private static void createTemplateXmls(String inputFile, BaseTemplateInput data) throws ParserConfigurationException, SAXException, IOException { String directory = (new File(inputFile)).getParent() + File.separator; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; builder = factory.newDocumentBuilder(); Document document = builder.parse(new File(inputFile)); NodeList nlist = document.getElementsByTagName("element"); if (nlist != null && nlist.getLength() > 0) { for (int i = 0; i < nlist.getLength(); i++) { Node node = nlist.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element ele = (Element) node; String attr = ele.getAttribute("id"); if (attr.contentEquals(data.getElementId())) { Node newNode = document.createTextNode(data.getReplacement()); node.getParentNode().insertBefore(newNode, node); try { } catch (Exception e1) { e1.printStackTrace(); }/*from w w w.java2 s. c o m*/ Node removedNode = node.getParentNode().removeChild(node); // System.out.println(nodeToString(removedNode)); String removed = nodeToString(removedNode); removed = replace(removed, data.getReplaceMap()); if (data.isReplaceElementId()) { removed = replaceElementId(removed); } document.normalize(); FileUtils.writeFile(directory + data.getOutputFile(), removed); System.out.println("Removed : " + ((Element) removedNode).getAttribute("id")); try { // prettyPrint(document); } catch (Exception e) { e.printStackTrace(); } break; } } } FileUtils.writeFile(inputFile, transformToString(document)); } }
From source file:com.jktsoftware.amazondownloader.download.Application.java
public static void downloadObject(IObject objecttodownload, IQueueManager queuemanager) { ConsoleProgressBar progressbar = new ConsoleProgressBar(); System.out.println("Attempting to get object: " + objecttodownload.getObjectKey()); try {/*w ww . ja va 2 s . c o m*/ //create an inputstream object for the download from the repo InputStream input = objecttodownload.getObjectContent(); //create an outputstream for writing the stream to a local file OutputStream outStream = new FileOutputStream(objecttodownload.getObjectKey()); //current bytes read from the repo long currentbytes = 0; //bytes read within the loop int bytesread = 0; //print status message to the console System.out.println("Starting download of :" + objecttodownload.getObjectKey()); //progress message variable String previousprogress = ""; //buffer for holding downloaded bytes byte[] bytebuffer = new byte[512 * 1024]; //start downloading file bit by bit while ((bytesread = input.read(bytebuffer)) != -1) { //write downloaded bytes to the file outStream.write(bytebuffer, 0, bytesread); //update downloaded byte count currentbytes = currentbytes + bytesread; //get a text representation of a progress bar String newprogress = progressbar.getProgress(currentbytes, objecttodownload.getObjectSize()) + "\r"; if (!newprogress.contentEquals(previousprogress)) { //write progress bar to console System.out.print(newprogress); previousprogress = newprogress; } } //write progress bar to console System.out.println(progressbar.getProgress(currentbytes, objecttodownload.getObjectSize())); System.out.println("Object downloaded"); //close the streams input.close(); outStream.close(); //update queue with details of downloaded file queuemanager.sendReceivedObjectMessageToQueue(objecttodownload.getObjectKey()); } catch (IOException e) { e.printStackTrace(); //update queue with details of failed file queuemanager.sendFailedObjectMessageToQueue(objecttodownload.getObjectKey(), e.getStackTrace().toString()); } }
From source file:net.xy.jcms.controller.configurations.ControllerConfiguration.java
/** * parses an string to an controller goniguration each controller gets the * global and its all other configuration. * /*from ww w .ja v a2s. c om*/ * @param in * @return value */ @SuppressWarnings("unchecked") public static Configuration<?> initByString(final String in) { final Map<String, Map<String, Object>> config = new HashMap<String, Map<String, Object>>(); final String[] lines = in.split("\n"); for (int i = 0; i < lines.length; i++) { final String line = lines[i].trim(); if (StringUtils.isBlank(line) || line.startsWith("#")) { continue; } if (line.matches("^[A-Z]{1}[a-zA-Z0-9]+\\{$")) { // start controller section final String controllerName = line.substring(0, line.length() - 1); // forward to next line until } reached i++; if (!config.containsKey(controllerName)) { config.put(controllerName, new LinkedHashMap<String, Object>()); } final Map<String, Object> ctrlConfig = config.get(controllerName); for (; i < lines.length; i++) { final String ctrlLine = lines[i].trim(); if (ctrlLine.contentEquals("}")) { break; } if (StringUtils.isBlank(ctrlLine) || ctrlLine.startsWith("#")) { continue; } if (ctrlLine.matches("^[a-zA-Z0-9.]+\\{$")) { // begin of an controller config clustering final String subSectionName = ctrlLine.substring(0, ctrlLine.length() - 1); // forward to next line until } reached i++; final Object oldValue = ctrlConfig.get(subSectionName); if (!List.class.isInstance(oldValue)) { ctrlConfig.put(subSectionName, new LinkedList<Map<String, Object>>()); if (oldValue != null) { final HashMap<String, Object> old = new HashMap<String, Object>(); old.put(subSectionName, oldValue); ((List<Map<String, Object>>) ctrlConfig.get(subSectionName)).add(old); } } final List<Map<String, Object>> subSections = (List<Map<String, Object>>) ctrlConfig .get(subSectionName); final Map<String, Object> subParam = new LinkedHashMap<String, Object>(); for (; i < lines.length; i++) { final String subSec = lines[i].trim(); if (subSec.contentEquals("}")) { break; } if (StringUtils.isBlank(subSec) || subSec.startsWith("#")) { continue; } addLine(subSec, subParam); } if (!subParam.isEmpty()) { subSections.add(subParam); } } else if (ctrlLine.contentEquals("}")) { throw new IllegalArgumentException( "There are unmatching controller subsection parentheses at line " + i + "."); } else { // simple controller config pair key = val addLine(ctrlLine, ctrlConfig); } } } else if (line.contentEquals("}")) { throw new IllegalArgumentException( "There are global unmatching subsection parentheses at line " + i + "."); } else { // fill in globals section if (!config.containsKey(GLOBAL_CONFIG)) { config.put(GLOBAL_CONFIG, new HashMap<String, Object>()); } final Map<String, Object> global = config.get(GLOBAL_CONFIG); addLine(line, global); } } return new ControllerConfiguration(config); }
From source file:org.archive.util.UriUtils.java
public static boolean isLikelyUriJavascriptContextLegacy(CharSequence candidate) { if (!TextUtils.matches(STRING_URI_DETECTOR, candidate)) { return false; }//from ww w . j a v a2s .c o m for (String s : STRING_URI_DETECTOR_EXCEPTIONS) { if (s.contentEquals(candidate)) return false; } // matches detector and not an exception: so a likely URI return true; }
From source file:org.xbmc.kore.testhelpers.action.ViewActions.java
public static ViewAction setCurrentViewPagerItem(final int pageTitleResourceId) { return new ViewAction() { @Override/*from www . ja v a 2 s .c o m*/ public Matcher<View> getConstraints() { return new TypeSafeMatcher<View>() { @Override protected boolean matchesSafely(View item) { return item instanceof ViewPager; } @Override public void describeTo(Description description) { description.appendText("is a SeekBar."); } }; } @Override public String getDescription() { return null; } @Override public void perform(UiController uiController, View view) { ViewPager viewPager = (ViewPager) view; String expectedTitle = view.getResources().getString(pageTitleResourceId); PagerAdapter pagerAdapter = viewPager.getAdapter(); for (int i = 0; i < pagerAdapter.getCount(); i++) { if (expectedTitle.contentEquals(pagerAdapter.getPageTitle(i))) { viewPager.setCurrentItem(i); return; } } } }; }
From source file:hydrograph.engine.spark.helper.DelimitedAndFixedWidthHelper.java
public static boolean hasaNewLineField(String[] lengthsAndDelimiters) { for (String string : lengthsAndDelimiters) { if (string.contains("\n") || string.contentEquals("\\n")) return true; }/* ww w . ja v a 2s . c om*/ return false; }
From source file:org.archive.util.UriUtils.java
protected static boolean isLikelyFalsePositive(CharSequence candidate) { if (TextUtils.matches("(?:text|application)/[^/]+", candidate)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("rejected: looks like an application or text mimetype: " + candidate); }//from w w w.ja va 2s. co m return true; } for (String s : AUDIO_VIDEO_IMAGE_MIMETYPES) { if (s.contentEquals(candidate)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("rejected: looks like an audio video or image mimetype: " + candidate); } return true; } } if (TextUtils.matches("\\d+(?:\\.\\d+)*", candidate)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("rejected: looks like a decimal number: " + candidate); } return true; } if (TextUtils.matches(".*[$()'\"\\[\\]{}|].*", candidate)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("rejected: contains unusual characters: " + candidate); } return true; } // starting or ending with + particularly common because of string concatenation in javascript if (TextUtils.matches("^[,;+:].*|.*[.,;+:]$", candidate)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("rejected: starts or ends with an unusual starting or ending character: " + candidate); } return true; } if (candidate.charAt(0) == '.' && !TextUtils.matches("^\\.{1,2}/.*", candidate)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("rejected: starts with '.' (but not './' or '../'): " + candidate); } return true; } if (TextUtils.matches("^.*[^:]//.*$", candidate)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("rejected: contains '//' (but not '://'): " + candidate); } return true; } // look for things that look like hostnames and not filenames? // look for too many dots but make sure we take into account that url may have hostname? if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("accepted: does not look like a false positive: " + candidate); } return false; }