Java Code Examples for org.apache.commons.lang3.StringUtils.getCommonPrefix()

The following are Jave code examples for showing how to use getCommonPrefix() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: cas-fortress-example   File: FortressDecisionVoter.java   View Source Code Vote up 6 votes
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;
}
 
Example 2
Project: DecompiledMinecraft   File: GuiChat.java   View Source Code Vote up 5 votes
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();
        }
    }
}
 
Example 3
Project: BaseClient   File: GuiChat.java   View Source Code Vote up 5 votes
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();
        }
    }
}
 
Example 4
Project: BaseClient   File: GuiChat.java   View Source Code Vote up 5 votes
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();
        }
    }
}