All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rdfreactor.generator.5.0.0.source-code.staticclass.vm Maven / Gradle / Ivy

Go to download

RDFReactor creates domain-specific, type-safe Java classes which act as a view over domain-free, loosely typed RDF instances. This package generates the Java classes form an RDF vocabulary.

There is a newer version: 5.0.1
Show newest version
#macro( mixedcase $name )$name.substring(0,1).toUpperCase()$name.substring(1)#end
#macro( lowercase $name )$name.toLowerCase()#end
#macro( uppercase $name )$name.toUpperCase()#end
/*
 * generated by http://RDFReactor.semweb4j.org ($generatorVersion) on ${now}
 */
package $package.name;

import org.ontoware.aifbcommons.collection.ClosableIterator;
import org.ontoware.rdf2go.model.Model;
import org.ontoware.rdf2go.model.node.URI;
import org.ontoware.rdf2go.model.node.Node;
import org.ontoware.rdf2go.model.node.Resource;
import org.ontoware.rdf2go.model.node.impl.URIImpl;
import org.ontoware.rdfreactor.runtime.Base;
#if ($class.throwsCardinalityException())
import org.ontoware.rdfreactor.runtime.CardinalityException;
#end

/**
#if($class.getComment())
 * ${class.getComment()}
 *
#end
#if ($class.properties.size() > 0)
 * This class manages access to these properties:
 * 
    #foreach( $prop in $class.properties ) *
  • #mixedcase($prop.name)
  • #end *
* #end * This class was generated by RDFReactor on ${now} */ public class ${class.name} extends ${class.superclass} { /** $class.mappedTo */ public static final URI RDFS_CLASS = new URIImpl("${class.mappedTo}", false); #foreach( $prop in $class.properties ) /** $prop.mappedTo */ public static final URI #uppercase($prop.name) = new URIImpl("${prop.mappedTo}", false); #end /** all property-URIs with this class as domain */ public static final URI[] MANAGED_URIS = { #foreach( $prop in $class.properties ) new URIImpl("${prop.mappedTo}",false)#if (${velocityCount} < $class.properties.size()), #end #end }; /////////////////////////////////////////////////////////////////// // typing /** * Create a new instance of this class in the model. * That is, create the statement (instanceResource,RDF.type, this class). * @param model an RDF2Go model * @param instanceResource an RDF2Go resource */ public static void createInstance(Model model, Resource instanceResource) { Base.createInstance(model, RDFS_CLASS, instanceResource); } /** * @param model an RDF2Go model * @param instanceResource an RDF2Go resource * @return true if instanceResource is an instance of classResource in the model */ public static boolean hasInstance(Model model, Resource instanceResource) { return Base.hasInstance(model, RDFS_CLASS, instanceResource); } /** * @return all instances of this class in Model 'model' */ public static ClosableIterator getAllInstances(Model model) { return Base.getAllInstances(model, RDFS_CLASS); } /** * Delete all rdf:types from this instance. All other triples are not affected. * @param model an RDF2Go model * @param instanceResource an RDF2Go resource */ public static void deleteInstance(Model model, Resource instanceResource) { Base.deleteInstance(model, RDFS_CLASS, instanceResource); } /////////////////////////////////////////////////////////////////// // property accessors #foreach( $inverse in $class.inverseProperties ) /** * @return all A's that have a relation '#mixedcase( $inverse.getInverse().getName() )' to this ${class.name} instance */ public static ClosableIterator<${classname}> getAll${methodnameprefix}#mixedcase($inverse.name)_Inverse( Model model, Object objectValue) { return Base.getAll_Inverse(model, ${inverse.getFirstType()}.#uppercase($inverse.name), objectValue); } #end #foreach( $prop in $class.properties ) #if ($prop.types.size() == 1) #set( $classname = $prop.getFirstType() ) ## ## generate get & set only if no cardinality is set (== -1) or ## max cardinality is exactly == 1 ## #if($prop.maxCardinality == -1 || $prop.maxCardinality == 1) /** #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * @return the only value. null if none is found * @throws RDFDataException, if the property has multiple values */ public static ${classname} get${methodnameprefix}#mixedcase($prop.name)(Model model, Resource resource) { return (Node) Base.get(model, resource, #uppercase($prop.name), ${classname}.class); } /** * removes all values and sets this one * @param value the value to be set #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end */ public static void set${methodnameprefix}#mixedcase($prop.name)( Model model, Resource resource, Node value ) { Base.set(model, resource, #uppercase($prop.name), value); } /** * removes current value(s) #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end */ public static void remove${methodnameprefix}#mixedcase($prop.name)(Model model, Resource resource) { Base.removeAll(model, resource, #uppercase($prop.name)); } #end ####if($prop.maxCardinality == -1 || $prop.maxCardinality == 1) #if($prop.minCardinality != -1) /** * Removes a value. * @param value the value to be removed #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * @throws CardinalityException if removing would change the number of * values below the minimal cardinality $prop.minCardinality */ public static void remove${methodnameprefix}#mixedcase($prop.name)( Model model, Resource resource, ${classname} value ) throws CardinalityException { Base.remove(model, resource, #uppercase($prop.name), value, $prop.minCardinality); } #else /** * removes a value * @param value the value to be removed #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end */ public static void remove${methodnameprefix}#mixedcase($prop.name)( Model model, Resource resource, ${classname} value ) { Base.remove(model, resource, #uppercase($prop.name), value); } /** * removes all values #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end */ public static void removeAll${methodnameprefix}#mixedcase($prop.name)(Model model, Resource resource) { Base.removeAll( model, resource, #uppercase($prop.name)); } #end ## if /** * @param value * @return true if the model contains a statement (this, #uppercase($prop.name), value) */ public static boolean has${methodnameprefix}#mixedcase($prop.name)( Model model, Resource resource, Node value) { return Base.hasValue(model, resource, #uppercase($prop.name), value); } /** * @return true if the model contains a statement (this, #uppercase($prop.name), *) */ public static boolean has${methodnameprefix}#mixedcase($prop.name)(Model model, Resource resource) { return Base.hasValue(model, resource, #uppercase($prop.name)); } #if($prop.maxCardinality > 1) /** * adds a value * @param value the value to be added #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * @throws CardinalityException if adding would change the number of * values above the maximal cardinality $prop.maxCardinality */ public static void add${methodnameprefix}#mixedcase($prop.name)( Model model, Resource resource, Node value ) throws CardinalityException { Base.add(model, resource,#uppercase($prop.name), value, $prop.maxCardinality); } #end ## if #if($prop.maxCardinality == -1) /** * adds a value * @param value the value to be added #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end */ public static void add${methodnameprefix}#mixedcase($prop.name)( Model model, Resource resource, Node value ) { Base.add(model, resource,#uppercase($prop.name), value); } /** * @return all values #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end */ public static ClosableIterator getAll${methodnameprefix}#mixedcase($prop.name)(Model model, Resource resource) { return Base.getAll(model, resource,#uppercase($prop.name), ${classname}.class); } #end ## if #else ## ------------------------------- start multi-range handling -------------------------------------- #foreach($classname in $prop.types) ## ## generate get & set only if no cardinality is set (== -1) or ## max cardinality is exactly == 1 ## #if($prop.maxCardinality == -1 || $prop.maxCardinality == 1) /** #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * Technical detail: This is modelling a property with multiple ranges. * @return the only value. null if none is found * @throws RDFDataException, if the property has multiple values */ public static ${classname} get#mixedcase($prop.name)_as_${classname.plainName}() { return ($classname) Base.get(#uppercase($prop.name), ${classname}.class); } /** * removes all values and sets this one * @param value the value to be set #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * Technical detail: This is modelling a property with multiple ranges. */ public static void set${methodnameprefix}#mixedcase($prop.name)( Node value ) { Base.set(#uppercase($prop.name), value); } #end ###if($prop.maxCardinality == -1 || $prop.maxCardinality == 1) #if($prop.minCardinality != -1) /** * removes a value * @param value the value to be removed #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * @throws CardinalityException if removing would change the number of * values below the minimal cardinality $prop.minCardinality * Technical detail: This is modeling a property with multiple ranges. */ public static void remove${methodnameprefix}#mixedcase($prop.name)( Node value ) throws CardinalityException { Base.remove(#uppercase($prop.name), value, $prop.minCardinality); } #else /** * removes a value * @param value the value to be removed #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * Technical detail: This is modeling a property with multiple ranges. */ public static void remove${methodnameprefix}#mixedcase($prop.name)( Node value ) { Base.remove(#uppercase($prop.name), value); } #end ## if #if($prop.maxCardinality > 1) /** * adds a value * @param value the value to be added #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * @throws CardinalityException if adding would change the number of * values above the maximal cardinality $prop.maxCardinality * Technical detail: This is modeling a property with multiple ranges. */ public static void add${methodnameprefix}#mixedcase($prop.name)( Node value ) throws CardinalityException { Base.add(#uppercase($prop.name), value, $prop.maxCardinality); } #end ## if #if($prop.maxCardinality == -1) /** * adds a value * @param value the value to be added #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * Technical detail: This is modeling a property with multiple ranges. */ public static void add${methodnameprefix}#mixedcase($prop.name)( Node value ) { Base.add(#uppercase($prop.name), value); } #end ## if /** * @return all values #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * Technical detail: This is modeling a property with multiple ranges. */ public static ${classname}[] getAll${methodnameprefix}#mixedcase($prop.name)_as_${classname.plainName}() { return (${classname}[]) Base.getAll(#uppercase($prop.name), ${classname}.class); } #end ## foreach /** * @return all values, generic version #if($prop.getComment()) * Schema Comment: ${prop.getComment()} #end * Technical detail: This is modeling a property with multiple ranges. */ public static ${root}[] getAll${methodnameprefix}#mixedcase($prop.name)() { return (${root}[]) Base.getAll(#uppercase($prop.name), ${root}.class); } #end ## multi range handling #end ## for-each }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy