Advertisement
Corosus

get/set Private Value Ex

Feb 13th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static void setPrivateValueBoth(Class var0, Object var1, String obf, String mcp, Object var3) {
  2.         try {
  3.             try {
  4.                 setPrivateValue(var0, var1, obf, var3);
  5.             } catch (NoSuchFieldException ex) {
  6.                 setPrivateValue(var0, var1, mcp, var3);
  7.             }
  8.         } catch (Exception ex) {
  9.             ex.printStackTrace();
  10.         }
  11.     }
  12.    
  13.     public static Object getPrivateValueBoth(Class var0, Object var1, String obf, String mcp) {
  14.         try {
  15.             try {
  16.                 return getPrivateValue(var0, var1, obf);
  17.             } catch (NoSuchFieldException ex) {
  18.                 return getPrivateValue(var0, var1, mcp);
  19.             }
  20.         } catch (Exception ex) {
  21.             ex.printStackTrace();
  22.         }
  23.         return null;
  24.     }
  25.  
  26. public static Object getPrivateValue(Class class1, Object obj, int i)
  27.     throws IllegalArgumentException, SecurityException, NoSuchFieldException
  28.     {
  29.         try
  30.         {
  31.             Field field = class1.getDeclaredFields()[i];
  32.             field.setAccessible(true);
  33.             return field.get(obj);
  34.         }
  35.         catch (IllegalAccessException illegalaccessexception)
  36.         {
  37.  
  38.             ThrowException("An impossible error has occured!", illegalaccessexception);
  39.             return null;
  40.         }
  41.     }
  42.  
  43.     public static Object getPrivateValue(Class class1, Object obj, String s)
  44.     throws IllegalArgumentException, SecurityException, NoSuchFieldException
  45.     {
  46.         try
  47.         {
  48.             Field field = class1.getDeclaredField(s);
  49.             field.setAccessible(true);
  50.             return field.get(obj);
  51.         }
  52.         catch (IllegalAccessException illegalaccessexception)
  53.         {
  54.             ThrowException("An impossible error has occured!", illegalaccessexception);
  55.             return null;
  56.         }
  57.     }
  58.  
  59. public static void setPrivateValue(Class class1, Object obj, int i, Object obj1)
  60.     throws IllegalArgumentException, SecurityException, NoSuchFieldException
  61.     {
  62.         try
  63.         {
  64.             Field field = class1.getDeclaredFields()[i];
  65.             field.setAccessible(true);
  66.             int j = field_modifiers.getInt(field);
  67.             if ((j & 0x10) != 0)
  68.             {
  69.                 field_modifiers.setInt(field, j & 0xffffffef);
  70.             }
  71.             field.set(obj, obj1);
  72.         }
  73.         catch (IllegalAccessException illegalaccessexception)
  74.         {
  75.  
  76.             ThrowException("An impossible error has occured!", illegalaccessexception);
  77.         }
  78.     }
  79.  
  80.     public static void setPrivateValue(Class class1, Object obj, String s, Object obj1)
  81.     throws IllegalArgumentException, SecurityException, NoSuchFieldException
  82.     {
  83.         try
  84.         {
  85.             Field field = class1.getDeclaredField(s);
  86.             int i = field_modifiers.getInt(field);
  87.             if ((i & 0x10) != 0)
  88.             {
  89.                 field_modifiers.setInt(field, i & 0xffffffef);
  90.             }
  91.             field.setAccessible(true);
  92.             field.set(obj, obj1);
  93.         }
  94.         catch (IllegalAccessException illegalaccessexception)
  95.         {
  96.  
  97.             ThrowException("An impossible error has occured!", illegalaccessexception);
  98.         }
  99.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement