Class ProbeReflectionUtils

java.lang.Object
microsim.gui.probe.ProbeReflectionUtils

public class ProbeReflectionUtils extends Object
A collection of static methods using the java reflection to manipulate objects.

Title: JAS

Description: Java Agent-based Simulation library

Copyright (C) 2002 Michele Sonnessa

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
Author:
Michele Sonnessa

  • Constructor Details

    • ProbeReflectionUtils

      public ProbeReflectionUtils()
  • Method Details

    • isCollection

      public static boolean isCollection(Class<?> f)
      Test if the given class implements the java.util.Collection interface. The whole hierarchy of the class is tested.
      Parameters:
      f - The class to be tested.
      Returns:
      True if the class is a Collection, false otherwise.
    • isEditable

      public static boolean isEditable(Class<?> c)
      Test if the given class is a wrapper for a native type or a string. It could be a Double, Long, Integer, Float, String, Character or Boolean.
      Parameters:
      c - The class to be tested.
      Returns:
      True if class is of a native type, false in any other case.
    • isEditable

      public static boolean isEditable(Object o)
      Test if the given object is a wrapper for a native type or a string. It could be a Byte, Double, Long, Short, Integer, Float, String, Character or Boolean.
      Parameters:
      o - The object to be tested.
      Returns:
      True if class is of a native type, false in any other case.
    • isAnExecutableMethod

      public static boolean isAnExecutableMethod(Method m)
      Test if the given method requires parameters of a native type. In this case the method can be executed.
      Parameters:
      m - The method to be tested.
      Returns:
      True if the method requires only native-type parameters. A parameter is native type if int, long, ... or its corresponding wrapper class (Integer, Double, Long, ...).
    • setValueToObject

      public static void setValueToObject(Object o, Object val)
      Set a given value wrapped by an Object into the wrapper object.
      Parameters:
      o - The object to be updated. It must be of a native wrapper class (String, Double, Long, ...).
      val - An object whose toString() method return a valid format for the class type of object o.