AGCreateLiteral.java
package com.franz.ag.examples;
import com.franz.ag.*;
import org.openrdf.model.Literal;
import org.openrdf.model.URI;
public class AGCreateLiteral {
@param
@throws
public static void main(String[] args) throws AllegroGraphException {
AllegroGraphConnection ags = new AllegroGraphConnection();
try {
ags.enable();
} catch (Exception e) {
throw new AllegroGraphException("Server connection problem", e);
}
AllegroGraph ts = ags.renew("createliteral", AGPaths.TRIPLE_STORES);
Literal lit1 = ts.createLiteral("Fido");
Literal lit2 = ts.createLiteral(true);
Literal lit3 = ts.createLiteral(123);
Literal lit4 = ts.createLiteral(123.0);
Literal lit5 = ts.createLiteral((long)123);
Literal lit6 = ts.createLiteral((double)123);
AGUtils.showLiteral(lit1);
AGUtils.showLiteral(lit2);
AGUtils.showLiteral(lit3);
AGUtils.showLiteral(lit4);
AGUtils.showLiteral(lit5);
AGUtils.showLiteral(lit6);
URI subject = ts.createURI("http://example.org/fido");
URI predicate = ts.createURI("http://example.org/name");
ts.addStatement(subject, predicate, lit1);
Literal cat = ts.addLiteral("chat","fr");
AGUtils.showLiteral(cat);
URI dt = ts.createURI("http://www.w3.org/2001/XMLSchema#int");
Literal lit7 = ts.addLiteral("123", dt);
AGUtils.showLiteral(lit7);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next