/** * Returns the element at the (zero based) index wrapped as {@link sirius.kernel.commons.Value} * <p> * If the index is out of the valid range for the wrapped elements, an empty value will be returned * * @param index the zero based index of the element to return * @return the requested element wrapped as value or an empty value if no such element exists */ @Nonnull public Value at(int index) { if (dataArray != null) { return Value.indexOf(index, dataArray); } else { return Value.indexOf(index, dataList); } }
@Override public void execute(Output output, String... params) throws Exception { String filter = Value.indexOf(0, params).asString().toLowerCase(); for (String name : index.getSchema().getTypeNames()) { if (Strings.isEmpty(filter) || name.toLowerCase().contains(filter)) { outputMapping(output, name); } } }
@Override public void execute(Output output, String... params) throws Exception { Value name = Value.indexOf(0, params); if (name.isEmptyString()) { output.line("No class name given. Try: doc <classname>"); return; } Injector.getAllLoadedClasses() .stream() .filter(c -> c.getName().toLowerCase().contains(name.asString().toLowerCase())) .forEach(c -> { output.line(c.getName()); output.separator(); for (Method m : c.getMethods()) { output.line(m.toString()); } output.blankLine(); }); }
@Override public void execute(Output output, String... params) throws Exception { boolean withTraces = Value.indexOf(0, params).isFilled(); boolean includeWaiting = "Y".equals(Value.indexOf(1, params).asString()); if (withTraces) { outputThreadInfos(output, includeWaiting, params[0]); } else { output.line("Usage: threads [<filter> (or 'all')] [Y=include WAITING/NATIVE]"); output.separator(); output.apply("%-15s %10s %53s", "STATE", "ID", "NAME"); output.separator(); for (ThreadInfo info : t.dumpAllThreads(false, false)) { output.apply("%-15s %10s %53s", info.isInNative() ? "NATIVE" : info.getThreadState().name(), info.getThreadId(), info.getThreadName()); } output.separator(); } }
@Override public void execute(Output output, String... params) throws Exception { if (Value.indexOf(0, params).isEmptyString()) { output.line("Usage: updateMapping <type>"); } else { Class<? extends Entity> type = findTypeOrReportError(output, params[0]); if (type != null) { EntityDescriptor ed = index.getDescriptor(type); try { index.addMapping(index.getIndexName(ed.getIndex()), type); output.line("Mapping was updated..."); } catch (Exception e) { output.line(e.getMessage()); output.line("If necessary use the force option but be aware that there might be data loss!"); } } } }
@Override public void execute(Output output, String... params) { if (params.length > 0) { for (Cache<?, ?> c : CacheManager.getCaches()) { if (Value.indexOf(0, params).asString().equals(c.getName())) { output.apply("Flushing: %s", params[0]); c.clear(); } } } else { output.line("Use cache <name> to flush the given cache..."); } output.blankLine(); output.apply("%-53s %8s %8s %8s", "NAME", "SIZE", "MAX-SIZE", "HIT-RATE"); output.separator(); for (Cache<?, ?> c : CacheManager.getCaches()) { output.apply("%-53s %8d %8d %8d", c.getName(), c.getSize(), c.getMaxSize(), c.getHitRate()); } output.separator(); }