Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Value types



When Adding values, the API will create the value in the SPARQL request according to the Class of the property value, for boolean or primitive types.

For example, the following code:
   SparqlRequest request = new SparqlRequest("sitac");
   request.addSelect("elt");
   request.addType("elt", "Waypoint");
   request.addPropertyValue("elt", "inFlightPlan", true);
   String query = request.getSPARQL();
We will generate the following query:
   SELECT ?elt
   WHERE {
     ?elt rdf:type sitac:Waypoint .
     ?elt sitac:inFlightPlan "true"^^xsd:boolean .      
   }      

Built-in supported types

  • For a boolean: the datatype IRI will be xsd:boolean
  • For an int: the datatype IRI will be xsd:int
  • For a long: the datatype IRI will be xsd:long
  • For a float: the datatype IRI will be xsd:float
  • For a double: the datatype IRI will be xsd:double
  • For a short: the datatype IRI will be xsd:short
  • For a byte: the datatype IRI will be xsd:byte
Note that if no primitive type is found, the type will be the default String litteral.

Specifying the datatype IRI explicitly

It is also possible to specify the datatype IRI explicitly.

To do that you will need to access the OperationResult. For example:
   SparqlRequest request = new SparqlRequest("sitac");
   request.addSelect("elt");
   request.addType("elt", "Waypoint");
   OperationResult result = request.addPropertyValue("elt", "CustomProperty", "myData");
   String query = request.getSPARQL();
Then you need to get the associated SparqlElement and cast it to a Property:
   Property property = (Property)result.getSparqlElement();      
Then two methods allow to define the value type: For example:
   property.setValueType("my:CustomType");   

Value types for a list of values


When adding a list of values, thr built-in type for each of the values will be set.

For example:
   SparqlRequest request = new SparqlRequest("sitac");
   request.addSelect("zone");
   request.addType("zone", "TaskZone");
   request.addAdditionalVariable("hostile");
   request.addPropertyRef("zone", "Hostile", "hostile");
   request.addPropertyValues("hostile", SparqlRequest.createValuesList(true, false));      
Will return the following SPARQL content:
   SELECT ?zone
   WHERE {
      ?zone rdf:type sitac:TaskZone .
      ?zone sitac:Hostile ?hostile .
      VALUES ?hostile {"true"^^xsd:boolean "false"^^xsd:boolean }
   }

Examples

With a built-in type

The following code:
   SparqlRequest request = new SparqlRequest("sitac");
   request.addSelect("elt");
   request.addType("elt", "Waypoint");
   request.addPropertyValue("elt", "inFlightPlan", true);
   String query = request.getSPARQL();
We will generate the following query:
   SELECT ?elt
   WHERE {
     ?elt rdf:type sitac:Waypoint .
     ?elt sitac:inFlightPlan "true"^^xsd:boolean .      
   }      
But this code:
   SparqlRequest request = new SparqlRequest("sitac");
   request.addSelect("elt");
   request.addType("elt", "Waypoint");
   request.addPropertyValue("elt", "inFlightPlan", "true");
   String query = request.getSPARQL();
We will generate the following query:
   SELECT ?elt
   WHERE {
     ?elt rdf:type sitac:Waypoint .
     ?elt sitac:inFlightPlan "true" .      
   }      

With a custom dataType IRI

The following code:
   SparqlRequest request = new SparqlRequest("sitac");
   request.addSelect("elt");
   request.addType("elt", "Waypoint");
   OperationResult result = request.addPropertyValue("elt", "CustomProperty", "myData");
   Property property = (Property)result.getSparqlElement(); 
   property.setValueType("my:CustomType");      
   String query = request.getSPARQL();
Will generate the following query:
   SELECT ?elt
   WHERE {
     ?elt rdf:type sitac:Waypoint .
     ?elt sitac:CustomProperty "myData"^^my:CustomType .      
   }      

See also


Categories: Requestcreation

Copyright 2025 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence

Project Web Hosted by SourceForge.net Copyright 1999-2010 - Geeknet, Inc., All Rights Reserved About - Legal - Help