--list-formatter-properties: optional column declared_in
Usage:
sql-dk --list-formatter-properties tabular --list-formatter-properties xml --list-formatter-properties xhtml --list-formatter-properties tex --formatter xhtml --formatter-property InfoLister:print:declared_in true > formatter-properties.xhtml
--- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sat Aug 15 14:00:47 2015 +0200
+++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sat Aug 15 14:35:27 2015 +0200
@@ -203,13 +203,20 @@
FormatterDefinition fd = configurationProvider.getConfiguration().getFormatter(formatterName);
try {
- ColumnsHeader header = constructHeader(
- new HeaderField("name", SQLType.VARCHAR),
- new HeaderField("type", SQLType.VARCHAR),
- new HeaderField("default", SQLType.VARCHAR),
- new HeaderField("description", SQLType.VARCHAR),
- new HeaderField("declared_in", SQLType.VARCHAR)
- );
+ // currently only for debugging purposes
+ // TODO: introduce --info-lister-property or generic filtering capability in printTable() ?
+ boolean printDeclaredIn = options.getFormatterProperties().getBoolean("InfoLister:print:declared_in", false);
+
+ List<HeaderField> headerFields = new ArrayList<>();
+ headerFields.add(new HeaderField("name", SQLType.VARCHAR));
+ headerFields.add(new HeaderField("type", SQLType.VARCHAR));
+ headerFields.add(new HeaderField("default", SQLType.VARCHAR));
+ headerFields.add(new HeaderField("description", SQLType.VARCHAR));
+ if (printDeclaredIn) {
+ headerFields.add(new HeaderField("declared_in", SQLType.VARCHAR));
+ }
+
+ ColumnsHeader header = constructHeader(headerFields.toArray(new HeaderField[0]));
Map<String, Object[]> data = new HashMap<>();
Class<Formatter> formatterClass = (Class<Formatter>) Class.forName(fd.getClassName());
@@ -217,7 +224,7 @@
Collections.reverse(hierarchy);
hierarchy.stream().forEach((c) -> {
for (PropertyDeclaration p : getPropertyDeclarations(c)) {
- data.put(p.name(), propertyDeclarationToRow(p, c));
+ data.put(p.name(), propertyDeclarationToRow(p, c, printDeclaredIn));
}
});
@@ -230,14 +237,18 @@
}
}
- private static Object[] propertyDeclarationToRow(PropertyDeclaration p, Class formatterClass) {
- return new Object[]{
- p.name(),
- CommonProperties.getSimpleTypeName(p.type()),
- p.defaultValue(),
- p.description(),
- formatterClass.getName()
- };
+ private static Object[] propertyDeclarationToRow(PropertyDeclaration p, Class formatterClass, boolean printDeclaredIn) {
+ List list = new ArrayList();
+
+ list.add(p.name());
+ list.add(CommonProperties.getSimpleTypeName(p.type()));
+ list.add(p.defaultValue());
+ list.add(p.description());
+ if (printDeclaredIn) {
+ list.add(formatterClass.getName());
+ }
+
+ return list.toArray();
}
private void listTypes() throws FormatterException, ConfigurationException {