Class JavaTypes

  • Direct Known Subclasses:
    JavaSQLTypes

    public class JavaTypes
    extends java.lang.Object
    Type constants for managed fields.
    Author:
    Abe White
    • Constructor Summary

      Constructors 
      Constructor Description
      JavaTypes()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Class<?> classForName​(java.lang.String name, ClassMetaData context)
      Check the given name against the same set of standard packages used when parsing metadata.
      static java.lang.Class<?> classForName​(java.lang.String name, ClassMetaData context, java.lang.ClassLoader loader)
      Check the given name against the same set of standard packages used when parsing metadata.
      static java.lang.Class<?> classForName​(java.lang.String name, ClassMetaData context, java.lang.ClassLoader loader, boolean mustExist)
      Check the given name against the same set of standard packages used when parsing metadata.
      static java.lang.Class<?> classForName​(java.lang.String name, ValueMetaData context)
      Check the given name against the same set of standard packages used when parsing metadata.
      static java.lang.Class<?> classForName​(java.lang.String name, ValueMetaData context, java.lang.ClassLoader loader)
      Check the given name against the same set of standard packages used when parsing metadata.
      static java.lang.Class<?> classForName​(java.lang.String name, ValueMetaData context, java.lang.ClassLoader loader, boolean mustExist)
      Try to load a class using the provided loader.
      static java.lang.Object convert​(java.lang.Object val, int typeCode)
      Convert the given object to the given type if possible.
      static int getTypeCode​(java.lang.Class<?> type)
      Return the field metadata type code for the given class.
      static boolean isPrimitiveDefault​(java.lang.Object o, int typeCode)
      Determine whether or not the provided Object value is the default for the provided typeCode.
      static boolean maybePC​(FieldMetaData field)
      Return true if the (possibly unresolved) field or its elements might be persistence capable objects.
      static boolean maybePC​(ValueMetaData val)
      Return true if the (possibly unresolved) value might be a first class object.
      static java.lang.Object toArray​(java.util.Collection<?> coll, java.lang.Class<?> elem)
      Helper method to return the given collection as an array.
      static <T> java.util.List<T> toList​(java.lang.Object val, java.lang.Class<T> elem, boolean mutable)
      Helper method to return the given array value as a collection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JavaTypes

        public JavaTypes()
    • Method Detail

      • getTypeCode

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

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

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

        public static java.lang.Class<?> classForName​(java.lang.String name,
                                                      ClassMetaData context,
                                                      java.lang.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 java.lang.Class<?> classForName​(java.lang.String name,
                                                      ValueMetaData context)
        Check the given name against the same set of standard packages used when parsing metadata.
      • classForName

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

        public static java.lang.Class<?> classForName​(java.lang.String name,
                                                      ValueMetaData context,
                                                      java.lang.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 java.lang.Object convert​(java.lang.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> java.util.List<T> toList​(java.lang.Object val,
                                                   java.lang.Class<T> elem,
                                                   boolean mutable)
        Helper method to return the given array value as a collection.
      • toArray

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

        public static boolean isPrimitiveDefault​(java.lang.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.