List of usage examples for org.apache.commons.lang3 StringUtils endsWith
public static boolean endsWith(final CharSequence str, final CharSequence suffix)
Check if a CharSequence ends with a specified suffix.
null s are handled without exceptions.
From source file:org.opensilk.music.App.java
boolean isProviderProcess() { return StringUtils.endsWith(getProcName(), ":prvdr"); }
From source file:org.phenotips.data.internal.controller.FeaturesController.java
private boolean isFieldSuffixIncluded(Collection<String> selectedFields, String fieldSuffix) { if (selectedFields == null) { return true; }/* ww w.java2s. co m*/ for (String fieldName : selectedFields) { if (StringUtils.endsWith(fieldName, fieldSuffix)) { return true; } } return false; }
From source file:org.phenotips.security.authorization.ModularRightServiceImpl.java
@Override public boolean hasAccessLevel(String right, String username, String docname, XWikiContext context) throws XWikiException { User user = this.userManager.getUser(StringUtils.endsWith(username, "XWikiGuest") ? null : username, true); WikiReference wikiReference = new WikiReference(context.getWikiId()); DocumentReference document = resolveDocumentName(docname, wikiReference); return this.service.hasAccess(user, Right.toRight(right), document); }
From source file:org.pircbotx.hooks.ListenerAdapterTest.java
/** * Makes sure adapter uses all events//w w w . j a va 2 s .c o m * * @throws Exception */ @Test(dataProviderClass = TestUtils.class, dataProvider = "eventAllDataProvider", description = "Verify ListenerAdapter has methods for all events") public void eventImplementTest(Class eventClass) throws NoSuchMethodException { //Just try to load it. If the method doesn't exist then it throws a NoSuchMethodException String eventName = eventClass.getSimpleName(); assertTrue(StringUtils.endsWith(eventName, "Event"), "Unknown event class " + eventClass); String methodName = "on" + StringUtils.removeEnd(StringUtils.capitalize(eventName), "Event"); ListenerAdapter.class.getDeclaredMethod(methodName, eventClass); }
From source file:org.pircbotx.TestUtils.java
public static String getRootName(Class aClass) { String name = aClass.getSimpleName(); if (StringUtils.endsWith(name, "Event")) return name.split("Event")[0]; else if (StringUtils.endsWith(name, "Listener")) return name.split("Listener")[0]; //Can't get anything, error out throw new IllegalArgumentException("Cannot get root of class name " + aClass.toString()); }
From source file:org.sakaiproject.contentreview.service.BaseContentReviewService.java
public String getWebhookUrl(Optional<String> customParam) { StringBuilder sb = new StringBuilder(); sb.append(serverConfigurationService.getServerUrl()); if (!StringUtils.endsWith(sb.toString(), "/")) { sb.append("/"); }//from ww w.j a v a 2 s . com return String.format(WEBHOOK_URL_TEMPLATE, sb.toString(), getProviderId()) + (customParam.isPresent() ? "&custom=" + customParam.get() : ""); }
From source file:org.sejda.cli.OptionDecriptionAndShortNameTest.java
@Test public void descriptionsHaveOptionalityInformation() { for (MethodAndOption eachMethod : extractOptionAnnotations()) { String description = eachMethod.getOption().description(); boolean hasOptionalityInfo = StringUtils.endsWith(description, "(optional)") || StringUtils.endsWith(description, "(required)"); if (!hasOptionalityInfo) { throw new SejdaRuntimeException( getTaskName() + " is missing optionality information [(optional) or (required)] on " + eachMethod.getMethodName()); }/* w ww . j a va 2s . com*/ } }
From source file:org.structr.core.property.Property.java
protected void determineSearchType(final SecurityContext securityContext, final String requestParameter, final Query query) throws FrameworkException { if (StringUtils.startsWith(requestParameter, "[") && StringUtils.endsWith(requestParameter, "]")) { // check for existance of range query string Matcher matcher = rangeQueryPattern.matcher(requestParameter); if (matcher.matches()) { if (matcher.groupCount() == 2) { String rangeStart = matcher.group(1); String rangeEnd = matcher.group(2); PropertyConverter inputConverter = inputConverter(securityContext); Object rangeStartConverted = rangeStart; Object rangeEndConverted = rangeEnd; if (inputConverter != null) { rangeStartConverted = inputConverter.convert(rangeStartConverted); rangeEndConverted = inputConverter.convert(rangeEndConverted); }//w ww .j av a 2 s .c o m query.andRange(this, rangeStartConverted, rangeEndConverted); return; } logger.log(Level.WARNING, "Unable to determine range query bounds for {0}", requestParameter); } else { if ("[]".equals(requestParameter)) { if (isIndexedWhenEmpty()) { // requestParameter contains only [], // which we use as a "not-blank" selector query.notBlank(this); return; } else { throw new FrameworkException(400, "PropertyKey " + jsonName() + " must be indexedWhenEmpty() to be used in not-blank search query."); } } else { throw new FrameworkException(422, "Invalid range pattern."); } } } if (requestParameter.contains(",") && requestParameter.contains(";")) { throw new FrameworkException(422, "Mixing of AND and OR not allowed in request parameters"); } if (requestParameter.contains(";")) { if (multiValueSplitAllowed()) { // descend into a new group query.and(); for (final String part : requestParameter.split("[;]+")) { query.or(this, convertSearchValue(securityContext, part)); } // ascend to the last group query.parent(); } else { query.or(this, convertSearchValue(securityContext, requestParameter)); } } else { query.and(this, convertSearchValue(securityContext, requestParameter)); } }
From source file:org.xwiki.lesscss.internal.compiler.DefaultLESSCompilerTest.java
@Test public void compileWhenError() throws Exception { // Mocks/*from ww w.j a va 2 s. c om*/ LESSCompilerException expectedException = new LESSCompilerException("an exception"); when(cachedLESSCompiler.compute(any(LESSResourceReference.class), anyBoolean(), anyBoolean(), anyBoolean(), any())).thenThrow(expectedException); // Test String result = mocker.getComponentUnderTest().compile(lessResourceReference, false, false, false); // Asserts assertTrue(StringUtils.startsWith(result, "/* org.xwiki.lesscss.compiler.LESSCompilerException: an exception")); assertTrue(StringUtils.endsWith(result, "*/")); verify(cache).set(eq(lessResourceReference), eq(skinReference), eq(colorThemeReference), eq(result)); verify(mocker.getMockedLogger()).error(eq("Error during the compilation of the resource [{}]."), eq(lessResourceReference), eq(expectedException)); }
From source file:org.zanata.dao.ProjectDAO.java
/** * Build BooleanQuery on single lucene field by splitting searchQuery with * white space.//from www. ja v a2s. com * * @param searchQuery * - query string, will escape special char * @param field * - lucene field * @param wildcard * - whether append wildcard to the end */ private BooleanQuery buildSearchFieldQuery(@Nonnull String searchQuery, @Nonnull String field, boolean wildcard) throws ParseException { BooleanQuery.Builder query = new BooleanQuery.Builder(); for (String searchString : searchQuery.split("\\s+")) { QueryParser parser = new QueryParser(field, new CaseInsensitiveWhitespaceAnalyzer()); //escape special character search String escaped = QueryParser.escape(searchString); escaped = wildcard && !StringUtils.endsWith(searchQuery, "*") ? escaped + "*" : escaped; query.add(parser.parse(escaped), BooleanClause.Occur.MUST); } return query.build(); }