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

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

Introduction

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

Prototype

public static boolean endsWith(final CharSequence str, final CharSequence suffix) 

Source Link

Document

Check if a CharSequence ends with a specified suffix.

null s are handled without exceptions.

Usage

From source file:net.sf.dynamicreports.site.ExamplesAspect.java

@Around("build()")
public void build(ProceedingJoinPoint pjp) throws Throwable {
    Class<?> design = pjp.getSignature().getDeclaringType();
    name = design.getSimpleName();/* w w  w.jav  a 2s .c o m*/
    if (StringUtils.endsWith(name, "Design")) {
        name = StringUtils.substringBeforeLast(name, "Design");
    }
    String path = design.getName().substring(Templates.class.getPackage().getName().length() + 1)
            .split("\\.")[0];
    GenerateSite.addExample(name, path, design);
    pjp.proceed();
}

From source file:com.glaf.core.execution.UpdateExecutionHandler.java

@Override
public void execute(String content) {
    FileExecutionHelper helper = new FileExecutionHelper();
    String currentSystemName = Environment.getCurrentSystemName();
    Connection conn = null;// w  ww  . j  a  v  a 2  s.c o  m
    Statement stmt = null;
    try {
        conn = DBConnectionFactory.getConnection(currentSystemName);
        if (conn != null) {
            helper.createTable(conn);
            String path = SystemProperties.getConfigRootPath() + "/conf/bootstrap/update";
            File dir = new File(path);
            File contents[] = dir.listFiles();
            if (contents != null) {
                for (int i = 0; i < contents.length; i++) {
                    if (contents[i].isFile() && StringUtils.endsWith(contents[i].getName(), ".sql")) {
                        try {
                            if (!helper.exists(conn, "update_sql", contents[i])) {
                                long lastModified = helper.lastModified(conn, "update_sql", contents[i]);
                                if (contents[i].lastModified() > lastModified) {
                                    conn.setAutoCommit(false);
                                    String ddlStatements = FileUtils.readFile(contents[i].getAbsolutePath());
                                    DBUtils.executeSchemaResourceIgnoreException(conn, ddlStatements);
                                    helper.save(conn, "update_sql", contents[i]);
                                    conn.commit();
                                }
                            }
                        } catch (Exception ex) {
                            ex.printStackTrace();
                            logger.error(ex);
                        }
                    }
                }
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        logger.error(ex);
    } finally {
        JdbcUtils.close(stmt);
        JdbcUtils.close(conn);
    }
}

From source file:com.github.ferstl.depgraph.graph.style.StyleKey.java

private static boolean wildcardMatch(String value1, String value2) {
    if (StringUtils.endsWith(value1, "*")) {
        return StringUtils.startsWith(value2, value1.substring(0, value1.length() - 1));
    }//from   w  w w . j  a v a  2s  .  c  o m

    return match(value1, value2);
}

From source file:com.sinnerschrader.s2b.accounttool.logic.component.licences.LicenseSummary.java

@Override
public void afterPropertiesSet() throws Exception {
    for (String licenseFile : licenseFiles) {
        Resource res = resourceLoader.getResource(licenseFile);
        if (res != null && res.exists()) {
            try {
                log.info("Loading License Summary file {} of Project ", licenseFile);
                String fileName = StringUtils.lowerCase(res.getFilename());
                if (StringUtils.endsWith(fileName, ".json")) {
                    storeForType(DependencyType.NPM, loadFromJSON(res));
                } else if (StringUtils.endsWith(fileName, ".xml")) {
                    storeForType(DependencyType.MAVEN, loadFromXML(res));
                } else {
                    log.warn("Could not identify file ");
                }/*from   ww  w . j av  a2 s  .  co m*/
            } catch (Exception e) {
                log.warn("Could not load license file {}", licenseFile);
                if (log.isDebugEnabled()) {
                    log.error("Exception on loading license file", e);
                }
            }
        }
    }
    freeze();
}

From source file:com.github.ferstl.depgraph.dependency.style.StyleKey.java

private static boolean wildcardMatch(String value1, String value2) {
    if (StringUtils.endsWith(value1, "*")) {
        return startsWith(value2, value1.substring(0, value1.length() - 1));
    }//from   w  w  w .  j  av a 2 s  .  co m

    return match(value1, value2);
}

From source file:io.apiman.common.util.ApimanPathUtils.java

/**
 * Join endpoint and path with sensible / behaviour.
 *
 * @param endpoint the endpoint//  ww  w  .  j  av  a2  s .  co m
 * @param path the destination (path)
 * @return the joined endpoint + destination.
 */
public static String join(String endpoint, String path) {
    if (endpoint == null || endpoint.isEmpty())
        return path;
    if (path == null || path.isEmpty())
        return endpoint;

    if (StringUtils.endsWith(endpoint, "/") && path.startsWith("/")) {
        return endpoint + path.substring(1);
    } else if (StringUtils.endsWith(endpoint, "/") ^ path.startsWith("/")) {
        return endpoint + path;
    }
    return endpoint + "/" + path;
}

From source file:de.micromata.tpsb.doc.parser.ParserResult.java

public FileInfo getFileInfoForClassName(final String className) {
    return CollectionUtils.find(this, new Predicate<FileInfo>() {
        @Override/*from   w w w . j a v a2  s .  c  o  m*/
        public boolean evaluate(FileInfo fInfo) {
            return StringUtils.equals(className, fInfo.getClassName())
                    || StringUtils.endsWith(fInfo.getClassName(), className);
        }
    });
}

From source file:io.github.moosbusch.lumpi.gui.impl.Expression.java

public String getSubExpression(int startIndex, int tokenCount) {
    String separator = new String(new char[] { getSeparatorChar() });
    String result = "";
    if (tokenCount == 0) {
        return get(startIndex);
    } else {/* www. ja v a  2  s  .c om*/
        StringBuilder buf = new StringBuilder();
        buf.append(result);
        for (int cnt = 0; cnt < tokenCount; cnt++) {
            String token = get(startIndex + cnt);
            buf.append(getSeparatorChar());
            buf.append(token);
        }
        if (StringUtils.startsWith(result, separator)) {
            result = StringUtils.substringAfter(result, separator);
        }
        if (StringUtils.endsWith(result, separator)) {
            result = StringUtils.substringBeforeLast(result, separator);
        }
    }
    return result;
}

From source file:com.dominion.salud.mpr.configuration.MPRInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.scan("com.dominion.salud.mpr.configuration");
    ctx.setServletContext(servletContext);
    System.setProperty("mpr.conf.home", findConfigurationAndLogger(ctx));
    ctx.refresh();/* ww  w  . j av  a2 s .  c o m*/

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
            new DispatcherServlet(ctx));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");
    dispatcher.addMapping("/controller/*");
    dispatcher.addMapping("/services/*");
    servletContext.addListener(new ContextLoaderListener(ctx));

    // Configuracion GENERAL DEL MODULO
    MPRConstantes._MPR_HOME = StringUtils.endsWith(servletContext.getRealPath("/"), File.separator)
            ? servletContext.getRealPath("/")
            : servletContext.getRealPath("/") + File.separator;
    MPRConstantes._MPR_CONF_HOME = ctx.getEnvironment().getProperty("mpr.conf.home");
    MPRConstantes._MPR_VERSION = ResourceBundle.getBundle("version").getString("version");
    MPRConstantes._MPR_RESOURCES = MPRConstantes._MPR_HOME + "resources" + File.separator;
    MPRConstantes._MPR_TEMP = MPRConstantes._MPR_HOME + "WEB-INF" + File.separator + "temp" + File.separator;
    MPRConstantes._MPR_CONTEXT_NAME = servletContext.getServletContextName();
    MPRConstantes._MPR_CONTEXT_PATH = servletContext.getContextPath();
    MPRConstantes._MPR_CONTEXT_SERVER = servletContext.getServerInfo();

    // Configuracion de LOGS DEL MODULO
    if (StringUtils.isBlank(
            ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile())) {
        ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE"))
                .setFile(MPRConstantes._MPR_HOME + "WEB-INF" + File.separator + "classes" + File.separator
                        + "logs" + File.separator + "mpr-desktop.log");
    }
    MPRConstantes._MPR_LOGS = new File(
            ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile())
                    .getParent();

    // Parametrizacion GENERAL DEL SISTEMA
    MPRConstantes._ENABLE_TECHNICAL_INFORMATION = StringUtils
            .isNotBlank(ctx.getEnvironment().getProperty("mpr.enable.technical.information"))
                    ? Boolean.parseBoolean(ctx.getEnvironment().getProperty("mpr.enable.technical.information"))
                    : false;

    // Parametrizacion de CONEXION A EMPI
    MPRConstantes._EMPI_ENABLE = StringUtils.isNotBlank(ctx.getEnvironment().getProperty("mpr.empi.enable"))
            ? Boolean.parseBoolean(ctx.getEnvironment().getProperty("mpr.empi.enable"))
            : false;
    MPRConstantes._EMPI_USUARIO = StringUtils.isNotBlank(ctx.getEnvironment().getProperty("mpr.empi.usuario"))
            ? ctx.getEnvironment().getProperty("mpr.empi.usuario")
            : "";
    MPRConstantes._EMPI_SISTEMA = StringUtils.isNotBlank(ctx.getEnvironment().getProperty("mpr.empi.sistema"))
            ? ctx.getEnvironment().getProperty("mpr.empi.sistema")
            : "";
    MPRConstantes._EMPI_URL = StringUtils.isNotBlank(ctx.getEnvironment().getProperty("mpr.empi.url"))
            ? ctx.getEnvironment().getProperty("mpr.empi.url")
            : "";

    // Parametrizacion de TAREAS PROGRAMADAS
    MPRConstantes._TASK_BUZON_IN_PROCESS_MESSAGES = StringUtils
            .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.in.process.messages"))
                    ? ctx.getEnvironment().getProperty("mpr.task.buzon.in.process.messages")
                    : MPRConstantes._TASK_BUZON_IN_PROCESS_MESSAGES;
    MPRConstantes._TASK_BUZON_OUT_PROCESS_MESSAGES = StringUtils
            .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.out.process.messages"))
                    ? ctx.getEnvironment().getProperty("mpr.task.buzon.out.process.messages")
                    : MPRConstantes._TASK_BUZON_OUT_PROCESS_MESSAGES;
    MPRConstantes._TASK_BUZON_IN_HIS_CLEAN = StringUtils
            .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.in.his.clean"))
                    ? ctx.getEnvironment().getProperty("mpr.task.buzon.in.his.clean")
                    : MPRConstantes._TASK_BUZON_IN_HIS_CLEAN;
    MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN = StringUtils
            .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.out.his.clean"))
                    ? ctx.getEnvironment().getProperty("mpr.task.buzon.out.his.clean")
                    : MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN;
    MPRConstantes._TASK_BUZON_IN_HIS_CLEAN_OLD = StringUtils
            .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.in.his.clean.old"))
                    ? Integer.parseInt(ctx.getEnvironment().getProperty("mpr.task.buzon.in.his.clean.old"))
                    : MPRConstantes._TASK_BUZON_IN_HIS_CLEAN_OLD;
    MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN_OLD = StringUtils
            .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.out.his.clean.old"))
                    ? Integer.parseInt(ctx.getEnvironment().getProperty("mpr.task.buzon.out.his.clean.old"))
                    : MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN_OLD;
    MPRConstantes._TASK_BUZON_IN_CLEAN = StringUtils
            .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.in.clean"))
                    ? ctx.getEnvironment().getProperty("mpr.task.buzon.in.clean")
                    : MPRConstantes._TASK_BUZON_IN_CLEAN;
    MPRConstantes._TASK_BUZON_OUT_CLEAN = StringUtils
            .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.out.clean"))
                    ? ctx.getEnvironment().getProperty("mpr.task.buzon.out.clean")
                    : MPRConstantes._TASK_BUZON_OUT_CLEAN;
    MPRConstantes._TASK_BUZON_ERRORES_CLEAN = StringUtils
            .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.errores.clean"))
                    ? ctx.getEnvironment().getProperty("mpr.task.buzon.errores.clean")
                    : MPRConstantes._TASK_BUZON_ERRORES_CLEAN;

    logger.info("Iniciando el modulo de [" + MPRConstantes._MPR_CONTEXT_NAME + "]");
    logger.debug("     Configuracion GENERAL DEL MODULO");
    logger.debug("          mpr.home: " + MPRConstantes._MPR_HOME);
    logger.debug("          mpr.conf.home: " + MPRConstantes._MPR_CONF_HOME);
    logger.debug("          mpr.version: " + MPRConstantes._MPR_VERSION);
    logger.debug("          mpr.resources: " + MPRConstantes._MPR_RESOURCES);
    logger.debug("          mpr.temp: " + MPRConstantes._MPR_TEMP);
    logger.debug("          mpr.logs: " + MPRConstantes._MPR_LOGS);
    logger.debug("          mpr.logs.file: "
            + ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile());
    logger.debug("          mpr.context.name: " + MPRConstantes._MPR_CONTEXT_NAME);
    logger.debug("          mpr.context.path: " + MPRConstantes._MPR_CONTEXT_PATH);
    logger.debug("          mpr.context.server: " + MPRConstantes._MPR_CONTEXT_SERVER);
    logger.debug("          java.version: " + ctx.getEnvironment().getProperty("java.version"));
    logger.debug("");
    logger.debug("     Parametrizacion GENERAL DEL SISTEMA");
    logger.debug("          mpr.enable.technical.information: " + MPRConstantes._ENABLE_TECHNICAL_INFORMATION);
    logger.debug("     Parametrizacion de CONEXION A EMPI");
    logger.debug("          mpr.empi.enable: " + MPRConstantes._EMPI_ENABLE);
    logger.debug("          mpr.empi.usuario: " + MPRConstantes._EMPI_USUARIO);
    logger.debug("          mpr.empi.sistema: " + MPRConstantes._EMPI_SISTEMA);
    logger.debug("          mpr.empi.url: " + MPRConstantes._EMPI_URL);
    logger.debug("     Parametrizacion de TAREAS PROGRAMADAS");
    logger.debug(
            "          mpr.task.buzon.in.process.messages: " + MPRConstantes._TASK_BUZON_IN_PROCESS_MESSAGES);
    logger.debug(
            "          mpr.task.buzon.out.process.messages: " + MPRConstantes._TASK_BUZON_OUT_PROCESS_MESSAGES);
    logger.debug("          mpr.task.buzon.in.his.clean: " + MPRConstantes._TASK_BUZON_IN_HIS_CLEAN);
    logger.debug("          mpr.task.buzon.out.his.clean: " + MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN);
    logger.debug("          mpr.task.buzon.in.his.clean.old: " + MPRConstantes._TASK_BUZON_IN_HIS_CLEAN_OLD);
    logger.debug("          mpr.task.buzon.out.his.clean.old: " + MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN_OLD);
    logger.debug("          mpr.task.buzon.in.clean: " + MPRConstantes._TASK_BUZON_IN_CLEAN);
    logger.debug("          mpr.task.buzon.out.clean: " + MPRConstantes._TASK_BUZON_OUT_CLEAN);
    logger.debug("          mpr.task.buzon.errores.clean: " + MPRConstantes._TASK_BUZON_ERRORES_CLEAN);
    logger.debug("     Variables de ENTORNO de utilidad");
    logger.debug("          catalina.home: " + ctx.getEnvironment().getProperty("catalina.home"));
    logger.debug("          jboss.home.dir: " + ctx.getEnvironment().getProperty("jboss.home.dir"));
    logger.info("Modulo [" + MPRConstantes._MPR_CONTEXT_NAME + "] iniciado correctamente");
}

From source file:io.wcm.devops.conga.resource.ResourceLoaderFilesystemTest.java

@Test
public void testResourceCollection() throws Exception {
    ResourceCollection col = underTest.getResourceCollection(FILE_PREFIX + ROOT + "/folder1");

    assertTrue(col.exists());//  ww  w.ja va2  s .c o  m
    assertEquals("folder1", col.getName());
    assertEquals(ROOT + "/folder1", unifySlashes(col.getPath()));
    assertTrue(
            "Canonical path " + unifySlashes(col.getCanonicalPath()) + " does not end with /" + ROOT
                    + "/folder1",
            StringUtils.endsWith(unifySlashes(col.getCanonicalPath()), "/" + ROOT + "/folder1"));

    List<Resource> resources = ImmutableList.copyOf(col.getResources());
    assertEquals(2, resources.size());
    assertEquals("file1.txt", resources.get(0).getName());
    assertEquals("file2.txt", resources.get(1).getName());

    List<ResourceCollection> resourceCollections = ImmutableList.copyOf(col.getResourceCollections());
    assertEquals(1, resourceCollections.size());
    assertEquals("folder2", resourceCollections.get(0).getName());

    List<Resource> folder2Resources = ImmutableList.copyOf(resourceCollections.get(0).getResources());
    assertEquals(1, folder2Resources.size());
    assertEquals("file3.txt", folder2Resources.get(0).getName());
}