本文整理汇总了Java中org.springframework.util.StringUtils类的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringUtils类属于org.springframework.util包,在下文中一共展示了StringUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOAuthMock
import org.springframework.util.StringUtils; //导入依赖的package包/类
@RequestMapping(path = "/oauthmock", method = RequestMethod.GET)
public ResponseEntity<String> getOAuthMock(@CookieValue("_oauth2_proxy") String oAuthToken) {
if (StringUtils.isEmpty(mockOAuth) || !mockOAuth.equals("true")) {
return new ResponseEntity<>(new StatusJSON("mocking disabled").getJSON().toString(), HttpStatus.LOCKED);
}
if (userRepository.findByMail(sessionService.extractMail(oAuthToken)) != null) {
return new ResponseEntity<>(new StatusJSON("ok").getJSON().toString(), HttpStatus.ACCEPTED);
}
return new ResponseEntity<>(new StatusJSON("forbidden").getJSON().toString(), HttpStatus.FORBIDDEN);
}
示例2: getChecksum
import org.springframework.util.StringUtils; //导入依赖的package包/类
private String getChecksum(String defaultValue, String url,
String version) {
String result = defaultValue;
if (result == null && StringUtils.hasText(url)) {
CloseableHttpClient httpClient = HttpClients.custom()
.setSSLHostnameVerifier(new NoopHostnameVerifier())
.build();
HttpComponentsClientHttpRequestFactory requestFactory
= new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
url = constructUrl(url, version);
try {
ResponseEntity<String> response
= new RestTemplate(requestFactory).exchange(
url, HttpMethod.GET, null, String.class);
if (response.getStatusCode().equals(HttpStatus.OK)) {
result = response.getBody();
}
}
catch (HttpClientErrorException httpException) {
// no action necessary set result to undefined
logger.debug("Didn't retrieve checksum because", httpException);
}
}
return result;
}
示例3: build
import org.springframework.util.StringUtils; //导入依赖的package包/类
/**
* by map
* @param map
* @return
*/
public HbaseFindBuilder build(Map<String,String> map) {
if (map == null || map.size() <= 0) {
return this;
}
PropertyDescriptor p = null;
byte[] qualifierByte = null;
for (String value : map.values()) {
if (StringUtils.isEmpty(value)) {
continue;
}
p = fieldsMap.get(value.trim());
qualifierByte = result.getValue(family.getBytes(), HumpNameOrMethodUtils.humpEntityForVar(value).getBytes());
if (qualifierByte != null && qualifierByte.length > 0) {
beanWrapper.setPropertyValue(p.getName(), Bytes.toString(qualifierByte));
propertiesSet.add(p.getName());
}
}
return this;
}
示例4: getDisplayName
import org.springframework.util.StringUtils; //导入依赖的package包/类
/**
* Gets display name.
*
* @return the display name
*/
public String getDisplayName() {
final Collection<String> items = getDisplayNames();
if (items.isEmpty()) {
return this.registeredService.getName();
}
return StringUtils.collectionToDelimitedString(items, ".");
}
示例5: getInfoAndVersionsFor
import org.springframework.util.StringUtils; //导入依赖的package包/类
@Override
public AddOnInfoAndVersions getInfoAndVersionsFor(AddOnToIndex addOnToIndex) throws Exception {
if (StringUtils.isEmpty(bintrayUsername) || StringUtils.isEmpty(bintrayApiKey)) {
logger.error("You need to specify the bintray.username and bintray.api_key configuration settings");
}
String url = packageUrlFor(addOnToIndex);
ResponseEntity<String> entity = restTemplateBuilder.basicAuthorization(bintrayUsername, bintrayApiKey).build()
.getForEntity(url, String.class);
if (!entity.getStatusCode().is2xxSuccessful()) {
logger.warn("Problem fetching " + url + " -> " + entity.getStatusCode() + " " + entity.getBody());
return null;
} else {
String json = entity.getBody();
return handlePackageJson(addOnToIndex, json);
}
}
示例6: process
import org.springframework.util.StringUtils; //导入依赖的package包/类
public boolean process(Element parent, Attr attribute, BeanDefinitionBuilder builder) {
String name = attribute.getLocalName();
if (BeanDefinitionParserDelegate.ID_ATTRIBUTE.equals(name)) {
return false;
}
if (BeanDefinitionParserDelegate.DEPENDS_ON_ATTRIBUTE.equals(name)) {
builder.getBeanDefinition().setDependsOn(
(StringUtils.tokenizeToStringArray(attribute.getValue(),
BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS)));
return false;
}
if (BeanDefinitionParserDelegate.LAZY_INIT_ATTRIBUTE.equals(name)) {
builder.setLazyInit(Boolean.valueOf(attribute.getValue()));
return false;
}
return true;
}
示例7: removeFromSessionsMap
import org.springframework.util.StringUtils; //导入依赖的package包/类
public synchronized void removeFromSessionsMap(SseEmitter session, String dashboardId){
LOGGER.debug("Remove SseEmitter {} to sessions map", dashboardId);
if(!StringUtils.isEmpty(dashboardId)){
List<SseEmitter> dashboardEmitters = emittersPerDashboard.get(dashboardId);
if(dashboardEmitters != null){
dashboardEmitters.remove(session);
if(dashboardEmitters.isEmpty()){
emittersPerDashboard.remove(dashboardId);
}
}
}
}
示例8: parseLocaleCookieIfNecessary
import org.springframework.util.StringUtils; //导入依赖的package包/类
private void parseLocaleCookieIfNecessary(HttpServletRequest request) {
if (request.getAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME) == null) {
// Retrieve and parse cookie value.
Cookie cookie = WebUtils.getCookie(request, getCookieName());
Locale locale = null;
TimeZone timeZone = null;
if (cookie != null) {
String value = cookie.getValue();
// Remove the double quote
value = StringUtils.replace(value, "%22", "");
String localePart = value;
String timeZonePart = null;
int spaceIndex = localePart.indexOf(' ');
if (spaceIndex != -1) {
localePart = value.substring(0, spaceIndex);
timeZonePart = value.substring(spaceIndex + 1);
}
locale = (!"-".equals(localePart) ? StringUtils.parseLocaleString(localePart.replace('-', '_')) : null);
if (timeZonePart != null) {
timeZone = StringUtils.parseTimeZoneString(timeZonePart);
}
if (logger.isTraceEnabled()) {
logger.trace("Parsed cookie value [" + cookie.getValue() + "] into locale '" + locale +
"'" + (timeZone != null ? " and time zone '" + timeZone.getID() + "'" : ""));
}
}
request.setAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME,
(locale != null ? locale: determineDefaultLocale(request)));
request.setAttribute(TIME_ZONE_REQUEST_ATTRIBUTE_NAME,
(timeZone != null ? timeZone : determineDefaultTimeZone(request)));
}
}
示例9: changePassword
import org.springframework.util.StringUtils; //导入依赖的package包/类
@Override
public User changePassword(String userId, String newPassword) {
User user = userRepository.findById(userId);
if (user == null) {
throw new UserNotFoundException(userId);
}
if (StringUtils.isEmpty(newPassword)) {
throw new UserPasswordException("新设置的密码不能为空");
}
if (newPassword.length() < 8) {
throw new UserPasswordException("新设置的密码长度不能少于8位");
}
String passwordHash = passwordEncoder.encode(newPassword);
user.setPassword(passwordHash);
return userRepository.save(user);
}
示例10: constructUrl
import org.springframework.util.StringUtils; //导入依赖的package包/类
private String constructUrl(String url, String version) {
final String VERSION_TAG = "{version}";
final String REPOSITORY_TAG = "{repository}";
if (url.contains(VERSION_TAG)) {
url = StringUtils.replace(url, VERSION_TAG, version);
url = StringUtils.replace(url, REPOSITORY_TAG, repoSelector(version));
}
return url;
}
示例11: arroundHandler
import org.springframework.util.StringUtils; //导入依赖的package包/类
@Around("@annotation(demoExceptionHandler)")
public Object arroundHandler(final ProceedingJoinPoint joinPoint, final DemoExceptionHandler demoExceptionHandler)
throws Throwable {
Object rval = null;
try {
rval = joinPoint.proceed();
} catch (final RuntimeException re) {
// log error.
if (!StringUtils.isEmpty(demoExceptionHandler.fallbackMethod())) {
rval = executeFallbackMethod(joinPoint, demoExceptionHandler);
} else {
throw re;
}
}
return rval;
}
示例12: findAccountByUsername
import org.springframework.util.StringUtils; //导入依赖的package包/类
@Override
public User findAccountByUsername(String username) {
if (StringUtils.isEmpty(username)) {
return null;
}
username = username.trim().toLowerCase();
User account = userRepository.findByUsername(username);
if (account == null) {
return null;
}
User result = new User();
BeanUtils.copyProperties(account, result, "roles");
//populate sys roles
result.getAuthorities().addAll(account.getRoles());
//populate app role
result.getAuthorities()
.addAll(userRoleRelationshipRepository.findListByUser(account)
.stream()
.map(relationship -> relationship.getRole())
.collect(Collectors.toList()));
return result;
}
示例13: setInterceptorHandlers
import org.springframework.util.StringUtils; //导入依赖的package包/类
public void setInterceptorHandlers(String interceptorHandlers) {
String[] handlerNames = StringUtils.tokenizeToStringArray(interceptorHandlers,
ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
for (String name : handlerNames) {
if (CacheHandler.NAME.equals(name)) {
this.interceptorHandlers.add(new CacheHandler());
cacheEnabled = true;
} else if (RwRouteHandler.NAME.equals(name)) {
this.interceptorHandlers.add(new RwRouteHandler());
rwRouteEnabled = true;
} else if (DatabaseRouteHandler.NAME.equals(name)) {
this.interceptorHandlers.add(new DatabaseRouteHandler());
dbShardEnabled = true;
} else if (PaginationHandler.NAME.equals(name)) {
this.interceptorHandlers.add(new PaginationHandler());
}
}
//排序
Collections.sort(this.interceptorHandlers, new Comparator<InterceptorHandler>() {
@Override
public int compare(InterceptorHandler o1, InterceptorHandler o2) {
return Integer.compare(o1.interceptorOrder(), o2.interceptorOrder());
}
});
}
示例14: getEtatCivil
import org.springframework.util.StringUtils; //导入依赖的package包/类
/**
* @param candidat
* @return l'etat civil
*/
@Override
public MAJEtatCivilDTO getEtatCivil(Candidat candidat) {
MAJEtatCivilDTO etatCivil = new MAJEtatCivilDTO();
// Etat Civil
etatCivil.setLibNomPatIndOpi(MethodUtils.cleanForApogee(candidat.getNomPatCandidat()));
etatCivil.setLibNomUsuIndOpi(MethodUtils.cleanForApogee(candidat.getNomUsuCandidat()));
etatCivil.setLibPr1IndOpi(MethodUtils.cleanForApogee(candidat.getPrenomCandidat()));
etatCivil.setLibPr2IndOpi(MethodUtils.cleanForApogee(candidat.getAutrePrenCandidat()));
// separer le clé du code nne
if (StringUtils.hasText(candidat.getIneCandidat()) && StringUtils.hasText(candidat.getCleIneCandidat())) {
etatCivil.setCodNneIndOpi(MethodUtils.cleanForApogee(candidat.getIneCandidat()));
etatCivil.setCodCleNneIndOpi(MethodUtils.cleanForApogee(candidat.getCleIneCandidat()));
}
if (candidat.getCivilite() != null && candidat.getCivilite().getCodApo() != null) {
String codSex = "";
if (candidat.getCivilite().getCodApo().equals("1")) {
codSex = "M";
} else {
codSex = "F";
}
etatCivil.setCodSexEtuOpi(codSex);
}
return etatCivil;
}
示例15: parseArguments
import org.springframework.util.StringUtils; //导入依赖的package包/类
public static String[] parseArguments(final String input) {
if (StringUtils.isEmpty(input)) {
return new String[0];
}
return ArgumentTokenizer.tokenize(input).toArray(new String[0]);
// final Matcher m = ARG_PATTERN.matcher(input);
// final List<String> list = new ArrayList<>();
// while (m.find()) {
// final String group3 = m.group(3);
// if (group3 == null) {
// list.add(m.group(1));
// } else {
// list.add(group3);
// }
// }
// return list.toArray(new String[list.size()]);
}