protected DataPropertyStatement fillDataPropertyStatementWithJenaLiteral(
     DataPropertyStatement dataPropertyStatement, Literal l) {
   dataPropertyStatement.setData(l.getLexicalForm());
   dataPropertyStatement.setDatatypeURI(l.getDatatypeURI());
   dataPropertyStatement.setLanguage(l.getLanguage());
   return dataPropertyStatement;
 }
 /**
  * Converts a JENA API Literal object into an OWL API OWLLiteral object.
  *
  * @param lit
  * @return
  */
 protected OWLLiteral convertLiteral(Literal lit) {
   String datatypeURI = lit.getDatatypeURI();
   OWLLiteral owlLiteral;
   if (datatypeURI == null) { // rdf:PlainLiteral
     owlLiteral = df.getOWLLiteral(lit.getLexicalForm(), lit.getLanguage());
   } else {
     owlLiteral =
         df.getOWLLiteral(lit.getLexicalForm(), df.getOWLDatatype(IRI.create(datatypeURI)));
   }
   return owlLiteral;
 }
Exemple #3
0
 @Test
 public void testInfoStamp() {
   String versionString = "E3.14159", commentString = "gloopSmurfale";
   String resourceString =
       "_x eye:assumed 'ABC'; _x eye:checked 'DEF'; _x eye:version '%v'; _x eye:comment '%c'"
           .replaceAll("%v", versionString)
           .replaceAll("%c", commentString);
   InfoStamp i = new InfoStamp(resourceInModel(resourceString));
   Calendar now = Calendar.getInstance();
   Resource root = i.stamp(now);
   Model stamp = root.getModel();
   Literal dateLiteral = ModelFactory.createDefaultModel().createTypedLiteral(now);
   String dateString = "'" + dateLiteral.getLexicalForm() + "'" + dateLiteral.getDatatypeURI();
   String expectedFormat =
       "[eye:assumed 'ABC' & eye:checked 'DEF' & eye:dated <date>"
           + " & eye:comment '<comment>' & eye:version '<version>']";
   String expectedString =
       expectedFormat
           .replaceAll("<date>", dateString)
           .replaceAll("<version>", versionString)
           .replaceAll("<comment>", commentString);
   Model expected = model(expectedString);
   assertIsoModels(expected, stamp);
 }
Exemple #4
0
 private static void doDatatype(StringBuffer json, Literal literal) {
   String datatype = literal.getDatatypeURI();
   if (datatype != null) {
     json.append(", \"datatype\": \"" + datatype + "\"");
   }
 }