本文整理汇总了Java中org.apache.commons.lang.StringUtils.countMatches方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.countMatches方法的具体用法?Java StringUtils.countMatches怎么用?Java StringUtils.countMatches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.StringUtils
的用法示例。
在下文中一共展示了StringUtils.countMatches方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValidJWT
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static boolean isValidJWT(String jwt) {
if (StringUtils.countMatches(jwt, ".") != 2) {
return false;
}
try {
DecodedJWT decoded = JWT.decode(jwt);
decoded.getAlgorithm();
return true;
} catch (Exception exception) {}
return false;
}
示例2: populateDependenciesTree
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private void populateDependenciesTree(ScanTreeNode scanTreeNode, DataNode<? extends AbstractDependencyData> dataNode) {
String componentId = dataNode.getData().getExternalName();
int colonCount = StringUtils.countMatches(componentId, ":");
if (colonCount == 3) {
// <Group ID>:<Artifact ID>:<Classifier>:<Version>. The classifier should be ignored.
int secondColonIdx = componentId.indexOf(":", componentId.indexOf(":") + 1);
int thirdColonIdx = componentId.indexOf(":", secondColonIdx + 1);
componentId = componentId.substring(0, secondColonIdx) + componentId.substring(thirdColonIdx);
colonCount--;
}
if (colonCount != 2) {
if (StringUtils.isNotBlank(componentId)) {
logger.warn("Bad component ID structure. Should be <GroupID>:<ArtifactID>:<Version>, got '" + componentId + "'");
}
return;
}
ComponentDetailImpl scanComponent = new ComponentDetailImpl(componentId, getArtifactChecksum(dataNode));
ScanTreeNode treeNode = new ScanTreeNode(scanComponent);
for (DataNode child : dataNode.getChildren()) {
populateDependenciesTree(treeNode, child);
}
scanTreeNode.add(treeNode);
}
示例3: getPathElements
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@VisibleForTesting
String[] getPathElements(String path) {
path = path.trim();
if (path.charAt(0) != Path.SEPARATOR_CHAR) {
throw new IllegalArgumentException("It must be an absolute path: " +
path);
}
int numOfElements = StringUtils.countMatches(path, Path.SEPARATOR);
if (path.length() > 1 && path.endsWith(Path.SEPARATOR)) {
numOfElements--;
}
String[] pathElements = new String[numOfElements];
int elementIdx = 0;
int idx = 0;
int found = path.indexOf(Path.SEPARATOR_CHAR, idx);
while (found > -1) {
if (found > idx) {
pathElements[elementIdx++] = path.substring(idx, found);
}
idx = found + 1;
found = path.indexOf(Path.SEPARATOR_CHAR, idx);
}
if (idx < path.length()) {
pathElements[elementIdx] = path.substring(idx);
}
return pathElements;
}
示例4: createJoinedAppHomeRelativePath
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
String createJoinedAppHomeRelativePath(String scriptRelPath) {
int depth = StringUtils.countMatches(scriptRelPath, "/");
if (depth == 0) {
return "";
}
List<String> appHomeRelativePath = new ArrayList<String>(depth);
for (int i = 0; i < depth; i++) {
appHomeRelativePath.add("..");
}
return Joiner.on(windows ? "\\" : "/").join(appHomeRelativePath);
}
示例5: getTrimmedErrorMessageString
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private static String getTrimmedErrorMessageString(String errMessage, int errorCount) {
StringBuilder trimmedErrMsgSb = new StringBuilder();
trimmedErrMsgSb.append(StringUtils.substringBeforeLast(
errMessage.substring(0, ERROR_MESSAGE_MAX_LENGTH), BulkUploadMgr.MESSAGE_DELIMITER));
int remainingErrorCount = errorCount - (StringUtils.countMatches(trimmedErrMsgSb.toString(), MESSAGE_DELIMITER) + 1);
trimmedErrMsgSb.append(BulkUploadMgr.MESSAGE_DELIMITER).append(CharacterConstants.SPACE).append(ERRORS_TRUNCATED_MSG).append(CharacterConstants.O_BRACKET).append(ERROR_COUNT_MSG).append(remainingErrorCount).append(CharacterConstants.C_BRACKET);
return trimmedErrMsgSb.toString();
}
示例6: getArtifactId
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public String getArtifactId() {
if (!isValid()) {
return "";
}
int indexOfColon = componentId.indexOf(":");
if (StringUtils.countMatches(componentId, ":") == 1) {
return componentId.substring(0, indexOfColon);
}
return componentId.substring(indexOfColon + 1, componentId.lastIndexOf(":"));
}
示例7: isValid
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private boolean isValid() {
int colonCount = StringUtils.countMatches(componentId, ":");
if (colonCount != 1 && colonCount != 2) {
log.warn("Bad component ID structure. Should be <GroupID>:<ArtifactID>:<Version> or <ArtifactID>:<Version>, got '" + componentId + "'");
return false;
}
return true;
}
示例8: arePrefixesActive
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public boolean arePrefixesActive() {
for(String propertyName : this.tableNames) {
if(StringUtils.countMatches(propertyName, "_") > 2)
return false;
}
return true;
}
示例9: getJWTFromPostBody
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public KeyValuePair getJWTFromPostBody() {
int from = 0;
int index = body.indexOf("&") == -1 ? body.length() : body.indexOf("&");
int parameterCount = StringUtils.countMatches(body, "&") + 1;
List<KeyValuePair> postParameterList = new ArrayList<KeyValuePair>();
for (int i = 0; i < parameterCount; i++) {
String parameter = body.substring(from, index);
parameter = parameter.replace("&", "");
String[] parameterSplit = parameter.split(Pattern.quote("="));
if (parameterSplit.length > 1) {
String name = parameterSplit[0];
String value = parameterSplit[1];
postParameterList.add(new KeyValuePair(name, value));
from = index;
index = body.indexOf("&", index + 1);
if (index == -1) {
index = body.length();
}
}
}
for (String keyword : tokenKeyWords) {
for (KeyValuePair postParameter : postParameterList) {
if (keyword.equals(postParameter.getName())
&& TokenCheck.isValidJWT(postParameter.getValue())) {
return postParameter;
}
}
}
return null;
}
示例10: getCountMatchesInCollectiont
import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private int getCountMatchesInCollectiont(String expectedValue, Collection<String> values) {
int count = 0;
for (String content : values) {
count += StringUtils.countMatches(content, expectedValue);
}
return count;
}