当前位置: 首页>>代码示例>>Java>>正文


Java Str类代码示例

本文整理汇总了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()));
            }
        }
    });
}
 
开发者ID:advantageous,项目名称:qbit-extensions,代码行数:19,代码来源:RedisKeyValueStore.java

示例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;
}
 
开发者ID:advantageous,项目名称:qbit-extensions,代码行数:22,代码来源:RedisKeyValueStoreBuilder.java

示例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);
    }

}
 
开发者ID:advantageous,项目名称:boon,代码行数:34,代码来源:Annotations.java

示例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( '}' );

    }
 
开发者ID:advantageous,项目名称:boon,代码行数:27,代码来源:JsonSimpleSerializerImpl.java

示例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);
}
 
开发者ID:advantageous,项目名称:boon,代码行数:20,代码来源:Bug247.java

示例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) );
    }
}
 
开发者ID:advantageous,项目名称:boon,代码行数:27,代码来源:LazyValueMapTest.java

示例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) );
    }
}
 
开发者ID:advantageous,项目名称:boon,代码行数:27,代码来源:LazyValueMapTest.java

示例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 );

}
 
开发者ID:advantageous,项目名称:boon,代码行数:24,代码来源:Runner.java

示例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;
    }
 
开发者ID:advantageous,项目名称:qbit,代码行数:25,代码来源:RequestUtils.java

示例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;
}
 
开发者ID:advantageous,项目名称:qbit,代码行数:22,代码来源:ManagedServiceBuilder.java

示例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;
}
 
开发者ID:advantageous,项目名称:qbit,代码行数:27,代码来源:ManagedServiceBuilder.java

示例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;
    }
 
开发者ID:advantageous,项目名称:qbit,代码行数:20,代码来源:AdminBuilder.java

示例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);

    }
}
 
开发者ID:advantageous,项目名称:qbit,代码行数:27,代码来源:StandardMetaDataProvider.java

示例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;
}
 
开发者ID:advantageous,项目名称:qbit,代码行数:19,代码来源:AnnotationUtils.java

示例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);
        }
    }
}
 
开发者ID:advantageous,项目名称:qbit,代码行数:24,代码来源:EventConnectorHub.java


注:本文中的io.advantageous.boon.core.Str类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。