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:io.wcm.handler.media.markup.ResponsiveImageMediaMarkupBuilder.java
@Override public final boolean isValidMedia(HtmlElement<?> element) { if (element instanceof Image) { Image img = (Image) element; // if it's a responsive image, we don't need the src attribute set return imageSourceIsNotEmpty(img) && !StringUtils.contains(img.getCssClass(), MediaNameConstants.CSS_DUMMYIMAGE); }/*from w ww .ja v a2s . c om*/ return false; }
From source file:ch.cyberduck.core.irods.IRODSSession.java
protected String getRegion() { if (StringUtils.contains(host.getRegion(), ':')) { return StringUtils.splitPreserveAllTokens(host.getRegion(), ':')[0]; }//from w ww . j av a2 s . c o m return host.getRegion(); }
From source file:com.amazon.alexa.avs.http.MultipartParser.java
private boolean isPartJSON(Map<String, String> headers) { String contentType = getMultipartHeaderValue(headers, HttpHeaders.CONTENT_TYPE); return StringUtils.contains(contentType, ContentTypes.JSON); }
From source file:io.wcm.devops.conga.plugins.aem.util.ContentPackageUtil.java
/** * Merges description and file header to a single string. * @param description Description from configuration - may be null * @param fileHeader File header from file - may be null * @return Merged description or null if all input is null *///from w w w. j a v a 2s . c o m private static String mergeDescriptionFileHeader(String description, FileHeaderContext fileHeader) { boolean hasDescription = StringUtils.isNotBlank(description); boolean hasFileHeader = fileHeader != null && !fileHeader.getCommentLines().isEmpty(); if (!hasDescription && !hasFileHeader) { return null; } StringBuilder result = new StringBuilder(); if (hasDescription) { result.append(description); } if (hasDescription && hasFileHeader) { result.append("\n---\n"); } if (hasFileHeader) { @SuppressWarnings("null") String fileHeaderString = StringUtils .trim(fileHeader.getCommentLines().stream().filter(line -> !StringUtils.contains(line, "*****")) .map(line -> StringUtils.trim(line)).collect(Collectors.joining("\n"))); result.append(fileHeaderString); } return result.toString(); }
From source file:ch.cyberduck.core.irods.IRODSSession.java
protected String getResource() { if (StringUtils.contains(host.getRegion(), ':')) { return StringUtils.splitPreserveAllTokens(host.getRegion(), ':')[1]; }// w w w. j a v a2s . c o m return StringUtils.EMPTY; }
From source file:com.thruzero.common.core.fs.SubstitutionVisitorTest.java
private void validateTest(final File tempTestFile, final String originalContents) { String substitutedContents = null; try {//from www .ja va 2 s. c o m substitutedContents = FileUtilsExt.readFromFile(tempTestFile); } catch (FileUtilsException e1) { // ignore } assertNotNull("Could not read substitution file after walk.", substitutedContents); assertFalse("Substitution failed - files are same before and after substitution.", StringUtils.equals(originalContents, substitutedContents)); assertNull("Substitution failed - files contain substitution variables.", StringUtils.substringBetween(substitutedContents, "${", "}")); assertFalse("Substitution failed - files contain remnants of substitution variables.", StringUtils.contains(substitutedContents, "${")); assertFalse("Substitution failed - files contain remnants of substitution variables.", StringUtils.contains(substitutedContents, "$")); assertFalse("Substitution failed - files contain remnants of substitution variables.", StringUtils.contains(substitutedContents, "}")); }
From source file:io.wcm.handler.url.impl.Externalizer.java
/** * Mangle the namespaces in the given path for usage in sling-based URLs. * <p>//from ww w . j ava2 s . c o m * Example: /path/jcr:content to /path/_jcr_content * </p> * @param path Path to mangle * @return Mangled path */ public static String mangleNamespaces(String path) { if (!StringUtils.contains(path, NAMESPACE_SEPARATOR)) { return path; } Matcher matcher = NAMESPACE_PATTERN.matcher(path); StringBuffer sb = new StringBuffer(); while (matcher.find()) { String replacement = MANGLED_NAMESPACE_PREFIX + matcher.group(1) + MANGLED_NAMESPACE_SUFFIX; matcher.appendReplacement(sb, replacement); } matcher.appendTail(sb); return sb.toString(); }
From source file:io.wcm.devops.conga.plugins.aem.postprocessor.ContentPackageOsgiConfigPostProcessor.java
/** * Generate OSGi configuration for all feature and run modes. * @param model Provisioning Model/* w w w .jav a2 s . com*/ * @param contentPackage Content package * @param rootPath Root path * @param fileHeader File header * @param context Post processor context * @throws IOException */ private void generateOsgiConfigurations(Model model, ContentPackage contentPackage, String rootPath, FileHeaderContext fileHeader, PostProcessorContext context) throws IOException { ProvisioningUtil.visitOsgiConfigurations(model, new ConfigConsumer<Void>() { @Override public Void accept(String path, Dictionary<String, Object> properties) throws IOException { String contentPath = rootPath + (StringUtils.contains(path, "/") ? "." : "/") + path; context.getLogger().info(" Include " + contentPath); // write configuration to temporary file File tempFile = File.createTempFile(NAME, ".config"); try (OutputStream os = new FileOutputStream(tempFile)) { ConfigurationHandler.write(os, properties); } try { FileContext tempFileContext = new FileContext().file(tempFile).charset(StandardCharsets.UTF_8); // apply file header applyFileHeader(tempFileContext, fileHeader, context); // write configuration to content package try (InputStream is = new BufferedInputStream(new FileInputStream(tempFile))) { contentPackage.addFile(contentPath, is, "text/plain;charset=" + StandardCharsets.UTF_8.name()); } } finally { // remove temporary file tempFile.delete(); } return null; } }); }
From source file:com.dchq.docker.volume.driver.controller.DockerVolumeDriverControllerIntegrationTests.java
@Test public void unmountTest() { String name = RandomStringUtils.randomAlphabetic(6); CreateRequest request = new CreateRequest(); request.setName(name);// w w w . j a va 2 s. c o m String response = restTemplate.postForObject(baseUrl + DockerVolumeDriverController.CREATE, request, String.class); Assert.assertNotNull(response); Assert.assertEquals(response, "{\"Err\":\"\"}"); MountRequest unmountRequest = new MountRequest(); unmountRequest.setName(name); String unmountResponse = restTemplate.postForObject(baseUrl + DockerVolumeDriverController.UNMOUNT, unmountRequest, String.class); Assert.assertNotNull(unmountResponse); Assert.assertTrue(StringUtils.contains(unmountResponse, "\"Err\":\"\"")); logger.info("Response [{}]", unmountResponse); }
From source file:com.glaf.survey.service.impl.SurveyServiceImpl.java
@Transactional public void save(Survey survey) { if (survey.getId() == null) { survey.setId(idGenerator.nextId()); survey.setCreateDate(new Date()); surveyMapper.insertSurvey(survey); } else {/*from w w w . j av a2s. c o m*/ surveyItemMapper.deleteSurveyItemBySurveyId(survey.getId()); surveyMapper.updateSurvey(survey); } if (survey.getItems() != null && !survey.getItems().isEmpty()) { for (SurveyItem item : survey.getItems()) { item.setId(idGenerator.nextId()); item.setSurveyId(survey.getId()); surveyItemMapper.insertSurveyItem(item); } } else { if (StringUtils.isNotEmpty(survey.getContent())) { int sort = 0; StringTokenizer token = new StringTokenizer(survey.getContent()); while (token.hasMoreTokens()) { String tmp = token.nextToken(); if (StringUtils.contains(tmp, "=")) { SurveyItem item = new SurveyItem(); item.setId(idGenerator.nextId()); item.setSurveyId(survey.getId()); item.setValue(tmp.substring(0, tmp.indexOf("="))); item.setName(tmp.substring(tmp.indexOf("=") + 1, tmp.length())); item.setSort(sort++); surveyItemMapper.insertSurveyItem(item); } } } } }