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


Java StringUtils.countMatches方法代码示例

本文整理汇总了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;
}
 
开发者ID:mvetsch,项目名称:JWT4B,代码行数:12,代码来源:TokenCheck.java

示例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);
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:26,代码来源:GradleScanManager.java

示例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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:INodeAttributeProvider.java

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

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

示例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(":"));
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:11,代码来源:GeneralInfo.java

示例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;
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:9,代码来源:GeneralInfo.java

示例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;
}
 
开发者ID:tf-dbis-uni-freiburg,项目名称:PRoST,代码行数:10,代码来源:Stats.java

示例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;
}
 
开发者ID:mvetsch,项目名称:JWT4B,代码行数:33,代码来源:PostBody.java

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


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