Example usage for org.apache.commons.lang3 StringUtils chomp

List of usage examples for org.apache.commons.lang3 StringUtils chomp

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils chomp.

Prototype

@Deprecated
public static String chomp(final String str, final String separator) 

Source Link

Document

Removes separator from the end of str if it's there, otherwise leave it alone.

NOTE: This method changed in version 2.0.

Usage

From source file:org.apache.struts2.osgi.FelixOsgiHost.java

protected void addExportedPackages(Properties strutsConfigProps, Properties configProps) {
    String[] rootPackages = StringUtils.split((String) strutsConfigProps.get("scanning.package.includes"), ",");
    ResourceFinder finder = new ResourceFinder(StringUtils.EMPTY);
    List<String> exportedPackages = new ArrayList<String>();
    //build a list of subpackages
    for (String rootPackage : rootPackages) {
        try {//w w w. j a v a  2  s  .com
            String version = null;
            if (rootPackage.indexOf(";") > 0) {
                String[] splitted = rootPackage.split(";");
                rootPackage = splitted[0];
                version = splitted[1];
            }
            Map<URL, Set<String>> subpackagesMap = finder
                    .findPackagesMap(StringUtils.replace(rootPackage.trim(), ".", "/"));
            for (Map.Entry<URL, Set<String>> entry : subpackagesMap.entrySet()) {
                URL url = entry.getKey();
                Set<String> packages = entry.getValue();

                //get version if not set
                if (StringUtils.isBlank(version))
                    version = getVersion(url);

                if (packages != null) {
                    for (String subpackage : packages) {
                        exportedPackages.add(subpackage + "; version=" + version);
                    }
                }
            }
        } catch (IOException e) {
            if (LOG.isErrorEnabled())
                LOG.error("Unable to find subpackages of [#0]", e, rootPackage);
        }
    }

    //make a string with the exported packages and add it to the system properties
    if (!exportedPackages.isEmpty()) {
        String systemPackages = (String) configProps.get(Constants.FRAMEWORK_SYSTEMPACKAGES);
        systemPackages = StringUtils.chomp(systemPackages, ",") + "," + StringUtils.join(exportedPackages, ",");
        configProps.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages);
    }
}

From source file:org.lockss.devtools.plugindef.EditableDefinablePlugin.java

public Map getHashFilterRules() {
    logger.info("Retrieving the AU filter rules");
    HashMap rules = new HashMap();
    Iterator it = definitionMap.keySet().iterator();
    for (int ix = 1; it.hasNext(); ++ix) {
        String key = (String) it.next();
        if (key.endsWith(DefinableArchivalUnit.SUFFIX_FILTER_RULE)) {
            String mimeType = StringUtils.chomp(key, DefinableArchivalUnit.SUFFIX_FILTER_RULE);
            logger.debug("MIME type " + ix + ": " + key + " maps to: " + definitionMap.getMapElement(key));
            rules.put(mimeType, definitionMap.getMapElement(key));
        }//from   w  ww .  j  av  a 2  s .com
    }
    return rules;
}

From source file:org.lockss.devtools.plugindef.EditableDefinablePlugin.java

public Map getHashFilterFactories() {
    logger.info("Retrieving the hash filter factories");
    Map rules = new HashMap();
    Iterator it = definitionMap.keySet().iterator();
    for (int ix = 1; it.hasNext(); ++ix) {
        String key = (String) it.next();
        if (key.endsWith(DefinableArchivalUnit.SUFFIX_HASH_FILTER_FACTORY)
                // XXX hack until hash filter key changed
                && !key.endsWith(DefinableArchivalUnit.SUFFIX_CRAWL_FILTER_FACTORY)) {
            String mimeType = StringUtils.chomp(key, DefinableArchivalUnit.SUFFIX_HASH_FILTER_FACTORY);
            logger.debug("MIME type " + ix + ": " + key + " maps to: " + definitionMap.getMapElement(key));
            rules.put(mimeType, definitionMap.getMapElement(key));
        }/*  w w  w  . j  av a 2s . c  o m*/
    }
    return rules;
}

From source file:org.lockss.devtools.plugindef.EditableDefinablePlugin.java

public Map getCrawlFilterFactories() {
    logger.info("Retrieving the crawl filter factories");
    Map rules = new HashMap();
    Iterator it = definitionMap.keySet().iterator();
    for (int ix = 1; it.hasNext(); ++ix) {
        String key = (String) it.next();
        if (key.endsWith(DefinableArchivalUnit.SUFFIX_CRAWL_FILTER_FACTORY)) {
            String mimeType = StringUtils.chomp(key, DefinableArchivalUnit.SUFFIX_CRAWL_FILTER_FACTORY);
            logger.debug("MIME type " + ix + ": " + key + " maps to: " + definitionMap.getMapElement(key));
            rules.put(mimeType, definitionMap.getMapElement(key));
        }//from   w w w .jav  a2  s.c o  m
    }
    return rules;
}

From source file:org.xwiki.rendering.internal.wiki.XWikiWikiModel.java

/**
 * Creates the query string that can be added to an image URL to resize the image on the server side.
 *
 * @param imageParameters image parameters, including width and height then they are specified
 * @return the query string to be added to an image URL in order to resize the image on the server side
 *//*from   w  w  w .  ja v a  2  s. co m*/
private StringBuilder getImageURLQueryString(Map<String, String> imageParameters) {
    String width = StringUtils.chomp(getImageDimension(WIDTH, imageParameters), PIXELS);
    String height = StringUtils.chomp(getImageDimension(HEIGHT, imageParameters), PIXELS);
    boolean useHeight = StringUtils.isNotEmpty(height) && StringUtils.isNumeric(height);
    StringBuilder queryString = new StringBuilder();
    if (StringUtils.isEmpty(width) || !StringUtils.isNumeric(width)) {
        // Width is unspecified or is not measured in pixels.
        if (useHeight) {
            // Height is specified in pixels.
            queryString.append('&').append(HEIGHT).append('=').append(height);
        } else {
            // If image width and height are unspecified or if they are not expressed in pixels then limit the image
            // size to best fit the rectangle specified in the configuration (keeping aspect ratio).
            int widthLimit = this.xwikiRenderingConfiguration.getImageWidthLimit();
            if (widthLimit > 0) {
                queryString.append('&').append(WIDTH).append('=').append(widthLimit);
            }
            int heightLimit = this.xwikiRenderingConfiguration.getImageHeightLimit();
            if (heightLimit > 0) {
                queryString.append('&').append(HEIGHT).append('=').append(heightLimit);
            }
            if (widthLimit > 0 && heightLimit > 0) {
                queryString.append("&keepAspectRatio=").append(true);
            }
        }
    } else {
        // Width is specified in pixels.
        queryString.append('&').append(WIDTH).append('=').append(width);
        if (useHeight) {
            // Height is specified in pixels.
            queryString.append('&').append(HEIGHT).append('=').append(height);
        }
    }
    return queryString;
}