public String _isdir(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${isdir;...}"); return null; } else { boolean isdir = true; for (int i = 1; i < args.length; i++) { File f = new File(args[i]).getAbsoluteFile(); isdir &= f.isDirectory(); } return isdir ? "true" : "false"; } }
public String _isfile(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${isfile;...}"); return null; } else { boolean isfile = true; for (int i = 1; i < args.length; i++) { File f = new File(args[i]).getAbsoluteFile(); isfile &= f.isFile(); } return isfile ? "true" : "false"; } }
public String _isfile(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${isfile;...}"); return null; } else { boolean isfile = true; for (int i = 1; i < args.length; i++) { File f = new File(args[i]).getAbsoluteFile(); isfile &= f.isFile(); } return isfile ? "true" : "false"; } }
public String _isdir(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${isdir;...}"); return null; } else { boolean isdir = true; for (int i = 1; i < args.length; i++) { File f = new File(args[i]).getAbsoluteFile(); isdir &= f.isDirectory(); } return isdir ? "true" : "false"; } }
public String _tstamp(String args[]) { String format = "yyyyMMddHHmm"; long now = System.currentTimeMillis(); if (args.length > 1) { format = args[1]; if (args.length > 2) { now = Long.parseLong(args[2]); if (args.length > 3) { domain.warning("Too many arguments for tstamp: " + Arrays.toString(args)); } } } SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(new Date(now)); }
public String _warning(String args[]) { for (int i = 1; i < args.length; i++) { domain.warning(process(args[i])); } return ""; }
public String _warning(String args[]) { for (int i = 1; i < args.length; i++) { domain.warning(process(args[i])); } return ""; }
public String _tstamp(String args[]) { String format = "yyyyMMddHHmm"; long now = System.currentTimeMillis(); if (args.length > 1) { format = args[1]; if (args.length > 2) { now = Long.parseLong(args[2]); if (args.length > 3) { domain.warning("Too many arguments for tstamp: " + Arrays.toString(args)); } } } SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(new Date(now)); }
public void error(String string, Object... args) { if (isFailOk()) warning(string, args); else { String s = String.format(string, args); if (!errors.contains(s)) errors.add(s); } }
public void error(String string, Throwable t, Object... args) { if (isFailOk()) warning(string + ": " + t, args); else { String s = String.format(string, args); if (!errors.contains(s)) errors.add(s); } if (exceptions) t.printStackTrace(); }
private String doCommand(Object target, String method, String[] args) { if (target == null) ; // System.out.println("Huh? Target should never be null " + // domain); else { String cname = "_" + method.replaceAll("-", "_"); try { Method m = target.getClass().getMethod(cname, new Class[] { String[].class }); return (String) m.invoke(target, new Object[] { args }); } catch (NoSuchMethodException e) { // Ignore } catch (InvocationTargetException e) { domain.warning("Exception in replace: " + e.getCause()); e.printStackTrace(); } catch (Exception e) { domain.warning("Exception in replace: " + e + " method=" + method); e.printStackTrace(); } } return null; }
public String _basename(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${basename;...}"); return null; } else { String del = ""; StringBuffer sb = new StringBuffer(); for (int i = 1; i < args.length; i++) { File f = new File(args[i]).getAbsoluteFile(); if (f.exists() && f.getParentFile().exists()) { sb.append(del); sb.append(f.getName()); del = ","; } } return sb.toString(); } }
public String _dir(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${dir;...}"); return null; } else { String del = ""; StringBuffer sb = new StringBuffer(); for (int i = 1; i < args.length; i++) { File f = new File(args[i]).getAbsoluteFile(); if (f.exists() && f.getParentFile().exists()) { sb.append(del); sb.append(f.getParentFile().getAbsolutePath()); del = ","; } } return sb.toString(); } }
public String _dir(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${dir;...}"); return null; } else { String del = ""; StringBuffer sb = new StringBuffer(); for (int i = 1; i < args.length; i++) { File f = domain.getFile(args[i]); if (f.exists() && f.getParentFile().exists()) { sb.append(del); sb.append(f.getParentFile().getAbsolutePath()); del = ","; } } return sb.toString(); } }
public String _basename(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${basename;...}"); return null; } else { String del = ""; StringBuffer sb = new StringBuffer(); for (int i = 1; i < args.length; i++) { File f = domain.getFile(args[i]); if (f.exists() && f.getParentFile().exists()) { sb.append(del); sb.append(f.getName()); del = ","; } } return sb.toString(); } }
private String doCommand(Object target, String method, String[] args) { if (target == null) ; // System.out.println("Huh? Target should never be null " + // domain); else { String cname = "_" + method.replaceAll("-", "_"); try { Method m = target.getClass().getMethod(cname, new Class[] { String[].class }); return (String) m.invoke(target, new Object[] { args }); } catch (NoSuchMethodException e) { // Ignore } catch (InvocationTargetException e) { if ( e.getCause() instanceof IllegalArgumentException ) { domain.error("%s, for cmd: %s, arguments; %s", e.getMessage(), method, Arrays.toString(args)); } else { domain.warning("Exception in replace: " + e.getCause()); e.getCause().printStackTrace(); } } catch (Exception e) { domain.warning("Exception in replace: " + e + " method=" + method); e.printStackTrace(); } } return null; }
public String _toclassname(String args[]) { verifyCommand(args, _toclassnameHelp, null, 2, 2); Collection<String> paths = Processor.split(args[1]); List<String> names = new ArrayList<String>(paths.size()); for (String path : paths) { if (path.endsWith(".class")) { String name = path.substring(0, path.length() - 6).replace('/', '.'); names.add(name); } else if (path.endsWith(".java")) { String name = path.substring(0, path.length() - 5).replace('/', '.'); names.add(name); } else { domain.warning("in toclassname, " + args[1] + " is not a class path because it does not end in .class"); } } return Processor.join(names, ","); }
public String _toclassname(String args[]) { verifyCommand(args, _toclassnameHelp, null, 2, 2); Collection<String> paths = Processor.split(args[1]); List<String> names = new ArrayList<String>(paths.size()); for (String path : paths) { if (path.endsWith(".class")) { String name = path.substring(0, path.length() - 6).replace('/', '.'); names.add(name); } else if (path.endsWith(".java")) { String name = path.substring(0, path.length() - 5).replace('/', '.'); names.add(name); } else { domain .warning("in toclassname, " + args[1] + " is not a class path because it does not end in .class"); } } return Processor.join(names, ","); }
public void error(String string, Throwable t, Object... args) { Processor p = current(); if (p.isFailOk()) p.warning(string + ": " + t, args); else { p.errors.add("Exception: " + t.getMessage()); String s = formatArrays(string, args); if (!p.errors.contains(s)) p.errors.add(s); } if (p.exceptions) t.printStackTrace(); p.signal(); }
public void error(String string, Object... args) { Processor p = current(); if (p.isFailOk()) p.warning(string, args); else { String s = formatArrays(string, args); if (!p.errors.contains(s)) p.errors.add(s); } p.signal(); }