Methods Summary |
---|
public java.lang.String | asString()
final String[] s = reg.findManagedBeans();
final StringBuffer sb = new StringBuffer();
sb.append(getClassPreamble());
for (int i = 0 ; i < s.length ; i ++) {
sb.append(mb2s(s[i]));
}
sb.append('\n" + "}");
return ( sb.toString() );
|
private java.lang.String | getClassJavadoc()
final StringBuffer sb = new StringBuffer("/** An Auto-generated MBean ObjectName Factory */");
sb.append('\n");
sb.append("public class ConfigMBeanNames {");
sb.append('\n");
return ( sb.toString() );
|
private java.lang.String | getClassPreamble()
final StringBuffer sb = new StringBuffer();
sb.append(getPackageDeclaration());
sb.append(getImports());
sb.append(getClassJavadoc());
return ( sb.toString() );
|
private java.lang.String | getImports()
return ("import javax.management.ObjectName;" + '\n");
|
private java.lang.String | getMethodBody(com.sun.org.apache.commons.modeler.ManagedBean mb)
final String onv = getObjectNameValue(mb);
final String params = getParameterList(onv);
final String nodm = onv.substring(onv.indexOf(ONDELIMITER) + 1);
//System.out.println(nodm);
//System.out.println(params);
final String ong = positionalReplace(nodm);
final String ret = getReturnStatement(ong);
final StringBuffer sb = new StringBuffer("{").append('\n").append(ret).append('\n").append("}");
return ( sb.toString() );
|
private java.lang.String | getMethodSignature(com.sun.org.apache.commons.modeler.ManagedBean mb)
final StringBuffer sb = new StringBuffer("public static final ObjectName ");
sb.append("get");
final String humped = AttributeListUtils.dash2CamelCase(mb.getName());
sb.append(getValidJavaMethodName(humped));
sb.append("ObjectName(");
final String onv = getObjectNameValue(mb);
sb.append(getParameterList(onv));
sb.append(" )");
return ( sb.toString() );
|
private java.lang.String | getObjectNameValue(com.sun.org.apache.commons.modeler.ManagedBean mb)
final List fields = mb.getFields();
final Iterator iter = fields.iterator();
String val = null;
while (iter.hasNext()) {
final FieldInfo f = (FieldInfo)iter.next();
if ("ObjectName".equals(f.getName())) {
val = (String) f.getValue();
}
}
return ( val );
|
private java.lang.String | getPackageDeclaration()
final StringBuffer sb = new StringBuffer();
sb.append("package TBD...").append('\n");
sb.append('\n");
return ( sb.toString() );
|
private java.lang.String | getParameterList(java.lang.String on)
return ( Tok2Params.convert2ParamList(on) );
|
private java.lang.String | getReturnStatement(java.lang.String s)
final StringBuffer sb = new StringBuffer();
final String qs = "\"" + s + "\"";
sb.append("return ( ").append(ANY_GETTER).append("( ").append(qs).append(" )").append(" )");
return ( sb.toString() );
|
private java.lang.String | getValidJavaMethodName(java.lang.String s)
/* Currently '#' is the only culprit */
String n = s.replace('#", '_");
return ( n );
|
public static void | main(java.lang.String[] args)
try {
final File r = new File("/export/home/kedar/ee/LATEST/admin-core/admin/dtds/admin-mbeans-descriptors.xml");
final OutputStream op = System.out;
final ObjectNamesSourceGenerator o = new ObjectNamesSourceGenerator(r, op);
final String s = o.asString();
op.write(s.getBytes());
System.out.println("Done");
System.out.println("The length of Java source file would be, Characters: " + s.length());
}
catch (final Throwable e) {
e.printStackTrace();
}
|
private java.lang.String | mb2s(java.lang.String name)
final ManagedBean mb = reg.findManagedBean(name);
final StringBuffer sb = new StringBuffer();
final String method = getMethodSignature(mb);
sb.append(method).append('\n");
sb.append(getMethodBody(mb)).append('\n");
//System.out.println(sb.toString());
return ( sb.toString() );
|
private java.lang.String | positionalReplace(java.lang.String tk)
final String rs = Tok2Params.replacePositionalTokens(tk);
return ( rs );
|
private void | setClassName(java.lang.String c)
this.className = c;
|
private void | setPackageName(java.lang.String p)
this.pkgName = p;
|
public void | write()
out.write(this.asString().getBytes());
|