package me.allenz.zlog;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

/**
 * Utility tools.
 * 
 * @author Allenz
 * @since 0.10.-RELEASE
 */
public class Utils {

	private Utils() {
		throw new UnsupportedOperationException();
	}

	/**
	 * Get the integer value of static field the declared in specified class.
	 * 
	 * @param className
	 *            the fullname of the class
	 * @param fieldName
	 *            the name of the field
	 * @param defaultValue
	 *            the default value to return when failed to get value of the
	 *            field
	 * @return the value of the field when successed, or the default value when
	 *         failure
	 */
	public int intReflectStaticFieldValue(final String className,
			final String fieldName, final int defaultValue) {
		try {
			final Class<?> clazz = Class.forName(className);
			final Field field = clazz.getDeclaredField(fieldName);
			if (Modifier.isStatic(field.getModifiers())
					&& field.getType().getName().equals("int")) {
				field.setAccessible(true);
				return field.getInt(null);
			}
		} catch (final Exception e) {
			LoggerFactory.getInternalLogger().warn(e,
					"Can not get the value of %s.%s", className, fieldName);
		}
		return defaultValue;
	}

	/**
	 * Get the boolean value of static field the declared in specified class.
	 * 
	 * @param className
	 *            the fullname of the class
	 * @param fieldName
	 *            the name of the field
	 * @param defaultValue
	 *            the default value to return when failed to get value of the
	 *            field
	 * @return the value of the field when successed, or the default value when
	 *         failure
	 */
	public boolean booleanReflectStaticFieldValue(final String className,
			final String fieldName, final boolean defaultValue) {
		try {
			final Class<?> clazz = Class.forName(className);
			final Field field = clazz.getDeclaredField(fieldName);
			if (Modifier.isStatic(field.getModifiers())
					&& field.getType().getName().equals("int")) {
				field.setAccessible(true);
				return field.getBoolean(null);
			}
		} catch (final Exception e) {
			LoggerFactory.getInternalLogger().warn(e,
					"Can not get the value of %s.%s", className, fieldName);
		}
		return defaultValue;
	}
}

@@ -143,18 +143,18 @@
 ince 0.1
-0
 .
+0
 -RELEASE
@@ -673,23 +673,55 @@
 lure%0A%09 *
-/%0A%09publ
+ @since 0.1.0-RELEASE%0A%09 */%0A%09public stat
 ic int i
@@ -1701,23 +1701,55 @@
 lure%0A%09 *
-/%0A%09publ
+ @since 0.1.0-RELEASE%0A%09 */%0A%09public stat
 ic boole
@@ -1774,32 +1774,36 @@
 taticFieldValue(
+%0A%09%09%09
 final String cla
@@ -1801,36 +1801,33 @@
 tring className,
-%0A%09%09%09
+ 
 final String fie
@@ -1829,25 +1829,28 @@
 g fieldName,
- 
+%0A%09%09%09
 final boolea

add static modifier to the methods of Utils