本文整理汇总了Java中org.apache.commons.lang3.StringUtils.removeEnd方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.removeEnd方法的具体用法?Java StringUtils.removeEnd怎么用?Java StringUtils.removeEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.removeEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toSpace
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Map API JSON Space and history values to a bean.
*/
private Space toSpace(final String baseUrl, final Map<String, Object> spaceRaw, final String history, final CurlProcessor processor)
throws MalformedURLException {
final Space space = toSpaceLight(spaceRaw);
final String hostUrl = StringUtils.removeEnd(baseUrl, new java.net.URL(baseUrl).getPath());
// Check the activity if available
final Matcher matcher = ACTIVITY_PATTERN.matcher(StringUtils.defaultString(history));
if (matcher.find()) {
// Activity has been found
final SpaceActivity activity = new SpaceActivity();
getAvatar(processor, activity, hostUrl + matcher.group(1));
activity.setAuthor(toSimpleUser(matcher.group(2), matcher.group(3)));
activity.setPageUrl(hostUrl + matcher.group(4));
activity.setPage(matcher.group(5));
activity.setMoment(matcher.group(6));
space.setActivity(activity);
}
return space;
}
示例2: validateSpace
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Validate the space configuration and return the corresponding details.
*
* @param parameters
* the space parameters.
* @return Space's details.
*/
protected Space validateSpace(final Map<String, String> parameters) throws IOException {
final String baseUrl = StringUtils.removeEnd(parameters.get(PARAMETER_URL), "/");
CurlRequest[] requests = null;
try {
// Validate the space key and get activity
requests = validateSpaceInternal(parameters, "/rest/api/space/",
"/plugins/recently-updated/changes.action?theme=social&pageSize=1&spaceKeys=");
// Parse the space details
final Map<String, Object> details = objectMapper.readValue(requests[0].getResponse(), TYPE_SPACE_REF);
// Build the full space object
return toSpace(baseUrl, details, requests[1].getResponse(), requests[0].getProcessor());
} finally {
// Close the processor
closeQuietly(requests);
}
}
示例3: validateSpaceInternal
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Validate the space configuration and return the corresponding details.
*/
protected CurlRequest[] validateSpaceInternal(final Map<String, String> parameters, final String... partialRequests) {
final String url = StringUtils.removeEnd(parameters.get(PARAMETER_URL), "/");
final String space = ObjectUtils.defaultIfNull(parameters.get(PARAMETER_SPACE), "0");
final CurlRequest[] result = new CurlRequest[partialRequests.length];
for (int i = 0; i < partialRequests.length; i++) {
result[i] = new CurlRequest(HttpMethod.GET, url + partialRequests[i] + space, null);
result[i].setSaveResponse(true);
}
// Prepare the sequence of HTTP requests to Confluence
final ConfluenceCurlProcessor processor = new ConfluenceCurlProcessor();
authenticate(parameters, processor);
// Execute the requests
processor.process(result);
// Get the space if it exists
if (result[0].getResponse() == null) {
// Invalid couple PKEY and id
throw new ValidationJsonException(PARAMETER_SPACE, "confluence-space", parameters.get(PARAMETER_SPACE));
}
return result;
}
示例4: concatenate
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Concatenate all elements in the given collection to form a regex pattern.
*
* @param requiredValues the required values
* @param caseInsensitive the case insensitive
* @return the pattern
*/
public static Pattern concatenate(final Collection<String> requiredValues, final boolean caseInsensitive) {
final StringBuilder builder = new StringBuilder(requiredValues.size());
for (final String requiredValue : requiredValues) {
builder.append('(').append(requiredValue).append(")|");
}
final String pattern = StringUtils.removeEnd(builder.toString(), "|");
if (isValidRegex(pattern)) {
return Pattern.compile(pattern, caseInsensitive ? Pattern.CASE_INSENSITIVE : 0);
}
return null;
}
示例5: getAuthorsArticlesPagedAuthorId
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Gets the request author id from the specified request URI.
*
* @param requestURI
* the specified request URI
* @return author id
*/
private static String getAuthorsArticlesPagedAuthorId(final String requestURI) {
String authorIdAndPageNum = requestURI.substring((Latkes.getContextPath() + "/articles/authors/").length());
if (authorIdAndPageNum.endsWith("/")) {
authorIdAndPageNum = StringUtils.removeEnd(authorIdAndPageNum, "/");
}
return StringUtils.substringBefore(authorIdAndPageNum, "/");
}
示例6: getValidResult
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* @desc 根据BindingResult获取数据校验信息
*
* @author liuliang
*
* @param br
* @return
*/
public static Result getValidResult(BindingResult br){
if(!br.hasErrors()){
return ResultUtil.success(new Result());
}else{
List<FieldError> list = br.getFieldErrors();
StringBuilder sb = new StringBuilder();
for (FieldError e: list) {
sb.append(e.getField()).append(":").append(e.getDefaultMessage()).append(";");
}
String errorMessage = StringUtils.removeEnd(sb.toString(),";");
logger.error("参数异常,errorMessage:{}",errorMessage);
return ResultUtil.fail(ErrorCode.REQUEST_PARA_ERROR,errorMessage,new Result());
}
}
示例7: removeTrailingSemicolons
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Remove all trailing ";" from SQL command
*
* @param sql
* the sql command
* @return the sql command without the trailing ";"
*/
private String removeTrailingSemicolons(String sql) {
sql = sql.trim();
// Remove the trailing ";", there may be some blanks, so we always trim
while (sql.endsWith(";")) {
sql = StringUtils.removeEnd(sql, ";");
sql = sql.trim();
}
return sql;
}
示例8: cleanContentTailHtml
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String cleanContentTailHtml(String content) {
String[] tags = {"<p>\r\n</p>", "<p></p>", "<p><br></p>", "<br>"};
String result = content;
for (String t :
tags) {
result = StringUtils.removeEnd(result, t);
}
return result;
}
示例9: parseSerializedCon
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private IWaySegmentConnection parseSerializedCon(String serializedCon) { // (100000833,960301,101021339,"{15,4,22,2,9,19,11,13,12,1,10,3}",24)
if (serializedCon == null) {
return null;
}
String stripedSerializedCon = StringUtils.removeStart(serializedCon, "(");
stripedSerializedCon = StringUtils.removeEnd(stripedSerializedCon, ")");
stripedSerializedCon = stripedSerializedCon.substring(0, stripedSerializedCon.indexOf("}")); // ignore everything after access types
stripedSerializedCon = stripedSerializedCon.replace("\"", ""); //100000833,960301,101021339,{15,4,22,2,9,19,11,13,12,1,10,3,24
String[] splitCons = stripedSerializedCon.split("\\{"); //[100000833,960301,101021339,, 15,4,22,2,9,19,11,13,12,1,10,3,24]
String[] tokens = splitCons[0].split(ARRAYVALUESEP);
String[] accessTypeIdsArray = splitCons[1].split(ARRAYVALUESEP); //[15, 4, 22, 2, 9, 19, 11, 13, 12, 1, 10, 3, 24]
// String s1 = StringUtils.removePattern(stripedSerializedCon, "\\\"\\{[0-9,]*\\}\\\"");
int[] accessTypeIds = new int[accessTypeIdsArray.length];
int i = 0;
for (String accessTypeId : accessTypeIdsArray) {
accessTypeIds[i++] = Integer.parseInt(accessTypeId);
}
Set<Access> accessTypesTow = Access.getAccessTypes(accessTypeIds);
return new WaySegmentConnection(
Long.parseLong(tokens[0]),
Long.parseLong(tokens[1]),
Long.parseLong(tokens[2]),
accessTypesTow);
}
示例10: getConfluenceResource
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Return a Jenkins's resource. Return <code>null</code> when the resource
* is not found.
*/
protected String getConfluenceResource(final CurlProcessor processor, final String url, final String resource) {
// Get the resource using the preempted authentication
final CurlRequest request = new CurlRequest(HttpMethod.GET, StringUtils.removeEnd(url, "/") + resource, null);
request.setSaveResponse(true);
// Execute the requests
processor.process(request);
processor.close();
return request.getResponse();
}
示例11: getNodeNameFromPath
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Extracts the node from path
*
* @param path string containing the path
* @return the node without parent path
*/
protected String getNodeNameFromPath(final String path) {
// TODO define the output for all the cases (e.g. paths with trailing slash)
final String normalizedPath = StringUtils.removeEnd(path, "/"); // remove trailing slash in case of folders
final int pos = normalizedPath.lastIndexOf('/');
if (pos != -1) {
return normalizedPath.substring(pos + 1, normalizedPath.length());
}
return normalizedPath;
}
示例12: testCreateContainer
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Test
public void testCreateContainer() throws Exception {
final String temp = StringUtils.removeEnd(System.getProperty("java.io.tmpdir"), File.separator);
final String s = System.getProperty("file.separator");
final Path file = new Path("/container", EnumSet.of(Path.Type.directory));
file.attributes().setRegion("region");
assertEquals(String.format("%s%su%sregion%scontainer", temp, s, s, s),
new DefaultTemporaryFileService().create("u", file).getAbsolute());
}
示例13: testPathTooLong
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Test
public void testPathTooLong() {
final String temp = StringUtils.removeEnd(System.getProperty("java.io.tmpdir"), File.separator);
final String testPathDirectory = "/Lorem/ipsum/dolor/sit/amet/consetetur/sadipscing/elitr/sed/diam/nonumy/eirmod/tempor/invidunt/ut/labore/et/dolore/magna/aliquyam/erat/sed/diam/voluptua/At/vero/eos/et/accusam/et/justo/duo/dolores/et/ea/rebum/Stet/clita/kasd/gubergren/no/sea";
final String testPathFile = "takimata.sanc";
final String testPath = String.format("%s/%s", testPathDirectory, testPathFile);
final String testPathMD5 = DigestUtils.md5Hex(testPathDirectory);
final Path file = new Path(testPath, EnumSet.of(Path.Type.file));
file.attributes().setVersionId("2");
final Local local = new DefaultTemporaryFileService().create("UID", file);
final String localFile = local.getAbsolute();
assertNotEquals(String.format("%s/%s%s/2/%s", temp, "UID", testPathDirectory, testPathFile).replace('/', File.separatorChar), localFile);
assertEquals(String.format("%s/%s/%s/2/%s", temp, "UID", testPathMD5, testPathFile).replace('/', File.separatorChar), localFile);
}
示例14: getServerAddress
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Return the server address without a trailing slash. E.g. http://col.letturedametropolitana.it
* @return
*/
public String getServerAddress() {
if (serverAddress==null) {
serverAddress = StringUtils.removeEnd(configuration.getString("config/paths/serverAddress", "serverAddressUnset"), "/");
}
return serverAddress;
}
示例15: getNextTag
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Find and check the next tag marker, validate the syntax, find the corresponding {@link Processor} and return the
* corresponding context of this match.Is <code>null</code> when no tag has been found.
*/
private TagContext getNextTag(final Map<String, Processor<?>> tags, final int start, final int end) {
final int nextTag = input.indexOf("{{", start);
if (nextTag == -1 || nextTag >= end) {
// End of template
return null;
}
final int nextEndTag = input.indexOf("}}", nextTag);
if (nextEndTag == -1 || nextEndTag >= end) {
// Opening tag syntax
throw new IllegalStateException("Invalid opening tag syntax '{{' without '}}' at position " + nextTag);
}
if (nextEndTag - nextTag > MAX_TAG_LENGTH) {
// Too long tag
throw new IllegalStateException(
"Too long (max is " + MAX_TAG_LENGTH + " tag " + input.substring(nextTag + 2, nextTag + 30) + "...}} found at position " + start);
}
final String tag = input.substring(nextTag + 2, nextEndTag);
final String tagClean = StringUtils.removeEnd(tag, "/");
if (StringUtils.trimToEmpty(tagClean).length() == 0) {
// Empty tag
throw new IllegalStateException("Empty tag {{}} found at position " + start);
}
final Processor<?> processor = tags.get(tagClean);
if (processor == null) {
throw new IllegalStateException("Not mapped template tag {{" + tagClean + "}} found at position " + nextTag);
}
return new TagContext(nextTag, processor, tag, tagClean.length() == tag.length());
}