org.xenei.jena.entities.impl
Class EntityManagerImpl

java.lang.Object
  extended by org.xenei.jena.entities.impl.EntityManagerImpl
All Implemented Interfaces:
EntityManager

public class EntityManagerImpl
extends Object
implements EntityManager

An implementation of the EntityManager interface.


Constructor Summary
EntityManagerImpl()
          Constructor.
 
Method Summary
 com.hp.hpl.jena.rdf.model.Resource addInstanceProperties(com.hp.hpl.jena.rdf.model.Resource r, Class<?> clazz)
          Read an instance of clazz from Resource r.
 SubjectInfo getSubjectInfo(Class<?> clazz)
          Get the SubjectInfo for the class.
 boolean isInstance(Object target, Class<?> clazz)
          Determine if target has all the properties required in the Subject( type ) annotation value.
 void parseClasses(String packageName)
          Parses the the classes in a package (and subpackages) looking for Subject annotated classes.
 void parseClasses(String[] packageNames)
          Parses the the classes in an array of packages (and subpackages) looking for Subject annotated classes.
<T> T
read(Object source, Class<T> primaryClass, Class<?>... secondaryClasses)
          Read an instance of clazz from source.
 Object update(Object source, Object target)
          Since the EntityManger implements the manager as a live data read against the Model, this method provides a mechanism to copy all the values from the source to the target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityManagerImpl

public EntityManagerImpl()
Constructor.

Method Detail

getSubjectInfo

public SubjectInfo getSubjectInfo(Class<?> clazz)
Description copied from interface: EntityManager
Get the SubjectInfo for the class.

Specified by:
getSubjectInfo in interface EntityManager
Parameters:
clazz - The class to get SubjectInfo for.
Returns:
The SubjectInfo

read

public <T> T read(Object source,
                  Class<T> primaryClass,
                  Class<?>... secondaryClasses)
Description copied from interface: EntityManager
Read an instance of clazz from source. Does not verify that the resource passes the isInstance() check.

Specified by:
read in interface EntityManager
Parameters:
source - Must either implement Resource or ResourceWrapper interfaces.
primaryClass - The class of the object to be returned.
secondaryClasses - A lost of other classes that are implemented.
Returns:
primaryClass instance that also implements ResourceWrapper.
See Also:
EntityManager.isInstance(Object, Class)

isInstance

public boolean isInstance(Object target,
                          Class<?> clazz)
Description copied from interface: EntityManager
Determine if target has all the properties required in the Subject( type ) annotation value. If target is not a Resource or ResourceWrapper returns false.

Specified by:
isInstance in interface EntityManager
Parameters:
target - The object to check.
clazz - A Subject annotated class.
Returns:
true if the resource represented by target has all of the required type predicates.

addInstanceProperties

public com.hp.hpl.jena.rdf.model.Resource addInstanceProperties(com.hp.hpl.jena.rdf.model.Resource r,
                                                                Class<?> clazz)
Read an instance of clazz from Resource r. If r does not have the required types as defined in the Subject annotation they will be added.

Parameters:
r - The Resource to verify.
clazz - The Subject annotated class to verify against.
Returns:
r for chaining

parseClasses

public void parseClasses(String packageName)
                  throws MissingAnnotation
Description copied from interface: EntityManager
Parses the the classes in a package (and subpackages) looking for Subject annotated classes. Classes are located using classLoader.getResource(packageAsPath)

Specified by:
parseClasses in interface EntityManager
Parameters:
packageName - The name of the package to process
Throws:
MissingAnnotation
See Also:
If any Subject annotated classes are missing required annotations, a log entry is written. If any Subject annotated classes faild parsing a MissingAnnotation exception is thrown after all classes have been processed.

parseClasses

public void parseClasses(String[] packageNames)
                  throws MissingAnnotation
Description copied from interface: EntityManager
Parses the the classes in an array of packages (and subpackages) looking for Subject annotated classes. Classes are located using classLoader.getResource(packageAsPath) If any Subject annotated classes are missing required annotations, a log entry is written. If any Subject annotated classes faild parsing a MissingAnnotation exception is thrown after all classes have been processed.

Specified by:
parseClasses in interface EntityManager
Parameters:
packageNames - The array of package names to process
Throws:
MissingAnnotation
See Also:
ClassLoader.getResources(String)

update

public Object update(Object source,
                     Object target)
Since the EntityManger implements the manager as a live data read against the Model, this method provides a mechanism to copy all the values from the source to the target. It reads scans the target class for "set" methods and the source class for associated "get" methods. If a pairing is found the value of the "get" call is passed to the "set" call.

Specified by:
update in interface EntityManager
Parameters:
source - The object that has the values to transfer.
target - The object that has the receptors for the values.
Returns:
The target object after all setters have been called.


Copyright © 2012 XENEI.com. All Rights Reserved.