{
out.print(JavaColorizer.format(out, ((JavaResource) resource).getJavaSource().toString()));
}
else
{
JavaResource javaResource = (JavaResource) resource;
JavaSource<?> javaSource = javaResource.getJavaSource();
List<String> output = new ArrayList<String>();
if (!out.isPiped())
{
out.println();
out.println(ShellColor.RED, "[fields]");
}
if (javaSource instanceof JavaClass)
{
JavaClass javaClass = (JavaClass) javaSource;
List<Field<JavaClass>> fields = javaClass.getFields();
for (Field<JavaClass> field : fields)
{
String entry = out.renderColor(ShellColor.BLUE, field.getVisibility().scope());
entry += out.renderColor(ShellColor.GREEN, DELIM + field.getType() + "");
entry += DELIM + field.getName() + ";";
output.add(entry);
}
if (out.isPiped())
{
GeneralUtils.OutputAttributes attr = new GeneralUtils.OutputAttributes(120, 1);
printOutColumns(output, ShellColor.NONE, out, attr, null, false);
}
else
{
GeneralUtils.printOutColumns(output, out, shell, true);
out.println();
}
// rinse and repeat for methods
output = new ArrayList<String>();
List<Method<JavaClass>> methods = javaClass.getMethods();
if (!out.isPiped())
{
out.println(ShellColor.RED, "[methods]");
}
for (Method<JavaClass> method : methods)
{
String entry = out.renderColor(ShellColor.BLUE, method.getVisibility().scope());
String parameterString = "(";
for (Parameter param : method.getParameters())
{
parameterString += param.toString();
}
parameterString += ")";
entry += DELIM + method.getName() + parameterString;
String returnType = method.getReturnType() == null ? "void" : method.getReturnType();
entry += out.renderColor(ShellColor.GREEN, DELIM + returnType + "");
output.add(entry);
}
if (out.isPiped())
{
GeneralUtils.OutputAttributes attr = new GeneralUtils.OutputAttributes(120, 1);
printOutColumns(output, ShellColor.NONE, out, attr, null, false);
}
else
{
GeneralUtils.printOutColumns(output, out, shell, true);
out.println();
}
}
else if (javaSource instanceof JavaEnum)
{
JavaResource enumTypeResource = (JavaResource) resource;
List<Resource<?>> members = enumTypeResource.listResources();
for (Resource<?> member : members)
{
String entry = member.getName();
output.add(entry);
}