Search in sources :

Example 21 with Literal

use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.

the class LiteralsTest method testCreateLiteralObjectByte.

/**
 * Test method for
 * {@link org.eclipse.rdf4j.model.util.Literals#createLiteral(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
 * .
 */
@Test
public void testCreateLiteralObjectByte() throws Exception {
    Object obj = new Integer(42).byteValue();
    Literal l = Literals.createLiteral(SimpleValueFactory.getInstance(), obj);
    assertNotNull(l);
    assertEquals(l.getDatatype(), XMLSchema.BYTE);
    assertEquals(l.getLabel(), "42");
}
Also used : Literal(org.eclipse.rdf4j.model.Literal) Test(org.junit.Test)

Example 22 with Literal

use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.

the class LiteralsTest method testCreateLiteralOrFailObjectFloat.

/**
 * Test method for
 * {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
 * .
 */
@Test
public void testCreateLiteralOrFailObjectFloat() throws Exception {
    Object obj = new Float(42);
    Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj);
    assertNotNull(l);
    assertEquals(l.getDatatype(), XMLSchema.FLOAT);
    assertEquals(l.getLabel(), "42.0");
}
Also used : Literal(org.eclipse.rdf4j.model.Literal) Test(org.junit.Test)

Example 23 with Literal

use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.

the class LiteralsTest method testCreateLiteralOrFailObjectDouble.

/**
 * Test method for
 * {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
 * .
 */
@Test
public void testCreateLiteralOrFailObjectDouble() throws Exception {
    Object obj = new Double(42);
    Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj);
    assertNotNull(l);
    assertEquals(l.getDatatype(), XMLSchema.DOUBLE);
    assertEquals(l.getLabel(), "42.0");
}
Also used : Literal(org.eclipse.rdf4j.model.Literal) Test(org.junit.Test)

Example 24 with Literal

use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.

the class LiteralsTest method testCreateLiteralOrFailObjectDate.

/**
 * Test method for
 * {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
 * .
 */
@Test
public void testCreateLiteralOrFailObjectDate() throws Exception {
    Object obj = new Date();
    Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj);
    assertNotNull(l);
    assertEquals(l.getDatatype(), XMLSchema.DATETIME);
}
Also used : Literal(org.eclipse.rdf4j.model.Literal) Date(java.util.Date) Test(org.junit.Test)

Example 25 with Literal

use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.

the class LiteralsTest method testCreateLiteralOrFailObjectShort.

/**
 * Test method for
 * {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
 * .
 */
@Test
public void testCreateLiteralOrFailObjectShort() throws Exception {
    Object obj = Short.parseShort("42");
    Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj);
    assertNotNull(l);
    assertEquals(l.getDatatype(), XMLSchema.SHORT);
    assertEquals("42", l.getLabel());
}
Also used : Literal(org.eclipse.rdf4j.model.Literal) Test(org.junit.Test)

Aggregations

Literal (org.eclipse.rdf4j.model.Literal)98 Test (org.junit.Test)52 IRI (org.eclipse.rdf4j.model.IRI)34 Value (org.eclipse.rdf4j.model.Value)17 BNode (org.eclipse.rdf4j.model.BNode)14 Statement (org.eclipse.rdf4j.model.Statement)14 Model (org.eclipse.rdf4j.model.Model)13 Resource (org.eclipse.rdf4j.model.Resource)9 LinkedHashModel (org.eclipse.rdf4j.model.impl.LinkedHashModel)8 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)7 InputStream (java.io.InputStream)6 Date (java.util.Date)6 BindingSet (org.eclipse.rdf4j.query.BindingSet)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 ValueFactory (org.eclipse.rdf4j.model.ValueFactory)4 SimpleValueFactory (org.eclipse.rdf4j.model.impl.SimpleValueFactory)4 AbstractQueryResultIOTupleTest (org.eclipse.rdf4j.query.resultio.AbstractQueryResultIOTupleTest)4 QueryResultCollector (org.eclipse.rdf4j.query.resultio.helpers.QueryResultCollector)4 SPARQLResultsJSONParser (org.eclipse.rdf4j.query.resultio.sparqljson.SPARQLResultsJSONParser)4