本文整理汇总了Java中org.threadly.util.StringUtils.isNullOrEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.isNullOrEmpty方法的具体用法?Java StringUtils.isNullOrEmpty怎么用?Java StringUtils.isNullOrEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threadly.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.isNullOrEmpty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryToString
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
public static String queryToString(Map<String,String> map) {
if(map.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
sb.append('?');
for(String k: map.keySet()) {
if(sb.length() > 1) {
sb.append('&');
}
sb.append(k);
String v = map.get(k);
if(! StringUtils.isNullOrEmpty(v)) {
sb.append('=');
sb.append(v);
}
}
return sb.toString();
}
示例2: queryToMap
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
public static Map<String, String> queryToMap(String query) {
if (StringUtils.isNullOrEmpty(query)) {
return Collections.emptyMap();
}
Map<String, String> map = new HashMap<>();
if(query.startsWith("?")) {
query = query.substring(1);
}
String[] tmpQ = query.trim().split("&");
for(String kv: tmpQ) {
String[] tmpkv = kv.split("=");
if (tmpkv.length == 0) {
// case where either no `=` or empty key string
continue;
}
if(tmpkv.length == 1) {
map.put(tmpkv[0].trim(), "");
} else {
map.put(tmpkv[0].trim(), tmpkv[1].trim());
}
}
return Collections.unmodifiableMap(map);
}
示例3: runBenchmark
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
private static BenchmarkResult runBenchmark(String classpath,
Class<? extends AbstractBenchmark> benchmarkClass,
String executionArgs) {
String[] command = {SHELL, "-c",
JAVA_EXECUTE_CMD + "-cp " + classpath + ' ' +
benchmarkClass.getName() + ' ' + executionArgs};
System.gc();
try {
ExecResult runResult = runCommand(command);
if (StringUtils.isNullOrEmpty(runResult.stdErr)) {
int delimIndex = runResult.stdOut.indexOf(AbstractBenchmark.OUTPUT_DELIM);
if (delimIndex > 0) {
delimIndex += AbstractBenchmark.OUTPUT_DELIM.length();
long runVal = Long.parseLong(runResult.stdOut.substring(delimIndex));
return new BenchmarkResult(runVal);
} else {
return new BenchmarkResult("Invalid benchmark output: " + runResult.stdOut);
}
} else {
return new BenchmarkResult(runResult.stdErr);
}
} catch (Exception e) {
return new BenchmarkResult(ExceptionUtils.stackToString(e));
}
}
示例4: masterScheduler
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
/**
* Returns the master scheduler with a default priority requested.
* @param defaultPriority Default priority for tasks submitted to scheduler
* @param threadName if name should be set during execution
*
* @return Master scheduler with the provided default priority
*/
private static PrioritySchedulerService masterScheduler(TaskPriority defaultPriority,
String threadName) {
PrioritySchedulerService result;
if (defaultPriority == TaskPriority.High) {
result = MASTER_SCHEDULER;
} else if (defaultPriority == TaskPriority.Low) {
result = LOW_PRIORITY_MASTER_SCHEDULER;
} else {
result = STARVABLE_PRIORITY_MASTER_SCHEDULER;
}
if (StringUtils.isNullOrEmpty(threadName)) {
return result;
} else {
return new ThreadRenamingPriorityScheduler(result, threadName, false);
}
}
示例5: doExecute
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
/**
* Internal call to actually execute prepared runnable.
*
* @param permits resource permits for this task
* @param taskKey object key where {@code equals()} will be used to determine execution thread
* @param task Runnable to execute when ready
* @return Time in milliseconds task was delayed to maintain rate, or {@code -1} if rejected but handler did not throw
*/
protected long doExecute(double permits, Object taskKey, Runnable task) {
RateLimiterExecutor rle;
Object lock = sLock.getLock(taskKey);
synchronized (lock) {
rle = currentLimiters.get(taskKey);
if (rle == null) {
String keyedPoolName = subPoolName + (addKeyToThreadName ? taskKey.toString() : "");
SubmitterScheduler threadNamedScheduler;
if (StringUtils.isNullOrEmpty(keyedPoolName)) {
threadNamedScheduler = scheduler;
} else {
threadNamedScheduler = new ThreadRenamingSubmitterScheduler(scheduler, keyedPoolName, false);
}
rle = new RateLimiterExecutor(threadNamedScheduler, permitsPerSecond,
maxScheduleDelayMillis, rejectedExecutionHandler);
currentLimiters.put(taskKey, rle);
// schedule task to check for removal later, should only be one task per limiter
limiterCheckerScheduler.schedule(new LimiterChecker(taskKey, rle), 1000);
}
// must execute while in lock to prevent early removal
return rle.execute(permits, task);
}
}
示例6: getContentLength
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
public long getContentLength() {
String scl = headers.get(HTTPConstants.HTTP_KEY_CONTENT_LENGTH);
long cl = -1;
if (! StringUtils.isNullOrEmpty(scl)) {
try {
cl = Long.parseLong(scl);
} catch (NumberFormatException e) {
cl = -1;
}
}
return cl;
}
示例7: chartGenerated
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
protected static void chartGenerated(CategoryChart chart, String writeLocation) throws IOException {
if (StringUtils.isNullOrEmpty(writeLocation)) {
new SwingWrapper<CategoryChart>(chart).displayChart();
System.in.read();
} else {
BitmapEncoder.saveBitmap(chart, writeLocation, BitmapFormat.PNG);
}
}
示例8: computationPool
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
/**
* Thread pool well suited for running CPU intensive computations on the tasks thread.
*
* @param threadName Name to prefix to thread while tasks on this pool execute
* @return Pool for CPU bound tasks
*/
public static SchedulerService computationPool(String threadName) {
if (StringUtils.isNullOrEmpty(threadName)) {
return COMPUTATION_POOL;
} else {
return new ThreadRenamingSchedulerService(COMPUTATION_POOL, threadName, false);
}
}
示例9: makeLimiter
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
@Override
protected SubmitterSchedulerLimiter makeLimiter(String limiterThreadName) {
return new SubmitterSchedulerLimiter(StringUtils.isNullOrEmpty(limiterThreadName) ?
scheduler : new ThreadRenamingSubmitterScheduler(scheduler,
limiterThreadName,
false),
getMaxConcurrencyPerKey(), limitFutureListenersExecution);
}
示例10: makeLimiter
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
@Override
protected SchedulerServiceLimiter makeLimiter(String limiterThreadName) {
return new SchedulerServiceLimiter(StringUtils.isNullOrEmpty(limiterThreadName) ?
scheduler : new ThreadRenamingSchedulerService(scheduler,
limiterThreadName,
false),
getMaxConcurrencyPerKey(), limitFutureListenersExecution);
}
示例11: makeLimiter
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
@Override
protected ExecutorLimiter makeLimiter(String limiterThreadName) {
return new ExecutorLimiter(StringUtils.isNullOrEmpty(limiterThreadName) ?
executor : new ThreadRenamingExecutor(executor, limiterThreadName, false),
getMaxConcurrencyPerKey(), limitFutureListenersExecution);
}
示例12: lowPriorityPool
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
/**
* Low priority pool for scheduling cleanup or otherwise tasks which could be significantly
* delayed. If not single threaded this pool will execute only on any general processing threads
* which are available. By default there is only one, but it can be increased by invoking
* {@link #increaseGenericThreads(int)}.
*
* @param singleThreaded {@code true} indicates that being blocked by other low priority tasks is not a concern
* @param threadName Name to prefix to thread while tasks on this pool execute
* @return Pool for running or scheduling out low priority tasks
*/
public static SchedulerService lowPriorityPool(boolean singleThreaded, String threadName) {
SchedulerService scheduler = singleThreaded ? SINGLE_THREADED_LOW_PRIORITY_POOL : LOW_PRIORITY_POOL;
if (StringUtils.isNullOrEmpty(threadName)) {
return scheduler;
} else {
return new ThreadRenamingSchedulerService(scheduler, threadName, false);
}
}
示例13: isolatedTaskPool
import org.threadly.util.StringUtils; //导入方法依赖的package包/类
/**
* This returns a thread pool which is designed for an "isolated" task. An isolated task is one
* where there is not other scheduling needs in this area of code. This is equivalent to
* invoking {@link #singleThreadPool()} for every task submitted. However that implementation is
* better if you have a multiple tasks you need to execute, and this one is much better if you
* have a single task to execute / schedule.
* <p>
* Implementation wise every task submitted on the returned pool will increase the pool size
* (if necessary) to allow execution, and then decrease the size once execution completes.
* Because of this, {@link #singleThreadPool()} is much better if you can reuse the pool (to
* reduce size churn), and this is much better if you only have a single task (to reduce memory
* overhead).
*
* @param threadName Name to prefix to thread while tasks on this pool execute
* @return Pool which will ensure there is a thread available for every task executed on it
*/
public static SchedulerService isolatedTaskPool(String threadName) {
if (StringUtils.isNullOrEmpty(threadName)) {
return PER_TASK_SIZING_POOL;
} else {
return new ThreadRenamingSchedulerService(PER_TASK_SIZING_POOL, threadName, false);
}
}