Class AttributeValueRetriever
java.lang.Object
org.eclipse.esmf.metamodel.loader.AttributeValueRetriever
- Direct Known Subclasses:
Instantiator,ModelElementFactory
This class provides utilities to retrieve attribute values from model elements, e.g., a samm:Property's samm:characteristic.
It knows how to handle:
- optionality (e.g., samm-c:upperBoundDefinition on a samm-c:RangeConstraint is not mandatory)
- n-ary attributes (e.g., samm:preferredName and samm:description can appear multiple times)
- abstract Properties (i.e., a bnode with samm:extends used as a Property)
- Property references (i.e., a bnode with samm:property used as a Property)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.jena.rdf.model.StatementattributeValue(org.apache.jena.rdf.model.Resource modelElement, org.apache.jena.rdf.model.Property attribute) Returns the value of an attribute on a model element (or its super elements)protected List<org.apache.jena.rdf.model.Statement>attributeValues(org.apache.jena.rdf.model.Resource modelElement, org.apache.jena.rdf.model.Property attribute) Returns the values of n-ary attributes on a model element (or its super elements), or if a given attribute is an rdf:List, the list elements.protected Optional<org.apache.jena.rdf.model.Statement>optionalAttributeValue(org.apache.jena.rdf.model.Resource modelElement, org.apache.jena.rdf.model.Property attribute) Returns the optional value of an attribute on a model element (or its super elements)
-
Field Details
-
samm
-
-
Constructor Details
-
AttributeValueRetriever
-
-
Method Details
-
attributeValue
protected org.apache.jena.rdf.model.Statement attributeValue(org.apache.jena.rdf.model.Resource modelElement, org.apache.jena.rdf.model.Property attribute) Returns the value of an attribute on a model element (or its super elements)- Parameters:
modelElement- the model elementattribute- the given attribute- Returns:
- the statement asserting the value
- Throws:
AspectLoadingException- when the attribute is not present or is present multiple times, or if samm:extends is used wrong
-
optionalAttributeValue
protected Optional<org.apache.jena.rdf.model.Statement> optionalAttributeValue(org.apache.jena.rdf.model.Resource modelElement, org.apache.jena.rdf.model.Property attribute) Returns the optional value of an attribute on a model element (or its super elements)- Parameters:
modelElement- the model elementattribute- the given attribute- Returns:
- the optional statement asserting the value
-
attributeValues
protected List<org.apache.jena.rdf.model.Statement> attributeValues(org.apache.jena.rdf.model.Resource modelElement, org.apache.jena.rdf.model.Property attribute) Returns the values of n-ary attributes on a model element (or its super elements), or if a given attribute is an rdf:List, the list elements. The list will be ordered by precedence, e.g., if a Property is present on both the current element and it's superelement, the assertion on the current element will be on a lower list index. Duplicate attribute assertions are removed and only the assertion with the highest precedence will be returned (bottom-most in the inheritance tree), this includes multiple assertions for the same attribute with rdf:langString values with the same language tag. For example: :SuperEntity a samm:AbstractEntity ; samm:description "I'm abstract"@en ; samm:description "Ich bin abstrakt"@de ; samm:properties () . :MyEntity a samm:Entity ; samm:extends :SuperEntity ; samm:description "I'm concrete"@en ; samm:properties () . Here, attributeValues( :MyEntity, samm:description ) will return: List( Statement( :MyEntity samm:description "I'm contrete"@en ), Statement( :SuperEntity samm:description "Ich bin abstrakt"@de ) ) The attribute that is overridden with a new value takes precedence, the one that is not overridden is inherited.- Parameters:
modelElement- the model elementattribute- the given attribute- Returns:
- the list of statements asserting values for the attribute
-