本文整理匯總了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;
}
示例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!");
}
}
示例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();
}
示例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);
}
}
示例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());
}
}
示例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));
}
}
示例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;
}
示例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);
}
}
示例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.
}
示例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;
}
示例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.
}
示例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();
}
示例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);
}
}
示例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;
}
}
示例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);
}