Here are the examples of the java api com.blade.kit.StringKit.isEmpty() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
7 Examples
19
View Complete Implementation : Utils.java
Copyright MIT License
Author : biezhi
Copyright MIT License
Author : biezhi
public static Double parseDouble(String value, double defaultValue) {
try {
if (StringKit.isEmpty(value)) {
return defaultValue;
}
return Double.valueOf(value);
} catch (Exception e) {
return defaultValue;
}
}
19
View Complete Implementation : Utils.java
Copyright MIT License
Author : biezhi
Copyright MIT License
Author : biezhi
public static Integer parseInt(String value, int defaultValue) {
try {
if (StringKit.isEmpty(value)) {
return defaultValue;
}
return Integer.valueOf(value);
} catch (Exception e) {
return defaultValue;
}
}
18
View Complete Implementation : HttpRequest.java
Copyright Apache License 2.0
Author : lets-blade
Copyright Apache License 2.0
Author : lets-blade
@Override
public boolean useGZIP() {
boolean useGZIP = WebContext.blade().environment().getBoolean(Const.ENV_KEY_GZIP_ENABLE, false);
if (!useGZIP) {
return false;
}
String acceptEncoding = this.header(HttpConst.ACCEPT_ENCODING);
if (StringKit.isEmpty(acceptEncoding)) {
return false;
}
return acceptEncoding.contains("gzip");
}
18
View Complete Implementation : BasicAuthMiddleware.java
Copyright Apache License 2.0
Author : lets-blade
Copyright Apache License 2.0
Author : lets-blade
private String searchCredential(String authValue) {
if (StringKit.isEmpty(authValue)) {
return null;
}
return authPairs.stream().filter(authPair -> authPair.getValue().equals(authValue)).map(AuthPair::getUser).findFirst().orElse(null);
}
17
View Complete Implementation : SessionHandler.java
Copyright Apache License 2.0
Author : lets-blade
Copyright Apache License 2.0
Author : lets-blade
private Session getSession(Request request) {
String cookieHeader = request.cookie(WebContext.sessionKey());
if (StringKit.isEmpty(cookieHeader)) {
return null;
}
return sessionManager.getSession(cookieHeader);
}
15
View Complete Implementation : CsrfMiddleware.java
Copyright Apache License 2.0
Author : lets-blade
Copyright Apache License 2.0
Author : lets-blade
public String genToken(RouteContext context) {
String tokenUUID = context.session().attribute(sessionToken);
if (StringKit.isEmpty(tokenUUID)) {
tokenUUID = UUID.UU64();
context.session().attribute(sessionToken, tokenUUID);
}
String token = Base64.getEncoder().encodeToString(PreplacedwordKit.hashPreplacedword(tokenUUID).getBytes());
context.attribute("_csrf_token", token);
context.attribute("_csrf_token_input", "<input type='hidden' name='_token' value='" + token + "'/>");
return token;
}
15
View Complete Implementation : CsrfMiddleware.java
Copyright Apache License 2.0
Author : lets-blade
Copyright Apache License 2.0
Author : lets-blade
@Override
public boolean before(RouteContext context) {
if (csrfOption.isIgnoreMethod(context.method())) {
if (csrfOption.isStartExclusion(context.uri())) {
return true;
}
this.genToken(context);
return true;
}
if (csrfOption.isExclusion(context.uri())) {
return true;
}
String tokenUUID = context.session().attribute(sessionToken);
if (StringKit.isEmpty(tokenUUID)) {
csrfOption.getErrorHandler().accept(context);
return false;
}
String token = csrfOption.getTokenGetter().apply(context.request());
if (StringKit.isEmpty(token)) {
csrfOption.getErrorHandler().accept(context);
return false;
}
String hash = new String(Base64.getDecoder().decode(token));
if (!PreplacedwordKit.checkPreplacedword(tokenUUID, hash)) {
csrfOption.getErrorHandler().accept(context);
return false;
}
return true;
}