当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.endsWith方法代码示例

本文整理汇总了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;
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:22,代码来源:GoServerUrlField.java

示例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);
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:19,代码来源:ForbidFilter.java

示例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);
	}
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:29,代码来源:GenerationUtils.java

示例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;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:18,代码来源:Proto2Java.java

示例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);
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:20,代码来源:DefaultS3Responder.java

示例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);
}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:21,代码来源:PatternLabUtils.java

示例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;
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:35,代码来源:URIEncoder.java

示例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;
}
 
开发者ID:liuxx001,项目名称:bird-java,代码行数:13,代码来源:PagedQueryProvider.java

示例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");
}
 
开发者ID:sdadas,项目名称:spring2ts,代码行数:14,代码来源:TSOutputProcessor.java

示例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);
    }

}
 
开发者ID:BigBrassBand,项目名称:remittanceparse,代码行数:11,代码来源:RemittanceParser.java

示例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;
	}
}
 
开发者ID:Erudika,项目名称:scoold,代码行数:8,代码来源:Profile.java

示例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)
        );
    }
}
 
开发者ID:alibaba,项目名称:jvm-sandbox,代码行数:15,代码来源:ModuleJarLoader.java

示例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);
    }
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:9,代码来源:EndsWith.java

示例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;
}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:13,代码来源:PatternPatternCategoryFactoryImpl.java

示例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);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:81,代码来源:PreferenceConsole.java


注:本文中的org.apache.commons.lang3.StringUtils.endsWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。