Package com.db4o.qlin

Class Prototypes


  • public class Prototypes
    extends java.lang.Object
    creates prototype objects for classes. Each field on prototype objects is set to a newly created object or primitive that can be identified either by it's identity or by an int ID that is generated by the system. Creation of fields is recursed to the depth specified in the constructor.

    Allows analyzing expressions called on prototype objects to find the underlying field that delivers the return value of the expression. Passed expressions should not have side effects on objects, otherwise the "prototype world" will no longer work.

    We plan to supply an ImmutableFieldClassLoader to instrument the code to throw on every modification. This ClassLoader could also supply information about all the method calls involved.

    For now our approach only works if expressions are directly backed by a single field.

    We were inspired for this approach when we saw that Thomas Mueller managed to map expressions to fields for his JaQu query interface, Kudos! http://www.h2database.com/html/jaqu.html

    We took the idea a bit further and made it work for all primitives except for boolean and we plan to also get deeper expressions, collections and interfaces working nicely.
    • Constructor Summary

      Constructors 
      Constructor Description
      Prototypes()  
      Prototypes​(Reflector reflector, int recursionDepth, boolean ignoreTransient)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> Iterator4<java.lang.String> backingFieldPath​(ReflectClass claxx, java.lang.Object expression)
      analyzes the passed expression and tries to find the path to the backing field that is accessed.
      <T> Iterator4<java.lang.String> backingFieldPath​(java.lang.Class<T> clazz, java.lang.Object expression)
      analyzes the passed expression and tries to find the path to the backing field that is accessed.
      <T> Iterator4<java.lang.String> backingFieldPath​(java.lang.String className, java.lang.Object expression)
      analyzes the passed expression and tries to find the path to the backing field that is accessed.
      static Reflector defaultReflector()  
      <T> T prototypeForClass​(java.lang.Class<T> clazz)
      returns a prototype object for a specific class.
      Reflector reflector()  
      • Methods inherited from class java.lang.Object

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

      • Prototypes

        public Prototypes​(Reflector reflector,
                          int recursionDepth,
                          boolean ignoreTransient)
      • Prototypes

        public Prototypes()
    • Method Detail

      • prototypeForClass

        public <T> T prototypeForClass​(java.lang.Class<T> clazz)
        returns a prototype object for a specific class.
      • backingFieldPath

        public <T> Iterator4<java.lang.String> backingFieldPath​(java.lang.Class<T> clazz,
                                                                java.lang.Object expression)
        analyzes the passed expression and tries to find the path to the backing field that is accessed.
      • backingFieldPath

        public <T> Iterator4<java.lang.String> backingFieldPath​(ReflectClass claxx,
                                                                java.lang.Object expression)
        analyzes the passed expression and tries to find the path to the backing field that is accessed.
      • backingFieldPath

        public <T> Iterator4<java.lang.String> backingFieldPath​(java.lang.String className,
                                                                java.lang.Object expression)
        analyzes the passed expression and tries to find the path to the backing field that is accessed.
      • defaultReflector

        public static Reflector defaultReflector()