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:cc.recommenders.names.CoReFieldName.java

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

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

@Override
public IMethodName getDeclaringMethod() {
    final String declaringType = StringUtils.substringBeforeLast(identifier, "#");
    return VmMethodName.get(declaringType);
}

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

@Override
public ICoReMethodName getDeclaringMethod() {
    final String declaringType = StringUtils.substringBeforeLast(identifier, "#");
    return CoReMethodName.get(declaringType);
}

From source file:de.vandermeer.skb.base.utils.Skb_STUtils_Tests.java

@Test
public void testGetStgName() {
    assertNull(Skb_STUtils.getStgName(null));

    STGroup stg = new STGroupFile(this.stgFileEmpty);
    assertNotNull(stg);/*from w w  w .  ja  v  a 2s. c om*/
    assertEquals(StringUtils.substringBeforeLast(this.stgFileEmpty, "."), Skb_STUtils.getStgName(stg));
}

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

@Override
public void genServiceImpl(String entityFullClassName) {

    ServiceImplModel serviceModel = new ServiceImplModel();

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

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

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

    String interfacePackageName = path + ".service";

    String className = entitySimpleClassName + "ServiceImpl";

    String daoPackageName = path + ".dao";

    serviceModel.setPackageName(packageName);
    serviceModel.setEntitySimpleClassName(entitySimpleClassName);
    serviceModel.setInterfacePackageName(interfacePackageName);
    serviceModel.setEntityFullClassName(entityFullClassName);
    serviceModel.setDaoPackageName(daoPackageName);
    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.serviceImpl_template_dir, data, filePath);
}

From source file:com.thinkbiganalytics.annotations.AnnotationFieldNameResolver.java

public AnnotationFieldNameResolver(String parentPrefix, Class<? extends Annotation> annotation) {
    this.parentPrefix = parentPrefix;
    if (StringUtils.isNotBlank(this.parentPrefix) && this.parentPrefix.endsWith(".")) {
        this.parentPrefix = StringUtils.substringBeforeLast(this.parentPrefix, ".");
    }//  w w w. ja va 2 s  .  c om
    this.annotation = annotation;
}

From source file:ch.ivyteam.ivy.maven.util.ClasspathJar.java

public void create(List<String> classpathEntries) throws IOException {
    jar.getParentFile().mkdir();/*from  w w  w.j  ava  2  s.co  m*/
    try (ZipOutputStream zipStream = new ZipOutputStream(new FileOutputStream(jar))) {
        String name = StringUtils.substringBeforeLast(jar.getName(), ".");
        writeManifest(name, zipStream, classpathEntries);
    }
}

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.
 *//* w w w. ja v  a  2 s  .co  m*/
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;
}

From source file:de.vandermeer.skb.interfaces.antlr.IsSTGroup.java

/**
 * Returns the name of the STGroup object (file name, source name, or group directory name).
 * @return STGroup name, null if {@link #getSTGroup()} was null or if no name was found
 */// ww w.j  a v a2  s .  co  m
default String getGroupName() {
    STGroup stg = this.getSTGroup();
    String ret = null;

    if (stg instanceof STGroupFile) {
        ret = ((STGroupFile) stg).fileName;
    } else if (stg instanceof STGroupString) {
        ret = ((STGroupString) stg).sourceName;
    } else if (stg instanceof STGroupDir) {
        ret = ((STGroupDir) stg).groupDirName;
    }
    return (ret == null) ? ret : StringUtils.substringBeforeLast(ret, ".");
}

From source file:com.zht.common.codegen.util.HiberStrUtil.java

public static void handlerProperty_String(GenEntityProperty prop) {
    StringBuffer hiberColumnStr = new StringBuffer("");
    StringBuffer hiberValidateStr = new StringBuffer("");

    String clumnname = prop.getColumnName();
    Boolean nullAble = prop.getNullable();
    Boolean unique = prop.getUnique();
    Integer length = prop.getLength();
    //-------hiberValidateStr---------
    Integer minLen = prop.getMinLength();
    Integer maxLen = prop.getMaxLength();
    String lenvali = "";
    String minl = "";
    String maxl = "";
    String isBlank = "";
    if (minLen != null) {
        minl = "min=" + minLen + "";
        if (minLen > 0) {
            hiberValidateStr.append("@org.hibernate.validator.constraints.NotBlank\r\t");
            ;/*from   w  ww . j av  a 2 s  . c  om*/
        }
    }
    if (maxLen != null) {
        maxl = "max=" + maxLen + "";
    }
    lenvali = minl + "," + maxl;
    if (lenvali.endsWith(",")) {
        lenvali = StringUtils.substringBeforeLast(lenvali, ",");
    }
    if (lenvali.length() > 0) {
        hiberValidateStr.append("@org.hibernate.validator.constraints.Length(" + lenvali + ")\r\t");
    }

    if (nullAble != null && nullAble == false) {
        hiberValidateStr.append("@javax.validation.constraints.NotNull \r\t");
        hiberValidateStr.append("@org.hibernate.validator.constraints.NotBlank\r\t");
        ;
    }
    if (isBlank.length() > 0) {

    }
    //-------hiberValidateStr---------

    hiberColumnStr.append("name = \"" + clumnname + "\",");

    if (unique != null) {
        hiberColumnStr.append("unique = " + unique + ",");
    }
    if (nullAble != null) {
        hiberColumnStr.append("nullable = " + nullAble + ",");
    }
    if (length != null) {
        hiberColumnStr.append("length = " + length + ",");
    } else {
        length = 255;
        hiberColumnStr.append("length = " + length + ",");
    }

    String tempStr = hiberColumnStr.toString().trim();

    if (tempStr.endsWith(",")) {
        tempStr = StringUtils.substringBeforeLast(tempStr, ",");
    }
    if (tempStr != null && tempStr.length() > 0) {
        tempStr = "@javax.persistence.Column(" + tempStr + ")";
    }
    prop.setGeneratedHibernateModelOfPropertyStr(hiberValidateStr + tempStr);

}