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

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

Introduction

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

Prototype

public static boolean endsWith(String str, String suffix) 

Source Link

Document

Check if a String ends with a specified suffix.

Usage

From source file:org.talend.mdm.commmon.metadata.annotation.DefaultValueRuleProcessor.java

private boolean isValue(String text) {
    boolean isValue = false;

    if (StringUtils.isNotBlank(text)) {
        if (StringUtils.startsWith(text, "\"") && StringUtils.endsWith(text, "\"")) { //$NON-NLS-1$ //$NON-NLS-2$
            isValue = true;/*from www .  ja  va  2  s .c  om*/
        } else if (NumberUtils.isNumber(text)) {
            isValue = true;
        } else if (StringUtils.equalsIgnoreCase(text, MetadataRepository.FN_FALSE)
                || StringUtils.equalsIgnoreCase(text, MetadataRepository.FN_TRUE)) {
            isValue = true;
        }
    }
    return isValue;
}

From source file:org.tinygroup.springmvc.view.TinyTemplateLayoutView.java

private boolean isPagelet(String path) {
    return StringUtils.endsWith(path, noLayoutExtFileName);
}

From source file:org.twinkql.result.PropertySetter.java

/**
 * Adjust for collection.//from www  .java  2  s  .c o m
 *
 * @param target the target
 * @param property the property
 * @return the string
 */
private String adjustForCollection(Object target, String property) {
    if (StringUtils.countMatches(property, "[]") > 1) {
        throw new MappingException(
                "Cannot have more than one Collection Indicator ('[]') in a 'property' attribute.");
    }

    String[] parts = StringUtils.split(property, '.');

    for (int i = 0; i < parts.length; i++) {
        String part = parts[i];
        if (StringUtils.endsWith(part, "[]")) {
            String propertySoFar = StringUtils
                    .removeEnd(StringUtils.join(ArrayUtils.subarray(parts, 0, i + 1), '.'), "[]");

            Collection<?> collection = (Collection<?>) BeanUtil.getSimplePropertyForced(target, propertySoFar,
                    true);
            int index = collection.size();

            parts[i] = StringUtils.replace(part, "[]", "[" + index + "]");
        }
    }

    return StringUtils.join(parts, '.');
}

From source file:org.whizu.widget.Widget.java

public void style(String style) {
    this.style.append(style);
    if (!StringUtils.endsWith(style, ";")) {
        this.style.append(';');
    }/*w w  w. j  ava 2 s. c  o m*/

    if (this.isRendered()) {
        throw new UnsupportedOperationException();
    }
}

From source file:org.xlcloud.xsa.ext.hpc.service.impl.SlurmHpcJobsManager.java

@Override
public HpcJob schedule(String applicationName, HpcJobSubmission jobSubmission)
        throws ValidationException, InternalErrorException, ObjectNotFoundException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Trying to schedule job, got submission: "
                + ToStringBuilder.reflectionToString(jobSubmission, ToStringStyle.SHORT_PREFIX_STYLE));
    }/*from   w w  w . j a v a2  s.  co  m*/

    Application application = applicationsManager.get(applicationName);
    validateJobSubmission(application, jobSubmission);

    List<String> command = new ArrayList<>();
    command.add("sbatch");
    addOption(command, "-J", jobSubmission.getName());

    ExecParams execParams = jobSubmission.getExecParams();
    if (execParams != null) {
        addOption(command, "-N", execParams.getNumNodes());
        addOption(command, "-c", execParams.getNumCores());
    }

    String appWorkDir = workDir + (StringUtils.endsWith(workDir, File.separator) ? "" : File.separator)
            + applicationName;
    addOption(command, "-D", appWorkDir);

    List<String> inputLines = new ArrayList<>();
    inputLines.add("#!/bin/sh");
    for (String singleCommand : application.getCommands()) {
        inputLines.add(singleCommand);
    }
    ProcessExecutionResult result = executor.run(command, inputLines);

    String jobId = jobSubmissionParser.parse(result);
    return get(jobId);
}

From source file:org.yestech.publish.util.PublishUtilsUnitTest.java

@Test
public void testGenerateUniqueIdentifierFromMetaData() {
    final IFileArtifactMetaData metaData = context.mock(IFileArtifactMetaData.class, "metaData");
    final String fileName = "1.jpg";
    context.checking(new Expectations() {
        {//w  w w  .j ava  2  s  . c o m
            oneOf(metaData).getFileName();
            will(returnValue(fileName));
        }
    });
    String id = PublishUtils.generateUniqueIdentifier(metaData);
    assertEquals(46, id.length());
    String idSuffix = "_" + fileName;
    assertTrue(StringUtils.endsWith(id, idSuffix));
}

From source file:pt.webdetails.cdc.plugin.CdcContentGenerator.java

@Override
protected String getDefaultPath(String path) {
    if (StringUtils.endsWith(path, "/")) {
        return "home";
    } else {/*from  w w  w .ja  va 2s .  c  om*/
        return "cdc/home";
    }
}

From source file:pt.webdetails.cdc.ws.DashboardCacheCleanService.java

private static IBasicFileFilter getDashboardFilter() {
    return new IBasicFileFilter() {
        @Override//from   w  w  w  .  j  a v  a 2  s.  c  o  m
        public boolean accept(IBasicFile iBasicFile) {
            return StringUtils.endsWith(iBasicFile.getName(), ".cdfde");
        }
    };
}

From source file:pt.webdetails.cdf.dd.datasources.CdaDataSourceReader.java

protected static List<CdaDataSource> getCdaDataSources(JXPathContext docContext) {
    ArrayList<CdaDataSource> dataSources = new ArrayList<CdaDataSource>();
    //external/*from w  w w  .  j ava 2 s. co m*/
    @SuppressWarnings("unchecked")
    Iterator<Pointer> extDataSources = docContext
            .iteratePointers("/datasources/rows[properties/name='dataAccessId']");
    while (extDataSources.hasNext()) {
        Pointer source = extDataSources.next();
        if (!(source instanceof NullPointer)) {
            dataSources.add(new CdaDataSource(docContext.getRelativeContext(source)));
        }
    }

    @SuppressWarnings("unchecked")
    Iterator<Pointer> builtInDataSources = docContext.iteratePointers("/datasources/rows[meta='CDA']");
    if (builtInDataSources.hasNext()) {
        //built-in
        String fileName = XPathUtils.getStringValue(docContext, "/filename");
        if (StringUtils.endsWith(fileName, ".wcdf")) {
            fileName = StringUtils.replace(fileName, ".wcdf", ".cda");
        } else {
            fileName = StringUtils.replace(fileName, ".cdfde", ".cda");
        }
        //just add cda name
        dataSources.add(new CdaDataSource(fileName, null));
    }

    return dataSources;
}

From source file:pt.webdetails.cdf.dd.datasources.DataSourceReader.java

private static List<CdaDataSource> getCdaDataSources(JXPathContext docContext) {

    ArrayList<CdaDataSource> dataSources = new ArrayList<CdaDataSource>();
    //external/*from   ww w. j a  v a  2s .c  o  m*/
    @SuppressWarnings("unchecked")
    Iterator<Pointer> extDataSources = docContext
            .iteratePointers("/datasources/rows[properties/name='dataAccessId']");
    while (extDataSources.hasNext()) {
        Pointer source = extDataSources.next();
        if (!(source instanceof NullPointer)) {
            dataSources.add(new CdaDataSource(docContext.getRelativeContext(source)));
        }
    }

    @SuppressWarnings("unchecked")
    Iterator<Pointer> builtInDataSources = docContext.iteratePointers("/datasources/rows[meta='CDA']");
    if (builtInDataSources.hasNext()) {
        //built-in
        String fileName = XPathUtils.getStringValue(docContext, "/filename");
        String toReplace = ".cdfde";
        String replaceWith = ".cda";
        if (StringUtils.endsWith(fileName, ".wcdf")) {
            toReplace = ".wcdf";
        }
        fileName = StringUtils.replace(fileName, toReplace, replaceWith);
        //just add cda name
        dataSources.add(new CdaDataSource(fileName, null));
        //      
        //  
        //      while(builtInDataSources.hasNext()){
        //        Pointer source = builtInDataSources.next();
        //        if(!(source instanceof NullPointer)){
        //          dataSources.add(new CdaDataSource(docContext.getRelativeContext(source), fileName));
        //        }
        //      }
    }

    return dataSources;
}