當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils類代碼示例

本文整理匯總了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);
}
 
開發者ID:sinnerschrader,項目名稱:SkillWill,代碼行數:13,代碼來源:OAuthMock.java

示例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;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:27,代碼來源:AboutController.java

示例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;
}
 
開發者ID:cwenao,項目名稱:springboot_cwenao,代碼行數:31,代碼來源:HbaseFindBuilder.java

示例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, ".");
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:13,代碼來源:SimpleMetadataUIInfo.java

示例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);
	}
}
 
開發者ID:openmrs,項目名稱:openmrs-contrib-addonindex,代碼行數:17,代碼來源:Bintray.java

示例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;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:20,代碼來源:StandardAttributeCallback.java

示例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);
                }
            }
        }
    }
 
開發者ID:BBVA,項目名稱:mirrorgate,代碼行數:17,代碼來源:ServerSentEventsHandler.java

示例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)));
    }
}
 
開發者ID:klask-io,項目名稱:klask-io,代碼行數:36,代碼來源:AngularCookieLocaleResolver.java

示例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);
}
 
開發者ID:melthaw,項目名稱:spring-backend-boilerplate,代碼行數:20,代碼來源:UserAccountServiceImpl.java

示例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;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:10,代碼來源:AboutController.java

示例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;
}
 
開發者ID:srhojo,項目名稱:springDemos,代碼行數:20,代碼來源:ExceptionHandlerAspect.java

示例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;
}
 
開發者ID:melthaw,項目名稱:spring-backend-boilerplate,代碼行數:24,代碼來源:UserAccountServiceImpl.java

示例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());
        }
    });

}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:28,代碼來源:MybatisInterceptor.java

示例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;
}
 
開發者ID:EsupPortail,項目名稱:esup-ecandidat,代碼行數:30,代碼來源:SiScolApogeeWSServiceImpl.java

示例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()]);
    }
 
開發者ID:avast,項目名稱:hdfs-shell,代碼行數:18,代碼來源:BashUtils.java


注:本文中的org.springframework.util.StringUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。