edu.neu.ccs.util
Class StaticFields

java.lang.Object
  extended byedu.neu.ccs.util.StaticFields

public class StaticFields
extends Object

The class StaticFields contains a general static method to extract the public static fields from a given class with given field type.

The class also contains two special static methods that deal with a field whose type is int.

This class cannot be instantiated.

Since:
2.5.0
Version:
2.5.0

Constructor Summary
private StaticFields()
          Prevent instantiation.
 
Method Summary
static Field[] getPublicStaticFields(Class type, Class fieldtype)
          Returns the public static fields in the given class of the given field type.
static StringIntPair[] getPublicStaticIntFieldData(Class type)
          For each public static field in the given class of field type int, create a StringIntPair with the name of the field and its int value; then return all such pairs in a StringIntPair array.
static int[] getPublicStaticIntFieldValues(Class type)
          For each public static field in the given class of field type int, extract the int value; then return all such extracted int values in an int array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticFields

private StaticFields()
Prevent instantiation.

Method Detail

getPublicStaticFields

public static Field[] getPublicStaticFields(Class type,
                                            Class fieldtype)

Returns the public static fields in the given class of the given field type.

Returns null if type is null.

Returns all public static fields if fieldtype is null.

Parameters:
type - the class type to inspect
fieldtype - the field type of the desired public static fields

getPublicStaticIntFieldData

public static StringIntPair[] getPublicStaticIntFieldData(Class type)

For each public static field in the given class of field type int, create a StringIntPair with the name of the field and its int value; then return all such pairs in a StringIntPair array.

In case of an error in extracting the int value, an error message will be appended to the field name before the corresponding StringIntPair is created.

Parameters:
type - the class type to inspect

getPublicStaticIntFieldValues

public static int[] getPublicStaticIntFieldValues(Class type)

For each public static field in the given class of field type int, extract the int value; then return all such extracted int values in an int array.

In case of an error in extracting the int value, a value of 0 will be used.

Parameters:
type - the class type to inspect