当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.hasText方法代码示例

本文整理汇总了Java中org.springframework.util.StringUtils.hasText方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.hasText方法的具体用法?Java StringUtils.hasText怎么用?Java StringUtils.hasText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.util.StringUtils的用法示例。


在下文中一共展示了StringUtils.hasText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filterByKeywordAndStatus

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public static Specification<Post> filterByKeywordAndStatus(
    final String keyword,//
    final Post.Status status) {
    return (Root<Post> root, CriteriaQuery<?> query, CriteriaBuilder cb) -> {
        List<Predicate> predicates = new ArrayList<>();
        if (StringUtils.hasText(keyword)) {
            predicates.add(
                cb.or(
                    cb.like(root.get(Post_.title), "%" + keyword + "%"),
                    cb.like(root.get(Post_.content), "%" + keyword + "%")
                )
            );
        }

        if (status != null) {
            predicates.add(cb.equal(root.get(Post_.status), status));
        }

        return cb.and(predicates.toArray(new Predicate[predicates.size()]));
    };
}
 
开发者ID:hantsy,项目名称:spring-microservice-sample,代码行数:22,代码来源:PostSpecifications.java

示例2: getTags

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public Iterable<Tag> getTags(String urlTemplate, HttpRequest request, ClientHttpResponse response) 
{
	Tag uriTag = StringUtils.hasText(urlTemplate)? RestTemplateExchangeTags.uri(urlTemplate): RestTemplateExchangeTags.uri(request);
	
	
            
	return Arrays.asList(RestTemplateExchangeTags.method(request), uriTag,
			RestTemplateExchangeTags.status(response),
            RestTemplateExchangeTags.clientName(request),
            modelName(request),
            modelImage(request),
            modelVersion(request),
            projectName(),
            deploymentName(),
            deploymentVersion(),
            predictorName(),
            predictorVersion());
}
 
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:20,代码来源:SeldonRestTemplateExchangeTagsProvider.java

示例3: constructCredentialsFromRequest

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(
        final RequestContext context) {
    final HttpServletRequest request = WebUtils
            .getHttpServletRequest(context);
    final String remoteUser = request.getRemoteUser();

    if (StringUtils.hasText(remoteUser)) {
        logger.debug("Remote  User [{}] found in HttpServletRequest", remoteUser);
        return new PrincipalBearingCredential(this.principalFactory.createPrincipal(remoteUser));
    }

    logger.debug("Remote User not found in HttpServletRequest.");

    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:PrincipalFromRequestRemoteUserNonInteractiveCredentialsAction.java

示例4: writeTo

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public void writeTo(ApplicationResponse t, Class<?> type, Type genericType, Annotation[] annotations,
        MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
        throws IOException {
    
    ByteArrayOutputStream boss = new ByteArrayOutputStream();
    ObjectMapper om = jsonProvider.locateMapper(type, MediaType.APPLICATION_JSON_TYPE);
    if(om != null) {
        jsonProvider.writeTo(t, type, genericType, annotations, MediaType.APPLICATION_JSON_TYPE, httpHeaders, boss);
        boss.flush();
    }

    Writer osWriter = new OutputStreamWriter(entityStream);
    String code, text, prefix;
    if(StringUtils.hasText(t.getMsgCode())) { 
        code = "400"; prefix = t.getMsgCode();
    } else {
        code = "200"; prefix = "";
    }
    if(StringUtils.hasText(t.getMessage())) { 
        text = prefix + " " + t.getMessage();
    } else {
        text = "ok";
    }
    osWriter.write("<html><body status='"+code+"' statusText='" + text + "'>");
    osWriter.flush();
    entityStream.write(boss.toByteArray());
    boss.close();
    osWriter.write("</body></html>");
    osWriter.close();
}
 
开发者ID:cerner,项目名称:jwala,代码行数:32,代码来源:ResponseMessageBodyWriter.java

示例5: mergeConfigValues

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Merge configuration values from the Package and values passed at runtime. Values passed
 * at runtime override those specified in the package. The ConfigValue string is assumed
 * to be in YAML format and parsed into a Map.
 * <p>
 * The values for dependencies of packages are also merged, which higher level packages
 * overriding lower level packages. Only one level of dependent packages are currently
 * supported.
 * <p>
 * @param pkg The package to be installed or upgraded.
 * @param overrideValues Configuration values pass in at runtime, when installing or
 * updating.
 * @return The merged configuration values.
 */
public static Map<String, Object> mergeConfigValues(Package pkg, ConfigValues overrideValues) {
	// parse ConfigValues to a map.
	Yaml yaml = new Yaml();
	Map<String, Object> mergedValues;
	// merge top level override values on top level package values
	if (StringUtils.hasText(overrideValues.getRaw())) {
		Object data = yaml.load(overrideValues.getRaw());
		if (data instanceof Map) {
			Map<String, Object> overrideMap = (Map<String, Object>) yaml.load(overrideValues.getRaw());
			mergedValues = mergeOverrideMap(pkg, overrideMap);
		}
		else {
			throw new SkipperException("Was expecting override values to produce a Map, instead got class = " +
					data.getClass() + "overrideValues.getRaw() = " + overrideValues.getRaw());
		}
	}
	else {
		mergedValues = mergeOverrideMap(pkg, new TreeMap<>());
	}
	// return mergedValues;
	return mergePackagesIncludingDependencies(pkg, mergedValues);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:37,代码来源:ConfigValueUtils.java

示例6: loadResources

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@DataProvider
public Collection<ReportResource> loadResources(String definitionId){
	String hql="from "+ReportResource.class.getName()+" where reportDefinitionId=:definitionId";
	Map<String,Object> map=new HashMap<String,Object>();
	map.put("definitionId", definitionId);
	Collection<ReportResource> resources=this.query(hql, map);
	IFileService fileService=ContextHolder.getBean(IFileService.BEAN_ID);
	for(ReportResource res:resources){
		String resFile=res.getResourceFile();
		if(StringUtils.hasText(resFile)){
			UploadDefinition uploadDefinition=fileService.getUploadDefinition(resFile);
			if(uploadDefinition!=null){
				res.setResourceFileName(uploadDefinition.getFileName());
			}
		}
	}
	return resources;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:19,代码来源:ReportMaintain.java

示例7: parse

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
	BeanDefinition bd =
			LangNamespaceUtils.registerScriptFactoryPostProcessorIfNecessary(parserContext.getRegistry());
	String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
	if (StringUtils.hasText(refreshCheckDelay)) {
		bd.getPropertyValues().add("defaultRefreshCheckDelay", new Long(refreshCheckDelay));
	}
	String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
	if (StringUtils.hasText(proxyTargetClass)) {
		bd.getPropertyValues().add("defaultProxyTargetClass", new TypedStringValue(proxyTargetClass, Boolean.class));
	}
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:ScriptingDefaultsParser.java

示例8: doParse

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder)
{

	String key = element.getAttribute("key");
	
	builder.addPropertyValue("key", key);
	
	setDefault(element,builder);
	
	String className = element.getAttribute("class");
	if (StringUtils.hasText(className)) {
		builder.getBeanDefinition().setBeanClassName(className);
	}

	List<Element> childElts = DomUtils.getChildElements(element);
	// 解析fields
	if (CollectionUtils.isEmpty(childElts)) {
		throw new IllegalArgumentException("cjava:tc-header node must contain fields");
	}

	Field[] values = new Field[childElts.size()];
	for (int i = 0; i < childElts.size(); i++) {
		Element node = childElts.get(i);
		// 解析
		values[i] = parserField(node,false);
	}
	builder.addPropertyValue("fields", values);

}
 
开发者ID:yanghao0518,项目名称:cstruct-parser,代码行数:31,代码来源:CjavaTcHeaderBeanDefinitionParser.java

示例9: initBasePackagesFromBeanType

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private static List<Package> initBasePackagesFromBeanType(Class<?> beanType, ControllerAdvice annotation) {
	List<Package> basePackages = new ArrayList<Package>();
	List<String> basePackageNames = new ArrayList<String>();
	basePackageNames.addAll(Arrays.asList(annotation.value()));
	basePackageNames.addAll(Arrays.asList(annotation.basePackages()));
	for (String pkgName : basePackageNames) {
		if (StringUtils.hasText(pkgName)) {
			Package pkg = Package.getPackage(pkgName);
			if(pkg != null) {
				basePackages.add(pkg);
			}
			else {
				logger.warn("Package [" + pkgName + "] was not found, see [" + beanType.getName() + "]");
			}
		}
	}
	for (Class<?> markerClass : annotation.basePackageClasses()) {
		Package pack = markerClass.getPackage();
		if (pack != null) {
			basePackages.add(pack);
		}
		else {
			logger.warn("Package was not found for class [" + markerClass.getName() +
					"], see [" + beanType.getName() + "]");
		}
	}
	return basePackages;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:ControllerAdviceBean.java

示例10: resolveToken

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private String resolveToken(HttpServletRequest request){
    String bearerToken = request.getHeader(JWTConfigurer.AUTHORIZATION_HEADER);
    if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) {
        return bearerToken.substring(7, bearerToken.length());
    }
    return null;
}
 
开发者ID:torgcrm,项目名称:TorgCRM-Server,代码行数:8,代码来源:JWTFilter.java

示例11: getFormat

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * @return Optional of format string that should be used for formatting the
 *         cell value. Most commonly used with number or date formats but
 *         can also be used to pad strings in textual fields etc.
 */
public Optional<String> getFormat() {
	if (StringUtils.hasText(columnDefinitionAnnotation.format())) {
		return Optional.of(columnDefinitionAnnotation.format());
	}

	return Optional.empty();
}
 
开发者ID:peterl1084,项目名称:bean-grid,代码行数:13,代码来源:ColumnDefinition.java

示例12: of

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Return the appropriate {@link ParameterBindingType} for the given {@link String}. Returns {@keyword #AS_IS} in
 * case no other {@link ParameterBindingType} could be found.
 *
 * @param typeSource
 * @return
 */
static ParameterBindingType of(String typeSource) {

  if (!StringUtils.hasText(typeSource)) {
    return AS_IS;
  }

  for (ParameterBindingType type : values()) {
    if (type.name().equalsIgnoreCase(typeSource.trim())) {
      return type;
    }
  }

  throw new IllegalArgumentException(String.format("Unsupported parameter binding type %s!", typeSource));
}
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:22,代码来源:StringQuery.java

示例13: parseManagedClasses

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Parse the {@code class} XML elements.
 */
protected void parseManagedClasses(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) {
	List<Element> classes = DomUtils.getChildElementsByTagName(persistenceUnit, MANAGED_CLASS_NAME);
	for (Element element : classes) {
		String value = DomUtils.getTextValue(element).trim();
		if (StringUtils.hasText(value))
			unitInfo.addManagedClassName(value);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:PersistenceUnitReader.java

示例14: resolveBeanClassname

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 *  Try getting the beanClassName from the definition and if that fails try to get it from 
 *  the parent (and even parent BeanFactory if we have to).
 *  
 *  @param definition 
 *  @param registry
 *  @return class name or null if not found
 */
private String resolveBeanClassname(BeanDefinition definition, BeanDefinitionRegistry registry) 
{
    String beanClassName = definition.getBeanClassName();    
    if (!StringUtils.hasText(beanClassName)) 
    {
        while (definition instanceof ChildBeanDefinition )
        {
            String parentName = ((ChildBeanDefinition)definition).getParentName();                    
            BeanDefinition parentDefinition = findParentDefinition(parentName, registry);
            if (parentDefinition == null)
            {
                if (log.isDebugEnabled()) 
                {
                    log.debug("No parent bean named '" + parentName + "' could be found in the " + 
                              "hierarchy of BeanFactorys. Check you've defined a bean called '" + parentName + "'");
                }
                break;
            }
            beanClassName = parentDefinition.getBeanClassName();
            if (StringUtils.hasText(beanClassName ))
            {
                // found the class name we were looking for
                break;
            }
            definition = parentDefinition;
        }
    }
   
    return beanClassName;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:39,代码来源:DwrNamespaceHandler.java

示例15: parsePointcutProperty

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Parses the {@code pointcut} or {@code pointcut-ref} attributes of the supplied
 * {@link Element} and add a {@code pointcut} property as appropriate. Generates a
 * {@link org.springframework.beans.factory.config.BeanDefinition} for the pointcut if  necessary
 * and returns its bean name, otherwise returns the bean name of the referred pointcut.
 */
private Object parsePointcutProperty(Element element, ParserContext parserContext) {
	if (element.hasAttribute(POINTCUT) && element.hasAttribute(POINTCUT_REF)) {
		parserContext.getReaderContext().error(
				"Cannot define both 'pointcut' and 'pointcut-ref' on <advisor> tag.",
				element, this.parseState.snapshot());
		return null;
	}
	else if (element.hasAttribute(POINTCUT)) {
		// Create a pointcut for the anonymous pc and register it.
		String expression = element.getAttribute(POINTCUT);
		AbstractBeanDefinition pointcutDefinition = createPointcutDefinition(expression);
		pointcutDefinition.setSource(parserContext.extractSource(element));
		return pointcutDefinition;
	}
	else if (element.hasAttribute(POINTCUT_REF)) {
		String pointcutRef = element.getAttribute(POINTCUT_REF);
		if (!StringUtils.hasText(pointcutRef)) {
			parserContext.getReaderContext().error(
					"'pointcut-ref' attribute contains empty value.", element, this.parseState.snapshot());
			return null;
		}
		return pointcutRef;
	}
	else {
		parserContext.getReaderContext().error(
				"Must define one of 'pointcut' or 'pointcut-ref' on <advisor> tag.",
				element, this.parseState.snapshot());
		return null;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:ConfigBeanDefinitionParser.java


注:本文中的org.springframework.util.StringUtils.hasText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。