db4o 8.0

com.db4o.qlin
Class Prototypes

java.lang.Object
  extended by com.db4o.qlin.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
Prototypes()
           
Prototypes(Reflector reflector, int recursionDepth, boolean ignoreTransient)
           
 
Method Summary
<T> com.db4o.foundation.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> com.db4o.foundation.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> com.db4o.foundation.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
equals, 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> com.db4o.foundation.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> com.db4o.foundation.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> com.db4o.foundation.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.


reflector

public Reflector reflector()

defaultReflector

public static Reflector defaultReflector()

db4o 8.0

Copyright 2009 Versant Corporation. All rights reserved.