private String getFullPath(ConfigOption<?> opt) { StringBuilder sb = new StringBuilder(64); sb.insert(0, opt.getName()); for (ConfigNamespace parent = opt.getNamespace(); null != parent && !parent.isRoot(); parent = parent.getNamespace()) { if (parent.isUmbrella()) sb.insert(0, "[X]."); sb.insert(0, "."); sb.insert(0, parent.getName()); } return sb.toString(); }
private String getNamespaceSectionHeader(ConfigNamespace n, String prefix) { String fullName = prefix + n.getName(); if (n.isUmbrella()) fullName += " *"; return "==== " + fullName + " ====\n[role=\"font16\"]\n" + n.getDescription() + "\n\n"; }
Pattern.quote(STORAGE_NS.getName()) + "\\..*" + "(" + Pattern.quote(STORAGE_DIRECTORY.getName()) + "|" + Pattern.quote(STORAGE_CONF_FILE.getName()) + ")" + "|" + Pattern.quote(INDEX_NS.getName()) + "\\..*" + "(" + Pattern.quote(INDEX_DIRECTORY.getName()) + "|" + Pattern.quote(INDEX_CONF_FILE.getName()) + ")"
public static String getPath(ConfigElement element, boolean includeRoot, String... umbrellaElements) { Preconditions.checkNotNull(element); if (umbrellaElements==null) umbrellaElements = new String[0]; StringBuilder path = new StringBuilder(element.getName()); int umbrellaPos = umbrellaElements.length-1; while (!element.isRoot() && !element.getNamespace().isRoot()) { ConfigNamespace parent = element.getNamespace(); if (parent.isUmbrella()) { Preconditions.checkArgument(umbrellaPos>=0,"Missing umbrella element path for element: %s",element); String umbrellaName = umbrellaElements[umbrellaPos]; Preconditions.checkArgument(!StringUtils.containsAny(umbrellaName,ILLEGAL_CHARS),"Invalid umbrella name provided: %s. Contains illegal chars",umbrellaName); path.insert(0, umbrellaName + SEPARATOR); umbrellaPos--; } path.insert(0, parent.getName() + SEPARATOR); element = parent; } if (includeRoot) { // Assumes that roots are not umbrellas // If roots could be umbrellas, we might have to change the interpretation of umbrellaElements path.insert(0, (element.isRoot() ? element.getName() : element.getNamespace().getName()) + SEPARATOR); } //Don't make this check so that we can still access more general config items Preconditions.checkArgument(umbrellaPos<0,"Found unused umbrella element: %s",umbrellaPos<0?null:umbrellaElements[umbrellaPos]); return path.toString(); }
private void printNamespace(ConfigNamespace n, String prefix) { String newPrefix = prefix + n.getName() + "."; if (n.isUmbrella()) newPrefix += "[X]."; if (n.isRoot()) newPrefix = ""; //Override for root namespace //Only print namespace if it contains (visible) options if (!Iterables.isEmpty(getSortedChildOptions(n))) { stream.println(getNamespaceSectionHeader(n, prefix)); stream.println(getTableHeader()); for (ConfigOption<?> o : getSortedChildOptions(n)) { stream.println(getTableLineForOption(o, newPrefix)); } stream.println(TABLE_FOOTER_LINES); } for (ConfigNamespace cn : getSortedChildNamespaces(n)) { printNamespace(cn, newPrefix); } }