Example usage for org.apache.commons.lang StringUtils endsWith

List of usage examples for org.apache.commons.lang StringUtils endsWith

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils endsWith.

Prototype

public static boolean endsWith(String str, String suffix) 

Source Link

Document

Check if a String ends with a specified suffix.

Usage

From source file:com.edgenius.wiki.render.filter.UserFilter.java

@Override
protected void replaceHTML(HTMLNode node, ListIterator<HTMLNode> nodeIter, RenderContext context) {
    if (node.getPair() == null) {
        AuditLogger.error("Unexpected case: Unable to find close </a> tag");
        return;/*  w w w .  j  a  v a2 s  . co  m*/
    }

    LinkModel link = new LinkModel();
    //we don't need view info,so just skip it
    link.fillToObject(node.getText(), null);

    //We put username into last part of anchor: /$CPAGE/up/admin
    String linkURL = link.getAnchor();
    if (StringUtils.endsWith(linkURL, "/")) {
        linkURL = StringUtils.removeEnd(linkURL, "/");
    }

    int idx = StringUtils.lastIndexOf(linkURL, "/");
    if (idx != -1) {
        String username = linkURL.substring(idx + 1);
        HTMLNode subnode = node.next();
        while (subnode != null && subnode != node.getPair()) {
            if (subnode.isTextNode())
                subnode.reset("", true);
            subnode = subnode.next();
        }
        node.getPair().reset("", true);
        String markupBorder = getSeparatorFilter(node);
        StringBuffer markup = new StringBuffer(markupBorder).append("@");
        markup.append(username);
        markup.append("@").append(markupBorder);

        node.reset(markup.toString(), true);
    }
}

From source file:com.htmlhifive.tools.jslint.util.ConfigBeanUtil.java

/**
 * ??./* w ww.  ja  va  2 s.  com*/
 * 
 * @param changedBean ??.
 * @return .
 */
public static String[] checkProperty(ConfigBean changedBean) {

    List<String> errorMessageList = new ArrayList<String>();
    if (changedBean.isUseOtherProject() && StringUtils.isEmpty(changedBean.getOtherProjectPath())) {
        errorMessageList.add(Messages.DM0001.format(Messages.DL0000.getText()));
    }
    if (!changedBean.isUseOtherProject()) {
        if (!PluginResourceUtils.isExistFile(changedBean.getJsLintPath())
                || !StringUtils.endsWith(changedBean.getJsLintPath(), JSLintPluginConstant.EXTENTION_JS)) {
            errorMessageList.add(Messages.EM0000.format(Messages.E0000.getText()));
        }
        if (StringUtils.isNotEmpty(changedBean.getOptionFilePath())
                && (!PluginResourceUtils.isExistFile(changedBean.getOptionFilePath()) || !StringUtils
                        .endsWith(changedBean.getOptionFilePath(), JSLintPluginConstant.EXTENTION_OPTION))) {
            errorMessageList.add(Messages.EM0000.format(Messages.E0001.getText()));
        }
    }
    return (String[]) errorMessageList.toArray(new String[errorMessageList.size()]);
}

From source file:gemlite.core.webapp.tools.ClusterController.java

/**
 * hoemDir//from w  w  w  .j a va2  s .c  o  m
U
 * /home/gemfire/order
 * @param homeDir
 * @return
 */
private String getParentDir(String homeDir) {
    if (StringUtils.endsWith(homeDir, "/"))
        homeDir = StringUtils.substring(homeDir, 0, homeDir.length() - 1);
    int index = StringUtils.lastIndexOf(homeDir, "/");
    String left = StringUtils.substring(homeDir, 0, index);
    return left;
}

From source file:com.enonic.cms.upgrade.task.datasource.DataSourceConverterUpgradeModel206.java

private boolean isElExpression(final String right) {
    return StringUtils.startsWithIgnoreCase(right, "${") && StringUtils.endsWith(right, "}");
}

From source file:com.inktomi.wxmetar.MetarParser.java

static boolean parseVisibility(String token, String nextToken, final Metar metar) {
    boolean rval = Boolean.FALSE;

    Matcher numberMatcher = NUMBER.matcher(token);
    Matcher fractionMatcher = FRACTION.matcher(nextToken);

    // Check for that fraction
    if (!StringUtils.endsWith(token, "SM") && numberMatcher.matches() && StringUtils.endsWith(nextToken, "SM")
            && fractionMatcher.matches()) {

        // add them together
        float visMiles = Float.parseFloat(token); // this should be something like 1 or 2

        // Assemble the fraction
        float visFraction = Float.parseFloat(fractionMatcher.group(1))
                / Float.parseFloat(fractionMatcher.group(2));

        metar.visibility = visMiles + visFraction;

        rval = Boolean.TRUE;/*from  w w w  .  ja v  a2 s  .co  m*/
    }

    // Get the SM out of the way
    if (StringUtils.endsWith(token, "SM")) {
        metar.visibility = Float.parseFloat(StringUtils.substring(token, 0, token.length() - 2));
    }

    return rval;
}

From source file:info.magnolia.cms.beans.config.URI2RepositoryMapping.java

public String getURI(Link uuidLink) {
    String uri = uuidLink.getPath();
    if (StringUtils.isNotEmpty(this.handlePrefix)) {
        uri = StringUtils.removeStart(uri, this.handlePrefix);
    }/*from  w w w  .  j a  va2s  .co m*/
    if (StringUtils.isNotEmpty(this.URIPrefix)) {
        uri = this.URIPrefix + "/" + uri;
    }

    String nodeDataName = uuidLink.getNodeDataName();
    String fileName = uuidLink.getFileName();
    String extension = uuidLink.getExtension();

    if (StringUtils.isNotEmpty(nodeDataName)) {
        uri += "/" + nodeDataName;
    }
    if (StringUtils.isNotEmpty(fileName)) {
        uri += "/" + fileName;
    }
    if (StringUtils.isNotEmpty(uri) && StringUtils.isNotEmpty(extension) && !StringUtils.endsWith(uri, "/")) {
        uri += "." + extension;
    }

    return cleanHandle(uri);
}

From source file:hydrograph.ui.expression.editor.util.ExpressionEditorUtil.java

public String lastString(String field, String seperator) {
    String result = Constants.EMPTY_STRING;
    if (StringUtils.isNotBlank(field)) {
        String[] strArray = StringUtils.split(field, seperator);
        result = strArray[strArray.length - 1];
        if (StringUtils.endsWith(result, Constants.SEMICOLON)) {
            result = StringUtils.remove(result, Constants.SEMICOLON);
        }/*  w  ww.ja va2s. c o m*/
    }
    return result;
}

From source file:com.steeleforge.aem.ironsites.xss.XSSUtil.java

/**
 * @param request/*from w  ww  .ja v  a  2  s  .  c o  m*/
 * @param policy
 * @return anti-samy policy path
 */
private static String findPolicyPath(SlingHttpServletRequest request, String policy) {
    String path = null;
    if (StringUtils.isBlank(policy)) {
        return path;
    }
    ResourceResolver resolver = request.getResourceResolver();
    Resource resource = request.getResource();
    String resourceType = resource.getResourceType();
    if (StringUtils.startsWith(policy, "/")) {
        path = policy;
    } else {
        if ((StringUtils.startsWith(resourceType, "./")) || (StringUtils.startsWith(resourceType, "../"))) {
            resourceType = ResourceUtil.normalize(resource.getResourceType() + "/" + resourceType);
        }
        path = resourceType + "/" + policy;
    }
    path = ResourceUtil.normalize(path);
    if (!StringUtils.endsWith(path, ".xml")) {
        path = path + ".xml";
    }
    if (null == resolver.getResource(path)) {
        LOG.debug("Could not find XSS policy at {}", path);
        path = null;
    }
    return path;
}

From source file:com.gst.infrastructure.documentmanagement.data.ImageData.java

private void setImageContentType(String filename) {
    fileExtension = ContentRepositoryUtils.IMAGE_FILE_EXTENSION.JPEG;

    if (StringUtils.endsWith(filename.toLowerCase(),
            ContentRepositoryUtils.IMAGE_FILE_EXTENSION.GIF.getValue())) {
        fileExtension = ContentRepositoryUtils.IMAGE_FILE_EXTENSION.GIF;
    } else if (StringUtils.endsWith(filename, ContentRepositoryUtils.IMAGE_FILE_EXTENSION.PNG.getValue())) {
        fileExtension = ContentRepositoryUtils.IMAGE_FILE_EXTENSION.PNG;
    }/*  ww w  . j av  a 2s  .  c  o  m*/
}

From source file:com.huawei.streaming.cql.CQLClient.java

private int processLine(String line) {
    int lastRet = 0;
    int ret = 0;//from  w  w w. ja  v  a  2  s  . co  m
    String command = "";
    for (String oneCmd : line.split(";")) {
        if (StringUtils.isBlank(oneCmd.trim())) {
            continue;
        }

        if (StringUtils.endsWith(oneCmd, "\\")) {
            command += StringUtils.chop(oneCmd) + ";";
            continue;
        } else {
            command += oneCmd;
        }

        if (StringUtils.isBlank(command)) {
            continue;
        }

        ret = processCQL(command, true);
        lastRet = ret;
    }
    return lastRet;
}