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:com.phoenixnap.oss.ramlapisync.verification.Issue.java

/**
 * Uniform way of identifying a location in the Raml file based on the
 * Resource and Action/* w ww .  j  a va2s.c  o m*/
 * 
 * @param resource The Resource that this Issue relates to
 * @param action The Action that this Issue relates to
 * @param parameter The parameter name that this Issue Relates to
 * @return String identifying the location of this issue
 */
public static String buildRamlLocation(Resource resource, Action action, String parameter) {
    String outLocation = resource.getUri();
    if (action != null && action.getType() != null) {
        outLocation = action.getType().name() + " " + outLocation;
    }
    if (StringUtils.hasText(parameter)) {
        outLocation = parameter + " : " + outLocation;
    }
    return outLocation;
}

From source file:com.frank.search.solr.server.support.MulticoreSolrClientFactory.java

@Override
public SolrClient getSolrClient(String core) {
    if (!StringUtils.hasText(core)) {
        return getSolrClient();
    }//from  w w  w  . ja  va  2 s .  c o m

    if (createMissingSolrClient && !clientMap.containsKey(core)) {
        clientMap.put(core, createClientForCore(getSolrClient(), core));
    }
    return clientMap.get(core);
}

From source file:org.drools.container.spring.namespace.KnowledgeAgentDefinitionParser.java

@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {

    BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(KnowledgeAgentBeanFactory.class);

    String id = element.getAttribute("id");
    emptyAttributeCheck(element.getLocalName(), "id", id);
    factory.addPropertyValue("id", id);

    String kbase = element.getAttribute("kbase");
    if (StringUtils.hasText(kbase)) {
        factory.addPropertyReference("kbase", kbase);
    }/*from www  .ja  va  2 s  .  com*/

    String newInstance = element.getAttribute("new-instance");
    if (StringUtils.hasText(newInstance)) {
        factory.addPropertyValue("newInstance", newInstance);
    }

    String useKbaseClassloader = element.getAttribute("use-kbase-classloader");
    if (!useKbaseClassloader.trim().equals("")) {
        factory.addPropertyValue("useKbaseClassloader", useKbaseClassloader);
    }

    ManagedList resources = KnowledgeBaseDefinitionParser.getResources(element, parserContext, factory);

    if (resources != null) {
        factory.addPropertyValue("resources", resources);
    }

    // inject the kagent into any stateless sessions
    for (String beanName : parserContext.getRegistry().getBeanDefinitionNames()) {
        BeanDefinition def = parserContext.getRegistry().getBeanDefinition(beanName);
        if (StatelessKnowledgeSessionBeanFactory.class.getName().equals(def.getBeanClassName())) {
            PropertyValue pvalue = def.getPropertyValues().getPropertyValue("kbase");
            RuntimeBeanReference tbf = (RuntimeBeanReference) pvalue.getValue();
            if (kbase.equals(tbf.getBeanName())) {
                def.getPropertyValues().addPropertyValue("knowledgeAgent", new RuntimeBeanReference(id));
            }
        }
    }

    return factory.getBeanDefinition();
}

From source file:ch.rasc.extclassgenerator.ReferenceBean.java

public boolean typeOnly() {
    return StringUtils.hasText(this.type) && !StringUtils.hasText(this.association)
            && !StringUtils.hasText(this.child) && !StringUtils.hasText(this.parent)
            && !StringUtils.hasText(this.role) && !StringUtils.hasText(this.inverse);
}

From source file:org.xinta.eazycode.components.shiro.web.vo.EditUserVO.java

public void updateUser(User user) {
    Assert.isTrue(userId.equals(user.getId()), "User ID of command must match the user being updated.");
    user.setLoginName(getLoginName());//from w  w  w. jav  a  2  s .co m
    user.setEmail(getEmail());
    if (StringUtils.hasText(getPassword())) {
        user.setPassword(new Sha256Hash(getPassword()).toHex());
    }
}

From source file:com.kenshoo.freemarker.util.DataModelParser.java

public static Map<String, Object> parse(String src, TimeZone timeZone) throws DataModelParsingException {
    if (!StringUtils.hasText(src)) {
        return Collections.emptyMap();
    }/*w  w  w  .  j  av  a 2s  .c  o  m*/

    Map<String, Object> dataModel = new LinkedHashMap<>();

    String lastName = null;
    int lastAssignmentStartEnd = 0;
    final Matcher assignmentStart = ASSIGNMENT_START.matcher(src);
    findAssignments: while (true) {
        boolean hasNextAssignment = assignmentStart.find(lastAssignmentStartEnd);

        if (lastName != null) {
            String value = src.substring(lastAssignmentStartEnd,
                    hasNextAssignment ? assignmentStart.start() : src.length()).trim();
            final Object parsedValue;
            try {
                parsedValue = parseValue(value, timeZone);
            } catch (DataModelParsingException e) {
                throw new DataModelParsingException(
                        "Failed to parse the value of \"" + lastName + "\":\n" + e.getMessage(), e.getCause());
            }
            dataModel.put(lastName, parsedValue);
        }

        if (lastName == null && (!hasNextAssignment || assignmentStart.start() != 0)) {
            throw new DataModelParsingException(
                    "The data model specification must start with an assignment (name=value).");
        }

        if (!hasNextAssignment) {
            break findAssignments;
        }

        lastName = assignmentStart.group(1).trim();
        lastAssignmentStartEnd = assignmentStart.end();
    }

    return dataModel;
}

From source file:com.consol.citrus.selenium.xml.WebActionParser.java

/**
 * @param element//from  w w  w.j  a v a2  s.  com
 * @param builder
 * @return
 * @see
 * org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element,
 * org.springframework.beans.factory.xml.ParserContext)
 */
protected BeanDefinition doParse(Element element, BeanDefinitionBuilder builder) {
    DescriptionElementParser.doParse(element, builder);

    String url = element.getAttribute("url").trim();
    if (StringUtils.hasText(url)) {
        BeanDefinitionParserUtils.setPropertyValue(builder, url, "url");
    }

    String name = element.getAttribute("name").trim();
    if (StringUtils.hasText(name)) {
        BeanDefinitionParserUtils.setPropertyValue(builder, name, "name");
    }

    builder.addPropertyReference("webClient", element.getAttribute("client"));

    return builder.getBeanDefinition();
}

From source file:com.googlecode.spring.appengine.api.factory.AsyncMemcacheServiceFactoryBean.java

@Override
public void afterPropertiesSet() throws Exception {
    if (StringUtils.hasText(namespace)) {
        asyncMemcacheService = MemcacheServiceFactory.getAsyncMemcacheService(namespace);
    } else {//from   w  w  w  .  java  2s .c  o  m
        asyncMemcacheService = MemcacheServiceFactory.getAsyncMemcacheService();
    }
}

From source file:org.opencredo.couchdb.config.CouchDbIdToDocumentTransformerParser.java

@Override
protected void parseTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    String databaseUrl = element.getAttribute(COUCHDB_DATABASE_URL_ATTRIBUTE);
    String documentType = element.getAttribute(COUCHDB_DOCUMENT_TYPE_ATTRIBUTE);
    String documentOperations = element.getAttribute(COUCHDB_DOCUMENT_OPERATIONS_ATTRIBUTE);

    if (!StringUtils.hasText(documentType)) {
        parserContext.getReaderContext().error("The '" + COUCHDB_DOCUMENT_TYPE_ATTRIBUTE + "' is mandatory.",
                parserContext.extractSource(element));
    } else {// w  w w .j a va2 s .c  o  m
        builder.addConstructorArgValue(documentType);
    }

    if (StringUtils.hasText(databaseUrl)) {
        if (StringUtils.hasText(documentOperations)) {
            parserContext.getReaderContext().error("At most one of '" + COUCHDB_DATABASE_URL_ATTRIBUTE
                    + "' and '" + COUCHDB_DOCUMENT_OPERATIONS_ATTRIBUTE + "' may be provided.", element);
        } else {
            builder.addConstructorArgValue(databaseUrl);
        }
    } else if (StringUtils.hasText(documentOperations)) {
        builder.addConstructorArgReference(documentOperations);
    } else {
        parserContext.getReaderContext().error("Either '" + COUCHDB_DATABASE_URL_ATTRIBUTE + "' or '"
                + COUCHDB_DOCUMENT_OPERATIONS_ATTRIBUTE + "' must be provided.", element);
    }
}

From source file:com.dinstone.jrpc.spring.EndpointBeanDefinitionParser.java

@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    String id = element.getAttribute("id");
    if (!StringUtils.hasText(id)) {
        id = endpointClass.getSimpleName() + "-" + count.incrementAndGet();
        builder.addPropertyValue("id", id);
        element.setAttribute("id", id);
    } else {//from w ww.  j a va  2  s .  co m
        builder.addPropertyValue("id", id);
    }

    String name = element.getAttribute("name");
    if (!StringUtils.hasText(name)) {
        String[] pidName = ManagementFactory.getRuntimeMXBean().getName().split("@");
        builder.addPropertyValue("name", pidName[1] + ":" + pidName[0]);
    } else {
        builder.addPropertyValue("name", name);
    }

    builder.addPropertyValue("transportBean", getConfigBeanDefinition(element, parserContext, "transport"));

    builder.addPropertyValue("registryBean", getConfigBeanDefinition(element, parserContext, "registry"));
}