本文整理汇总了Java中io.advantageous.boon.core.Str类的典型用法代码示例。如果您正苦于以下问题:Java Str类的具体用法?Java Str怎么用?Java Str使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Str类属于io.advantageous.boon.core包,在下文中一共展示了Str类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBytes
import io.advantageous.boon.core.Str; //导入依赖的package包/类
@Override
public void getBytes(Callback<Optional<byte[]>> callback, String key) {
/* This redis client does not support this.
* https://github.com/vert-x3/vertx-redis-client/issues/41
* https://github.com/vert-x3/vertx-redis-client/issues/40
**/
redisClient.getBinary(key, event -> {
if (event.failed()) {
callback.onError(event.cause());
} else {
if (Str.isEmpty(event.result())) {
callback.returnThis(Optional.<byte[]>empty());
} else {
callback.returnThis(Optional.of(event.result().getBytes()));
}
}
});
}
示例2: setRedisUri
import io.advantageous.boon.core.Str; //导入依赖的package包/类
/**
* RedisKeyValueStoreBuilder redis://redisdb:<password>@<host>:<port>/0
*
* @return this
*/
public RedisKeyValueStoreBuilder setRedisUri(final URI uri) {
getRedisOptions().setPort(uri.getPort());
getRedisOptions().setHost(uri.getHost());
final String userInfo = uri.getUserInfo();
final String[] split = Str.split(userInfo);
if (split.length == 2) {
getRedisOptions().setAuth(split[1]);
} else if (split.length == 1) {
getRedisOptions().setAuth(split[0]);
}
return this;
}
示例3: extractAllAnnotationsForProperty
import io.advantageous.boon.core.Str; //导入依赖的package包/类
/**
* Extract all annotation for a given property.
* Searches current class and if none found searches
* super class for annotation. We do this because the class
* could be proxied with AOP.
*
* @param clazz Class containing the property.
* @param propertyName The name of the property.
* @return array of annotation data.
*/
private static Annotation[] extractAllAnnotationsForProperty( Class<?> clazz, String propertyName, boolean useRead ) {
try {
Annotation[] annotations = findPropertyAnnotations( clazz, propertyName, useRead );
/* In the land of dynamic proxied AOP classes,
* this class could be a proxy. This seems like a bug
* waiting to happen. So far it has worked... */
if ( annotations.length == 0 ) {
if (clazz.getSuperclass()!=null) {
annotations = findPropertyAnnotations(clazz.getSuperclass(), propertyName, useRead);
}
}
return annotations;
} catch ( Exception ex ) {
return Exceptions.handle (Annotation[].class,
Str.sputs(
"Unable to extract annotation for property",
propertyName, " of class ", clazz,
" useRead ", useRead), ex);
}
}
示例4: serializeMap
import io.advantageous.boon.core.Str; //导入依赖的package包/类
public final void serializeMap( Map<Object, Object> smap, CharBuf builder ) {
Map map = smap;
if ( map.size () == 0 ) {
builder.addChars ( EMPTY_MAP_CHARS );
return;
}
builder.addChar( '{' );
int index=0;
final Set<Map.Entry> entrySet = map.entrySet();
for ( Map.Entry entry : entrySet ) {
if (entry.getValue ()!=null ) {
serializeFieldName ( Str.toString(entry.getKey()), builder );
serializeObject( entry.getValue(), builder );
builder.addChar ( ',' );
index++;
}
}
if (index>0)
builder.removeLastChar ();
builder.addChar( '}' );
}
示例5: testUsingPrettyPrint
import io.advantageous.boon.core.Str; //导入依赖的package包/类
@Test
public void testUsingPrettyPrint() {
Map<String, String> map = map("Aaaaa", "aaaa", "Bbbbb", "bbbb", "Ccccc", "cccc");
Predicate<String> startsWithB = new Predicate<String>() {
@Override
public boolean apply(String s) {
return s.charAt(0) == 'B';
}
};
Map<String, String> filtered = Maps.filterKeys(map, startsWithB);
String result = Str.toPrettyJson(filtered);
Str.equalsOrDie(" {\n" +
" \"Bbbbb\" : \"bbbb\"\n" +
" }", result);
}
示例6: walkObject
import io.advantageous.boon.core.Str; //导入依赖的package包/类
private void walkObject( Object object, Map map, Object c ) {
leafCount++;
if ( object instanceof Value ) {
die ( "Found a value" );
} else if ( object instanceof Map ) {
walkMap ( ( Map ) object );
} else if ( object instanceof Collection ) {
walkCollection ( ( Collection ) object );
} else if ( object instanceof Long ) {
longCount++;
} else if ( object instanceof Integer ) {
integerCount++;
} else if ( object instanceof Double ) {
doubleCount++;
} else if ( object instanceof Boolean ) {
booleanCount++;
} else if ( object instanceof String ) {
stringCount++;
} else if ( object instanceof Date ) {
dateCount++;
} else if ( object == null ) {
nullCount++;
} else {
die ( Str.sputs(object, object.getClass().getName(), map, c) );
}
}
示例7: walkGetObject
import io.advantageous.boon.core.Str; //导入依赖的package包/类
private void walkGetObject( Object object, Map map, List list ) {
leafCount++;
if ( object instanceof Value ) {
die ( "Found a value" );
} else if ( object instanceof Map ) {
walkGetMap ( ( Map ) object );
} else if ( object instanceof List ) {
walkGetList ( ( List ) object );
} else if ( object instanceof Long ) {
longCount++;
} else if ( object instanceof Integer ) {
integerCount++;
} else if ( object instanceof Boolean ) {
booleanCount++;
} else if ( object instanceof Double ) {
doubleCount++;
} else if ( object instanceof String ) {
stringCount++;
} else if ( object instanceof Date ) {
dateCount++;
} else if ( object == null ) {
nullCount++;
} else {
die ( Str.sputs(object, object.getClass().getName(), map, list) );
}
}
示例8: run
import io.advantageous.boon.core.Str; //导入依赖的package包/类
public void run( final int timeout, final List<Path> path, final boolean verbose, final String... args ) {
done.set( false );
out = new ProcessOut();
runner = new ProcessRunner( ProcessInOut.this, null, timeout, path, verbose, args );
executorService = Executors.newSingleThreadExecutor();
Runnable task = new Runnable() {
@Override
public void run() {
out.exit = runner.exec();
out.stdout = runner.stdOut();
out.stderr = runner.stdErr();
out.commandLine = Str.joinCollection( ' ', runner.commandLine );
done.set( true );
}
};
executorService.submit( task );
}
示例9: consulResponseList
import io.advantageous.boon.core.Str; //导入依赖的package包/类
public static <T> ConsulResponse<List<T>> consulResponseList(final Class<T> responseType, final HttpTextResponse response) {
List<T> responseObject = null;
if (response.code() == 200) {
if (!Str.isEmpty(response.body())) {
responseObject = fromJsonArray(response.body(), responseType);
}
} else {
die("Unable to read response", response.code(), response.body());
}
int index = Integer.valueOf(response.headers().getFirst("X-Consul-Index"));
long lastContact = Long.valueOf(response.headers().getFirst("X-Consul-Lastcontact"));
boolean knownLeader = Boolean.valueOf(response.headers().getFirst("X-Consul-Knownleader"));
//noinspection UnnecessaryLocalVariable
@SuppressWarnings("UnnecessaryLocalVariable")
ConsulResponse<List<T>> consulResponse = new ConsulResponse<>(responseObject, lastContact, knownLeader, index);
return consulResponse;
}
示例10: getPublicPort
import io.advantageous.boon.core.Str; //导入依赖的package包/类
/**
* Get the public port for service meta generation (Swagger)
*
* @return public port
*/
public int getPublicPort() {
if (publicPort == -1) {
String sport = System.getenv("PUBLIC_WEB_PORT");
if (!Str.isEmpty(sport)) {
publicPort = Integer.parseInt(sport);
}
}
if (publicPort == -1) {
publicPort = getPort();
}
return publicPort;
}
示例11: getPort
import io.advantageous.boon.core.Str; //导入依赖的package包/类
/**
* Get the actual port to bind to.
* <p>
* Defaults to EndpointServerBuilder.DEFAULT_PORT.
* <p>
* Looks for PORT under PORT_WEB, PORT0, PORT.
*
* @return actual http port to bind to.
*/
public int getPort() {
if (port == EndpointServerBuilder.DEFAULT_PORT) {
String sport = System.getenv("PORT_WEB");
/** Looks up port for Mesoshpere and the like. */
if (Str.isEmpty(sport)) {
sport = System.getenv("PORT0");
}
if (Str.isEmpty(sport)) {
sport = System.getenv("PORT");
}
if (!Str.isEmpty(sport)) {
port = Integer.parseInt(sport);
}
}
return port;
}
示例12: getBlackListForSystemProperties
import io.advantageous.boon.core.Str; //导入依赖的package包/类
public List<String> getBlackListForSystemProperties() {
if (blackListForSystemProperties == null) {
final String blackListForSystemProps = System.getenv().get("BLACK_LIST_FOR_SYSTEM_PROPS");
if (blackListForSystemProps == null) {
blackListForSystemProperties = new ArrayList<>();
blackListForSystemProperties.add("PWD");
blackListForSystemProperties.add("PASSWORD");
} else {
final String[] names = Str.splitComma(blackListForSystemProps);
final List<String> list = Lists.list(names);
blackListForSystemProperties = list;
}
}
return blackListForSystemProperties;
}
示例13: addRequestEndPointUsingPath
import io.advantageous.boon.core.Str; //导入依赖的package包/类
private void addRequestEndPointUsingPath(final ContextMeta context,
final ServiceMeta service,
final ServiceMethodMeta method,
final RequestMeta requestMeta,
final String path,
final String requestURI,
final String servicePath) {
RequestMetaData metaData = new RequestMetaData(path, context, requestMeta, method, service);
if (requestMeta.getCallType() == CallType.ADDRESS) {
metaDataMap.put(path, metaData);
} else {
NavigableMap<Integer, RequestMetaData> map = treeMap.get(path);
if (map == null) {
map = new TreeMap<>();
treeMap.put(path, map);
}
int count = Str.split(servicePath + requestURI, '/').length - 1;
map.put(count, metaData);
}
}
示例14: readServiceName
import io.advantageous.boon.core.Str; //导入依赖的package包/类
public static String readServiceName(Annotated annotated) {
String name = readValue("Service", annotated);
if (Str.isEmpty(name)) {
name = readValue("ServiceName", annotated);
}
if (Str.isEmpty(name)) {
name = readValue("Named", annotated);
}
if (Str.isEmpty(name)) {
name = readValue("Name", annotated);
}
return name == null ? "" : name;
}
示例15: remove
import io.advantageous.boon.core.Str; //导入依赖的package包/类
/**
* Remove an event connector
*
* @param eventConnector eventConnector
*/
public void remove(final EventConnector eventConnector) {
if (eventConnector != null) {
try {
if (eventConnector instanceof RemoteTCPClientProxy) {
final RemoteTCPClientProxy remoteTCPClientProxy = (RemoteTCPClientProxy) eventConnector;
logger.info(Str.sputs("Removing event connector host ",
remoteTCPClientProxy.host(), " port ", remoteTCPClientProxy.port(),
"connected ", remoteTCPClientProxy.connected()));
remoteTCPClientProxy.silentClose();
}
this.eventConnectors.remove(eventConnector);
} catch (Exception ex) {
logger.error("Unable to remove event connector", ex);
}
}
}