Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.86 KB | None | 0 0
  1. <% @ Page language = "java" import = "java.lang.reflect. *"%>
  2.  <%!
  3.  public void processClass (Object instance, javax.servlet.jsp.JspWriter out, java.util.HashSet set, String poc) {
  4.      try {
  5.      <?> Class c = instance.getClass ();
  6.      set.add (instance);
  7.      Method [] allMethods = c.getMethods ();
  8.      for (Method m: allMethods) {
  9.          if (! m.getName (). startsWith ("set")) {
  10.          continue;
  11.          }
  12.          if (! m.toGenericString (). startsWith ("public")) {
  13.          continue;
  14.          }
  15.          <?> Class [] pType = m.getParameterTypes ();
  16.          if (! pType.length = 1) continue;
  17.        
  18.          if (pType [0] getName () equals ("java.lang.String").. | |
  19.          .. pType [0] getName () equals ("boolean") | |
  20.          pType [0]. getName (). equals ("int")) {
  21.              .. String fieldName = m.getName () substring (3,4) toLowerCase () + m.getName () substring (4).;
  22.              out.print (poc + + fieldName + "<br>" ".");
  23.          }
  24.      }
  25.      for (Method m: allMethods) {
  26.          if (! m.getName (). startsWith ("get")) {
  27.          continue;
  28.          }
  29.          if (! m.toGenericString (). startsWith ("public")) {
  30.          continue;
  31.          }     
  32.          <?> Class [] pType = m.getParameterTypes ();
  33.          if (! pType.length = 0) continue;
  34.          if (m.getReturnType () == Void.TYPE) continue;
  35.          Object o = m.invoke (instance);
  36.          if (o! = null)
  37.          {
  38.              if (set.contains (o)) continue;
  39.              processClass ("."... o, out, set, poc + + m.getName () substring (3,4) toLowerCase () + m.getName () substring (4));  
  40.          }
  41.      }
  42.      } Catch (java.io.IOException x) {
  43.      x.printStackTrace ();
  44.      } Catch (java.lang.IllegalAccessException x) {
  45.      x.printStackTrace ();
  46.      } Catch (java.lang.reflect.InvocationTargetException x) {
  47.      x.printStackTrace ();
  48.      } 
  49.  }
  50.  %>
  51.  <%
  52.  java.util.HashSet set = new java.util.HashSet <Object> ();
  53.  String poc = "class.classLoader";
  54.  example.HelloWorld action = new example.HelloWorld ();
  55.  processClass (action.getClass () getClassLoader (), out, set, poc.);
  56.  %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement