public static List getAllFields(final Object obj, final boolean excludeStatic,
			final boolean excludeTransient) {
		List fieldList = new ArrayList();

		for (Class clazz = obj.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
			Field[] declaredFields = clazz.getDeclaredFields();

			for (int i = 0; i < declaredFields.length; i++) {
				int mods = declaredFields[i].getModifiers();

				if ((!excludeStatic || !Modifier.isStatic(mods))
						&& (!excludeTransient || !Modifier.isTransient(mods))) {
					declaredFields[i].setAccessible(true);
					fieldList.add(declaredFields[i]);
				}
			}
		}

		return fieldList;
	}
public static List getAllFields ( final Object obj , final boolean excludeStatic , final boolean excludeTransient ) { List fieldList = new ArrayList ( ) ; for ( Class clazz = obj . getClass ( ) ; clazz != null ; clazz = clazz . getSuperclass ( ) ) { Field [ ] declaredFields = clazz . getDeclaredFields ( ) ; for ( int i = 0 ; i < declaredFields . length ; i ++ ) { int mods = declaredFields [ i ] . getModifiers ( ) ; if ( ( ! excludeStatic || ! Modifier . isStatic ( mods ) ) && ( ! excludeTransient || ! Modifier . isTransient ( mods ) ) ) { declaredFields [ i ] . setAccessible ( true ) ; fieldList . add ( declaredFields [ i ] ) ; } } } return fieldList ; }
Retrieves all the fields contained in the given object and its superclasses.

@param obj the object to examine
@param excludeStatic if true, static fields will be omitted
@param excludeTransient if true, transient fields will be omitted
@return a list of fields for the given object