當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtil類代碼示例

本文整理匯總了Java中io.netty.util.internal.StringUtil的典型用法代碼示例。如果您正苦於以下問題:Java StringUtil類的具體用法?Java StringUtil怎麽用?Java StringUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StringUtil類屬於io.netty.util.internal包,在下文中一共展示了StringUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleWebSocketFrame

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
    if (logger.isLoggable(Level.FINE)) {
        logger.fine(String.format(
                "Channel %s received %s", ctx.channel().hashCode(), StringUtil.simpleClassName(frame)));
    }

    if (frame instanceof CloseWebSocketFrame) {
        handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
    } else if (frame instanceof PingWebSocketFrame) {
        ctx.write(new PongWebSocketFrame(frame.isFinalFragment(), frame.rsv(), frame.content()), ctx.voidPromise());
    } else if (frame instanceof TextWebSocketFrame) {
        ctx.write(frame, ctx.voidPromise());
    } else if (frame instanceof BinaryWebSocketFrame) {
        ctx.write(frame, ctx.voidPromise());
    } else if (frame instanceof ContinuationWebSocketFrame) {
        ctx.write(frame, ctx.voidPromise());
    } else if (frame instanceof PongWebSocketFrame) {
        frame.release();
        // Ignore
    } else {
        throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass()
                .getName()));
    }
}
 
開發者ID:wuyinxian124,項目名稱:netty4.0.27Learn,代碼行數:25,代碼來源:AutobahnServerHandler.java

示例2: getImplClass

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
/**
 * 獲取一個接口的實現類
 * @param defineClass
 * @param lookup  指定名稱的實現類
 * @return
 */
public Class<?> getImplClass(Class<?> defineClass, String lookup) {
    if (StringUtil.isNullOrEmpty(lookup)) {
        return null;
    }
    Collection<SessionBean> beans = serviceimplmap.get(defineClass.getName());
    if (CollectionUtil.isNotEmpty(beans)) {
        Iterator<SessionBean> beanite = beans.iterator();
        while (beanite.hasNext()) {
            SessionBean bean = beanite.next();
            if (lookup.toLowerCase().equals(bean.getLookup().toLowerCase())) {
                return bean.getImplClass().getCls();
            }
        }
    }
    return null;
}
 
開發者ID:lemonJun,項目名稱:TakinRPC,代碼行數:23,代碼來源:ServiceInfosHolder.java

示例3: doLeaveRoom

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
private void doLeaveRoom(Channel channel, LeaveRoomMessage leaveRoom) {
    UserInfo userInfo = NetoChannelUtil.getUserInfo(channel);

    if (userInfo == null || StringUtil.isNullOrEmpty(userInfo.getUserId())) {
        throw new NotFoundUserInfoException(Constants.StatusCode.NOT_FOUND_USERINFO, "Not Found User Info");
    }

    String inputId = leaveRoom.getUserId();
    String sessionId = userInfo.getUserId();

    if (userInfo.getAccessLevel() > Constants.AccessLevel.ADMIN) {
        globalChannelGroup.stream().filter(c -> c != null && leaveRoom.getUserId().equals(NetoChannelUtil.getUserInfo(c).getUserId()))
                                   .forEach(c -> {
                                                    leaveRoom(c);
                                                    leaveRoom.setStatusCode(Constants.StatusCode.OK);
                                                    channel.writeAndFlush(leaveRoom);
                                                 });
    } else if (sessionId.equals(inputId)) {
        leaveRoom(channel);
        leaveRoom.setStatusCode(Constants.StatusCode.OK);
        sendMessage(channel, leaveRoom);
    } else {
        throw new BadAccessException(Constants.StatusCode.FAIL, "bad access!");
    }
}
 
開發者ID:veritasware,項目名稱:neto,代碼行數:26,代碼來源:MessageHandler.java

示例4: createNodeKey

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
private String createNodeKey(String... nodes) {

        if (nodes == null || StringUtil.isNullOrEmpty(nodes[0])) {
            return "";
        }

        final StringBuilder sb = new StringBuilder();

        for (int i = 0, len = nodes.length; i < len; i++) {
            if (i > 0) {
                sb.append(":");
            }
            sb.append(nodes[i]);
        }

        return sb.toString();
    }
 
開發者ID:veritasware,項目名稱:neto,代碼行數:18,代碼來源:RedisService.java

示例5: getEncodedTargetAddress

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
private ByteBuf getEncodedTargetAddress(ByteBufAllocator allocator, boolean resolve) throws ProxyConnectException {
    InetSocketAddress remoteAddress = destinationAddress();
    SocksAddressType remoteAddressType;
    String remoteHost;
    if (!resolve || remoteAddress.isUnresolved()) {
        remoteAddressType = SocksAddressType.DOMAIN;
        remoteHost = remoteAddress.getHostString();
    } else {
        remoteHost = remoteAddress.getAddress().getHostAddress();
        if (NetUtil.isValidIpV4Address(remoteHost)) {
            remoteAddressType = SocksAddressType.IPv4;
        } else if (NetUtil.isValidIpV6Address(remoteHost)) {
            remoteAddressType = SocksAddressType.IPv6;
        } else {
            throw new ProxyConnectException("unknown address type: " + StringUtil.simpleClassName(remoteHost));
        }
    }
    int remotePort = remoteAddress.getPort();
    SocksCmdRequest request = new SocksCmdRequest(SocksCmdType.UNKNOWN, remoteAddressType, remoteHost, remotePort);
    return SSocksAddressEncoder.INSTANCE.encode(allocator, request);
}
 
開發者ID:tridays,項目名稱:netty-socks,代碼行數:22,代碼來源:SSocksConnectHandler.java

示例6: execute

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void execute(ShardingContext shardingContext) {
	List<MessageEntity> findList = this.messageEntityMapper.queryTransactionNotComplete();
	log.info("查詢沒有完成的事務消息(查詢1分鍾之前的)記錄數:{}",findList);
	if(findList.isEmpty()){
		return;
	}
	try {
		for(MessageEntity entity : findList){
			Message message = new Message();
			message.setMessageId(entity.getMessageId());
			message.setBody(entity.getBody());
			message.setDestination(entity.getDestination());
			if(!StringUtil.isNullOrEmpty(entity.getProperties())){
				message.setProperties(JSON.parseObject(entity.getProperties(), Map.class));
			}
			RemotingCommand request = RemotingCommand.buildRequestCmd(message, RequestCode.SEND_MESSAGE, MessageCode.TRANSACTION_CHECK_MESSAGE);
			request.setGroup(entity.getGroup());
			sentToClient(request);
		}
	} catch (Exception e) {
		log.error("回查發送異常:{}",e);
	}
}
 
開發者ID:yanghuijava,項目名稱:elephant,代碼行數:26,代碼來源:TransactionCheckJob.java

示例7: checkMessage

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
public static void checkMessage(Message msg,DefaultMQProducer defaultMQProducer) throws MQClientException {
	if (null == msg) {
		throw new MQClientException(1,"the message is null");
	}
	if (null == msg.getBody()) {
		throw new MQClientException(2,"the message body is null");
	}
	if (0 == msg.getBody().length) {
		throw new MQClientException(3,"the message body length is zero");
	}
	if (msg.getBody().length > defaultMQProducer.getMaxMessageSize()) {
		throw new MQClientException(4,"the message body size over max value, MAX: " + defaultMQProducer.getMaxMessageSize());
	}
	if(StringUtil.isNullOrEmpty(msg.getMessageId())){
		msg.setMessageId(UUID.randomUUID().toString());
	}
}
 
開發者ID:yanghuijava,項目名稱:elephant,代碼行數:18,代碼來源:DefaultMQProducerImpl.java

示例8: toPoolName

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
public static String toPoolName(Class<?> poolType) {
    if (poolType == null) {
        throw new NullPointerException("poolType");
    }

    String poolName = StringUtil.simpleClassName(poolType);
    switch (poolName.length()) {
        case 0:
            return "unknown";
        case 1:
            return poolName.toLowerCase(Locale.US);
        default:
            if (Character.isUpperCase(poolName.charAt(0)) && Character.isLowerCase(poolName.charAt(1))) {
                return Character.toLowerCase(poolName.charAt(0)) + poolName.substring(1);
            } else {
                return poolName;
            }
    }
}
 
開發者ID:venus-boot,項目名稱:saluki,代碼行數:20,代碼來源:NamedThreadFactory.java

示例9: toString

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append(directArenas.length);
  buf.append(" direct arena(s):");
  buf.append(StringUtil.NEWLINE);
  for (PoolArena<ByteBuffer> a : directArenas) {
    buf.append(a);
  }

  buf.append("Large buffers outstanding: ");
  buf.append(this.hugeBufferCount.get());
  buf.append(" totaling ");
  buf.append(this.hugeBufferSize.get());
  buf.append(" bytes.");
  buf.append('\n');
  buf.append("Normal buffers outstanding: ");
  buf.append(this.normalBufferCount.get());
  buf.append(" totaling ");
  buf.append(this.normalBufferSize.get());
  buf.append(" bytes.");
  return buf.toString();
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:23,代碼來源:PooledByteBufAllocatorL.java

示例10: calculateProcessingTime_ShouldSetProcessingTimeInAllUnitsAndHumanReadableString

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
@Test
public void calculateProcessingTime_ShouldSetProcessingTimeInAllUnitsAndHumanReadableString() throws
    InterruptedException {
    assertThat(baseSyncStatistics.getLatestBatchProcessingTimeInMillis()).isEqualTo(0);
    assertThat(baseSyncStatistics.getLatestBatchHumanReadableProcessingTime()).isEqualTo(StringUtil.EMPTY_STRING);

    final int waitingTimeInMillis = 100;
    Thread.sleep(waitingTimeInMillis);
    baseSyncStatistics.calculateProcessingTime();

    assertThat(baseSyncStatistics.getLatestBatchProcessingTimeInDays()).isGreaterThanOrEqualTo(0);
    assertThat(baseSyncStatistics.getLatestBatchProcessingTimeInHours()).isGreaterThanOrEqualTo(0);
    assertThat(baseSyncStatistics.getLatestBatchProcessingTimeInMinutes()).isGreaterThanOrEqualTo(0);
    assertThat(baseSyncStatistics.getLatestBatchProcessingTimeInSeconds())
        .isGreaterThanOrEqualTo(waitingTimeInMillis / 1000);
    assertThat(baseSyncStatistics.getLatestBatchProcessingTimeInMillis())
        .isGreaterThanOrEqualTo(waitingTimeInMillis);

    final long remainingMillis = baseSyncStatistics.getLatestBatchProcessingTimeInMillis()
        - TimeUnit.SECONDS.toMillis(baseSyncStatistics.getLatestBatchProcessingTimeInSeconds());
    assertThat(baseSyncStatistics.getLatestBatchHumanReadableProcessingTime())
        .contains(format(", %dms", remainingMillis));
}
 
開發者ID:commercetools,項目名稱:commercetools-sync-java,代碼行數:24,代碼來源:BaseSyncStatisticsTest.java

示例11: filterOutboundMessage

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
@Override
protected Object filterOutboundMessage(Object msg) {
    if (msg instanceof UkcpPacket) {
        UkcpPacket p = (UkcpPacket) msg;
        ByteBuf content = p.content();
        if (isSingleDirectBuffer(content)) {
            return p;
        }
        content.retain(); // newDirectBuffer method call release method of content
        UkcpPacket np = UkcpPacket.newInstance(newDirectBuffer(content), p.remoteAddress());
        p.release();
        return np;
    }

    throw new UnsupportedOperationException(
            "unsupported message type: " + StringUtil.simpleClassName(msg) + EXPECTED_TYPES);
}
 
開發者ID:szhnet,項目名稱:kcp-netty,代碼行數:18,代碼來源:UkcpServerChannel.java

示例12: checkParams

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
private void checkParams(String cluster, String ipAddress, Integer port, List<SeedMember> seedMembers) throws Exception {
    String f = "[%s] is required!";
    String who = null;
    if (StringUtil.isNullOrEmpty(cluster)) {
        who = "cluster";
    } else if (StringUtil.isNullOrEmpty(ipAddress)) {
        who = "ip";
    } else if (StringUtil.isNullOrEmpty(String.valueOf(port))) {
        who = "port";
    } else if (seedMembers == null || seedMembers.isEmpty()) {
        who = "seed member";
    }
    if (who != null) {
        throw new IllegalArgumentException(String.format(f, who));
    }
}
 
開發者ID:monkeymq,項目名稱:jgossip,代碼行數:17,代碼來源:GossipService.java

示例13: parseRange

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
private long[] parseRange(String range, long availableLength)
        throws IllegalArgumentException {
    if (StringUtil.isNullOrEmpty(range)) {
        return null;
    }
    Matcher m = RANGE_HEADER.matcher(range);
    if (!m.matches()) {
        throw new IllegalArgumentException("Unsupported range: %s" + range);
    }
    long[] result = new long[2];
    result[0] = Long.parseLong(m.group(1));
    String sed = m.group(2);
    result[1] = StringUtil.isNullOrEmpty(sed) ? availableLength - 1 : Long.parseLong(sed);
    if (result[0] > result[1] || result[1] >= availableLength) {
        throw new IllegalArgumentException("Unsupported range: %s" + range);
    }
    return result;
}
 
開發者ID:noti0na1,項目名稱:HFSN,代碼行數:19,代碼來源:HttpFileServerHandler.java

示例14: filter

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    String version = requestContext.getHeaderString(HEADER_VERSION);
    if (StringUtil.isNullOrEmpty(version)) {
        return;
    }

    URI requestUri = requestContext.getUriInfo().getRequestUri();
    try {
        URI newUri = new URI(requestUri.getScheme(), requestUri.getAuthority(), "/" + version + requestUri.getPath(), requestUri.getQuery(), requestUri.getFragment());
        requestContext.setRequestUri(newUri);

    } catch (URISyntaxException e) {
        String info = String.format("requestContext.setRequestUri error: version[%s]=>requestUri[%s]", version, requestUri);
        log.error(info, e);
    }

}
 
開發者ID:sdcuike,項目名稱:dubbo-rpc-rest,代碼行數:19,代碼來源:VersionRequestFilter.java

示例15: EventHub

import io.netty.util.internal.StringUtil; //導入依賴的package包/類
EventHub(String name, String grpcURL, ExecutorService executorService, Properties properties) throws InvalidArgumentException {

        Exception e = checkGrpcUrl(grpcURL);
        if (e != null) {
            throw new InvalidArgumentException("Bad event hub url.", e);

        }

        if (StringUtil.isNullOrEmpty(name)) {
            throw new InvalidArgumentException("Invalid name for eventHub");
        }

        this.url = grpcURL;
        this.name = name;
        this.executorService = executorService;
        this.properties = properties == null ? null : (Properties) properties.clone(); //keep our own copy.
    }
 
開發者ID:hyperledger,項目名稱:fabric-sdk-java,代碼行數:18,代碼來源:EventHub.java


注:本文中的io.netty.util.internal.StringUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。