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

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

Introduction

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

Prototype

public static String substringAfterLast(final String str, final String separator) 

Source Link

Document

Gets the substring after the last occurrence of a separator.

Usage

From source file:com.zht.common.generator.excute.impl.JSPGeneratorImplNew.java

@Override
public void genjsp_list(String entityFullClassName, String controllerNameSpace, GenEntity genEntity,
        List<GenEntityProperty> genEntityPropertyList) {
    JSPModelNew jSPModel = new JSPModelNew();
    //??//from  ww  w .ja  va 2s  .c o  m
    String entitySimpleClassName = StringUtils.substringAfterLast(entityFullClassName, ".");
    //
    String str = StringUtils.substringBeforeLast(entityFullClassName, ".");
    str = StringUtils.substringBeforeLast(str, ".");
    String firstLower = ZStrUtil.toLowerCaseFirst(entitySimpleClassName);
    jSPModel.setControllerNameSpace(controllerNameSpace);
    jSPModel.setEntityFullClassName(entityFullClassName);
    jSPModel.setEntitySimpleClassName(entitySimpleClassName);
    jSPModel.setGenEntity(genEntity);
    jSPModel.setGenEntityPropertyList(genEntityPropertyList);

    Map<String, Object> data = new HashMap<String, Object>();
    data.put("model", jSPModel);
    String filePath = new String(GenConstant.project_path + "WebRoot/WEB-INF/jsp/" + controllerNameSpace + "/"
            + firstLower + "List.jsp");
    super.generate(GenConstant.jsp_list_dataGrid_template_dir, data, filePath);
}

From source file:com.zht.common.codegen.excute.impl.JSPGeneratorImplNew.java

@Override
public void genjsp_list(String entityFullClassName, String controllerNameSpace, GenEntity genEntity,
        List<GenEntityProperty> genEntityPropertyList) {
    JSPModelNew jSPModel = new JSPModelNew();
    //??/*from   w  w  w  . j av a  2s  . co m*/
    String entitySimpleClassName = StringUtils.substringAfterLast(entityFullClassName, ".");
    //
    String str = StringUtils.substringBeforeLast(entityFullClassName, ".");
    str = StringUtils.substringBeforeLast(str, ".");
    String firstLower = ZStrUtil.toLowerCaseFirst(entitySimpleClassName);
    jSPModel.setControllerNameSpace(controllerNameSpace);
    jSPModel.setEntityFullClassName(entityFullClassName);
    jSPModel.setEntitySimpleClassName(entitySimpleClassName);
    jSPModel.setGenEntity(genEntity);
    jSPModel.setGenEntityPropertyList(genEntityPropertyList);

    Map<String, Object> data = new HashMap<String, Object>();
    data.put("model", jSPModel);
    String filePath = new String(GenConstant.project_path + "WebRoot/WEB-INF/jsp/" + controllerNameSpace + "/"
            + firstLower + "DataGrid.jsp");
    if (true == (genEntity.getIsTree())) {
        filePath = new String(GenConstant.project_path + "WebRoot/WEB-INF/jsp/" + controllerNameSpace + "/"
                + firstLower + "TreeGrid.jsp");
        super.generate(GenConstant.jsp_list_treeGrid_template_dir, data, filePath);
    } else {
        super.generate(GenConstant.jsp_list_dataGrid_template_dir, data, filePath);
    }

}

From source file:de.micromata.genome.gwiki.pagetemplates_1_0.wizard.AbstractStepWizardAction.java

public Object onRenderHeader() {
    GWikiElement actionPage = wikiContext.getCurrentElement();
    GWikiElementInfo info = actionPage.getElementInfo();
    String tabTitle = info.getProps().getStringValue(GWikiPropKeys.TITLE);

    if (tabTitle.startsWith("I{") == true) {
        tabTitle = wikiContext.getTranslatedProp(tabTitle);
    }/*from w w w.  j  av a 2  s  .c  o m*/
    String divAnchor = StringUtils.substringAfterLast(info.getId(), "/");
    wikiContext.append("<li><a href='#").append(divAnchor).append("'>").append(tabTitle).append("</a></li>");
    return noForward();
}

From source file:lolth.autohome.buy.AutohomeBuyInfoListTaskFetch.java

@Override
protected void parsePage(Document doc, FetchTask task) throws Exception {
    Elements lis = doc.select("li.price-item");

    for (Element li : lis) {
        AutohomeBuyInfoBean bean = new AutohomeBuyInfoBean();
        bean.setUrl(task.getUrl());// w  w  w  .  j  a  va 2 s.co m
        bean.setForumId(task.getExtra());

        // post id
        Elements id = li.select("div.price-share a.share");
        if (!id.isEmpty()) {
            String idStr = id.first().attr("data-target");
            idStr = StringUtils.substringAfterLast(idStr, "_");
            if (StringUtils.isBlank(idStr)) {
                continue;
            }

            bean.setId(idStr);
        }

        // 
        Elements user = li.select("div.user-name a");
        if (!user.isEmpty()) {
            String userUrl = user.first().absUrl("href");
            String userId = StringUtils.substringAfterLast(userUrl, "/");
            String userName = user.first().text();

            bean.setUserId(userId);
            bean.setUserUrl(userUrl);
            bean.setUserName(userName);
        }

        // ?
        Elements postTime = li.select("div.user-name span");
        if (!postTime.isEmpty()) {
            bean.setPostTime(StringUtils.trim(StringUtils.substringBefore(postTime.first().text(), "?")));
        }

        Elements dataLis = li.select("div.price-item-bd li");
        for (Element dataLi : dataLis) {
            String data = dataLi.text();

            if (StringUtils.startsWith(data, "")) {
                bean.setCar(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }

            if (StringUtils.startsWith(data, "")) {
                bean.setPrice(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }

            if (StringUtils.startsWith(data, "")) {
                bean.setGuidePrice(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }

            if (StringUtils.startsWith(data, "?")) {
                bean.setTotalPrice(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }

            if (StringUtils.startsWith(data, "")) {
                bean.setPurchaseTax(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }

            if (StringUtils.startsWith(data, "?")) {
                bean.setCommercialInsurance(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }

            if (StringUtils.startsWith(data, "")) {
                bean.setVehicleUseTax(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }
            if (StringUtils.startsWith(data, "")) {
                bean.setCompulsoryInsurance(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }
            if (StringUtils.startsWith(data, "")) {
                bean.setLicenseFee(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }
            if (StringUtils.startsWith(data, "?")) {
                bean.setPromotion(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }
            if (StringUtils.startsWith(data, "")) {
                bean.setBuyTime(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }
            if (StringUtils.startsWith(data, "")) {
                String area = StringUtils.trim(StringUtils.substringAfter(data, ""));
                String[] pAndC = StringUtils.splitByWholeSeparator(area, ",", 2);

                if (pAndC.length == 1) {
                    bean.setBuyProvince(pAndC[0]);
                    bean.setBuyCity(pAndC[0]);
                }

                if (pAndC.length == 2) {
                    bean.setBuyProvince(pAndC[0]);
                    bean.setBuyCity(pAndC[1]);
                }

            }
            if (StringUtils.startsWith(data, "")) {
                Elements level = dataLi.select("span.level");
                // 
                if (!level.isEmpty()) {
                    bean.setSellerComment(level.first().text());
                }

                // ?
                Elements seller = dataLi.select("a.title");
                if (!seller.isEmpty()) {
                    String sellerUrl = seller.first().absUrl("href");
                    String sellerName = seller.first().text();
                    String sellerId = StringUtils.substringAfterLast(sellerUrl, "/");

                    bean.setSellerId(sellerId);
                    bean.setSellerName(sellerName);
                    bean.setSellerUrl(sellerUrl);
                }

                // ?
                Elements sellerPhone = dataLi.select("em.phone-num");
                if (!sellerPhone.isEmpty()) {
                    bean.setSellerPhone(sellerPhone.first().text());
                }

                // ?
                // Elements sellerAddress = dataLi.select("em.phone-num");

            }
            if (StringUtils.startsWith(data, "?")) {
                bean.setBuyFeeling(StringUtils.trim(StringUtils.substringAfter(data, "")));
            }
        }

        log.debug("Bean : {}", bean);

        bean.persistOnNotExist();
    }
}

From source file:com.threewks.thundr.view.negotiating.strategy.FileExtensionNegotiationStrategy.java

@Override
public Negotiator<?> findNegotiator(HttpServletRequest req, NegotiatingView view,
        ViewNegotiatorRegistry viewNegotiatorRegistry) {
    String requestUri = req.getRequestURI();
    String extension = StringUtils.trimToEmpty(StringUtils.substringAfterLast(requestUri, "."));
    String mimeType = MimeTypes.lookupMimeType(extension);
    return viewNegotiatorRegistry.getNegotiator(mimeType);
}

From source file:io.wcm.handler.mediasource.dam.impl.CropRenditionHandler.java

/**
 * @param asset DAM asset/*ww w  .  j a  va  2 s .c  om*/
 * @param cropDimension Crop dimension
 */
public CropRenditionHandler(Asset asset, CropDimension cropDimension) {
    super(asset);
    this.cropDimension = cropDimension;
    assetFileExtension = StringUtils.substringAfterLast(asset.getName(), ".");
}

From source file:com.willwinder.universalgcodesender.connection.JSerialCommConnection.java

@Override
public void setUri(String uri) {
    try {//from w  w  w . j  ava2 s  . c o  m
        String portName = StringUtils.substringBetween(uri, ConnectionDriver.JSERIALCOMM.getProtocol(), ":");
        int baudRate = Integer.valueOf(StringUtils.substringAfterLast(uri, ":"));
        initSerialPort(portName, baudRate);
    } catch (Exception e) {
        throw new ConnectionException("Couldn't parse connection string " + uri, e);
    }
}

From source file:com.willwinder.universalgcodesender.connection.JSSCConnection.java

@Override
public void setUri(String uri) {
    try {/*from w  w w.j  ava 2 s.com*/
        portName = StringUtils.substringBetween(uri, ConnectionDriver.JSSC.getProtocol(), ":");
        baudRate = Integer.valueOf(StringUtils.substringAfterLast(uri, ":"));
    } catch (Exception e) {
        throw new ConnectionException("Couldn't parse connection string " + uri, e);
    }
}

From source file:de.micromata.genome.gdbfs.MimeUtils.java

/**
 * Gets the mime type from file./*  ww  w. j a v  a2  s  .c o  m*/
 *
 * @param fname the fname
 * @return the mime type from file
 */
public static String getMimeTypeFromFile(String fname) {
    if (fname == null) {
        return null;
    }
    return mimeTypes.get(StringUtils.substringAfterLast(fname, "."));
}

From source file:com.thinkbiganalytics.servicemonitor.support.ServiceMonitorCheckUtil.java

/**
 * get a map of the Service and any components that should be checked within that service.
 *//*from  www .jav a 2  s  .  c om*/
public static Map<String, List<String>> getMapOfServiceAndComponents(String services) {
    Map<String, List<String>> map = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
    if (StringUtils.isNotBlank(services)) {
        String finalServiceString = services;
        if (services.contains("/")) {
            int i = 1;
            String serviceName = null;
            for (String servicePart : StringUtils.split(services, "/")) {
                //service name is the first string before the /

                if (serviceName == null) {
                    if (servicePart.contains(",")) {
                        serviceName = StringUtils.substringAfterLast(servicePart, ",");
                    } else {
                        serviceName = servicePart;
                    }
                } else {
                    String components = "";
                    String origComponents = "";
                    if (servicePart.contains("]")) {
                        components = StringUtils.substringBeforeLast(servicePart, "]");
                        components = StringUtils.substringAfter(components, "[");
                        origComponents = "[" + components + "]";
                    } else {
                        components = StringUtils.substringBefore(servicePart, ",");
                        origComponents = components;
                    }
                    String[] componentsArr = StringUtils.split(components, ",");
                    map.put(serviceName, Arrays.asList(componentsArr));

                    //now remove these from the finalServiceString
                    finalServiceString = StringUtils.replace(finalServiceString,
                            serviceName + "/" + origComponents, "");

                    //reset serviceName
                    serviceName = StringUtils.substringAfterLast(servicePart, ",");

                }
                i++;
            }
        }

        for (String service : StringUtils.split(finalServiceString, ",")) {
            String serviceName = service;
            map.put(serviceName, Arrays.asList(new String[] { ALL_COMPONENTS }));
        }
    }
    return map;
}