List of usage examples for org.apache.commons.lang3 StringUtils contains
public static boolean contains(final CharSequence seq, final CharSequence searchSeq)
Checks if CharSequence contains a search CharSequence, handling null .
From source file:com.utdallas.s3lab.smvhunter.monkey.NetworkMonitor.java
@Override public void run() { try {/*from w w w . j ava2 s.c o m*/ //get the pid first String pidString = UIEnumerator.execSpecial( String.format(GET_PID, MonkeyMe.adbLocation, device.getSerialNumber(), application)); if (StringUtils.isEmpty(pidString)) { logger.error(getStringforPrinting("pid string empty for app ", application, "trying again")); Thread.sleep(5000); //try again pidString = UIEnumerator.execSpecial( String.format(GET_PID, MonkeyMe.adbLocation, device.getSerialNumber(), application)); } logger.debug(getStringforPrinting("pid string for ", application, pidString)); List<String> outList = new ArrayList<String>(); if (StringUtils.isNotEmpty(pidString)) { Process pidCmd = null; try { //read the strace command output pidCmd = execCommand( String.format(TRACE_PID, MonkeyMe.adbLocation, device.getSerialNumber(), pidString)); BufferedReader pidReader = new BufferedReader(new InputStreamReader(pidCmd.getInputStream())); String out = ""; while ((out = pidReader.readLine()) != null) { //break the loop if the current thread has been cancelled if (Thread.currentThread().isInterrupted()) { break; } outList.add(getStringforPrinting(System.currentTimeMillis(), application, out)); if (StringUtils.contains(out, "connect")) { logger.debug(out); FileUtils.write(new File(MonkeyMe.straceOutputLocation), getStringforPrinting(System.currentTimeMillis(), application, out) + "\n", true); } } } finally { FileUtils.writeLines(new File(MonkeyMe.straceDumpLocation), outList, true); if (pidCmd != null) { pidCmd.destroy(); } } } } catch (Exception e) { logger.error("Error while processing monitoring network for " + application, e); } }
From source file:com.thoughtworks.go.matchers.ConsoleOutMatcher.java
public static TypeSafeMatcher<String> printedJobCompletedInfo(final Object jobIdentifer) { return new TypeSafeMatcher<String>() { private String consoleOut; public String stdout; public boolean matchesSafely(String consoleOut) { this.consoleOut = consoleOut; stdout = format("Job completed %s", jobIdentifer.toString()); return StringUtils.contains(consoleOut, stdout); }/* w w w. jav a2s . co m*/ public void describeTo(Description description) { description.appendText("expected console to contain [" + stdout + "]" + " but was " + consoleOut); } }; }
From source file:com.adobe.acs.commons.adobeio.service.impl.AdobeioHealthcheck.java
private void execute(final FormattingResultLog resultLog, EndpointService endpoint) { resultLog.info("Checking Adobe I/O endpoint {}", endpoint.getId()); if ("GET".equalsIgnoreCase(endpoint.getMethod())) { resultLog.debug("Executing Adobe I/O call to {}", endpoint.getUrl()); JsonObject json = endpoint.performIO_Action(); if (json != null) { resultLog.debug("JSON-response {}", json.toString()); if (StringUtils.contains(json.toString(), "error")) { resultLog.critical("Error returned from the API-call"); }//from w w w. j av a 2 s . c om } } else { resultLog.debug("Method != GET, but {}", endpoint.getMethod()); } }
From source file:com.adguard.commons.web.UrlUtils.java
/** * Removes jsessionid from string/* w w w .ja va 2s.c o m*/ * * @return url without jsessionid */ public static String removeJSessionId(String str) { // Removing jsessionid if (!StringUtils.isEmpty(str) && StringUtils.contains(str.toLowerCase(), ";jsessionid")) { return str.substring(0, StringUtils.indexOf(str, ";jsessionid")); } return str; }
From source file:de.micromata.genome.util.validation.ValMessage.java
public String getTranslatedMessage(I18NTranslationProvider transprov) { if (message != null) { return message; }/* www . j a va 2 s . c o m*/ String msg = (String) transprov.getTranslationForKey(getI18nkey()); if (getArguments() != null && getArguments().length > 0) { msg = MessageFormat.format(msg, getArguments()); } else if (exception != null && StringUtils.contains(msg, "{0}") == true) { msg = MessageFormat.format(msg, exception.getMessage()); } message = msg; return message; }
From source file:io.wcm.handler.media.markup.SimpleImageMediaMarkupBuilder.java
@Override public final boolean isValidMedia(HtmlElement<?> element) { if (element instanceof Image) { Image img = (Image) element; return StringUtils.isNotEmpty(img.getSrc()) && !StringUtils.contains(img.getCssClass(), MediaNameConstants.CSS_DUMMYIMAGE); }/*from w w w . ja v a 2s. c o m*/ return false; }
From source file:com.glaf.dts.web.springmvc.MxDtsQueryController.java
@RequestMapping("/chooseQuery") public ModelAndView chooseQuery(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); String elementValue = request.getParameter("elementValue"); QueryDefinitionQuery query = new QueryDefinitionQuery(); query.setOrderBy(" E.TARGETTABLENAME_ asc, E.TITLE_ asc "); List<QueryDefinition> list = queryDefinitionService.list(query); request.setAttribute("unselecteds", list); if (StringUtils.isNotEmpty(elementValue)) { StringBuffer sb01 = new StringBuffer(); StringBuffer sb02 = new StringBuffer(); List<String> selecteds = new java.util.ArrayList<String>(); for (QueryDefinition q : list) { if (StringUtils.contains(elementValue, q.getId())) { selecteds.add(q.getId()); sb01.append(q.getId()).append(","); sb02.append(q.getName()).append(","); }/*from w w w . ja va2s . co m*/ } if (sb01.toString().endsWith(",")) { sb01.delete(sb01.length() - 1, sb01.length()); } if (sb02.toString().endsWith(",")) { sb02.delete(sb02.length() - 1, sb02.length()); } request.setAttribute("selecteds", selecteds); request.setAttribute("queryIds", sb01.toString()); request.setAttribute("queryNames", sb02.toString()); } String x_view = ViewProperties.getString("dts.chooseQuery"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/bi/dts/query/chooseQuery", modelMap); }
From source file:com.nridge.core.io.gson.JSONDocument.java
/** * Parses an JSON stream and loads it into an internally managed * document instance.//from w w w . ja va 2 s .c o m * * @param aReader Json reader stream instance. * * @throws IOException I/O related exception. */ private void loadDocument(JsonReader aReader, Document aDocument) throws IOException { DataBag dataBag; JsonToken jsonToken; DataField dataField; String jsonName, jsonValue, jsonTitle; aReader.beginObject(); jsonToken = aReader.peek(); while (jsonToken == JsonToken.NAME) { jsonName = aReader.nextName(); jsonTitle = Field.nameToTitle(jsonName); jsonToken = aReader.peek(); switch (jsonToken) { case BOOLEAN: dataBag = aDocument.getBag(); dataField = new DataField(jsonName, jsonTitle, aReader.nextBoolean()); dataBag.add(dataField); break; case NUMBER: dataBag = aDocument.getBag(); jsonValue = aReader.nextString(); if (StringUtils.contains(jsonValue, StrUtl.CHAR_DOT)) dataField = new DataField(jsonName, jsonTitle, Double.valueOf(jsonValue)); else dataField = new DataField(jsonName, jsonTitle, Long.valueOf(jsonValue)); dataBag.add(dataField); break; case STRING: dataBag = aDocument.getBag(); jsonValue = aReader.nextString(); Date dateValue = DatUtl.detectCreateDate(jsonValue); if (dateValue != null) dataField = new DataField(jsonName, jsonTitle, dateValue); else dataField = new DataField(Field.Type.Text, jsonName, jsonTitle, jsonValue); dataBag.add(dataField); break; case NULL: dataBag = aDocument.getBag(); aReader.nextNull(); dataField = new DataField(Field.Type.Text, jsonName, jsonTitle); dataBag.add(dataField); break; case BEGIN_ARRAY: aReader.beginArray(); if (isNextTokenAnObject(aReader)) { Document childDocument = new Document(jsonTitle); childDocument.setName(jsonName); aDocument.addRelationship(jsonTitle, childDocument); loadDocumentArray(aReader, childDocument); } else { dataBag = aDocument.getBag(); dataField = new DataField(Field.Type.Text, jsonName, jsonTitle); jsonToken = aReader.peek(); while (jsonToken != JsonToken.END_ARRAY) { jsonValue = aReader.nextString(); dataField.addValue(jsonValue); jsonToken = aReader.peek(); } dataBag.add(dataField); } aReader.endArray(); break; case BEGIN_OBJECT: Document childDocument = new Document(jsonTitle); childDocument.setName(jsonName); aDocument.addRelationship(jsonTitle, childDocument); loadDocument(aReader, childDocument); break; default: aReader.skipValue(); break; } jsonToken = aReader.peek(); } aReader.endObject(); }
From source file:kenh.xscript.elements.Method.java
/** * Process method of {@code Method} element. * //from ww w . j a v a 2 s .c om * @param name * @param parameter * @throws UnsupportedScriptException */ @Processing public void process(@Attribute(ATTRIBUTE_NAME) String name, @Primal @Attribute(ATTRIBUTE_PARA) String parameter) throws UnsupportedScriptException { this.name = name; if (StringUtils.isBlank(name)) { UnsupportedScriptException ex = new UnsupportedScriptException(this, "The method name is empty."); throw ex; } Map<String, Element> methods = this.getEnvironment().getMethods(); if (methods.containsKey(name)) { UnsupportedScriptException ex = new UnsupportedScriptException(this, "Reduplicate method. [" + name + "]"); throw ex; } if (StringUtils.isNotBlank(parameter)) { String[] paras = StringUtils.split(parameter, ","); Vector<String[]> allParas = new Vector(); Vector<String> existParas = new Vector(); // exist parameters for (String para : paras) { if (StringUtils.isBlank(para)) { UnsupportedScriptException ex = new UnsupportedScriptException(this, "Parameter format incorrect. [" + name + ", " + parameter + "]"); throw ex; } String[] all = StringUtils.split(para, " "); String paraName = StringUtils.trimToEmpty(all[all.length - 1]); if (StringUtils.isBlank(paraName) || StringUtils.contains(paraName, "{")) { UnsupportedScriptException ex = new UnsupportedScriptException(this, "Parameter format incorrect. [" + name + ", " + parameter + "]"); throw ex; } if (existParas.contains(paraName)) { UnsupportedScriptException ex = new UnsupportedScriptException(this, "Reduplicate parameter. [" + name + ", " + paraName + "]"); throw ex; } else { existParas.add(paraName); } Vector<String> one = new Vector(); one.add(paraName); for (int i = 0; i < all.length - 1; i++) { String s = StringUtils.trimToEmpty(all[i]); if (StringUtils.isBlank(s)) continue; if (s.equals(MODI_FINAL) || s.equals(MODI_REQUIRED) || (s.startsWith(MODI_DEFAULT + "(") && s.endsWith(")"))) { one.add(s); } else { UnsupportedScriptException ex = new UnsupportedScriptException(this, "Unsupported modifier. [" + name + ", " + paraName + ", " + s + "]"); throw ex; } } String[] one_ = one.toArray(new String[] {}); allParas.add(one_); } parameters = allParas.toArray(new String[][] {}); } // store into {methods} methods.put(name, this); }
From source file:com.sludev.commons.vfs2.provider.s3.SS3FileObject.java
/** * Convenience method that returns the container ( i.e. "bucket ) and path from the current URL. * //from w w w .ja v a 2 s. co m * @return A tuple containing the bucket name and the path. */ private Pair<String, String> getContainerAndPath() { Pair<String, String> res = null; try { URLFileName currName = (URLFileName) getName(); String currPathStr = currName.getPath(); currPathStr = StringUtils.stripStart(currPathStr, "/"); if (StringUtils.isBlank(currPathStr)) { log.warn(String.format("getContainerAndPath() : Path '%s' does not appear to be valid", currPathStr)); return null; } // Deal with the special case of the container root. if (StringUtils.contains(currPathStr, "/") == false) { // Container and root return new ImmutablePair<>(currPathStr, "/"); } String[] resArray = StringUtils.split(currPathStr, "/", 2); res = new ImmutablePair<>(resArray[0], resArray[1]); } catch (Exception ex) { log.error(String.format("getContainerAndPath() : Path does not appear to be valid"), ex); } return res; }