Class JavaTypes

java.lang.Object
org.apache.openjpa.meta.JavaTypes
Direct Known Subclasses:
JavaSQLTypes

public class JavaTypes extends Object
Type constants for managed fields.
Author:
Abe White
  • Field Details

  • Constructor Details

    • JavaTypes

      public JavaTypes()
  • Method Details

    • getTypeCode

      public static int getTypeCode(Class<?> type)
      Return the field metadata type code for the given class. First class objects are not recognized in this method.
    • classForName

      public static Class<?> classForName(String name, ClassMetaData context)
      Check the given name against the same set of standard packages used when parsing metadata.
    • classForName

      public static Class<?> classForName(String name, ClassMetaData context, ClassLoader loader)
      Check the given name against the same set of standard packages used when parsing metadata.
    • classForName

      public static Class<?> classForName(String name, ClassMetaData context, ClassLoader loader, boolean mustExist)
      Check the given name against the same set of standard packages used when parsing metadata.
      Parameters:
      mustExist - Whether the supplied loader must be able to load the class. If true no attempt to use a different classloader will be made. If false the ClassResolver from the configuration will be used.
    • classForName

      public static Class<?> classForName(String name, ValueMetaData context)
      Check the given name against the same set of standard packages used when parsing metadata.
    • classForName

      public static Class<?> classForName(String name, ValueMetaData context, ClassLoader loader)
      Check the given name against the same set of standard packages used when parsing metadata.
    • classForName

      public static Class<?> classForName(String name, ValueMetaData context, ClassLoader loader, boolean mustExist)
      Try to load a class using the provided loader. Optionally tries the configuration's ClassResolver if the supplied loader cannot find the class.
      Parameters:
      name - Name of the class to load.
      loader - ClassLoader to use. If null, the configuration's ClassResolver will be used.
      mustExist - Whether the supplied loader must be able to load the class. If true no attempt to use a different classloader will be made. If false the ClassResolver from the configuration will be used.
    • convert

      public static Object convert(Object val, int typeCode)
      Convert the given object to the given type if possible. If the type is a numeric primitive, this method only guarantees that the return value is a Number. If no known conversion or the value is null, returns the original value.
    • maybePC

      public static boolean maybePC(FieldMetaData field)
      Return true if the (possibly unresolved) field or its elements might be persistence capable objects.
    • maybePC

      public static boolean maybePC(ValueMetaData val)
      Return true if the (possibly unresolved) value might be a first class object.
    • toList

      public static <T> List<T> toList(Object val, Class<T> elem, boolean mutable)
      Helper method to return the given array value as a collection.
    • toArray

      public static Object toArray(Collection<?> coll, Class<?> elem)
      Helper method to return the given collection as an array.
    • isPrimitiveDefault

      public static boolean isPrimitiveDefault(Object o, int typeCode)
      Determine whether or not the provided Object value is the default for the provided typeCode. For example: If o = Integer(0) and typeCode = JavaTypes.INT, this method will return true.