org.crsh.util.Utils类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.crsh.util.Utils类的一些代码示例,展示了Utils类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils类的具体详情如下:
包路径:org.crsh.util.Utils
类名称:Utils

Utils介绍

暂无

代码示例

代码示例来源:origin: crashub/crash

void close() {
 if (status == RUNNING) {
  status = CLOSED;
  Utils.close(driver);
 }
}

代码示例来源:origin: jooby-project/jooby

String commonCompletion = Utils.findLongestCommonPrefix(completions.getValues());
if (commonCompletion.length() > 0) {
 delimiter.escape(commonCompletion, sb);

代码示例来源:origin: crashub/crash

@Override
protected Iterable<PropertyDescriptor<?>> createConfigurationCapabilities() {
 return Utils.<PropertyDescriptor<?>>list(SMTP_HOST, SMTP_PORT, SMTP_SECURE, SMTP_USERNAME, SMTP_PASSWORD, SMTP_FROM, DEBUG);
}

代码示例来源:origin: crashub/crash

public void testMany() throws Exception {
 output.clear();
 lifeCycle.bindGroovy("consume_command", consume_command);
 lifeCycle.bindGroovy("produce_command", produce_command);
 assertOk("produce_command | filter -p A:C -p A:B | consume_command");
 assertEquals(list(map(map("A", "B"), "B", "B"), map(map("A", "C"), "B", "A")), output);
}

代码示例来源:origin: crashub/crash

private void _mergeEntries(URL url) throws IOException, URISyntaxException {
 if (url.getProtocol().equals("file")) {
  try {
   java.io.File f = Utils.toFile(url);
   if (f.isDirectory()) {
    merge(f);
   Utils.close(i);

代码示例来源:origin: crashub/crash

private static ByteArrayOutputStream read(InputStream in) throws IOException {
 if (in == null) {
  throw new NullPointerException();
 }
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 copy(in, baos);
 return baos;
}

代码示例来源:origin: crashub/crash

List<JavaFileObject> classes = collect(Utils.list(resolver.resolve("java.util", false)));
assertEquals(2, classes.size());
assertEndsWith("/HashMap.class", classes.get(0).getName());
byte[] bytes = Utils.readAsBytes(in);
assertTrue(bytes.length > 0);
classes = collect(Utils.list(resolver.resolve("java.util", true)));
assertEquals(3, classes.size());
assertEndsWith("/ConcurrentHashMap.class", classes.get(0).getName());

代码示例来源:origin: crashub/crash

public static boolean instanceOf(Class c, List<String> types) {
 for (String type: types) {
  if (instanceOf(c, type)) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: crashub/crash

public void afterPropertiesSet() throws Exception {
 // Initialise the registerable drivers
 try {
  drivers.put("classpath", new ClassPathMountFactory(loader));
  drivers.put("file", new FileMountFactory(Utils.getCurrentDirectory()));
 }
 catch (Exception e) {
  log.log(Level.SEVERE, "Coult not initialize classpath driver", e);
  return;
 }
 // List beans
 Map<String,Object> attributes = new HashMap<String, Object>();
 attributes.put("factory", factory);
 if (factory instanceof ListableBeanFactory) {
  ListableBeanFactory listable = (ListableBeanFactory)factory;
  attributes.put("beans", new SpringMap(listable));
 }
 //
 PluginDiscovery discovery = new SpringPluginDiscovery(loader, factory);
 //
 start(Collections.unmodifiableMap(attributes), discovery, loader);
}

代码示例来源:origin: crashub/crash

public static List<BindingRenderer.BindingData> lookup(List<String> filters, String name, Boolean verbose) {
 Pattern pattern = null;
 if (name != null) {
  pattern = Pattern.compile("^" + Utils.globexToRegex(name) + "$");
 }
 List<BindingRenderer.BindingData> data = new ArrayList<BindingRenderer.BindingData>();
 data.addAll(get(filters, pattern, verbose, ""));
 data.addAll(get(filters, pattern, verbose, "java:/"));
 data.addAll(get(filters, pattern, verbose, "java:comp/env/jdbc"));
 data.addAll(get(filters, pattern, verbose, "java:jboss"));
 data.addAll(get(filters, pattern, verbose, "java:global"));
 data.addAll(get(filters, pattern, verbose, "java:app"));
 data.addAll(get(filters, pattern, verbose, "java:module"));
 return data;
}

代码示例来源:origin: crashub/crash

private CRaSHTaskDef validateAndParseCronLine(String cronLine) {

  //
  cronLine = cronLine.trim();
  if (cronLine.length() == 0 || cronLine.charAt(0) == '#') {
   return null;
  }

  //
  List<String> cronLineParts = Arrays.asList(cronLine.split("\\s+"));
  if (cronLineParts.size() < 6) {
   return null;
  }

  //
  String schedulePart = Utils.join(cronLineParts.subList(0, 5), " ");
  String commandPart = Utils.join(cronLineParts.subList(5, cronLineParts.size()), " ");

  try {
   return new CRaSHTaskDef(new SchedulingPattern(schedulePart), commandPart);
  }
  catch (InvalidPatternException e) {
   // ?
   return null;
  }
 }
}

代码示例来源:origin: crashub/crash

/**
 * The path property is resolved from the servlet context parameters. When the parameter does not exist,
 * the <code>defaultValue</code> argument is used instead, so it should not be null.
 * After the path is resolved, it is interpolated using the JVM system properties and the syntax
 * defined by the {@link org.crsh.util.Utils#interpolate(String, java.util.Map)} function.
 *
 * @param propertyName the property name to resolve
 * @param defaultValue the default property value
 * @return the path value
 */
private String resolvePathProperty(String propertyName, String defaultValue) {
 String path = context.getInitParameter(propertyName);
 if (path == null) {
  path = defaultValue;
 }
 return Utils.interpolate(path, System.getProperties());
}

代码示例来源:origin: crashub/crash

private static int width(int width, Iterator<Object> stream, CharSequence current, Integer from) {
 while (current == null) {
  if (stream.hasNext()) {
   Object next = stream.next();
   if (next instanceof CharSequence) {
    current = (CharSequence)next;
    from = 0;
   }
  } else {
   break;
  }
 }
 if (current == null) {
  return width;
 } else {
  int pos = Utils.indexOf(current, from, '\n');
  if (pos == -1) {
   return width(width + current.length() - from, stream, current, from);
  } else {
   return Math.max(width + pos - from, width(0, stream, null, 0));
  }
 }
}

代码示例来源:origin: crashub/crash

private void copyConf(org.crsh.vfs.File src, File dst) throws IOException {
 if (!src.hasChildren()) {
  if (!dst.exists()) {
   Resource resource = ResourceManager.loadConf(src);
   if (resource != null) {
    log.info("Copied resource " + src.getPath().getValue() + " to " + dst.getCanonicalPath());
    Utils.copy(new ByteArrayInputStream(resource.getContent()), new FileOutputStream(dst));
   }
  }
 }
}

代码示例来源:origin: crashub/crash

public void testIntersect() throws Exception {
 output.clear();
 lifeCycle.bindGroovy("consume_command", consume_command);
 lifeCycle.bindGroovy("produce_command", produce_command);
 assertOk("produce_command | filter -p A:C -p B:A | consume_command");
 assertEquals(list(map(map("A", "C"), "B", "A")), output);
}

代码示例来源:origin: crashub/crash

public static ZipIterator create(URL url) throws IOException, URISyntaxException {
 if (url.getProtocol().equals("file")) {
  return create(Utils.toFile(url));
 } else if (url.getProtocol().equals("jar")) {
  int pos = url.getPath().lastIndexOf("!/");
    Utils.close(container);

代码示例来源:origin: crashub/crash

public static boolean instanceOf(Class c, String type) {
 if (c.getName().equals(type)) {
  return true;
 }
 for (Class i : c.getInterfaces()) {
  if (instanceOf(i, type)) {
   return true;
  }
 }
 if (c.getSuperclass() != null) {
  return instanceOf(c.getSuperclass(), type);
 }
 return false;
}

代码示例来源:origin: crashub/crash

private FS.Builder createBuilder() throws IOException {
 FileMountFactory fileDriver = new FileMountFactory(Utils.getCurrentDirectory());
 ClassPathMountFactory classpathDriver = new ClassPathMountFactory(Thread.currentThread().getContextClassLoader());
 return new FS.Builder().register("file", fileDriver).register("classpath", classpathDriver);
}

代码示例来源:origin: crashub/crash

private void assertMatchGlob(String test, String globex) {
 Pattern p = Pattern.compile("^" + Utils.globexToRegex(globex) + "$");
 Matcher matcher = p.matcher(test);
 assertTrue("Was expecting " + test + " to match " + globex, matcher.matches());
}

代码示例来源:origin: crashub/crash

public void assertRender(LineReader renderer, int width, String... expected) {
  List<String> result = render(renderer, width);
  if (result.size() != expected.length) {
   throw failure("Was expecting the same number of lines got:" + Utils.join(result, "/") + " expected:" +
     Utils.join(Arrays.asList(expected), "/"));
  } else {
   for (int i = 0;i < expected.length;i++) {
    if (!result.get(i).equals(expected[i])) {
     throw failure("Was expecting line " + i + " <" + result.get(i) + "> to be equals to <" + expected[i] + ">");
    }
   }
  }
 }
}

相关文章