private String determineLocation() { // Tries to find the most useful (neither generic, nor reflection nor our framework) point in the stacktrace StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); int idx = 1; while (idx++ < stackTrace.length) { StackTraceElement currentElement = stackTrace[idx]; if (!currentElement.getClassName().startsWith("sirius.db") && !currentElement.getClassName() .startsWith("com.sun") && !currentElement.getClassName().startsWith("java.")) { return currentElement.toString(); } } // That's the best guess anyway return Values.of(stackTrace).at(5).asString("<unknown>"); }
@Override public void execute(Output output, String... params) throws Exception { String filter = Values.of(params).at(0).toLowerCase(); output.apply("%-39s %40s", "NAME", "VALUE"); output.separator(); for (Map.Entry<Object, Object> prop : System.getProperties().entrySet()) { if (Strings.isEmpty(filter) || prop.getKey().toString().toLowerCase().contains(filter) || prop.getValue() .toString() .toLowerCase() .contains( filter)) { output.apply("%-39s %40s", prop.getKey(), prop.getValue()); } } output.separator(); }
private void readRow() throws IOException { List<String> row = Lists.newArrayList(); while (!isEOF() && !isAtNewline()) { row.add(readField()); if (buffer == separator) { read(); } } if (limit.nextRow()) { consumer.accept(Values.of(row)); } }
@Override public void execute(Output output, String... params) throws Exception { Values values = Values.of(params); if ("query".equalsIgnoreCase(values.at(0).asString())) { query(output, values); } else if ("update".equalsIgnoreCase(values.at(0).asString())) { update(output, values); } else if ("delete".equalsIgnoreCase(values.at(0).asString())) { delete(output, values); } else if ("resave".equalsIgnoreCase(values.at(0).asString())) { resave(output, values); } else if ("unbalance".equalsIgnoreCase(values.at(0).asString())) { unbalance(output); } else if ("balance".equalsIgnoreCase(values.at(0).asString())) { balance(output); } else { output.apply("Unknown command: %s", values.at(0)); output.line("Use: query <type> <filter>"); output.line(" or update <type> <filter> <field> <value> (Limit 500)"); output.line(" or delete <type> <filter>"); output.line(" or resave <type> <filter>"); output.line(" or unbalance"); output.line(" or balance"); } }
int currentHour = Values.of(params).at(1).asInt(25); output.line("Executing daily timers for hour: " + currentHour); ts.runEveryDayTimers(currentHour);
Values parameters = Values.of(params); if ("tracing".equals(parameters.at(0).asString())) { if (parameters.length() > 1) {