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


Java StringUtil类代码示例

本文整理汇总了Java中com.neverwinterdp.util.text.StringUtil的典型用法代码示例。如果您正苦于以下问题:Java StringUtil类的具体用法?Java StringUtil怎么用?Java StringUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: verify

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public boolean verify(ShellContext ctx, String[] line) {
  int matchCount = 0;
  for (String selLine : line) {
    boolean match = true;
    for (int i = 0; i < patterns.size(); i++) {
      Pattern pattern = patterns.get(i);
      if (!pattern.matcher(selLine).matches()) {
        match = false;
        break;
      }
    }
    if (match)
      matchCount++;
  }
  boolean matchLine = matchCount == expect;
  String info = "Match --line " + StringUtil.join(patterns, " ") + " " + expect;
  if (!matchLine) {
    ctx.console().println("  ", info, " - FAIL", "(Expect ", expect, " but found ", matchCount, ")");
  } else {
    ctx.console().println("  ", info, " - OK");
  }
  return matchLine;
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:24,代码来源:ShellBuiltinCommand.java

示例2: parseScript

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public String[] parseScript(String script) {
  List<String> holder = new ArrayList<String>() ;
  String[] line = StringUtil.splitAsArray(script, '\n');
  StringBuilder b = new StringBuilder() ;
  for(String selLine : line) {
    selLine = selLine.trim() ;
    if(selLine.length() == 0) continue ;
    if(selLine.startsWith("#")) continue ;
    boolean endLine = !selLine.endsWith("\\") ;
    if(!endLine) {
      b.append(selLine.substring(0, selLine.length() - 1)).append('\n') ;
    } else {
      b.append(selLine) ;
      holder.add(b.toString()) ;
      b = new StringBuilder() ;
    }
  }
  return holder.toArray(new String[holder.size()]) ;
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:20,代码来源:Shell.java

示例3: selectClusterMember

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public ClusterMember selectClusterMember(String connect) {
  int    port = 5700 ;
  String host = connect ;
  if(connect.indexOf(':') > 0) {
    String[] parts = StringUtil.toStringArray(connect, ":") ;
    host = parts[0] ;
    port = Integer.parseInt(parts[1]) ;
  }
  for(Member sel : this.memberMap.values()) {
    ClusterMember cmember = new ClusterMemberImpl(sel) ;
    if(host.equals(cmember.getHost()) || host.equals(cmember.getIpAddress())) {
      if(port == cmember.getPort()) return cmember ;
    }
  }
  return null ;
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:17,代码来源:HazelcastMemberSelector.java

示例4: format

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
static public String format(String title, List<VMDescriptor> descriptors) throws Exception {
  TabularFormater formater = new TabularFormater("ID", "Path", "Roles", "Cores", "Memory");
  formater.setIndent("  ");
  for(int i = 0; i < descriptors.size(); i++) {
    VMDescriptor descriptor = descriptors.get(i) ;
    formater.addRow(
        descriptor.getId(), 
        descriptor.getStoredPath(),
        StringUtil.join(descriptor.getVmConfig().getRoles(), ","),
        descriptor.getCpuCores(),
        descriptor.getMemory()
    );
  }
  formater.setTitle(title);
  return formater.getFormatText();
}
 
开发者ID:DemandCube,项目名称:Scribengin,代码行数:17,代码来源:VMFormater.java

示例5: RequestLog

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
/**
 * Constructor
 * @param httpReq HttpRequest object to be sent to Sparkngin
 */
public RequestLog(HttpRequest httpReq, Pattern[] headerMatcher) {
  QueryStringDecoder decoder = new QueryStringDecoder(httpReq.getUri());
  String path = decoder.path() ;
  List<String> segments = StringUtil.split(path, '/') ;
  this.trackerName = segments.get(1) ;
  this.site = segments.get(2) ;
  
  this.uri = httpReq.getUri() ;
  this.method = httpReq.getMethod().name() ;
  requestHeaders = new HashMap<String, String>() ;
  Iterator<Entry<String, String>> i = httpReq.headers().iterator() ;
  while(i.hasNext()) {
    Entry<String, String> entry =i.next();
    String key = entry.getKey() ;
    if(extractHeader(key, headerMatcher)) {
      requestHeaders.put(key, entry.getValue()) ;
    }
  }
}
 
开发者ID:DemandCube,项目名称:Sparkngin,代码行数:24,代码来源:RequestLog.java

示例6: printTimers

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public void printTimers(Map<String, Timer> timers) throws IOException {
  TimerPrinter tprinter = new TimerPrinter(out) ;
  String[] keys = StringUtil.toSortedArray(timers.keySet()) ;
  for(String key : keys) {
    tprinter.print(key, timers.get(key));
  }
  tprinter.flush(); 
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:9,代码来源:MetricPrinter.java

示例7: printCounters

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public void printCounters(Map<String, Counter> counters) throws IOException {
  CounterPrinter cPrinter = new CounterPrinter(out) ;
  String[] keys = StringUtil.toSortedArray(counters.keySet()) ;
  for(String key : keys) {
    cPrinter.print(key, counters.get(key));
  }
  cPrinter.flush(); 
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:9,代码来源:MetricPrinter.java

示例8: printCounters

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public void printCounters(Map<String, ClusterCounter> clusterCounters) throws IOException {
  MetricPrinter.CounterPrinter tPrinter = new MetricPrinter.CounterPrinter(out) ;
  String[] keys = StringUtil.toSortedArray(clusterCounters.keySet()) ;
  for(String key : keys) {
    ClusterCounter clusterCounter = clusterCounters.get(key) ;
    tPrinter.print(key, clusterCounter.getCounter());
    Map<String, Counter> counters = clusterCounter.getCounters() ;
    String[] serverNames = StringUtil.toSortedArray(counters.keySet()) ;
    for(String serverName : serverNames) {
      tPrinter.print(" - " + serverName, counters.get(serverName));
    }
  }
  tPrinter.flush(); 
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:15,代码来源:ClusterMetricPrinter.java

示例9: printCounterSnapshots

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public void printCounterSnapshots(Map<String, ClusterCounterSnapshot> clusterCounters) throws IOException {
  MetricPrinter.CounterPrinter tPrinter = new MetricPrinter.CounterPrinter(out) ;
  String[] keys = StringUtil.toSortedArray(clusterCounters.keySet()) ;
  for(String key : keys) {
    ClusterCounterSnapshot clusterCounter = clusterCounters.get(key) ;
    tPrinter.print(key, clusterCounter.getCount());
    Map<String, Long> counters = clusterCounter.getCounters(); ;
    String[] serverNames = StringUtil.toSortedArray(counters.keySet()) ;
    for(String serverName : serverNames) {
      tPrinter.print(" - " + serverName, counters.get(serverName));
    }
  }
  tPrinter.flush(); 
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:15,代码来源:ClusterMetricPrinter.java

示例10: printTimers

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public void printTimers(Map<String, ClusterTimer> clusterTimers) throws IOException {
  MetricPrinter.TimerPrinter tPrinter = new MetricPrinter.TimerPrinter(out) ;
  String[] keys = StringUtil.toSortedArray(clusterTimers.keySet()) ;
  for(String key : keys) {
    ClusterTimer clusterTimer = clusterTimers.get(key) ;
    tPrinter.print(key, clusterTimer.getTimer());
    Map<String, Timer> timers = clusterTimer.getTimers() ;
    String[] serverNames = StringUtil.toSortedArray(timers.keySet()) ;
    for(String serverName : serverNames) {
      tPrinter.print(" - " + serverName, timers.get(serverName));
    }
  }
  tPrinter.flush(); 
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:15,代码来源:ClusterMetricPrinter.java

示例11: printTimerSnapshots

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public void printTimerSnapshots(Map<String, ClusterTimerSnapshot> clusterTimers) throws IOException {
  MetricPrinter.TimerPrinter tPrinter = new MetricPrinter.TimerPrinter(out) ;
  String[] keys = StringUtil.toSortedArray(clusterTimers.keySet()) ;
  for(String key : keys) {
    ClusterTimerSnapshot clusterTimer = clusterTimers.get(key) ;
    tPrinter.print(key, clusterTimer.getTimer());
    Map<String, TimerSnapshot> timers = clusterTimer.getTimers() ;
    String[] serverNames = StringUtil.toSortedArray(timers.keySet()) ;
    for(String serverName : serverNames) {
      tPrinter.print(" - " + serverName, timers.get(serverName));
    }
  }
  tPrinter.flush(); 
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:15,代码来源:ClusterMetricPrinter.java

示例12: execute

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public void execute(Shell shell, ShellContext context, Command command) {
  command.mapAll(this);
  String[] pair = StringUtil.toStringArray(pairs.get(0), "=");
  String name = pair[0];
  String valueString = pair[1];
  Object value = valueString;
  if ("int".equalsIgnoreCase(type)) {
    value = Integer.parseInt(valueString);
  } else if ("double".equalsIgnoreCase(type)) {
    value = Double.parseDouble(valueString);
  } else if ("boolean".equalsIgnoreCase(type)) {
    value = Boolean.parseBoolean(valueString);
  }
  context.getVariables().put(name, value);
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:16,代码来源:ShellBuiltinCommand.java

示例13: dumpInfo

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public void dumpInfo(Appendable out) {
  int[] width = {35, 35} ;
  TabularPrinter p = new TabularPrinter(out, width) ;
  p.header("Server Config", "");
  p.row("Group", group);
  p.row("Host", host);
  p.row("Listen Port", listenPort);
  p.row("Server Version", version);
  p.row("Roles", StringUtil.join(roles, ","));
  p.row("Cluster Framework", clusterFramework);
  p.row("Description", description);
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:13,代码来源:ServerConfig.java

示例14: execute

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public ModuleRegistration[] execute(Server server) throws Exception {
  String[] moduleNames = StringUtil.toArray(modules) ;
  ModuleRegistration[] status = server.getModuleContainer().install(properties, moduleNames) ;
  if(autostart) {
    status = server.getModuleContainer().start(moduleNames) ;
  }
  return status ;
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:9,代码来源:ServerModuleCommands.java

示例15: LeaderId

import com.neverwinterdp.util.text.StringUtil; //导入依赖的package包/类
public LeaderId(String path) {
  this.path = path ;
  int idx = path.lastIndexOf('/') ;
  String nodeName = path.substring(idx + 1) ;
  String[] parts = StringUtil.toStringArray(nodeName, "-") ;
  this.sequence = Long.parseLong(parts[1]) ;
}
 
开发者ID:DemandCube,项目名称:Scribengin,代码行数:8,代码来源:LeaderId.java


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