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

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

Introduction

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

Prototype

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

Source Link

Document

Gets the substring before the last occurrence of a separator.

Usage

From source file:de.jcup.egradle.core.text.JavaImportFinder.java

public Set<String> findImportedPackages(String text) {
    Set<String> set = new TreeSet<>();
    if (text == null) {
        return set;
    }/*from  www . j  a v a2 s .  c o m*/
    Matcher m = PATTERN.matcher(text);
    while (m.find()) {
        String fullImportName = m.group(1);
        String packageName = StringUtils.substringBeforeLast(fullImportName, ".");
        set.add(packageName);
    }
    return set;
}

From source file:kenh.expl.functions.SubstringBefore.java

public String process(String str, String open, boolean last) {
    if (last)/*from  w ww  . j  av a  2s.  c  om*/
        return StringUtils.substringBeforeLast(str, open);
    else
        return StringUtils.substringBefore(str, open);
}

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();
    //??/* w  ww .j a va2  s. c om*/
    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  .ja  v a 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 + "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:com.adobe.acs.commons.mcp.impl.processes.renovator.MovingResource.java

@Override
public void move(ReplicatorQueue replicatorQueue, ResourceResolver rr) throws MovingException {
    String destinationParent = StringUtils.substringBeforeLast(getDestinationPath(), "/");
    try {// w w w  .  j  a v  a 2s . c o m
        waitUntilResourceFound(rr, destinationParent);
        Session session = rr.adaptTo(Session.class);
        session.move(getSourcePath(), getDestinationPath());
        session.save();
    } catch (RepositoryException e) {
        throw new MovingException(getSourcePath(), e);
    }
}

From source file:com.sketchy.drawing.DrawingSize.java

public static DrawingSize parse(String string) {
    double width = 0;
    double height = 0;

    String upperCasedString = StringUtils.upperCase(string);
    String widthString = StringUtils.substringBefore(upperCasedString, "X").trim();
    String heightString = StringUtils.substringAfter(upperCasedString, "X").trim();

    widthString = StringUtils.substringBeforeLast(widthString, "MM");
    heightString = StringUtils.substringBefore(heightString, " ");
    heightString = StringUtils.substringBeforeLast(heightString, "MM");

    try {/*from   w  w  w. jav a  2s.  c  o  m*/
        width = Double.parseDouble(widthString);
        height = Double.parseDouble(heightString);
    } catch (Exception e) {
        throw new RuntimeException("Invalid Drawing Size! '" + string + "'");
    }

    if ((width <= 0) || (height <= 0)) {
        throw new RuntimeException("Invalid Drawing Size! '" + string + "'");
    }
    return new DrawingSize(width, height);
}

From source file:de.micromata.genome.gwiki.pagelifecycle_1_0.model.FileInfoWrapper.java

public String getCategoryString() {
    final String cat = StringUtils.substringBeforeLast(elementInfo.getId(), "/");
    return StringUtils.replace(cat, "/", " > ");
}

From source file:com.threewks.thundr.route.controller.Controller.java

static final String classNameForAction(String actionName) {
    return StringUtils.substringBeforeLast(actionName, ".");
}

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

public void genDaoImpl(String entityFullClassName) {

    DaoImplModel daoModel = new DaoImplModel();

    String entitySimpleClassName = StringUtils.substringAfterLast(entityFullClassName, ".");

    String path = StringUtils.substringBeforeLast(entityFullClassName, ".");
    path = StringUtils.substringBeforeLast(path, ".");

    String packageName = path + ".dao.impl";

    String interfacePackageName = path + ".dao";

    String className = entitySimpleClassName + "DaoImpl";

    daoModel.setPackageName(packageName);
    daoModel.setEntitySimpleClassName(entitySimpleClassName);
    daoModel.setInterfacePackageName(interfacePackageName);

    Map<String, Object> data = new HashMap<String, Object>();
    data.put("model", daoModel);
    String filePath = new String(
            GenConstant.project_path + "src/" + package2path(packageName) + "/" + className + ".java");
    super.generate(GenConstant.daoImpl_template_dir, data, filePath);
}

From source file:cc.recommenders.names.VmFieldName.java

@Override
public ITypeName getDeclaringType() {
    final String declaringType = StringUtils.substringBeforeLast(identifier, ".");
    return VmTypeName.get(declaringType);
}