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


Java StringUtils.isInteger方法代码示例

本文整理汇总了Java中com.alibaba.dubbo.common.utils.StringUtils.isInteger方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.isInteger方法的具体用法?Java StringUtils.isInteger怎么用?Java StringUtils.isInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.dubbo.common.utils.StringUtils的用法示例。


在下文中一共展示了StringUtils.isInteger方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isMulticastAddress

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
private static boolean isMulticastAddress(String ip) {
    int i = ip.indexOf('.');
    if (i > 0) {
        String prefix = ip.substring(0, i);
        if (StringUtils.isInteger(prefix)) {
            int p = Integer.parseInt(prefix);
            return p >= 224 && p <= 239;
        }
    }
    return false;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:MulticastExchangeGroup.java

示例2: telnet

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public String telnet(Channel channel, String message) {
    int lines = 100;
    if (message.length() > 0) {
        if (! StringUtils.isInteger(message)) {
            return "Illegal lines " + message + ", must be integer.";
        }
        lines = Integer.parseInt(message);
    }
    StringBuilder buf = new StringBuilder();
    for (int i = 0; i < lines; i ++) {
        buf.append("\r\n");
    }
    return buf.toString();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:15,代码来源:ClearTelnetHandler.java

示例3: telnet

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public String telnet(Channel channel, String message) {
    long size = 0 ;
    File file = LoggerFactory.getFile();
    StringBuffer buf = new StringBuffer();
    if (message == null || message.trim().length() == 0) {
        buf.append("EXAMPLE: log error / log 100");
    }else {
        String str[] = message.split(" ");
        if (! StringUtils.isInteger(str[0])){
            LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
        } else {
            int SHOW_LOG_LENGTH = Integer.parseInt(str[0]);
            
            if (file != null && file.exists()) {
                try{
                    FileInputStream fis = new FileInputStream(file);
                    try {
                     FileChannel filechannel = fis.getChannel();
                     try {
                      size = filechannel.size();
                      ByteBuffer bb;
                      if (size <= SHOW_LOG_LENGTH) {
                          bb = ByteBuffer.allocate((int) size);
                          filechannel.read(bb, 0);
                      } else {
                          int pos = (int) (size - SHOW_LOG_LENGTH);
                          bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
                          filechannel.read(bb, pos);
                      }
                      bb.flip();
                      String content = new String(bb.array()).replace("<", "&lt;")
                      .replace(">", "&gt;").replace("\n", "<br/><br/>");
                      buf.append("\r\ncontent:"+content);
                      
                      buf.append("\r\nmodified:"+(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                      .format(new Date(file.lastModified()))));
                      buf.append("\r\nsize:"+size +"\r\n");
                     } finally {
                     	filechannel.close();
                     }
                    } finally {
                    	fis.close();
                    }
                }catch (Exception e) {
                    buf.append(e.getMessage());
                }
            }else {
                size = 0;
                buf.append("\r\nMESSAGE: log file not exists or log appender is console .");
            }
        }
    }
    buf.append("\r\nCURRENT LOG LEVEL:"+ LoggerFactory.getLevel())
    .append("\r\nCURRENT LOG APPENDER:"+ (file == null ? "console" : file.getAbsolutePath()));
    return buf.toString();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:57,代码来源:LogTelnetHandler.java

示例4: telnet

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public String telnet(Channel channel, String message) {
    String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
    if ((service == null || service.length() == 0)
            && (message == null || message.length() == 0)) {
        return "Please input service name, eg: \r\ntrace XxxService\r\ntrace XxxService xxxMethod\r\ntrace XxxService xxxMethod 10\r\nor \"cd XxxService\" firstly.";
    }
    String[] parts = message.split("\\s+");
    String method;
    String times;
    if (service == null || service.length() == 0) {
        service = parts.length > 0 ? parts[0] : null;
        method = parts.length > 1 ? parts[1] : null;
    } else {
        method = parts.length > 0 ? parts[0] : null;
    }
    if (StringUtils.isInteger(method)) {
        times = method;
        method = null;
    } else {
        times = parts.length > 2 ? parts[2] : "1";
    }
    if (! StringUtils.isInteger(times)) {
        return "Illegal times " + times + ", must be integer.";
    }
    Invoker<?> invoker = null;
    for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
        if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
                || service.equals(exporter.getInvoker().getInterface().getName())
                || service.equals(exporter.getInvoker().getUrl().getPath())) {
            invoker = exporter.getInvoker();
            break;
        }
    }
    if (invoker != null) {
        if (method != null && method.length() > 0) {
            boolean found = false;
            for (Method m : invoker.getInterface().getMethods()) {
                if (m.getName().equals(method)) {
                    found = true;
                    break;
                }
            }
            if (! found) {
                return "No such method " + method + " in class " + invoker.getInterface().getName();
            }
        }
        TraceFilter.addTracer(invoker.getInterface(), method, channel, Integer.parseInt(times));
    } else {
        return "No such service " + service;
    }
    return null;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:53,代码来源:TraceTelnetHandler.java

示例5: telnet

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public String telnet(Channel channel, String message) {
    long size = 0 ;
    File file = LoggerFactory.getFile();
    StringBuffer buf = new StringBuffer();
    if (message == null || message.trim().length() == 0) {
        buf.append("EXAMPLE: log error / log 100");
    }else {
        String str[] = message.split(" ");
        if (! StringUtils.isInteger(str[0])){
            LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
        } else {
            int SHOW_LOG_LENGTH = Integer.parseInt(str[0]);
            
            if (file != null && file.exists()) {
                try{
                    FileInputStream fis = new FileInputStream(file);
                    FileChannel filechannel = fis.getChannel();
                    size = filechannel.size();
                    ByteBuffer bb;
                    if (size <= SHOW_LOG_LENGTH) {
                        bb = ByteBuffer.allocate((int) size);
                        filechannel.read(bb, 0);
                    } else {
                        int pos = (int) (size - SHOW_LOG_LENGTH);
                        bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
                        filechannel.read(bb, pos);
                    }
                    bb.flip();
                    String content = new String(bb.array()).replace("<", "&lt;")
                    .replace(">", "&gt;").replace("\n", "<br/><br/>");
                    buf.append("\r\ncontent:"+content);
                    
                    buf.append("\r\nmodified:"+(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                    .format(new Date(file.lastModified()))));
                    buf.append("\r\nsize:"+size +"\r\n");
                }catch (Exception e) {
                    buf.append(e.getMessage());
                }
            }else {
                size = 0;
                buf.append("\r\nMESSAGE: log file not exists or log appender is console .");
            }
        }
    }
    buf.append("\r\nCURRENT LOG LEVEL:"+ LoggerFactory.getLevel())
    .append("\r\nCURRENT LOG APPENDER:"+ (file == null ? "console" : file.getAbsolutePath()));
    return buf.toString();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:49,代码来源:LogTelnetHandler.java


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