本文整理汇总了Java中org.apache.commons.lang3.StringUtils.endsWith方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.endsWith方法的具体用法?Java StringUtils.endsWith怎么用?Java StringUtils.endsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.endsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doValidate
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String doValidate(String input) {
String validationResult = super.doValidate(input);
if(StringUtils.isNotBlank(validationResult) || StringUtils.isBlank(input)) {
return validationResult;
}
try {
URI uri = new URI(input);
if (uri.getHost().equalsIgnoreCase("localhost") || uri.getHost().equalsIgnoreCase("127.0.0.1")) {
return this.displayName + " must not be localhost, since this gets resolved on the agents.";
}
if (!StringUtils.endsWith(input, "/go")) {
return this.displayName + " must be in format https://<GO_SERVER_URL>:<GO_SERVER_PORT>/go.";
}
} catch (URISyntaxException e) {
return this.displayName + " must be a valid URL (https://example.com:8154/go).";
}
return null;
}
示例2: doFilter
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String uri = httpRequest.getRequestURI().toString();
List<Object> forbidFiles = YiDuConstants.yiduConf.getList(YiDuConfig.FORBID_FILES);
for (Object object : forbidFiles) {
if (StringUtils.endsWith(uri, (String) object) && !StringUtils.endsWith(uri, "robots.txt")) {
HttpServletResponse httpResponse = (HttpServletResponse) response;
// 模拟不存在 返回404
httpResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
logger.warn("the template file was been request :" + uri);
return;
}
}
chain.doFilter(request, response);
}
示例3: clearCreatedFolders
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static void clearCreatedFolders(File root) {
File[] files = root.listFiles();
try {
for (File file : files) {
if (file.getName().equalsIgnoreCase("output")) {
FileUtils.deleteDirectory(file);
}
if (file.getName().equalsIgnoreCase("4-ComponentImplementations")) {
File[] child = file.listFiles();
for (File c : child) {
if (c.isFile())
FileUtils.forceDelete(c);
else {
File[] gChild = c.listFiles();
for (File gC : gChild) {
if (gC.isDirectory())
FileUtils.deleteDirectory(gC);
else if (!StringUtils.endsWith(gC.getName(), ".impl.xml"))
FileUtils.forceDelete(gC);
}
}
}
}
}
} catch (IOException e) {
System.out.println(e);
}
}
示例4: listAllProtoFile
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private File listAllProtoFile(File file) {
if (file != null) {
if (file.isDirectory()) {
File[] fileArray = file.listFiles();
if (fileArray != null) {
for (int i = 0; i < fileArray.length; i++) {
listAllProtoFile(fileArray[i]);
}
}
} else {
if (StringUtils.endsWith(file.getName(), "proto")) {
allProtoFile.add(file);
}
}
}
return null;
}
示例5: createResponse
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public MockResponse createResponse(MockRequest request) {
String action = request.getBodyParameters().get(S3RequestTransformer.ACTION);
if (StringUtils.equals(action, "requestPayment")) {
return new MockResponse("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<RequestPaymentConfiguration xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">\n"
+ " <Payer>Requester</Payer></RequestPaymentConfiguration>");
}
if (StringUtils.endsWith(action, "tagging")) {
return new MockResponse("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<Tagging xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">\n"
+ "<TagSet></TagSet></Tagging> ");
}
if (StringUtils.isEmpty(action)) {
return new MockResponse("");
}
return super.createResponse(request);
}
示例6: constructPatternId
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String constructPatternId(String patternResourcePath, String patternsPath, String templateName, String jsonDataFileName) {
final String patternPath = StringUtils.substringAfter(patternResourcePath, patternsPath + SLASH);
final StringBuilder patternIdBuilder = new StringBuilder();
if (StringUtils.endsWith(patternPath, HTML_EXT)) {
patternIdBuilder.append(StringUtils.substringBeforeLast(patternPath, HTML_EXT));
} else {
patternIdBuilder.append(patternPath);
}
if (StringUtils.isNotBlank(templateName)) {
patternIdBuilder.append(SLASH).append(templateName);
}
if (StringUtils.isNotBlank(jsonDataFileName)) {
final String patternFileName = StringUtils.substringAfterLast(patternPath, SLASH);
final String fileNameWithoutExt = StringUtils.substringBeforeLast(patternFileName, HTML_EXT);
final String dataFileSuffix = StringUtils.substringBetween(jsonDataFileName, fileNameWithoutExt
+ SELECTOR, DATA_EXT);
patternIdBuilder.append(SLASH).append(StringUtils.defaultString(dataFileSuffix, fileNameWithoutExt));
}
return StringUtils.replace(patternIdBuilder.toString(), SLASH, PATTERN_ID_REPLACEMENT);
}
示例7: encode
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* URL encode a path
*
* @param p Path
* @return URI encoded
* @see java.net.URLEncoder#encode(String, String)
*/
public static String encode(final String p) {
try {
final StringBuilder b = new StringBuilder();
final StringTokenizer t = new StringTokenizer(p, "/");
if(!t.hasMoreTokens()) {
return p;
}
if(StringUtils.startsWith(p, String.valueOf(Path.DELIMITER))) {
b.append(Path.DELIMITER);
}
while(t.hasMoreTokens()) {
b.append(URLEncoder.encode(t.nextToken(), "UTF-8"));
if(t.hasMoreTokens()) {
b.append(Path.DELIMITER);
}
}
if(StringUtils.endsWith(p, String.valueOf(Path.DELIMITER))) {
b.append(Path.DELIMITER);
}
// Because URLEncoder uses <code>application/x-www-form-urlencoded</code> we have to replace these
// for proper URI percented encoding.
return b.toString().replace("+", "%20").replace("*", "%2A").replace("%7E", "~");
}
catch(UnsupportedEncodingException e) {
return p;
}
}
示例8: getDbFieldName
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String getDbFieldName(PagedQueryParam param, String fieldName) {
Map<String, String> fieldMap = param.getFieldMap();
String dbFieldName = fieldMap.getOrDefault(fieldName, fieldName);
if (!StringUtils.startsWith(dbFieldName, "`")) {
dbFieldName = "`" + dbFieldName;
}
if (!StringUtils.endsWith(dbFieldName, "`")) {
dbFieldName = dbFieldName + "`";
}
return dbFieldName;
}
示例9: relativePath
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String relativePath(String source, String dest) {
Path sourcePath = Paths.get(outputDir.getAbsolutePath(), source).getParent();
Path destPath = Paths.get(outputDir.getAbsolutePath(), dest).getParent();
String path = sourcePath.relativize(destPath).toString();
if(StringUtils.isEmpty(path)) {
path = "./";
}
if(!StringUtils.endsWith(path, "/")) {
path += "/";
}
path = path.replace('\\', '/');
return path + StringUtils.removeEnd(FilenameUtils.getName(dest), ".ts");
}
示例10: parseTsvLine
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void parseTsvLine(ArrayList<String> destination, String source) {
final String[] split = StringUtils.splitPreserveAllTokens(source, "\t");
for (String s : split) {
if (StringUtils.startsWith(s, "\"") && StringUtils.endsWith(s, "\"")) {
destination.add(s.substring(1, s.length() - 1));
} else
destination.add(s);
}
}
示例11: id
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static final String id(String userid) {
if (StringUtils.endsWith(userid, Config.SEPARATOR + "profile")) {
return userid;
} else {
return userid != null ? userid + Config.SEPARATOR + "profile" : null;
}
}
示例12: toModuleJarFileArray
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private File[] toModuleJarFileArray() {
if (moduleLibDir.exists()
&& moduleLibDir.isFile()
&& moduleLibDir.canRead()
&& StringUtils.endsWith(moduleLibDir.getName(), ".jar")) {
return new File[]{
moduleLibDir
};
} else {
return convertFileCollectionToFileArray(
listFiles(moduleLibDir, new String[]{"jar"}, false)
);
}
}
示例13: handle
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
protected boolean handle(String input, String searchString, boolean ignoreCase) {
if (ignoreCase) {
return StringUtils.endsWithIgnoreCase(input, searchString);
} else {
return StringUtils.endsWith(input, searchString);
}
}
示例14: retrieveJsonDataFilesInFolder
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private List<String> retrieveJsonDataFilesInFolder(Resource filesParentResource, String name) {
final List<String> patternJsonDataFiles = Lists.newArrayList();
final Iterator<Resource> children = filesParentResource.listChildren();
while (children.hasNext()) {
final Resource childResource = children.next();
final String childResourceName = childResource.getName();
if (StringUtils.startsWith(childResourceName, name) && StringUtils.endsWith(childResourceName, PatternLabConstants.DATA_EXT)) {
patternJsonDataFiles.add(childResourceName);
}
}
return patternJsonDataFiles;
}
示例15: updateQiniu
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Updates the Qiniu preference by the specified request.
*
* @param request
* the specified http servlet request, for example,
*
* <pre>
* {
* "qiniuAccessKey": "",
* "qiniuSecretKey": "",
* "qiniuDomain": "",
* "qiniuBucket": ""
* }, see {@link org.b3log.solo.model.Option} for more details
* </pre>
*
* @param response
* the specified http servlet response
* @param context
* the specified http request context
* @throws Exception
* exception
*/
@RequestMapping(value = PREFERENCE_URI_PREFIX + "qiniu", method = RequestMethod.PUT)
public void updateQiniu(final HttpServletRequest request, final HttpServletResponse response, @RequestParam String body) throws Exception {
if (!userQueryService.isAdminLoggedIn(request)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
final JSONRenderer renderer = new JSONRenderer();
try {
body = URLDecoder.decode(body, "UTF-8");final JSONObject requestJSONObject = new JSONObject(body);
final String accessKey = requestJSONObject.optString(Option.ID_C_QINIU_ACCESS_KEY).trim();
final String secretKey = requestJSONObject.optString(Option.ID_C_QINIU_SECRET_KEY).trim();
String domain = requestJSONObject.optString(Option.ID_C_QINIU_DOMAIN).trim();
final String bucket = requestJSONObject.optString(Option.ID_C_QINIU_BUCKET).trim();
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
if (StringUtils.isNotBlank(domain) && !StringUtils.endsWith(domain, "/")) {
domain += "/";
}
final JSONObject accessKeyOpt = new JSONObject();
accessKeyOpt.put(Keys.OBJECT_ID, Option.ID_C_QINIU_ACCESS_KEY);
accessKeyOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_QINIU);
accessKeyOpt.put(Option.OPTION_VALUE, accessKey);
final JSONObject secretKeyOpt = new JSONObject();
secretKeyOpt.put(Keys.OBJECT_ID, Option.ID_C_QINIU_SECRET_KEY);
secretKeyOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_QINIU);
secretKeyOpt.put(Option.OPTION_VALUE, secretKey);
final JSONObject domainOpt = new JSONObject();
domainOpt.put(Keys.OBJECT_ID, Option.ID_C_QINIU_DOMAIN);
domainOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_QINIU);
domainOpt.put(Option.OPTION_VALUE, domain);
final JSONObject bucketOpt = new JSONObject();
bucketOpt.put(Keys.OBJECT_ID, Option.ID_C_QINIU_BUCKET);
bucketOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_QINIU);
bucketOpt.put(Option.OPTION_VALUE, bucket);
optionMgmtService.addOrUpdateOption(accessKeyOpt);
optionMgmtService.addOrUpdateOption(secretKeyOpt);
optionMgmtService.addOrUpdateOption(domainOpt);
optionMgmtService.addOrUpdateOption(bucketOpt);
ret.put(Keys.STATUS_CODE, true);
ret.put(Keys.MSG, langPropsService.get("updateSuccLabel"));
} catch (final ServiceException e) {
logger.error(e.getMessage(), e);
final JSONObject jsonObject = QueryResults.defaultResult();
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, e.getMessage());
}
renderer.render(request, response);
}