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:net.iharding.utils.FileUtils.java

/**
 * ?????/*from w  ww. ja va 2 s .c o m*/
 * @param fileName
 */
public static String getFileType(String fileName) {
    return StringUtils.substringAfterLast(fileName, ".");
}

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

public void genDaoInterface(String entityFullClassName) {
    DaoInterfaceModel daoModel = new DaoInterfaceModel();
    //??//from  ww w  .j  a  v a  2  s  .c  o  m
    String entitySimpleName = StringUtils.substringAfterLast(entityFullClassName, ".");
    //
    String str = StringUtils.substringBeforeLast(entityFullClassName, ".");
    str = StringUtils.substringBeforeLast(str, ".");
    String packageName = str + ".dao";

    daoModel.setPackageName(packageName);
    daoModel.setEntitySimpleClassName(entitySimpleName);

    String className = "I" + entitySimpleName + "Dao";

    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.daoInterface_template_dir, data, filePath);
}

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

@Override
public void genServiceInterface(String entityFullClassName) {

    ServiceInterfaceModel serviceModel = new ServiceInterfaceModel();
    //??//from  w  ww  .  j  ava  2s  . c  o m
    String entitySimpleName = StringUtils.substringAfterLast(entityFullClassName, ".");
    //
    String str = StringUtils.substringBeforeLast(entityFullClassName, ".");
    str = StringUtils.substringBeforeLast(str, ".");
    String packageName = str + ".service";

    serviceModel.setPackageName(packageName);
    serviceModel.setEntitySimpleClassName(entitySimpleName);
    serviceModel.setEntityFullClassName(entityFullClassName);

    String className = "I" + entitySimpleName + "Service";

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

From source file:com.quatico.base.aem.test.api.values.Template.java

public String getLabel() {
    return StringUtils.substringAfterLast(getName(), "/");
}

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

@Override
public void generatorModel(String entityFullClassName, GenEntity genEntity,
        List<GenEntityProperty> genEntityPropertyList) {

    HIberEntityModel hiberModel = new HIberEntityModel();
    //??//  www.j ava  2 s.  com
    String entitySimpleName = StringUtils.substringAfterLast(entityFullClassName, ".");
    //
    String str = StringUtils.substringBeforeLast(entityFullClassName, ".");
    str = StringUtils.substringBeforeLast(str, ".");
    String packageName = str + ".model";

    hiberModel.setPackageName(packageName);
    hiberModel.setEntitySimpleClassName(entitySimpleName);
    hiberModel.setEntityFullClassName(entityFullClassName);

    hiberModel.setGenEntity(genEntity);

    hiberModel.setGenEntityPropertyList(genEntityPropertyList);

    String className = entitySimpleName;

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

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

@Override
public void generatorAction(String entityFullClassName, String controllerNameSpace, GenEntity genEntity,
        List<GenEntityProperty> genEntityPropertyList) {

    ActionModel actionModel = new ActionModel();
    //??/*from www.  j  a v a  2  s  .co  m*/
    String entitySimpleName = StringUtils.substringAfterLast(entityFullClassName, ".");
    //
    String str = StringUtils.substringBeforeLast(entityFullClassName, ".");
    str = StringUtils.substringBeforeLast(str, ".");
    String packageName = str + ".web";
    String servicePackageName = str + ".service";

    actionModel.setPackageName(packageName);
    actionModel.setEntitySimpleClassName(entitySimpleName);
    actionModel.setServicePackageName(servicePackageName);
    actionModel.setEntityFullClassName(entityFullClassName);
    actionModel.setControllerNameSpace(controllerNameSpace);

    actionModel.setGenEntityPropertyList(genEntityPropertyList);
    actionModel.setGenEntity(genEntity);

    String className = entitySimpleName + "Controller";

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

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

@Override
public void generatorAction(String entityFullClassName, String controllerNameSpace, GenEntity genEntity,
        List<GenEntityProperty> genEntityPropertyList) {

    ActionModel actionModel = new ActionModel();
    //??/*from   w ww. j av a2s .co  m*/
    String entitySimpleName = StringUtils.substringAfterLast(entityFullClassName, ".");
    //
    String str = StringUtils.substringBeforeLast(entityFullClassName, ".");
    str = StringUtils.substringBeforeLast(str, ".");
    String packageName = str + ".web";
    String servicePackageName = str + ".service";

    actionModel.setPackageName(packageName);
    actionModel.setEntitySimpleClassName(entitySimpleName);
    actionModel.setServicePackageName(servicePackageName);
    actionModel.setEntityFullClassName(entityFullClassName);
    actionModel.setControllerNameSpace(controllerNameSpace);

    actionModel.setGenEntityPropertyList(genEntityPropertyList);
    actionModel.setGenEntity(genEntity);

    String className = entitySimpleName + "Controller";

    Map<String, Object> data = new HashMap<String, Object>();
    data.put("model", actionModel);
    String filePath = new String(
            GenConstant.project_path + "src/" + package2path(packageName) + "/" + className + ".java");
    if (genEntity == null || genEntityPropertyList == null) {
        super.generate(GenConstant.action_template_just_from_main_dir, data, filePath);
    } else {
        super.generate(GenConstant.action_template_dir, data, filePath);
    }
}

From source file:com.lianggzone.freemarkerutils.utils.FreeMarkerFactory.java

/**
 * ?ftl?,???HTML/* w w w.  ja v  a2 s . c  om*/
 * @param ftlPath   FTL?,["c:/liang/template.ftl"]
 * @param filePath  ?HMTL["d:/liang/lianggzone.html"]
 * @param data      Map?
 * @param isCreate4NoExists      ??
 * @return
 */
public static boolean createHTML(String ftlPath, String filePath, Map<String, Object> data,
        boolean isCreate4NoExists) throws IOException {
    String fileDir = StringUtils.substringBeforeLast(filePath, "/"); // ?HMTL
    //      String fileName = StringUtils.substringAfterLast(filePath, "/");  // ?HMTL??
    String ftlDir = StringUtils.substringBeforeLast(ftlPath, "/"); // ?FTL
    String ftlName = StringUtils.substringAfterLast(ftlPath, "/"); // ?FTL?? 

    //?
    if (isCreate4NoExists) {
        File realDirectory = new File(fileDir);
        if (!realDirectory.exists()) {
            realDirectory.mkdirs();
        }
    }

    // step1 ?freemarker?
    Configuration freemarkerCfg = new Configuration(Configuration.VERSION_2_3_23);
    // step2 freemarker??()
    freemarkerCfg.setDirectoryForTemplateLoading(new File(ftlDir));
    // step3 freemarker??
    freemarkerCfg.setEncoding(Locale.getDefault(), CharEncoding.UTF_8);
    // step4 freemarker?
    Template template = freemarkerCfg.getTemplate(ftlName, CharEncoding.UTF_8);
    // step5 ?IO?
    try (Writer writer = new BufferedWriter(
            new OutputStreamWriter(new FileOutputStream(new File(filePath)), CharEncoding.UTF_8))) {
        writer.flush();
        // step6 ??
        template.process(data, writer);
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return true;
}

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

public String process(String str, String open, boolean last) {
    if (last)/*  w ww  .  ja v a2  s.com*/
        return StringUtils.substringAfterLast(str, open);
    else
        return StringUtils.substringAfter(str, open);
}

From source file:de.jcup.egradle.template.TemplateFileNameTransformer.java

@Override
public String transform(String source) {
    if (source == null) {
        return null;
    }/*  w  ww.j a  v  a  2  s.  c o  m*/
    if (source.startsWith("_")) {
        source = StringUtils.substringAfterLast(source, "_");
    }
    if (source.startsWith("$")) {
        String key = StringUtils.substringAfterLast(source, "$");

        String found = properties.getProperty(key);

        if (StringUtils.isNotBlank(found)) {
            return found;
        }
    }
    return source;
}