Example usage for org.springframework.util StringUtils hasText

List of usage examples for org.springframework.util StringUtils hasText

Introduction

In this page you can find the example usage for org.springframework.util StringUtils hasText.

Prototype

public static boolean hasText(@Nullable String str) 

Source Link

Document

Check whether the given String contains actual text.

Usage

From source file:org.springmodules.cache.guava.GuavaCacheFactoryBean.java

@Override
public void afterPropertiesSet() throws Exception {
    if (StringUtils.hasText(this.spec)) {
        this.cache = new GuavaCache(this.name, CacheBuilder.from(spec), allowNullValues);
    } else {//from w  w w.  jav a 2 s  . com
        this.cache = new GuavaCache(this.name, allowNullValues);
    }
}

From source file:biz.c24.io.spring.batch.config.FileSourceParser.java

@Override
protected void doParse(Element element, BeanDefinitionBuilder bean) {

    // Optional/*from  w w  w . ja v a  2 s .  c  o m*/
    String resource = element.getAttribute("resource");
    if (StringUtils.hasText(resource)) {
        bean.addPropertyValue("resource", resource);
    }

    // Optional
    String skipLines = element.getAttribute("skip-lines");
    if (StringUtils.hasText(skipLines)) {
        bean.addPropertyValue("skipLines", skipLines);
    }

    // Optional
    String encoding = element.getAttribute("encoding");
    if (StringUtils.hasText(encoding)) {
        bean.addPropertyValue("encoding", encoding);
    }

    // Optional
    String consistentLineTerminators = element.getAttribute("consistent-line-terminators");
    if (StringUtils.hasText(consistentLineTerminators)) {
        bean.addPropertyValue("consistentLineTerminators", consistentLineTerminators);
    }
}

From source file:biz.c24.io.spring.batch.config.FileWriterSourceParser.java

@Override
protected void doParse(Element element, BeanDefinitionBuilder bean) {

    // Optional// w ww  .  j a v a  2  s .co  m
    String resource = element.getAttribute("resource");
    if (StringUtils.hasText(resource)) {
        bean.addPropertyValue("resource", resource);
    }

    // Optional
    String encoding = element.getAttribute("encoding");
    if (StringUtils.hasText(encoding)) {
        bean.addPropertyValue("encoding", encoding);
    }
}

From source file:org.codehaus.mojo.hibernate3.processor.implementations.RequiredImportProcessor.java

@Override
public String processClass(File fi, String contents) {
    String auditClass = this.componentProperties.get(AuditingProcessor.AUDIT_ENTITY_LISTENER_CLASS);

    String revisions = contents;//from www. j  ava  2s . c om
    revisions = ProcessorUtil.insertImportIntoClassDefinition(Date.class, revisions);
    revisions = ProcessorUtil.insertImportIntoClassDefinition(Temporal.class, revisions);
    revisions = ProcessorUtil.insertImportIntoClassDefinition(EntityListeners.class, revisions);

    if (StringUtils.hasText(auditClass)) {
        revisions = ProcessorUtil.insertImportIntoClassDefinition(auditClass, revisions);
    }
    return revisions;
}

From source file:csns.importer.RosterImporter.java

public void setText(String text) {
    if (StringUtils.hasText(text)) {
        this.text = text;
        importedStudents = rosterParser.parse(text);
    }
}

From source file:com.phoenixnap.oss.ramlapisync.javadoc.MethodVisitor.java

@Override
public void visit(MethodDeclaration n, String arg) {
    // here you can access the attributes of the method.
    // this method will be called for all methods in this
    // CompilationUnit, including inner class methods
    int parameterCount;
    if (n.getParameters() != null) {
        parameterCount = n.getParameters().size();
    } else {/*from   www  .j  ava  2s. c o m*/
        parameterCount = 0;
    }
    String javaDocContent = "";

    if (n.getComment() != null && n.getComment().getContent() != null) {
        javaDocContent = n.getComment().getContent().replaceAll("\\n *\\* *", "\n ");
    }

    if (StringUtils.hasText(javaDocContent)) {
        javaDoc.setJavaDoc(n.getName(), parameterCount, javaDocContent);
    }
}

From source file:org.impalaframework.extension.mvc.annotation.collector.RequestParameterArgumentCollector.java

public Object getArgument(NativeWebRequest request, ExtendedModelMap implicitModel,
        TypeConverter typeConverter) {//from www  .j  a v  a2s.  c  o m
    String value = annotation.value();
    boolean required = annotation.required();

    String parameter = request.getParameter(value);

    /*
    if (!StringUtils.hasText(parameter)) {
    parameter = annotation.defaultValue();
    }*/

    if (!StringUtils.hasText(parameter)) {
        if (required) {
            throw new IllegalArgumentException("Parameter '" + value + "' is required.");
        }
    }

    return typeConverter.convertIfNecessary(parameter, type);
}

From source file:org.jasig.cas.authentication.principal.SamlService.java

public static SamlService createServiceFrom(final HttpServletRequest request, final HttpClient httpClient) {
    final String service = request.getParameter(CONST_PARAM_SERVICE);
    final String artifactId;
    final String requestBody = getRequestBody(request);
    final String requestId;

    if (!StringUtils.hasText(service) && !StringUtils.hasText(requestBody)) {
        return null;
    }/*from w  w  w. j  a v  a  2  s .  com*/

    final String id = cleanupUrl(service);

    if (StringUtils.hasText(requestBody)) {

        final String tagStart;
        final String tagEnd;
        if (requestBody.contains(CONST_START_ARTIFACT_XML_TAG)) {
            tagStart = CONST_START_ARTIFACT_XML_TAG;
            tagEnd = CONST_END_ARTIFACT_XML_TAG;
        } else {
            tagStart = CONST_START_ARTIFACT_XML_TAG_NO_NAMESPACE;
            tagEnd = CONST_END_ARTIFACT_XML_TAG_NO_NAMESPACE;
        }
        final int startTagLocation = requestBody.indexOf(tagStart);
        final int artifactStartLocation = startTagLocation + tagStart.length();
        final int endTagLocation = requestBody.indexOf(tagEnd);

        artifactId = requestBody.substring(artifactStartLocation, endTagLocation).trim();

        // is there a request id?
        requestId = extractRequestId(requestBody);
    } else {
        artifactId = null;
        requestId = null;
    }

    if (log.isDebugEnabled()) {
        log.debug("Attempted to extract Request from HttpServletRequest.  Results:");
        log.debug(String.format("Request Body: %s", requestBody));
        log.debug(String.format("Extracted ArtifactId: %s", artifactId));
        log.debug(String.format("Extracted Request Id: %s", requestId));
    }

    return new SamlService(id, service, artifactId, httpClient, requestId);
}

From source file:com.roncoo.jui.common.dao.impl.DataDictionaryDaoImpl.java

@Override
public Page<RcDataDictionary> listForPage(int currentPage, int numPerPage, String orderField,
        String orderDirection, RcDataDictionary rcDataDictionary) {
    RcDataDictionaryExample example = new RcDataDictionaryExample();
    Criteria c = example.createCriteria();

    // //from  w  w  w .  j  a  v  a2s.c om
    if (StringUtils.hasText(rcDataDictionary.getFieldName())) {
        c.andFieldNameLike(SqlUtil.like(rcDataDictionary.getFieldName()));
    }

    // ?
    StringBuilder orderByClause = new StringBuilder();
    if (StringUtils.hasText(orderField)) {
        orderByClause.append(orderField).append(" ").append(orderDirection).append(", ");
    }
    example.setOrderByClause(orderByClause.append("update_time desc").toString());

    int totalCount = mapper.countByExample(example);
    numPerPage = SqlUtil.checkPageSize(numPerPage);
    currentPage = SqlUtil.checkPageCurrent(totalCount, numPerPage, currentPage);
    example.setLimitStart(SqlUtil.countOffset(currentPage, numPerPage));
    example.setPageSize(numPerPage);
    Page<RcDataDictionary> page = new Page<RcDataDictionary>(totalCount,
            SqlUtil.countTotalPage(totalCount, numPerPage), currentPage, numPerPage,
            mapper.selectByExample(example));
    page.setOrderField(orderField);
    page.setOrderDirection(orderDirection);
    return page;
}

From source file:spring.osgi.utils.OsgiResourceUtils.java

/**
 * Return the search type to be used for the give string based on the
 * prefix./* ww  w . jav a2s .  c o  m*/
 *
 * @param path path
 * @return type
 */
public static int getSearchType(String path) {
    Assert.notNull(path);
    int type;
    String prefix = getPrefix(path);

    // no prefix is treated just like osgibundle:
    if (!StringUtils.hasText(prefix))
        type = PREFIX_TYPE_NOT_SPECIFIED;
    else if (prefix.startsWith(OsgiBundleResource.BUNDLE_URL_PREFIX))
        type = PREFIX_TYPE_BUNDLE_SPACE;
    else if (prefix.startsWith(OsgiBundleResource.BUNDLE_JAR_URL_PREFIX))
        type = PREFIX_TYPE_BUNDLE_JAR;
    else if (prefix.startsWith(ResourceLoader.CLASSPATH_URL_PREFIX))
        type = PREFIX_TYPE_CLASS_SPACE;
    else if (prefix.startsWith(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX))
        type = PREFIX_TYPE_CLASS_ALL_SPACE;

    else
        type = PREFIX_TYPE_UNKNOWN;

    return type;
}