|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfo.sswap.http.rest.EntityFactory
public class EntityFactory
A class for creating SSWAPEntities based on their JSON description.
Field Summary | |
---|---|
private java.util.Map<java.lang.String,java.net.URI> |
anonURIMapping
|
private java.util.Set<java.lang.String> |
initializedEntities
|
Constructor Summary | |
---|---|
private |
EntityFactory()
Private constructor for a singleton |
Method Summary | ||
---|---|---|
private info.sswap.api.model.SSWAPElement |
createDefaultLiteralValue(info.sswap.api.model.SSWAPDocument document,
java.lang.String typeURI)
Creates a literal SSWAPElement that holds a default value for its type |
|
private
|
createEmptyEntity(info.sswap.api.model.SSWAPDocument document,
java.lang.String uri,
java.lang.Class<T> entityClass)
Creates an entity with no properties initialized yet. |
|
|
createEntity(info.sswap.api.model.SSWAPDocument document,
Entity jsonEntity,
java.lang.Class<T> entityClass)
Creates a SSWAPIndividual in the given model based on its definition in JSON |
|
private info.sswap.api.model.SSWAPIndividual |
createEntityValue(info.sswap.api.model.SSWAPDocument document,
java.lang.String uri,
java.lang.String typeURI)
Creates a SSWAP Entity for a property value |
|
private info.sswap.api.model.SSWAPIndividual |
createPropertyEntityValue(info.sswap.api.model.SSWAPModel entity,
info.sswap.api.model.SSWAPPredicate predicate,
Value jsonValue)
Creates a anonymous entity value for a property (object property) |
|
private info.sswap.api.model.SSWAPElement |
createPropertyLiteralValue(info.sswap.api.model.SSWAPModel entity,
info.sswap.api.model.SSWAPPredicate predicate,
Value jsonValue)
Creates a literal value for a property (a datatype property) |
|
info.sswap.api.model.SSWAPElement |
createPropertyValue(info.sswap.api.model.SSWAPModel entity,
info.sswap.api.model.SSWAPPredicate predicate,
Value jsonValue)
Creates a value for a property. |
|
static EntityFactory |
get()
The access method to the singleton instance. |
|
private java.net.URI |
getAnonURI(java.lang.String anonQName)
|
|
private void |
initializeProperties(info.sswap.api.model.SSWAPIndividual entity,
Entity jsonEntity)
Initializes SSWAPProperties/SSWAPTypes for the entity |
|
void |
initializeProperties(info.sswap.api.model.SSWAPIndividual entity,
Entity jsonEntity,
java.util.Collection<java.lang.String> excludedProperties)
|
|
private void |
initializePropertyValue(info.sswap.api.model.SSWAPIndividual entity,
Property jsonProperty,
Value jsonValue)
|
|
private void |
initializeTypeProperty(info.sswap.api.model.SSWAPIndividual entity,
Value typeValue)
Initializes rdf:type property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Map<java.lang.String,java.net.URI> anonURIMapping
private java.util.Set<java.lang.String> initializedEntities
Constructor Detail |
---|
private EntityFactory()
Method Detail |
---|
public static EntityFactory get()
public <T extends info.sswap.api.model.SSWAPIndividual> T createEntity(info.sswap.api.model.SSWAPDocument document, Entity jsonEntity, java.lang.Class<T> entityClass) throws java.lang.IllegalArgumentException
document
- SSWAPModel within which the entities should be createdjsonEntity
- the JSON description of the entityentityClass
- the subclass of the SSWAPIndividual that should be created (e.g., SSWAPSubject.class, SSWAPObject.class or
just SSWAPIndividual.class)
java.lang.IllegalArgumentException
- if one of the URIs in JSON was not a syntactically valid URIprivate java.net.URI getAnonURI(java.lang.String anonQName)
private <T extends info.sswap.api.model.SSWAPIndividual> T createEmptyEntity(info.sswap.api.model.SSWAPDocument document, java.lang.String uri, java.lang.Class<T> entityClass) throws java.lang.IllegalArgumentException
T
- document
- the model within which the entity should be createduri
- the URI of the entity (may be null for anonymous entities)entityClass
- the subclass of the SSWAPIndividual that should be created (e.g., SSWAPSubject.class, SSWAPObject.class or
just SSWAPIndividual.class)
java.lang.IllegalArgumentException
- if the URI is not a syntactically valid URIpublic void initializeProperties(info.sswap.api.model.SSWAPIndividual entity, Entity jsonEntity, java.util.Collection<java.lang.String> excludedProperties)
private void initializeProperties(info.sswap.api.model.SSWAPIndividual entity, Entity jsonEntity) throws java.lang.IllegalArgumentException
entity
- the entity for which the properties should be initializedjsonEntity
- the JSON data describing the entity
java.lang.IllegalArgumentException
- if one of the URIs in JSON was not a syntactically valid URIprivate void initializeTypeProperty(info.sswap.api.model.SSWAPIndividual entity, Value typeValue) throws java.lang.IllegalArgumentException
entity
- the entity whose type should be initializedtypeValue
- the json intermediate representation for the type value
java.lang.IllegalArgumentException
- if the data is not syntactically validprivate void initializePropertyValue(info.sswap.api.model.SSWAPIndividual entity, Property jsonProperty, Value jsonValue) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public info.sswap.api.model.SSWAPElement createPropertyValue(info.sswap.api.model.SSWAPModel entity, info.sswap.api.model.SSWAPPredicate predicate, Value jsonValue) throws java.lang.IllegalArgumentException
entity
- the entity for which the value is createdpredicate
- the predicate for which the value is createdjsonValue
- the JSON data describing the value
java.lang.IllegalArgumentException
- if JSON data is not syntactically validprivate info.sswap.api.model.SSWAPElement createPropertyLiteralValue(info.sswap.api.model.SSWAPModel entity, info.sswap.api.model.SSWAPPredicate predicate, Value jsonValue) throws java.lang.IllegalArgumentException
entity
- the entity for which the value is createdpredicate
- the predicate for which the value is created (this should be a datatype property)jsonValue
- the JSON data describing the the value
java.lang.IllegalArgumentException
- if the value encoded in JSON is not a literal (e.g., an entity or an array), or the literal is not a valid
value for the inferred range of the datatype propertyprivate info.sswap.api.model.SSWAPIndividual createPropertyEntityValue(info.sswap.api.model.SSWAPModel entity, info.sswap.api.model.SSWAPPredicate predicate, Value jsonValue) throws java.lang.IllegalArgumentException
entity
- the entity for which the value should be created (the subject of the property)predicate
- the predicate for which the value should be createdjsonValue
- the JSON data describing the value. This can either be an actual entity or a literal containing the
URI to the entity.
java.lang.IllegalArgumentException
- if the data encoded in JSON cannot be represented as an entity (e.g., it is an array)private info.sswap.api.model.SSWAPIndividual createEntityValue(info.sswap.api.model.SSWAPDocument document, java.lang.String uri, java.lang.String typeURI) throws java.lang.IllegalArgumentException
document
- the model where the entity should be createduri
- the URI for the entity (may be null, which will result in an anonymous entity)typeURI
- the type of the entity (may be null)
java.lang.IllegalArgumentException
- if any of the passed non-null URIs is not syntactically validprivate info.sswap.api.model.SSWAPElement createDefaultLiteralValue(info.sswap.api.model.SSWAPDocument document, java.lang.String typeURI) throws java.lang.IllegalArgumentException
document
- the model where SSWAPElement should be createdtypeURI
- the type of the element (may be null, which will return null value)
java.lang.IllegalArgumentException
- if the passed typeURI is not a syntactically valid URI
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |