本文整理汇总了Java中org.apache.commons.lang.StringUtils.strip方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.strip方法的具体用法?Java StringUtils.strip怎么用?Java StringUtils.strip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.StringUtils
的用法示例。
在下文中一共展示了StringUtils.strip方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStringPropertyValue
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Nullable
private String getStringPropertyValue(String propertyName) {
JsonStringLiteral stringLiteral = getPropertyValueOfType(propertyName, JsonStringLiteral.class);
if (stringLiteral != null) {
return StringUtils.strip(stringLiteral.getText(), "\"");
}
return null;
}
示例2: buildMatchPatterns
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
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));
}
}
}
}
示例3: copyResourceFolder
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
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);
}
}
}
}
示例4: generateWRAPIFileName
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
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";
}
示例5: checkFieldNotEmpty
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
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();
}
示例6: isSameLicenseType
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* 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;
}
示例7: strip
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* 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);
}