本文整理汇总了Java中org.apache.commons.lang3.StringUtils.getCommonPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.getCommonPrefix方法的具体用法?Java StringUtils.getCommonPrefix怎么用?Java StringUtils.getCommonPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.getCommonPrefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFilterUrl
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String getFilterUrl(HttpServletRequest request) {
String commonString = null;
for (String url : permissionModels) {
LOG.trace("url : {}", url);
if (commonString == null) {
LOG.trace("request uri contains url : {}",
request.getRequestURI().contains(url));
if (request.getRequestURI().contains(url)) {
String registeredUrl = getApplicationBasePath() + url;
LOG.trace("requested url : {}", request.getRequestURL().toString());
LOG.trace("registered url : {}", registeredUrl);
commonString = StringUtils
.getCommonPrefix(new String[] {request.getRequestURL().toString(), registeredUrl});
}
}
}
return commonString;
}
示例2: onAutocompleteResponse
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public void onAutocompleteResponse(String[] p_146406_1_)
{
if (this.waitingOnAutocomplete)
{
this.playerNamesFound = false;
this.foundPlayerNames.clear();
for (String s : p_146406_1_)
{
if (s.length() > 0)
{
this.foundPlayerNames.add(s);
}
}
String s1 = this.inputField.getText().substring(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false));
String s2 = StringUtils.getCommonPrefix(p_146406_1_);
if (s2.length() > 0 && !s1.equalsIgnoreCase(s2))
{
this.inputField.deleteFromCursor(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false) - this.inputField.getCursorPosition());
this.inputField.writeText(s2);
}
else if (this.foundPlayerNames.size() > 0)
{
this.playerNamesFound = true;
this.autocompletePlayerNames();
}
}
}