本文整理匯總了Java中org.apache.commons.lang.StringUtils.defaultIfBlank方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.defaultIfBlank方法的具體用法?Java StringUtils.defaultIfBlank怎麽用?Java StringUtils.defaultIfBlank使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.StringUtils
的用法示例。
在下文中一共展示了StringUtils.defaultIfBlank方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DefaultModuleCfg
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public DefaultModuleCfg(YMP owner) {
Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(IOAuth.MODULE_NAME);
//
__accessTokenExpireIn = BlurObject.bind(_moduleCfgs.get("access_token_expire_in")).toIntValue();
if (__accessTokenExpireIn <= 0) {
__accessTokenExpireIn = 7200;
}
//
__cacheNamePrefix = StringUtils.trimToEmpty(_moduleCfgs.get("cache_name_prefix"));
//
__snsEnabled = BlurObject.bind(_moduleCfgs.get("sns_enabled")).toBooleanValue();
if (__snsEnabled) {
__authorizationView = StringUtils.defaultIfBlank(_moduleCfgs.get("authorization_view"), "_views/oauth2/sns-authorization");
__userInfoAdaptor = ClassUtils.impl(_moduleCfgs.get("userinfo_adapter_class"), IOAuthUserInfoAdapter.class, getClass());
}
//
__tokenGenerator = ClassUtils.impl(_moduleCfgs.get("token_generator_class"), IOAuthTokenGenerator.class, getClass());
if (__tokenGenerator == null) {
__tokenGenerator = new DefaultTokenGenerator();
}
//
__storageAdapter = ClassUtils.impl(_moduleCfgs.get("storage_adapter_class"), IOAuthStorageAdapter.class, getClass());
}
示例2: populateForInvite
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
protected String populateForInvite(IThreePidInviteReply invite, String input) {
ThreePid tpid = new ThreePid(invite.getInvite().getMedium(), invite.getInvite().getAddress());
String senderName = invite.getInvite().getProperties().getOrDefault("sender_display_name", "");
String senderNameOrId = StringUtils.defaultIfBlank(senderName, invite.getInvite().getSender().getId());
String roomName = invite.getInvite().getProperties().getOrDefault("room_name", "");
String roomNameOrId = StringUtils.defaultIfBlank(roomName, invite.getInvite().getRoomId());
return populateForCommon(input, tpid)
.replace("%SENDER_ID%", invite.getInvite().getSender().getId())
.replace("%SENDER_NAME%", senderName)
.replace("%SENDER_NAME_OR_ID%", senderNameOrId)
.replace("%INVITE_MEDIUM%", tpid.getMedium())
.replace("%INVITE_ADDRESS%", tpid.getAddress())
.replace("%ROOM_ID%", invite.getInvite().getRoomId())
.replace("%ROOM_NAME%", roomName)
.replace("%ROOM_NAME_OR_ID%", roomNameOrId);
}
示例3: DefaultModuleCfg
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public DefaultModuleCfg(YMP owner) {
Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(IWxPay.MODULE_NAME);
//
__accountProvider = ClassUtils.impl(_moduleCfgs.get("account_provider_class"), IWxPayAccountProvider.class, getClass());
if (__accountProvider == null) {
__accountProvider = new DefaultWxPayAccountProvider();
//
WxPayAccountMeta _meta = new WxPayAccountMeta(_moduleCfgs.get("app_id"),
_moduleCfgs.get(IWxPay.Const.MCH_ID),
_moduleCfgs.get(IWxPay.Const.MCH_KEY),
_moduleCfgs.get("cert_file_path"),
_moduleCfgs.get(IWxPay.Const.NOTIFY_URL));
_meta.setSandboxEnabled(BlurObject.bind(_moduleCfgs.get("sandbox_enabled")).toBooleanValue());
_meta.setSandboxPrefix(StringUtils.defaultIfBlank(_moduleCfgs.get("sandbox_prefix"), "sandboxnew"));
//
__defaultAccountId = _meta.getAppId();
__accountProvider.registerAccount(_meta);
} else {
__defaultAccountId = StringUtils.trimToNull(_moduleCfgs.get("default_account_id"));
}
//
__eventHandler = ClassUtils.impl(_moduleCfgs.get("event_handler_class"), IWxPayEventHandler.class, getClass());
if (__eventHandler == null) {
throw new NullArgumentException("event_handler_class");
}
//
__jsApiView = StringUtils.defaultIfBlank(_moduleCfgs.get("jsapi_view"), "wxpay_jsapi");
__nativeView = StringUtils.defaultIfBlank(_moduleCfgs.get("native_view"), "wxpay_native");
//
__signCheckDisabled = BlurObject.bind(_moduleCfgs.get("sign_check_disabled")).toBooleanValue();
}
示例4: AliPayBaseRequest
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public AliPayBaseRequest(AliPayAccountMeta accountMeta, String method, String version, DATA bizContent, boolean needNotify, boolean needReturn, IAliPayResponseParser<RESPONSE> responseParser) {
if (accountMeta == null) {
throw new NullArgumentException("accountMeta");
}
if (StringUtils.isBlank(method)) {
throw new NullArgumentException("method");
}
if (bizContent == null) {
throw new NullArgumentException("bizContent");
}
if (responseParser == null) {
throw new NullArgumentException("responseParser");
}
//
this.accountMeta = accountMeta;
this.method = method;
this.version = StringUtils.defaultIfBlank(version, "1.0");
this.bizContent = bizContent;
//
this.needNotify = needNotify;
this.needReturn = needReturn;
//
this.responseParser = responseParser;
}
示例5: DefaultSSOToken
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public DefaultSSOToken(String uid, String userAgent, String remoteAddr, long createTime) {
this();
this.uid = uid;
this.remoteAddr = StringUtils.defaultIfBlank(remoteAddr, WebUtils.getRemoteAddr(WebContext.getRequest()));
this.userAgent = StringUtils.defaultIfBlank(userAgent, WebContext.getRequest().getHeader("User-Agent"));
this.createTime = createTime > 0 ? createTime : System.currentTimeMillis();
}
示例6: DefaultModuleCfg
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public DefaultModuleCfg(YMP owner) {
Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(ISSO.MODULE_NAME);
//
__tokenCookieName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_cookie_name"), ISSO.MODULE_NAME + "_token");
//
__tokenHeaderName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_header_name"), "X-ModuleSSO-Token");
//
__tokenParamName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_param_name"), "token");
//
__tokenMaxage = BlurObject.bind(_moduleCfgs.get("token_maxage")).toIntValue();
//
__tokenValidateTimeInterval = BlurObject.bind(_moduleCfgs.get("token_validate_time_interval")).toIntValue();
//
__cacheNamePrefix = StringUtils.trimToEmpty(_moduleCfgs.get("cache_name_prefix"));
//
__multiSessionEnabled = BlurObject.bind(_moduleCfgs.get("multi_session_enabled")).toBooleanValue();
//
__ipCheckEnabled = BlurObject.bind(_moduleCfgs.get("ip_check_enabled")).toBooleanValue();
//
__isClientMode = BlurObject.bind(_moduleCfgs.get("client_mode")).toBooleanValue();
//
__serviceAuthKey = StringUtils.trimToEmpty(_moduleCfgs.get("service_auth_key"));
//
if (__isClientMode) {
__serviceBaseUrl = StringUtils.trimToNull(_moduleCfgs.get("service_base_url"));
if (__serviceBaseUrl != null) {
if (!StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "http://") &&
!StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "https://")) {
throw new IllegalArgumentException("The parameter service_base_url is invalid");
} else if (!StringUtils.endsWith(__serviceBaseUrl, "/")) {
__serviceBaseUrl = __serviceBaseUrl + "/";
}
}
}
//
__tokenApater = ClassUtils.impl(_moduleCfgs.get("token_adapter_class"), ISSOTokenAdapter.class, getClass());
if (__tokenApater == null) {
__tokenApater = new DefaultSSOTokenAdapter();
}
//
__tokenStorageAdapter = ClassUtils.impl(_moduleCfgs.get("storage_adapter_class"), ISSOTokenStorageAdapter.class, getClass());
if (!__isClientMode && __tokenStorageAdapter == null) {
throw new IllegalArgumentException("The parameter storage_adapter_class is invalid");
}
//
if (!__isClientMode) {
__tokenAttributeAdapter = ClassUtils.impl(_moduleCfgs.get("attribute_adapter_class"), ISSOTokenAttributeAdapter.class, getClass());
}
}
示例7: find
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
@Override
public Optional<SingleLookupReply> find(SingleLookupRequest request) {
log.info("SQL lookup");
String stmtSql = StringUtils.defaultIfBlank(cfg.getIdentity().getMedium().get(request.getType()), cfg.getIdentity().getQuery());
log.info("SQL query: {}", stmtSql);
try (Connection conn = pool.get()) {
try (PreparedStatement stmt = conn.prepareStatement(stmtSql)) {
stmt.setString(1, request.getType().toLowerCase());
stmt.setString(2, request.getThreePid().toLowerCase());
try (ResultSet rSet = stmt.executeQuery()) {
while (rSet.next()) {
String uid = rSet.getString("uid");
log.info("Found match: {}", uid);
if (StringUtils.equals("uid", cfg.getIdentity().getType())) {
log.info("Resolving as localpart");
return Optional.of(new SingleLookupReply(request, new MatrixID(uid, mxCfg.getDomain())));
}
if (StringUtils.equals("mxid", cfg.getIdentity().getType())) {
log.info("Resolving as MXID");
return Optional.of(new SingleLookupReply(request, new MatrixID(uid)));
}
log.info("Identity type is unknown, skipping");
}
log.info("No match found in SQL");
return Optional.empty();
}
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
示例8: setSandboxPrefix
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public void setSandboxPrefix(String sandboxPrefix) {
sandboxPrefix = StringUtils.defaultIfBlank(sandboxPrefix, "sandboxnew");
if (StringUtils.startsWith(sandboxPrefix, "/")) {
sandboxPrefix = StringUtils.substringAfter(sandboxPrefix, "/");
}
if (!StringUtils.endsWith(this.sandboxPrefix, "/")) {
sandboxPrefix = sandboxPrefix + "/";
}
this.sandboxPrefix = sandboxPrefix;
}
示例9: build
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public IAliPayReqeustSender<RESPONSE> build() throws Exception {
Map<String, String> _params = new HashMap<String, String>();
//
String _charset = StringUtils.defaultIfBlank(accountMeta.getCharset(), IAliPay.Const.CHARSET_UTF8);
//
_params.put(IAliPay.Const.APP_ID, accountMeta.getAppId());
_params.put(IAliPay.Const.METHOD, method);
_params.put(IAliPay.Const.CHARSET, _charset);
_params.put(IAliPay.Const.FORMAT, accountMeta.getFormat());
_params.put(IAliPay.Const.SIGN_TYPE, accountMeta.getSignType().name());
_params.put(IAliPay.Const.TIMESTAMP, DateTimeUtils.formatTime(System.currentTimeMillis(), IAliPay.Const.DATE_TIME_FORMAT));
_params.put(IAliPay.Const.VERSION, version);
//
if (needNotify) {
if (StringUtils.isNotBlank(accountMeta.getNotifyUrl())) {
_params.put(IAliPay.Const.NOTIFY_URL, accountMeta.getNotifyUrl());
}
}
if (needReturn) {
if (StringUtils.isNotBlank(accountMeta.getReturnUrl())) {
_params.put(IAliPay.Const.RETURN_URL, accountMeta.getReturnUrl());
}
}
//
String _bizContentStr = JSON.toJSONString(this.bizContent.buildRequestParams(), SerializerFeature.QuoteFieldNames);
_params.put(IAliPay.Const.BIZ_CONTENT_KEY, _bizContentStr);
//
String _signStr = SignatureUtils.sign(_params, accountMeta.getPrivateKey(), _charset, accountMeta.getSignType());
_params.put(IAliPay.Const.SIGN, _signStr);
//
return new DefaultAliPayRequestSender<RESPONSE>(_params, _charset, this.responseParser);
}
示例10: DefaultModuleCfg
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public DefaultModuleCfg(YMP owner) {
Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(IAliPay.MODULE_NAME);
//
__gatewayUrl = StringUtils.defaultIfBlank(_moduleCfgs.get("gateway_url"), "https://openapi.alipay.com/gateway.do");
if (!StringUtils.startsWithIgnoreCase(__gatewayUrl, "https://") && !StringUtils.startsWithIgnoreCase(__gatewayUrl, "http://")) {
throw new IllegalArgumentException("gateway_url address is invalid");
}
//
__accountProvider = ClassUtils.impl(_moduleCfgs.get("account_provider_class"), IAliPayAccountProvider.class, getClass());
if (__accountProvider == null) {
__accountProvider = new DefaultAliPayAccountProvider();
//
AliPayAccountMeta _meta = new AliPayAccountMeta(_moduleCfgs.get(IAliPay.Const.APP_ID), _moduleCfgs.get(IAliPay.Const.SIGN_TYPE), _moduleCfgs.get("private_key"), _moduleCfgs.get("public_key"));
_meta.setCharset(StringUtils.defaultIfBlank(_moduleCfgs.get(IAliPay.Const.CHARSET), IAliPay.Const.CHARSET_UTF8));
_meta.setFormat(StringUtils.defaultIfBlank(_moduleCfgs.get(IAliPay.Const.FORMAT), IAliPay.Const.FORMAT_JSON));
_meta.setNotifyUrl(StringUtils.trimToNull(_moduleCfgs.get(IAliPay.Const.NOTIFY_URL)));
_meta.setReturnUrl(StringUtils.trimToNull(_moduleCfgs.get(IAliPay.Const.RETURN_URL)));
//
__defaultAccountId = _meta.getAppId();
__accountProvider.registerAccount(_meta);
} else {
__defaultAccountId = StringUtils.trimToNull(_moduleCfgs.get("default_account_id"));
}
//
__eventHandler = ClassUtils.impl(_moduleCfgs.get("event_handler_class"), IAliPayEventHandler.class, getClass());
if (__eventHandler == null) {
throw new NullArgumentException("event_handler_class");
}
//
__signCheckDisabled = BlurObject.bind(_moduleCfgs.get("sign_check_disabled")).toBooleanValue();
}
示例11: __toConnect
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* @param connectName 連接器名稱
* @param state 自定義狀態值(用於防CSRF攻擊)
* @return 跳轉至獲取第三方授權碼的URL地址
* @throws Exception 可能產生的任何異常
*/
@RequestMapping("/{connectName}")
public IView __toConnect(@PathVariable String connectName, @RequestParam String state) throws Exception {
IOAuthConnectProcessor _processor = OAuthConnector.get().getConnectProcessor(connectName);
if (_processor != null) {
state = StringUtils.defaultIfBlank(state, ParamUtils.createNonceStr());
IView _view = OAuthConnector.get().getModuleCfg().getConnectCallbackHandler().connect(connectName, state);
//
if (_view == null) {
return View.redirectView(_processor.getAuthorizeUrl(state));
}
return _view;
}
return View.httpStatusView(HttpServletResponse.SC_BAD_REQUEST);
}
示例12: AwsBucketCredentialsBinding
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* For use with {@link DataBoundConstructor}.
*
* @param credentialsId
*/
@DataBoundConstructor
public AwsBucketCredentialsBinding(@Nullable String usernameVariable, @Nullable String passwordVariable,
String credentialsId) {
super(credentialsId);
this.usernameVariable = StringUtils.defaultIfBlank(usernameVariable, DEFAULT_USERNAME_VARIABLE);
this.passwordVariable = StringUtils.defaultIfBlank(passwordVariable, DEFAULT_PASSWORD_VARIABLE);
}
示例13: AliPayException
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public AliPayException(String errCode) {
this.errCode = StringUtils.defaultIfBlank(errCode, "UNKNOWN_ERROR");
this.errMsg = __ERRORS.get(this.errCode);
}
示例14: AbstractOAuthConnectProcessor
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public AbstractOAuthConnectProcessor(String clientParamName, String secretParamName, String openIdParamName) {
__clientParamName = StringUtils.defaultIfBlank(clientParamName, "client_id");
__secretParamName = StringUtils.defaultIfBlank(secretParamName, "client_secret");
__openIdParamName = openIdParamName;
}
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:6,代碼來源:AbstractOAuthConnectProcessor.java
示例15: __doSetErrorFlag
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
protected void __doSetErrorFlag(String errorFlag) {
__errorFlag = StringUtils.defaultIfBlank(errorFlag, "error");
}
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:4,代碼來源:AbstractOAuthConnectProcessor.java