[jboss-cvs] JBossAS SVN: r89740 - projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/profileservice.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 3 10:41:04 EDT 2009
Author: ispringer
Date: 2009-06-03 10:41:04 -0400 (Wed, 03 Jun 2009)
New Revision: 89740
Modified:
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/profileservice/PsGetExe.java
Log:
add -c/--complex option to enable printing of values of complex props
Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/profileservice/PsGetExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/profileservice/PsGetExe.java 2009-06-03 14:40:06 UTC (rev 89739)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/profileservice/PsGetExe.java 2009-06-03 14:41:04 UTC (rev 89740)
@@ -44,6 +44,7 @@
out.println("Get either all properties or a single property for the specified component, where");
out.println("COMPONENT_TYPE is of the form <type>:<subtype> (e.g. JMSDestination:Queue), ");
out.println("and PROPERTY is either * for all properties or <name> for the property named name.");
+ out.println(" -c, --complex display values for complex properties");
out.println(" -h, --help display this help and exit");
out.println(" -m, --metadata display property metadata");
out.println(" -V, --version print version information and exit");
@@ -63,7 +64,7 @@
handleUsageError(exePath, out, "Too few arguments.");
}
- String[] invalidOptions = getInvalidSwitches(args, "hmV", new String[]{"help", "metadata", "version"});
+ String[] invalidOptions = getInvalidSwitches(args, "chmV", new String[]{"complex", "help", "metadata", "version"});
if (invalidOptions.length > 0)
{
StringBuilder sb = new StringBuilder("Unknown or invalid option(s):");
@@ -80,6 +81,12 @@
return;
}
+ boolean complex = false;
+ if (isSwitchActive(args, "c", "complex"))
+ {
+ complex = true;
+ }
+
boolean metadata = false;
if (isSwitchActive(args, "m", "metadata"))
{
@@ -135,17 +142,17 @@
}
properties.put(prop.getName(), prop);
}
- out.print(toString(properties, metadata));
+ out.print(toString(properties, metadata, complex));
}
- public static String toString(Map<String, ManagedProperty> managedProps, boolean metadata)
+ public static String toString(Map<String, ManagedProperty> managedProps, boolean metadata, boolean complex)
{
StringBuilder buf = new StringBuilder();
List<ManagedProperty> props = new ArrayList<ManagedProperty>(managedProps.values());
Collections.sort(props, new ManagedPropertyComparator()); // sort by name
for (ManagedProperty managedProperty : props)
{
- buf.append(managedProperty.getName()).append("=").append(toString(managedProperty.getValue()));
+ buf.append(managedProperty.getName()).append("=").append(toString(managedProperty.getValue(), complex));
if (metadata) {
buf.append(" (");
EnumSet<ViewUse> viewUses = getViewUses(managedProperty);
@@ -164,7 +171,7 @@
return buf.toString();
}
- private static String toString(MetaValue metaValue)
+ private static String toString(MetaValue metaValue, boolean complex)
{
if (metaValue == null) {
return "<null>";
@@ -179,31 +186,12 @@
String innerValue = enumValue.getValue();
return (innerValue != null) ? innerValue : "<null>";
} else {
- // TODO: Decide how to display complex values.
- /*if (metaValue.getMetaType().isCollection())
- {
- CollectionValue collectionValue = (CollectionValue)metaValue;
- buffer.append(collectionValue).append("\n");
- for (int i = 0; i < indentLevel; i++) buffer.append(" ");
- buffer.append("Elements:\n");
- indentLevel++;
- for (MetaValue elementMetaValue : collectionValue.getElements())
- convertMetaValueToString(elementMetaValue, buffer, true, indentLevel);
+ if (complex) {
+ // TODO?: Use our own recursive toString() impl, rather than the MetaValue's toString().
+ return "<" + metaValue + ">";
+ } else {
+ return("<complex>");
}
- else if (metaValue.getMetaType().isComposite())
- {
- CompositeValue compositeValue = (CompositeValue)metaValue;
- buffer.append(compositeValue).append("\n");
- for (int i = 0; i < indentLevel; i++) buffer.append(" ");
- buffer.append("Items:\n");
- indentLevel++;
- for (String key : compositeValue.getMetaType().keySet()) {
- for (int i = 0; i < indentLevel; i++) buffer.append(" ");
- buffer.append(key).append("=");
- convertMetaValueToString(compositeValue.get(key), buffer, false, indentLevel);
- }
- }*/
- return("<complex>");
}
}
More information about the jboss-cvs-commits
mailing list