Java Code Examples for org.apache.commons.lang.StringUtils.strip()

The following are Jave code examples for showing how to use strip() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: magento2-phpstorm-plugin   File: ComposerPackageModelImpl.java   Source Code and License Vote up 7 votes
@Nullable
private String getStringPropertyValue(String propertyName) {
    JsonStringLiteral stringLiteral = getPropertyValueOfType(propertyName, JsonStringLiteral.class);

    if (stringLiteral != null) {
        return StringUtils.strip(stringLiteral.getText(), "\"");
    }

    return null;
}
 
Example 2
Project: soundwave   File: EsServiceMapping.java   Source Code and License Vote up 6 votes
public void buildMatchPatterns() {
  if (StringUtils.isNotEmpty(this.getValue())) {
    patterns.clear();
    String[] expressions = this.getValue().split(",");
    for (String expression : expressions) {
      if (StringUtils.isNotEmpty(expression)) {
        String formalizedPattern = StringUtils.strip(StringUtils.strip(expression, " "), "/");
        patterns.add(Pattern.compile(formalizedPattern));
      }
    }
  }
}
 
Example 3
Project: wrdocletbase   File: Util.java   Source Code and License Vote up 6 votes
public static void copyResourceFolder(String resourceFolder, String destDir)
		throws IOException {
	final File jarFile = new File(Util.class.getProtectionDomain()
			.getCodeSource().getLocation().getPath());
	if (jarFile.isFile()) { // Run with JAR file
		resourceFolder = StringUtils.strip(resourceFolder, "/");
		final JarFile jar = new JarFile(jarFile);
		// gives ALL entries in jar
		final Enumeration<JarEntry> entries = jar.entries();
		while (entries.hasMoreElements()) {
			JarEntry element = entries.nextElement();
			final String name = element.getName();
			// filter according to the path
			if (name.startsWith(resourceFolder + "/")) {
				String resDestDir = Util.combineFilePath(destDir,
						name.replaceFirst(resourceFolder + "/", ""));
				if (element.isDirectory()) {
					File newDir = new File(resDestDir);
					if (!newDir.exists()) {
						boolean mkdirRes = newDir.mkdirs();
						if (!mkdirRes) {
							logger.error("Failed to create directory "
									+ resDestDir);
						}
					}
				} else {
					InputStream inputStream = null;
					try {
						inputStream = Util.class.getResourceAsStream("/"
								+ name);
						if (inputStream == null) {
							logger.error("No resource is found:" + name);
						} else {
							Util.outputFile(inputStream, resDestDir);
						}

						/* compress js files */
						inputStream = Util.class.getResourceAsStream("/"
								+ name);
						compressor.compress(inputStream, name, destDir);
					} finally {
						if (inputStream != null) {
							inputStream.close();
						}
					}
				}
			}
		}
		jar.close();
	} else { // Run with IDE
		final URL url = Util.class.getResource(resourceFolder);
		if (url != null) {
			try {
				final File src = new File(url.toURI());
				File dest = new File(destDir);
				FileUtils.copyDirectory(src, dest);
				Util.compressFilesInDir(src, destDir);
			} catch (URISyntaxException ex) {
				logger.error(ex);
			}
		}
	}
}
 
Example 4
Project: htmldoclet4jdk8   File: HtmlDoclet.java   Source Code and License Vote up 5 votes
protected String generateWRAPIFileName(String container, String url,
		String methodType) {
	return StringUtils.strip(
			(container + '-' + url + (methodType == null ? '-'
					: '-' + methodType + '-')).replace('/', '-')
					.replace('\\', '-').replace(':', '-').replace('*', '-')
					.replace('?', '-').replace('"', '-').replace('<', '-')
					.replace('>', '-').replace('|', '-').replace('{', '-')
					.replace('}', '-'), "-")
			+ ".html";
}
 
Example 5
Project: warrior-jenkins-plugin   File: WarriorPluginBuilder.java   Source Code and License Vote up 5 votes
private FormValidation checkFieldNotEmpty(String value, String field) {
    value = StringUtils.strip(value);
    if (value == null || value.equals("")) {
        return FormValidation.error(field + " is required.");
    }
    return FormValidation.ok();
}
 
Example 6
Project: htmldoclet4jdk7   File: HtmlDoclet.java   Source Code and License Vote up 5 votes
protected String generateWRAPIFileName(String container, String url,
		String methodType) {
	return StringUtils.strip(
			(container + '-' + url + (methodType == null ? '-'
					: '-' + methodType + '-')).replace('/', '-')
					.replace('\\', '-').replace(':', '-').replace('*', '-')
					.replace('?', '-').replace('"', '-').replace('<', '-')
					.replace('>', '-').replace('|', '-').replace('{', '-')
					.replace('}', '-'), "-")
			+ ".html";
}
 
Example 7
Project: lams   File: License.java   Source Code and License Vote up 3 votes
/**
    * Is this license and another license the same license? The licenseID and name fields
    * are checked, with the name fields having any leading or trailing spaces stripped
    * before comparison. If both licenseID fields are null, then they are assumed to be
    * different licenses.
    * 
    * This is to be used when importing designs, to see if licenses match. If the id and
    * name fields match, then the imported design is linked to the license record. If
    * they don't match, the design should be attached to the "Other" license.
    * 
    * The user selects the license based on the name, hence we have chosen to check the name.
    * 
    * @param otherLicense
    * @return true if they are the same type of license
    */
   public boolean isSameLicenseType(License otherLicense) {
if (licenseID != null && licenseID.equals(otherLicense.getLicenseID())) {
    String name1 = (name != null ? StringUtils.strip(name) : "");
    String name2 = (otherLicense.getName() != null ? StringUtils.strip(otherLicense.getName()) : "");
    return name1.equals(name2);
}
return false;
   }
 
Example 8
Project: athena   File: DefaultInfluxDbMetricsRetriever.java   Source Code and License Vote up 2 votes
/**
 * Strips special bracket from the full name.
 *
 * @param fullName full name
 * @return bracket stripped string
 */
private String strip(String fullName) {
    return StringUtils.strip(StringUtils.strip(fullName, BRACKET_START), BRACKET_END);
}