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.eryansky.common.orm.core.PropertyFilters.java
/** * ?//from ww w . j a va 2 s. c om * <p> * * </p> * <code> * PropertyFilters.get("EQS_propertyName","maurice") * </code> * * @param expression ? * @param matchValue * * @return {@link PropertyFilter} */ @SuppressWarnings("static-access") public static PropertyFilter get(String expression, String matchValue) { Assert.hasText(expression, "??"); String restrictionsNameAndClassType = StringUtils.substringBefore(expression, "_"); String restrictionsName = StringUtils.substring(restrictionsNameAndClassType, 0, restrictionsNameAndClassType.length() - 1); String classType = StringUtils.substring(restrictionsNameAndClassType, restrictionsNameAndClassType.length() - 1, restrictionsNameAndClassType.length()); FieldType FieldType = null; try { FieldType = FieldType.valueOf(classType); } catch (Exception e) { throw new IllegalAccessError( "[" + expression + "]??,?:" + classType); } String[] propertyNames = null; if (StringUtils.contains(expression, "_OR_")) { String temp = StringUtils.substringAfter(expression, restrictionsNameAndClassType + "_"); propertyNames = StringUtils.splitByWholeSeparator(temp, "_OR_"); } else { propertyNames = new String[1]; propertyNames[0] = StringUtils.substringAfterLast(expression, "_"); } return new PropertyFilter(restrictionsName, FieldType, propertyNames, matchValue); }
From source file:com.dominion.salud.mpr.web.interceptors.SecurityInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception { if (!StringUtils.contains(request.getServletPath(), "services")) { if (request.getSession() != null && request.getSession().getAttribute("mpr.usuario") != null) { return true; } else {/*from ww w . j av a 2 s . co m*/ throw new SesionExpiradaException("La sesion ha expirado"); } } else { return true; } }
From source file:io.wcm.handler.media.format.impl.DefaultMediaFormatListProviderTest.java
@Test public void testGet() throws Exception { underTest.service(context.request(), context.response()); String response = context.response().getOutputAsString(); assertTrue(StringUtils.contains(response, "\"" + DummyMediaFormats.EDITORIAL_1COL.getName() + "\"")); assertTrue(StringUtils.contains(response, "\"" + DummyMediaFormats.EDITORIAL_2COL.getName() + "\"")); assertTrue(StringUtils.contains(response, "\"" + DummyMediaFormats.EDITORIAL_3COL.getName() + "\"")); }
From source file:com.quancheng.saluki.core.grpc.client.internal.GrpcStubClient.java
@SuppressWarnings("unchecked") @Override//from ww w. j a va2 s. c o m public AbstractStub getGrpcClient(ChannelPool channelPool, int callType, int callTimeout) { String stubClassName = GrpcStubClient.this.getStubClassName(); Channel channel = null; if (StringUtils.contains(stubClassName, "$")) { try { String parentName = StringUtils.substringBefore(stubClassName, "$"); Class<?> clzz = ReflectUtils.name2class(parentName); Method method; switch (callType) { case Constants.RPCTYPE_ASYNC: method = clzz.getMethod("newFutureStub", io.grpc.Channel.class); break; case Constants.RPCTYPE_BLOCKING: method = clzz.getMethod("newBlockingStub", io.grpc.Channel.class); break; default: method = clzz.getMethod("newFutureStub", io.grpc.Channel.class); break; } channel = channelPool.borrowChannel(null); AbstractStub stubInstance = (AbstractStub) method.invoke(null, channel); return stubInstance; } catch (Exception e) { throw new IllegalArgumentException("stub definition not correctdo not edit proto generat file", e); } finally { if (channel != null) { channelPool.returnChannel(null, channel); } } } else { throw new IllegalArgumentException("stub definition not correctdo not edit proto generat file"); } }
From source file:com.thoughtworks.go.matchers.ConsoleOutMatcher.java
public static TypeSafeMatcher<String> printedPreparingInfo(final Object jobIdentifer) { return new TypeSafeMatcher<String>() { private String consoleOut; public String stdout; public boolean matchesSafely(String consoleOut) { this.consoleOut = consoleOut; stdout = format("Start to prepare %s", jobIdentifer.toString()); return StringUtils.contains(consoleOut, stdout); }//from w w w . jav a 2 s . c om public void describeTo(Description description) { description.appendText("expected console to contain [" + stdout + "]" + " but was " + consoleOut); } }; }
From source file:com.github.dactiv.orm.core.PropertyFilters.java
/** * ?//from ww w . j av a 2 s . c o m * <p> * * </p> * <code> * PropertyFilters.build("EQS_propertyName","maurice") * </code> * * @param expression ? * @param matchValue * * @return {@link PropertyFilter} */ @SuppressWarnings("static-access") public static PropertyFilter build(String expression, String matchValue) { Assert.hasText(expression, "??"); String restrictionsNameAndClassType = StringUtils.substringBefore(expression, "_"); String restrictionsName = StringUtils.substring(restrictionsNameAndClassType, 0, restrictionsNameAndClassType.length() - 1); String classType = StringUtils.substring(restrictionsNameAndClassType, restrictionsNameAndClassType.length() - 1, restrictionsNameAndClassType.length()); FieldType FieldType = null; try { FieldType = FieldType.valueOf(classType); } catch (Exception e) { throw new IllegalAccessError( "[" + expression + "]??,?:" + classType); } String[] propertyNames = null; if (StringUtils.contains(expression, "_OR_")) { String temp = StringUtils.substringAfter(expression, restrictionsNameAndClassType + "_"); propertyNames = StringUtils.splitByWholeSeparator(temp, "_OR_"); } else { propertyNames = new String[1]; propertyNames[0] = StringUtils.substringAfterLast(expression, "_"); } return new PropertyFilter(restrictionsName, FieldType, propertyNames, matchValue); }
From source file:com.nridge.connector.common.con_com.transform.WhitespacePropertiesReader.java
/** * Special algorithm for parsing properties keys with whitespace. This * method is called for each non-comment line read from the properties * file./* w ww. j a va 2s . co m*/ */ @Override protected void parseProperty(String aLine) { // Simply split the line at the first '=' character. if (StringUtils.contains(aLine, StrUtl.CHAR_EQUAL)) { int offset = aLine.indexOf('='); if (offset > 0) { String propertyKey = aLine.substring(0, offset).trim(); String propertyValue = aLine.substring(offset + 1).trim(); // Now store the key and the value of the property. initPropertyName(propertyKey); initPropertyValue(propertyValue); } else super.parseProperty(aLine); } else super.parseProperty(aLine); }
From source file:com.thoughtworks.go.matchers.ConsoleOutMatcherJunit5.java
public ConsoleOutMatcherJunit5 printedEnvVariable(final String key, final Object value) { String set = format("environment variable '%s' to value '%s'", key, value); String override = format("environment variable '%s' with value '%s'", key, value); if (!StringUtils.contains(actual, set) && !StringUtils.contains(actual, override)) { failWithMessage("Expected console to contain [<%s>] or [<%s>] but was <%s>.", set, override, actual); }/*from ww w .j a v a2 s.c o m*/ return this; }
From source file:com.netflix.genie.web.data.repositories.jpa.specifications.JpaSpecificationUtils.java
/** * Create either an equals or like predicate based on the presence of the '%' character in the search value. * * @param cb The criteria builder to use for predicate creation * @param expression The expression of the field the predicate is acting on * @param value The value to compare the field to * @return A LIKE predicate if the value contains a '%' otherwise an EQUAL predicate *///from w w w .j av a 2 s.c om static Predicate getStringLikeOrEqualPredicate(@NotNull final CriteriaBuilder cb, @NotNull final Expression<String> expression, @NotNull final String value) { if (StringUtils.contains(value, PERCENT)) { return cb.like(expression, value); } else { return cb.equal(expression, value); } }
From source file:io.wcm.devops.conga.plugins.sling.util.ProvisioningUtil.java
/** * Check if given file is a sling provisioning file. * @param file File/*from ww w. ja va 2 s.c om*/ * @return true if it seems to be so */ public static boolean isProvisioningFile(FileContext file) { if (FileUtil.matchesExtension(file, FILE_EXTENSION)) { return true; } try { // check for generic txt extension and do some heuristics on the content of the file return FileUtil.matchesExtension(file.getFile(), TEXT_FILE_EXTENSION) && StringUtils .contains(FileUtils.readFileToString(file.getFile(), file.getCharset()), "[feature "); } catch (IOException ex) { return false; } }