Java Code Examples for org.osgl.util.S#notBlank()
The following examples show how to use
org.osgl.util.S#notBlank() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Interaction.java From actframework with Apache License 2.0 | 6 votes |
private boolean verify() { Response resp = null; try { if (S.notBlank(request.email)) { doVerifyEmail(request.email); } else { resp = TestSession.current().sendRequest(request); doVerify(resp); } return true; } catch (Exception e) { errorMessage = e.getMessage(); if (null == errorMessage) { errorMessage = e.getClass().getName(); } cause = causeOf(e); return false; } finally { IO.close(resp); } }
Example 2
Source File: ControllerClassMetaInfo.java From actframework with Apache License 2.0 | 6 votes |
public String urlContext() { if (null != parent) { if (S.notBlank(urlContext) && urlContext.length() > 1 && urlContext.startsWith("/")) { return urlContext; } String parentContextPath = parent.urlContext(); if (null == urlContext) { return parentContextPath; } if (null == parentContextPath) { return urlContext; } S.Buffer sb = S.newBuffer(parentContextPath); if (parentContextPath.endsWith("/")) { sb.deleteCharAt(sb.length() - 1); } if (!urlContext.startsWith("/")) { sb.append("/"); } sb.append(urlContext); return sb.toString(); } return urlContext; }
Example 3
Source File: ControllerClassMetaInfo.java From actframework with Apache License 2.0 | 6 votes |
public String templateContext() { if (null != parent) { if (S.notBlank(templateContext) && templateContext.length() > 1 && templateContext.startsWith("/")) { return templateContext; } String parentContextPath = parent.templateContext(); if (null == templateContext) { return parentContextPath; } if (null == parentContextPath) { return templateContext; } S.Buffer sb = S.newBuffer(parentContextPath); if (parentContextPath.endsWith("/")) { sb.deleteCharAt(sb.length() - 1); } if (!templateContext.startsWith("/")) { sb.append("/"); } sb.append(templateContext); return sb.toString(); } return templateContext; }
Example 4
Source File: ContentTypeWithEncoding.java From actframework with Apache License 2.0 | 6 votes |
public static ContentTypeWithEncoding parse(String contentType) { if( contentType == null ) { return new ContentTypeWithEncoding("text/html".intern(), null); } else { String[] contentTypeParts = contentType.split(";"); String _contentType = contentTypeParts[0].trim().toLowerCase(); String _encoding = null; // check for encoding-info if (contentTypeParts.length >= 2) { String[] encodingInfoParts = contentTypeParts[1].split(("=")); if (encodingInfoParts.length == 2 && encodingInfoParts[0].trim().equalsIgnoreCase("charset")) { // encoding-info was found in request _encoding = encodingInfoParts[1].trim(); if (S.notBlank(_encoding) && ((_encoding.startsWith("\"") && _encoding.endsWith("\"")) || (_encoding.startsWith("'") && _encoding.endsWith("'"))) ) { _encoding = _encoding.substring(1, _encoding.length() - 1).trim(); } } } return new ContentTypeWithEncoding(_contentType, _encoding); } }
Example 5
Source File: CliArgumentLoader.java From actframework with Apache License 2.0 | 6 votes |
@Override public Object load(Object cached, ActContext<?> context, boolean noDefaultValue) { CliContext ctx = (CliContext) context; CliContext.ParsingContext ptx = ctx.parsingContext(); int id = ptx.curArgId().getAndIncrement(); String optVal = ctx.commandLine().argument(id); Object val = null; if (S.isBlank(optVal)) { optVal = ptx.argDefVals.get(id); } if (S.notBlank(optVal)) { val = resolver.resolve(optVal); } if (null == val && null != cached) { val = cached; } return val; }
Example 6
Source File: JobAdmin.java From actframework with Apache License 2.0 | 6 votes |
/** * List all jobs in the job manager * @return a list of {@link Job jobs} */ @Command(value = "act.job.list,act.job,act.jobs", help = "List jobs") @PropertySpec(Job.BRIEF_VIEW) @TableView public List<Job> listJobs(@Optional(lead = "-q", help = "search string") final String q, JobManager jobManager) { C.List<Job> jobs = jobManager.jobs().append(jobManager.virtualJobs()).unique(_UNIQ_JOB_FILTER); if (S.notBlank(q)) { jobs = jobs.filter(new $.Predicate<Job>() { @Override public boolean test(Job job) { String jobStr = job.toString(); return jobStr.contains(q) || jobStr.matches(q); } }); } return jobs; }
Example 7
Source File: YamlLoader.java From actframework with Apache License 2.0 | 6 votes |
protected void setFixtureFolder(String fixtureFolder, String legacyFixtureFolder) { if (S.notBlank(fixtureFolder)) { this.fixtureFolder = S.ensure(S.ensure(fixtureFolder.trim()).startWith("/")).endWith("/"); } if (S.notBlank(legacyFixtureFolder)) { this.legacyFixtureFolder = S.ensure(S.ensure(legacyFixtureFolder.trim()).startWith("/")).endWith("/"); } if (warned.get()) { return; } warned.set(true); App app = Act.app(); if (null != app) { if (S.blank(fixtureFolder) || !app.testResource(fixtureFolder).exists()) { if (S.notBlank(legacyFixtureFolder) && app.resource(legacyFixtureFolder).exists()) { Act.LOGGER.warn("Legacy test resource detected: src/main/resources/test. It recommend to migrate to new place: src/test/resources"); } else { Act.LOGGER.warn("No test resource found"); } } } }
Example 8
Source File: CliOverHttpContext.java From actframework with Apache License 2.0 | 6 votes |
private static String line(ActionContext actionContext) { String cmd = null; S.Buffer sb = S.buffer(); for (String s : actionContext.paramKeys()) { if ("cmd".equals(s)) { cmd = actionContext.paramVal(s); } else if (s.startsWith("-")) { String val = actionContext.paramVal(s); if (S.notBlank(val)) { val = val.replaceAll("[\n\r]+", "<br/>").trim(); if (val.contains(" ")) { char quote = val.contains("\"") ? '\'' : '\\'; val = S.wrap(val, quote); } if (s.contains(",")) { s = S.before(s, ","); } sb.append(s).append(" ").append(val).append(" "); } } } E.illegalArgumentIf(null == cmd, "cmd param required"); return S.builder(cmd).append(" ").append(sb.toString()).toString(); }
Example 9
Source File: Main.java From di-benchmark with MIT License | 6 votes |
public static void main(String[] args) { int warmUp = WARM_UP; int iteration = ITERATION; String singletonStr = conf("singleton"); boolean singleton = S.notBlank(singletonStr) && Boolean.parseBoolean(singletonStr); String s = conf("warmup"); if (S.notBlank(s)) { warmUp = Integer.parseInt(s); } s = conf("iteration"); if (S.notBlank(s)) { iteration = Integer.parseInt(s); } s = conf("type"); if (S.eq(s, "runtime")) { new RuntimeBenchmark().run(warmUp, iteration, singleton); } if (S.eq(s, "startup")) { new StartupBenchmark().run(warmUp, iteration); } if (S.eq(s, "split_startup")) { new SplitStartupBenchmark().run(iteration); } }
Example 10
Source File: ZXingResult.java From actframework with Apache License 2.0 | 5 votes |
@Override protected void applyMessage(H.Request request, H.Response response) { String msg = this.getMessage(); this.applyBeforeCommitHandler(request, response); if(S.notBlank(msg)) { renderCode(response); } else { IO.close(response.outputStream()); } this.applyAfterCommitHandler(request, response); }
Example 11
Source File: CliContext.java From actframework with Apache License 2.0 | 5 votes |
public static void foundArgument(String defVal) { ParsingContext ctx0 = ctx.get(); int n = ctx0.optionArgumentsCnt++; if (S.notBlank(defVal)) { ctx0.argDefVals.put(n, defVal); } }
Example 12
Source File: CompoundSesssionMapper.java From actframework with Apache License 2.0 | 5 votes |
@Override public String readSession(H.Request request) { for (SessionMapper mapper : sessionMappers) { String retVal = mapper.readSession(request); if (S.notBlank(retVal)) { return retVal; } } return null; }
Example 13
Source File: JsonWebTokenSessionCodec.java From actframework with Apache License 2.0 | 5 votes |
@Override public H.Session decodeSession(String encodedSession, H.Request request) { H.Session session = new H.Session(); boolean newSession = true; if (S.notBlank(encodedSession)) { resolveFromJwtToken(session, encodedSession, true); newSession = false; } session = DefaultSessionCodec.processExpiration( session, $.ms(), newSession, sessionWillExpire, ttlInMillis, pingPath, request); return session; }
Example 14
Source File: ActContext.java From actframework with Apache License 2.0 | 5 votes |
@Override public String templatePath() { String path = templatePath; String context = templateContext; if (S.notBlank(path)) { return path.startsWith("/") || S.blank(context) ? path : S.pathConcat(context, '/', path); } else { if (S.blank(context)) { return methodPath().replace('.', '/'); } else { return S.pathConcat(context, '/', S.afterLast(methodPath(), ".")); } } }
Example 15
Source File: MailerConfig.java From actframework with Apache License 2.0 | 5 votes |
public MailerConfig(String id, Map<String, String> properties, App app) { super(app); E.illegalArgumentIf(S.blank(id), "mailer config id expected"); this.id = id; this.isDefault = "default".equals(id); this.from = getFromConfig(properties); this.contentType = getContentTypeConfig(properties); this.locale = getLocaleConfig(properties); this.subject = getProperty(SUBJECT, properties); this.host = getProperty(SMTP_HOST, properties); if ("gmail".equals(this.host)) { this.host = "smtp.gmail.com"; } this.username = getProperty(SMTP_USERNAME, properties); if (null == host) { if (S.notBlank(this.username) && this.username.endsWith("gmail.com")) { this.host = "smtp.gmail.com"; } else { info("smtp host configuration not found, will use mock smtp to send email"); mock = true; } } if (!mock) { this.useTls = getBooleanConfig(SMTP_TLS, properties) || S.eq("smtp.gmail.com", this.host) || S.eq("smtp-mail.outlook.com", this.host); this.useSsl = !this.useTls && getBooleanConfig(SMTP_SSL, properties); this.port = getPortConfig(properties); this.password = getProperty(SMTP_PASSWORD, properties); if (null == username || null == password) { warn("Either smtp.username or smtp.password is not configured for mailer[%s]", id); } } this.toList = getEmailListConfig(TO, properties); this.ccList = getEmailListConfig(CC, properties); this.bccList = getEmailListConfig(BCC, properties); }
Example 16
Source File: CSRF.java From actframework with Apache License 2.0 | 5 votes |
private String retrieveCsrfToken(ActionContext context) { String token = context.csrfPrefetched(); if (S.blank(token)) { token = context.req().header(headerName); } if (S.blank(token)) { token = context.paramVal(paramName); } if (S.notBlank(token)) { context.setCsrfPrefetched(token); } return token; }
Example 17
Source File: SimpleMetricStore.java From actframework with Apache License 2.0 | 5 votes |
private void countOnce_(String name) { AtomicLong al = counters.get(name); if (null == al) { AtomicLong newAl = new AtomicLong(); al = counters.putIfAbsent(name, newAl); if (null == al) { al = newAl; } } al.incrementAndGet(); name = getParent(name); if (S.notBlank(name)) { countOnce_(name); } }
Example 18
Source File: SessionValueLoader.java From actframework with Apache License 2.0 | 4 votes |
private String key(String name, BeanSpec spec) { if (S.notBlank(name)) { return name; } return spec.name(); }
Example 19
Source File: ClassFinderData.java From actframework with Apache License 2.0 | 4 votes |
public boolean whatSpecified() { return S.notBlank(this.what) && S.neq(SubClassFinder.DEF_VALUE, this.what); }
Example 20
Source File: SimpleProgressGauge.java From actframework with Apache License 2.0 | 4 votes |
public boolean isFailed() { if (null != delegate) { return delegate.isFailed(); } return S.notBlank(error); }