org.apache.commons.lang3.StringUtils#removeEndIgnoreCase ( )源码实例Demo

下面列出了org.apache.commons.lang3.StringUtils#removeEndIgnoreCase ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: app-runner   文件: MavenRunnerFactory.java
public static Optional<MavenRunnerFactory> createIfAvailable(Config config) {
    HomeProvider homeProvider = config.javaHomeProvider();

    StringBuffer out = new StringBuffer();
    InvocationRequest request = new DefaultInvocationRequest()
        .setOutputHandler((str) -> out.append(str).append(" - "))
        .setErrorHandler((str) -> out.append(str).append(" - "))
        .setShowVersion(true)
        .setGoals(Collections.singletonList("--version"))
        .setBaseDirectory(new File("."));
    try {
        MavenRunner.runRequest(request, homeProvider);
        String versionInfo = StringUtils.removeEndIgnoreCase(out.toString(), " - ");
        return Optional.of(new MavenRunnerFactory(homeProvider, versionInfo));
    } catch (Exception e) {
        return Optional.empty();
    }
}
 
源代码2 项目: fess   文件: PluginHelper.java
public Artifact getArtifactFromFileName(final ArtifactType artifactType, final String filename, final String url) {
    final String baseName = StringUtils.removeEndIgnoreCase(filename, ".jar");
    final List<String> nameList = new ArrayList<>();
    final List<String> versionList = new ArrayList<>();
    boolean isName = true;
    for (final String value : baseName.split("-")) {
        if (isName && value.length() > 0 && value.charAt(0) >= '0' && value.charAt(0) <= '9') {
            isName = false;
        }
        if (isName) {
            nameList.add(value);
        } else {
            versionList.add(value);
        }
    }
    return new Artifact(nameList.stream().collect(Collectors.joining("-")), versionList.stream().collect(Collectors.joining("-")), url);
}
 
源代码3 项目: java-platform   文件: QQOauthPlugin.java
@Override
public OauthUser getOauthUser(String accessToken) {
	Assert.hasText(accessToken);
	Map<String, Object> parameterMap = new HashMap<>();
	parameterMap.put("access_token", accessToken);
	String responseString = get("https://graph.qq.com/oauth2.0/me", parameterMap);
	responseString = StringUtils.trim(responseString);
	responseString = StringUtils.removeStartIgnoreCase(responseString, "callback(");
	responseString = StringUtils.removeEndIgnoreCase(responseString, ");");
	JSONObject jsonObject = JSON.parseObject(responseString);

	String openid = jsonObject.getString("openid");
	OauthUser oauthUser = oauthUserService.findByOauthPluginIdAndUserId(getId(), openid);
	if (oauthUser == null) {
		Map<String, Object> apiMap = new HashMap<>();
		apiMap.put("access_token", accessToken);
		apiMap.put("oauth_consumer_key", jsonObject.getString("client_id"));
		apiMap.put("openid", openid);
		String apiString = get("https://graph.qq.com/user/get_user_info", apiMap);
		JSONObject userObject = JSON.parseObject(apiString);

		oauthUser = oauthUserService.newEntity();
		oauthUser.setOauthPluginId(getId());
		oauthUser.setUserId(openid);
		oauthUser.setUsername(openid);
		oauthUser.setName(userObject.getString("nickname"));
		oauthUser.setAvatarUrl(userObject.getString("figureurl_qq_2"));
	}

	return oauthUser;
}
 
源代码4 项目: para   文件: Utils.java
/**
 * Quick and dirty singular to plural conversion.
 * @param singul a word
 * @return a guess of its plural form
 */
public static String singularToPlural(String singul) {
	if (!StringUtils.isAsciiPrintable(singul)) {
		return singul;
	}
	return (StringUtils.isBlank(singul) || singul.endsWith("es") || singul.endsWith("ies")) ? singul :
			(singul.endsWith("s") ? singul + "es" :
			(singul.endsWith("y") ? StringUtils.removeEndIgnoreCase(singul, "y") + "ies" :
									singul + "s"));
}
 
源代码5 项目: windup   文件: RenderLinkDirective.java
private String getPrettyPathForFile(FileModel fileModel)
{
    if (fileModel instanceof JavaClassFileModel)
    {
        JavaClassFileModel jcfm = (JavaClassFileModel) fileModel;
        if (jcfm.getJavaClass() == null)
            return fileModel.getPrettyPathWithinProject();
        else
            return jcfm.getJavaClass().getQualifiedName();
    }
    else if (fileModel instanceof ReportResourceFileModel)
    {
        return "resources/" + fileModel.getPrettyPath();
    }
    else if (fileModel instanceof JavaSourceFileModel)
    {
        JavaSourceFileModel javaSourceModel = (JavaSourceFileModel) fileModel;
        String filename = StringUtils.removeEndIgnoreCase(fileModel.getFileName(), ".java");
        String packageName = javaSourceModel.getPackageName();
        return packageName == null || packageName.isEmpty() ? filename : packageName + "." + filename;
    }
    // This is used for instance when showing unparsable files in the Issues Report.
    else if (fileModel instanceof ArchiveModel)
    {
        return fileModel.getPrettyPath();
    }
    else
    {
        return fileModel.getPrettyPathWithinProject();
    }
}
 
源代码6 项目: vscrawler   文件: RemoveEndIgnoreCase.java
@Override
protected String handle(String input, String second) {
    return StringUtils.removeEndIgnoreCase(input, second);
}
 
源代码7 项目: app-runner   文件: AppManager.java
public static String nameFromUrl(String gitUrl) {
    String name = StringUtils.removeEndIgnoreCase(StringUtils.removeEnd(gitUrl, "/"), ".git");
    name = name.substring(Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')) + 1);
    return name;
}
 
源代码8 项目: para   文件: SecurityUtils.java
/**
 * Validates the signature of the request.
 * @param incoming the incoming HTTP request containing a signature
 * @param secretKey the app's secret key
 * @return true if the signature is valid
 */
public static boolean isValidSignature(HttpServletRequest incoming, String secretKey) {
	if (incoming == null || StringUtils.isBlank(secretKey)) {
		return false;
	}
	String auth = incoming.getHeader(HttpHeaders.AUTHORIZATION);
	String givenSig = StringUtils.substringAfter(auth, "Signature=");
	String sigHeaders = StringUtils.substringBetween(auth, "SignedHeaders=", ",");
	String credential = StringUtils.substringBetween(auth, "Credential=", ",");
	String accessKey = StringUtils.substringBefore(credential, "/");

	if (StringUtils.isBlank(auth)) {
		givenSig = incoming.getParameter("X-Amz-Signature");
		sigHeaders = incoming.getParameter("X-Amz-SignedHeaders");
		credential = incoming.getParameter("X-Amz-Credential");
		accessKey = StringUtils.substringBefore(credential, "/");
	}

	Set<String> headersUsed = new HashSet<>(Arrays.asList(sigHeaders.split(";")));
	Map<String, String> headers = new HashMap<>();
	for (Enumeration<String> e = incoming.getHeaderNames(); e.hasMoreElements();) {
		String head = e.nextElement().toLowerCase();
		if (headersUsed.contains(head)) {
			headers.put(head, incoming.getHeader(head));
		}
	}

	Map<String, String> params = new HashMap<>();
	for (Map.Entry<String, String[]> param : incoming.getParameterMap().entrySet()) {
		params.put(param.getKey(), param.getValue()[0]);
	}

	String path = incoming.getRequestURI();
	String endpoint = StringUtils.removeEndIgnoreCase(incoming.getRequestURL().toString(), path);
	String httpMethod = incoming.getMethod();
	InputStream entity;
	try {
		entity = new BufferedRequestWrapper(incoming).getInputStream();
		if (entity.available() <= 0) {
			entity = null;
		}
	} catch (IOException ex) {
		logger.error(null, ex);
		entity = null;
	}

	Signer signer = new Signer();
	Map<String, String> sig = signer.sign(httpMethod, endpoint, path, headers, params, entity, accessKey, secretKey);

	String auth2 = sig.get(HttpHeaders.AUTHORIZATION);
	String recreatedSig = StringUtils.substringAfter(auth2, "Signature=");

	boolean signaturesMatch = StringUtils.equals(givenSig, recreatedSig);
	if (Config.getConfigBoolean("debug_request_signatures", false)) {
		logger.info("Incoming client signature for request {} {}: {} == {} calculated by server, matching: {}",
				httpMethod, path, givenSig, recreatedSig, signaturesMatch);
	}
	return signaturesMatch;
}
 
源代码9 项目: gocd   文件: SystemEnvironment.java
private String trimMegaFromSize(String sizeInMega) {
    return StringUtils.removeEndIgnoreCase(sizeInMega, "M");
}
 
源代码10 项目: dhis2-core   文件: TextUtils.java
/**
 * Removes the last occurrence of the word "or" from the given string,
 * including potential trailing spaces, case-insensitive.
 *
 * @param string the string.
 * @return the chopped string.
 */
public static String removeLastOr( String string )
{
    string = StringUtils.stripEnd( string, " " );

    return StringUtils.removeEndIgnoreCase( string, "or" );
}
 
源代码11 项目: dhis2-core   文件: TextUtils.java
/**
 * Removes the last occurrence of the word "and" from the given string,
 * including potential trailing spaces, case-insensitive.
 *
 * @param string the string.
 * @return the chopped string.
 */
public static String removeLastAnd( String string )
{
    string = StringUtils.stripEnd( string, " " );

    return StringUtils.removeEndIgnoreCase( string, "and" );
}
 
源代码12 项目: dhis2-core   文件: TextUtils.java
/**
 * Removes the last occurrence of comma (",") from the given string,
 * including potential trailing spaces.
 *
 * @param string the string.
 * @return the chopped string.
 */
public static String removeLastComma( String string )
{
    string = StringUtils.stripEnd( string, " " );

    return StringUtils.removeEndIgnoreCase( string, "," );
}
 
源代码13 项目: dhis2-core   文件: TextUtils.java
/**
 * Removes the last occurrence of the the given string, including potential
 * trailing spaces.
 *
 * @param string the string, without potential trailing spaces.
 * @param remove the text to remove.
 * @return the chopped string.
 */
public static String removeLast( String string, String remove )
{
    string = StringUtils.stripEnd( string, " " );

    return StringUtils.removeEndIgnoreCase( string,  remove );
}
 
 同类方法