|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfo.sswap.impl.empire.model.ImplFactory
public class ImplFactory
Factory class for creating and initializing concrete implementations of SSWAP interfaces.
Field Summary | |
---|---|
private javax.persistence.EntityManagerFactory |
entityManagerFactory
The factory for creating Empire EntityManagers (one manager for each Jena model/data source). |
private static java.lang.String |
GET_TYPES_QUERY
|
private static ImplFactory |
instance
The instance singleton instance of this class. |
Constructor Summary | |
---|---|
private |
ImplFactory()
Private constructor (following the Singleton design pattern) that initializes Empire and creates Empire EntityManagerFactory. |
Method Summary | ||
---|---|---|
|
assertImplementation(A apiObject,
java.lang.Class<I> implementationClass)
Asserts that the parameter typed via an API interface has the expected implementation. |
|
SourceModel |
assertSourceModel(ModelImpl modelImpl)
Gets the source model of a dereferenced ModelImpl |
|
|
canAs(SourceModel sourceModel,
java.net.URI uri,
java.lang.Class<T> clazz)
Checks whether the given individual can be viewed using the specified Empire class. |
|
|
castDependentModel(SourceModel sourceModel,
java.net.URI uri,
java.lang.Class<T> clazz)
|
|
void |
copy(SSWAPIndividual srcInd,
SSWAPIndividual dstInd,
SSWAPDocument dstDoc,
java.util.Collection<java.lang.String> excludedTypes)
|
|
|
createDependentObject(SourceModel sourceModel,
java.net.URI uri,
java.lang.Class<T> clazz)
Creates a dependent object for a SourceModel (e.g., a SSWAPResource for an RDG). |
|
SSWAPElement |
createElement(SourceModel sourceModel,
com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
Creates a SSWAPElement based on an RDF node. |
|
|
createEmptySourceModel(java.net.URI uri,
java.lang.Class<T> clazz)
Creates a SourceModel based on an empty Jena model. |
|
|
createEmptySSWAPDataObject(java.net.URI uri,
java.lang.Class<T> clazz)
Creates an empty Empire-generated object. |
|
javax.persistence.EntityManager |
createEntityManager(com.hp.hpl.jena.rdf.model.Model model)
Creates an EntityManager for a specified Jena model |
|
javax.persistence.EntityManager |
createEntityManager(java.lang.Object stream,
java.lang.String format)
Creates a new entity manager for a Jena data source. |
|
IndividualImpl |
createIndividual(SourceModel sourceModel,
com.hp.hpl.jena.rdf.model.Resource resource)
Creates a SSWAPIndividual that for the Jena resource. |
|
IndividualImpl |
createIndividual(SourceModel sourceModel,
java.net.URI uri)
Creates a generic (non-Empire managed) SSWAP Entity. |
|
ListImpl |
createList(SourceModel sourceModel,
com.hp.hpl.jena.rdf.model.RDFList list)
Creates a SSWAPList implementation for an RDFList |
|
Literal |
createLiteral(com.hp.hpl.jena.rdf.model.Literal literal)
Creates a SSWAP implementation of a literal based on a Jena literal. |
|
com.hp.hpl.jena.rdf.model.Literal |
createLiteral(SourceModel sourceModel,
Literal literal)
Creates a Jena literal for a SSWAPLiteral |
|
Literal |
createLiteral(java.lang.String value,
SourceModel sourceModel)
|
|
Literal |
createLiteral(java.lang.String value,
java.lang.String language,
SourceModel sourceModel)
|
|
Literal |
createLiteral(java.lang.String value,
java.net.URI datatypeURI,
SourceModel sourceModel)
|
|
Literal |
createLiteral(java.lang.String value,
java.net.URI datatypeURI,
java.lang.String language,
SourceModel sourceModel)
Creates a literal with the specified value |
|
PropertyImpl |
createProperty(SourceModel sourceModel,
SSWAPIndividual individual,
SSWAPElement value,
java.net.URI uri)
Creates an implementation of SSWAPProperty with the specified URI |
|
com.hp.hpl.jena.rdf.model.RDFList |
createRDFList(SourceModel sourceModel,
SSWAPList list)
Creates an RDFList for a SSWAPList. |
|
com.hp.hpl.jena.rdf.model.RDFNode |
createRDFNode(SourceModel sourceModel,
SSWAPElement element)
Creates an RDFNode for a SSWAPElement. |
|
com.hp.hpl.jena.rdf.model.Resource |
createResource(SourceModel sourceModel,
SSWAPIndividual individual)
Creates a corresponding Jena Resource for the SSWAPIndividual |
|
SSWAPElement |
deepCopyElement(SourceModel newModel,
SSWAPElement originalElement,
java.util.Set<java.net.URI> copiedIndividuals)
Performs a deep copy of a SSWAPElement from one source model to another |
|
void |
deepCopyIndividual(SourceModel newModel,
SSWAPIndividual originalIndividual,
IndividualImpl dstIndividual,
java.util.Set<java.net.URI> copiedIndividuals)
|
|
private SSWAPIndividual |
deepCopyIndividual(SourceModel newModel,
SSWAPIndividual originalIndividual,
java.util.Set<java.net.URI> copiedIndividuals)
Perform a deep copy of a SSWAPIndividual into another source model |
|
private SSWAPList |
deepCopyList(SourceModel newModel,
SSWAPList originalList,
java.util.Set<java.net.URI> copiedIndividuals)
Perform a deep copy of a SSWAPList into another source model |
|
private boolean |
existsTyped(SourceModel sourceModel,
java.net.URI individualURI)
|
|
static ImplFactory |
get()
The getter method for the singleton instance. |
|
private java.lang.Throwable |
getRootCause(java.lang.Throwable e)
Gets the root cause for the exception |
|
private java.util.Collection<java.net.URI> |
getTypes(SourceModel sourceModel,
java.net.URI individualURI)
|
|
static void |
initURI(ModelImpl object)
Initializes the URI of a SSWAPModel based on its RDF identifier. |
|
private boolean |
isTypedAs(SourceModel sourceModel,
java.net.URI individualURI,
java.net.URI typeURI)
|
|
|
readSSWAPDataObject(javax.persistence.EntityManager aManager,
java.lang.Class<T> clazz)
Reads a single Empire-annotated object from the data source managed by the specified entity manager. |
|
|
readSSWAPDataObject(javax.persistence.EntityManager aManager,
java.lang.Class<T> clazz,
java.net.URI uri)
|
|
|
readSSWAPDataObject(java.lang.Object stream,
java.lang.String format,
java.lang.Class<T> clazz)
Reads a single Empire-annotated object from a data source (usually a stream). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String GET_TYPES_QUERY
private javax.persistence.EntityManagerFactory entityManagerFactory
private static ImplFactory instance
Constructor Detail |
---|
private ImplFactory()
Method Detail |
---|
public static ImplFactory get()
public <T extends ModelImpl> T createEmptySSWAPDataObject(java.net.URI uri, java.lang.Class<T> clazz) throws DataAccessException
T
- the Java class with Empire annotationsuri
- the URI that will be assigned to this SSWAPModelclazz
- the class for the implementation (it should contain Empire annotations)
DataAccessException
public javax.persistence.EntityManager createEntityManager(java.lang.Object stream, java.lang.String format) throws DataAccessException
stream
- the place to read the data from. Typically it is an InputStream, but it can be any Empire-supported
object (e.g., Reader, File, or URL).format
- the string containing the format of the data (e.g., "RDF/XML")
DataAccessException
- if an error should occur when accessing the data source (e.g., I/O error or malformed data)private java.lang.Throwable getRootCause(java.lang.Throwable e)
e
- exception
public javax.persistence.EntityManager createEntityManager(com.hp.hpl.jena.rdf.model.Model model)
model
- the Jena model for which the EntityManager should be created
public <T extends SourceModelImpl> T createEmptySourceModel(java.net.URI uri, java.lang.Class<T> clazz)
T
- the type parameteruri
- the URI of the SourceModelclazz
- the actual implementation class
public <T extends ModelImpl> T createDependentObject(SourceModel sourceModel, java.net.URI uri, java.lang.Class<T> clazz)
T
- the type parameter for the object to be createdsourceModel
- the SourceModel in which the dependent object should be createduri
- the URI of the newly created modelclazz
- the actual implementation class
private java.util.Collection<java.net.URI> getTypes(SourceModel sourceModel, java.net.URI individualURI)
private boolean isTypedAs(SourceModel sourceModel, java.net.URI individualURI, java.net.URI typeURI)
private boolean existsTyped(SourceModel sourceModel, java.net.URI individualURI)
public <T extends ModelImpl> boolean canAs(SourceModel sourceModel, java.net.URI uri, java.lang.Class<T> clazz)
T
- Empire classsourceModel
- SSWAP Model to which the individual belongsuri
- URI of individual to checkclazz
- Class to which to check the annotation RdfsClass.class
public <T extends ModelImpl> T castDependentModel(SourceModel sourceModel, java.net.URI uri, java.lang.Class<T> clazz)
public <T> T readSSWAPDataObject(javax.persistence.EntityManager aManager, java.lang.Class<T> clazz)
T
- Empire-annotated type of the object to be returned by the Empire (the annotation on the object will
allow Empire to identify which triples in the data source correspond to the object's fields).aManager
- the entity manager that manages that data sourceclazz
- the Empire-annotated class
public <T> T readSSWAPDataObject(javax.persistence.EntityManager aManager, java.lang.Class<T> clazz, java.net.URI uri)
public <T extends SourceModel> T readSSWAPDataObject(java.lang.Object stream, java.lang.String format, java.lang.Class<T> clazz)
T
- Empire-annotated type of the object to be returned by the Empire (the annotation on the object will
allow Empire to identify which triples in the data source correspond to the object's fields). This
type has to implement SourceModel to pass the underlying Jena model to the object.stream
- the place to read the data from. Typically it is an InputStream, but it can be any Empire-supported
object (e.g., Reader, File, or URL).format
- the string containing the format of the data (e.g., "RDF/XML")clazz
- the Empire-annotated class
public static void initURI(ModelImpl object)
object
- an object that does not correspond to a blank node in RDFpublic SSWAPElement createElement(SourceModel sourceModel, com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
sourceModel
- the source model for which the SSWAPElement should be createdrdfNode
- the RDF node based on which the SSWAPElement will be created
public Literal createLiteral(java.lang.String value, SourceModel sourceModel)
public Literal createLiteral(java.lang.String value, java.net.URI datatypeURI, SourceModel sourceModel) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public Literal createLiteral(java.lang.String value, java.lang.String language, SourceModel sourceModel)
public Literal createLiteral(java.lang.String value, java.net.URI datatypeURI, java.lang.String language, SourceModel sourceModel) throws java.lang.IllegalArgumentException
value
- the lexical representation of the valuedatatypeURI
- the URI of the XSD datatype (may be null)language
- the declared language of the datatype (may be null)sourceModel
- the source the source model where the literal should be created
java.lang.IllegalArgumentException
- if the lexical representation of the value is not valid according to the declared datatypeURIpublic Literal createLiteral(com.hp.hpl.jena.rdf.model.Literal literal)
literal
- the Jena literal
public ListImpl createList(SourceModel sourceModel, com.hp.hpl.jena.rdf.model.RDFList list)
sourceModel
- the source model where the SSWAPList should be createdlist
- the RDFList that should be represented as a SSWAPList
public IndividualImpl createIndividual(SourceModel sourceModel, com.hp.hpl.jena.rdf.model.Resource resource)
sourceModel
- the source model where the entity should be createdresource
- the Jena resource for which the entity should be created
public IndividualImpl createIndividual(SourceModel sourceModel, java.net.URI uri)
sourceModel
- a source model where the entity should be createduri
- the URI of the entity
public PropertyImpl createProperty(SourceModel sourceModel, SSWAPIndividual individual, SSWAPElement value, java.net.URI uri)
sourceModel
- the source model for which the SSWAPProperty should be createduri
- the URI of the property
public com.hp.hpl.jena.rdf.model.RDFNode createRDFNode(SourceModel sourceModel, SSWAPElement element)
sourceModel
- the source model where the RDFNode should be createdelement
- the SSWAPElement which should be reflected as the RDFNode
public com.hp.hpl.jena.rdf.model.Literal createLiteral(SourceModel sourceModel, Literal literal)
sourceModel
- the source model for which the Jena literal should be createdliteral
- the SSWAP literal
public com.hp.hpl.jena.rdf.model.RDFList createRDFList(SourceModel sourceModel, SSWAPList list)
sourceModel
- the source model in which the RDFList should be createdlist
- the list for which the RDFList should be created
public com.hp.hpl.jena.rdf.model.Resource createResource(SourceModel sourceModel, SSWAPIndividual individual)
sourceModel
- the source model in which the Jena resource should be createdindividual
- the entity for which the resource should be created
public <I extends ModelImpl,A extends SSWAPModel> I assertImplementation(A apiObject, java.lang.Class<I> implementationClass)
I
- the expected implementation typeA
- the API interfaceapiObject
- the object to be castedimplementationClass
- the expected implementation class
public SourceModel assertSourceModel(ModelImpl modelImpl) throws java.lang.IllegalArgumentException
modelImpl
- the implementation of a SSWAPModel that should be dereferenced
java.lang.IllegalArgumentException
- if the model has not been dereferenced, and therefore does not have a source modelprivate SSWAPList deepCopyList(SourceModel newModel, SSWAPList originalList, java.util.Set<java.net.URI> copiedIndividuals)
newModel
- the destination model into which the list should be copiedoriginalList
- the original list (in the source model) that should be copied
private SSWAPIndividual deepCopyIndividual(SourceModel newModel, SSWAPIndividual originalIndividual, java.util.Set<java.net.URI> copiedIndividuals)
newModel
- the destination model into which the individual should be copiedoriginalIndividual
- the original individual (in the source model) that should be copied
public void deepCopyIndividual(SourceModel newModel, SSWAPIndividual originalIndividual, IndividualImpl dstIndividual, java.util.Set<java.net.URI> copiedIndividuals)
public SSWAPElement deepCopyElement(SourceModel newModel, SSWAPElement originalElement, java.util.Set<java.net.URI> copiedIndividuals)
newModel
- the new source model to which the element should be copiedoriginalElement
- the original element (in the source model) to be copied
public void copy(SSWAPIndividual srcInd, SSWAPIndividual dstInd, SSWAPDocument dstDoc, java.util.Collection<java.lang.String> excludedTypes)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |