List of usage examples for org.apache.commons.rdf.api Literal ntriplesString
String ntriplesString();
From source file:example.UserGuideTest.java
@Test public void literal() throws Exception { Literal literal = factory.createLiteral("Hello world!"); System.out.println(literal.ntriplesString()); String lexical = literal.getLexicalForm(); System.out.println(lexical);//from w w w. j a va 2 s . co m IRI datatype = literal.getDatatype(); System.out.println(datatype.ntriplesString()); IRI xsdDouble = factory.createIRI("http://www.w3.org/2001/XMLSchema#double"); Literal literalDouble = factory.createLiteral("13.37", xsdDouble); System.out.println(literalDouble.ntriplesString()); Literal literalDouble2 = factory.createLiteral("13.37", Types.XSD_DOUBLE); System.out.println(literal.getDatatype().equals(Types.XSD_STRING)); Literal inSpanish = factory.createLiteral("Hola, Mundo!", "es"); System.out.println(inSpanish.ntriplesString()); System.out.println(inSpanish.getLexicalForm()); System.out.println(inSpanish.getDatatype().ntriplesString()); Optional<String> tag = inSpanish.getLanguageTag(); if (tag.isPresent()) { System.out.println(tag.get()); } System.out.println(literal.getLanguageTag().isPresent()); System.out.println(literalDouble.getLanguageTag().isPresent()); }
From source file:example.UserGuideTest.java
@Test public void creating() throws Exception { BlankNode aliceBlankNode = factory.createBlankNode(); IRI nameIri = factory.createIRI("http://example.com/name"); Literal aliceLiteral = factory.createLiteral("Alice"); Triple triple = factory.createTriple(aliceBlankNode, nameIri, aliceLiteral); System.out.println(aliceBlankNode.ntriplesString()); System.out.println(nameIri.ntriplesString()); System.out.println(aliceLiteral.ntriplesString()); }