Search in sources :

Example 1 with URI

use of fr.lirmm.graphik.util.URI in project graal by graphik-team.

the class TermTest method testURI.

@Test
public void testURI() {
    URI uri = URIUtils.createURI("http://toto.fr");
    Term t1 = DefaultTermFactory.instance().createConstant("http://toto.fr");
    Term t2 = DefaultTermFactory.instance().createConstant(uri);
    Assert.assertNotEquals(t1, t2);
}
Also used : Term(fr.lirmm.graphik.graal.api.core.Term) URI(fr.lirmm.graphik.util.URI) Test(org.junit.Test)

Example 2 with URI

use of fr.lirmm.graphik.util.URI in project graal by graphik-team.

the class RDF4jUtils method valueToTerm.

public Term valueToTerm(Value value) {
    if (value instanceof Resource) {
        return DefaultTermFactory.instance().createConstant(urizer.output(value.toString()));
    } else {
        //  Literal
        org.eclipse.rdf4j.model.Literal l = (org.eclipse.rdf4j.model.Literal) value;
        URI uri = URIUtils.createURI(l.getDatatype().toString());
        String label = l.getLabel();
        if (uri.equals(URIUtils.RDF_LANG_STRING)) {
            Optional<String> opt = l.getLanguage();
            if (opt.isPresent()) {
                label += "@";
                label += opt.get();
            }
        }
        return DefaultTermFactory.instance().createLiteral(uri, label);
    }
}
Also used : Literal(fr.lirmm.graphik.graal.api.core.Literal) Resource(org.eclipse.rdf4j.model.Resource) URI(fr.lirmm.graphik.util.URI)

Example 3 with URI

use of fr.lirmm.graphik.util.URI in project graal by graphik-team.

the class DlgpParserTest method backslashedDoubleQuoteTest.

// /////////////////////////////////////////////////////////////////////////
// MISCS
// /////////////////////////////////////////////////////////////////////////
@Test
public void backslashedDoubleQuoteTest() throws ParseException {
    Atom a = DlgpParser.parseAtom("p(\"test\\\"test\").");
    Term identifier = a.getTerm(0);
    Assert.assertTrue(identifier instanceof Literal);
    URI datatype = ((Literal) identifier).getDatatype();
    Assert.assertEquals(URIUtils.XSD_STRING, datatype);
    Object value = ((Literal) identifier).getValue();
    Assert.assertEquals("test\"test", value);
}
Also used : Literal(fr.lirmm.graphik.graal.api.core.Literal) Term(fr.lirmm.graphik.graal.api.core.Term) DefaultURI(fr.lirmm.graphik.util.DefaultURI) URI(fr.lirmm.graphik.util.URI) Atom(fr.lirmm.graphik.graal.api.core.Atom) Test(org.junit.Test)

Example 4 with URI

use of fr.lirmm.graphik.util.URI in project graal by graphik-team.

the class GraalUtils method createPredicate.

/**
 * @param property
 * @return a {@link Predicate} with arity 2 which represents the specified owl object property.
 */
public static Predicate createPredicate(OWLObjectPropertyExpression property) {
    Predicate predicate = null;
    URI uri = convertIRI(property.asOWLObjectProperty().getIRI());
    predicate = new Predicate(uri, 2);
    return predicate;
}
Also used : DefaultURI(fr.lirmm.graphik.util.DefaultURI) URI(fr.lirmm.graphik.util.URI) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 5 with URI

use of fr.lirmm.graphik.util.URI in project graal by graphik-team.

the class GraalUtils method createPredicate.

/**
 * @param property
 * @return a {@link Predicate} with arity 2 which represents the specified owl data property.
 */
public static Predicate createPredicate(OWLDataPropertyExpression property) {
    Predicate predicate = null;
    URI uri = convertIRI(property.asOWLDataProperty().getIRI());
    predicate = new Predicate(uri, 2);
    return predicate;
}
Also used : DefaultURI(fr.lirmm.graphik.util.DefaultURI) URI(fr.lirmm.graphik.util.URI) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Aggregations

URI (fr.lirmm.graphik.util.URI)6 Literal (fr.lirmm.graphik.graal.api.core.Literal)3 DefaultURI (fr.lirmm.graphik.util.DefaultURI)3 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)2 Term (fr.lirmm.graphik.graal.api.core.Term)2 Test (org.junit.Test)2 Atom (fr.lirmm.graphik.graal.api.core.Atom)1 AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 Resource (org.eclipse.rdf4j.model.Resource)1