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


Java StringUtil.isNullOrEmpty方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: parseGrpcUrl

import io.netty.util.internal.StringUtil; //導入方法依賴的package包/類
public static Properties parseGrpcUrl(String url) {
    if (StringUtil.isNullOrEmpty(url)) {
        throw new RuntimeException("URL cannot be null or empty");
    }

    Properties props = new Properties();
    Pattern p = Pattern.compile("([^:]+)[:]//([^:]+)[:]([0-9]+)", Pattern.CASE_INSENSITIVE);
    Matcher m = p.matcher(url);
    if (m.matches()) {
        props.setProperty("protocol", m.group(1));
        props.setProperty("host", m.group(2));
        props.setProperty("port", m.group(3));

        String protocol = props.getProperty("protocol");
        if (!"grpc".equals(protocol) && !"grpcs".equals(protocol)) {
            throw new RuntimeException(String.format("Invalid protocol expected grpc or grpcs and found %s.", protocol));
        }
    } else {
        throw new RuntimeException("URL must be of the format protocol://host:port");
    }

    // TODO: allow all possible formats of the URL
    return props;
}
 
開發者ID:hyperledger,項目名稱:fabric-sdk-java,代碼行數:25,代碼來源:Utils.java

示例11: Peer

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

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

        }

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

        this.url = grpcURL;
        this.name = name;
        this.properties = properties == null ? null : (Properties) properties.clone(); //keep our own copy.

    }
 
開發者ID:hyperledger,項目名稱:fabric-sdk-java,代碼行數:18,代碼來源:Peer.java

示例12: start

import io.netty.util.internal.StringUtil; //導入方法依賴的package包/類
/**
 * starts Field Agent module
 * 
 * @throws Exception
 */
public void start() throws Exception {

	if (StringUtil.isNullOrEmpty(Configuration.getInstanceId())	|| StringUtil.isNullOrEmpty(Configuration.getAccessToken()))
		StatusReporter.setFieldAgentStatus().setContollerStatus(ControllerStatus.NOT_PROVISIONED);

	elementManager = ElementManager.getInstance();
	orchestrator = new Orchestrator();

	boolean isConnected = ping();
	getFabricConfig();
	if (!notProvisioned()) {
		loadRegistries(!isConnected);
		loadElementsList(!isConnected);
		loadElementsConfig(!isConnected);
		loadRoutes(!isConnected);
	}

	new Thread(pingController, "FieldAgent : Ping").start();
	new Thread(getChangesList, "FieldAgent : GetChangesList").start();
	new Thread(postStatus, "FieldAgent : PostStaus").start();
}
 
開發者ID:iotracks,項目名稱:iofabric,代碼行數:27,代碼來源:FieldAgent.java

示例13: filter

import io.netty.util.internal.StringUtil; //導入方法依賴的package包/類
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    String version = requestContext.getHeaderString("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) {
        log.error("requestContext.setRequestUri error:{}=>{}", version, requestUri);
    }

}
 
開發者ID:sdcuike,項目名稱:book-reading,代碼行數:18,代碼來源:MyContainerRequestFilter.java

示例14: AddressPair

import io.netty.util.internal.StringUtil; //導入方法依賴的package包/類
public AddressPair(String ip, int port, String pass) {
	this.ip = ip;
	this.port = port;
	if (!StringUtil.isNullOrEmpty(pass)) {
		this.pass = pass;
	}
}
 
開發者ID:HankXV,項目名稱:Limitart,代碼行數:8,代碼來源:AddressPair.java

示例15: getAndCreateChannel

import io.netty.util.internal.StringUtil; //導入方法依賴的package包/類
private Channel getAndCreateChannel(String addr) throws InterruptedException {
	if (StringUtil.isNullOrEmpty(addr)){
		return getAndCreateRegisterCenterChannel();
	}
	ChannelWrapper cw = this.channelTables.get(addr);
       if (cw != null && cw.isOK()) {
           return cw.getChannel();
       }
       return this.createChannel(addr);
}
 
開發者ID:yanghuijava,項目名稱:elephant,代碼行數:11,代碼來源:NettyRemotingClient.java


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