Resource nextLi() { if (nextLi == null) { nextLi = SimpleValueFactory.getInstance().createIRI(RDF.NAMESPACE + "_" + nextLiIndex); } return nextLi; }
public Resource export(Model model) { BNode implNode = SimpleValueFactory.getInstance().createBNode(); if (type != null) { model.add(implNode, REPOSITORYTYPE, SimpleValueFactory.getInstance().createLiteral(type)); } return implNode; }
public static boolean isInstanceOf(Model theGraph, Resource theSubject, Resource theType) { return theGraph.contains(SimpleValueFactory.getInstance().createStatement(theSubject, RDF.TYPE, theType)); } }
@Override protected Resource getValueInternal(String value) { switch (type) { case URI: return SimpleValueFactory.getInstance().createIRI(value); case BNODE: return SimpleValueFactory.getInstance().createBNode(value); default: throw new IllegalStateException(); } }
private static Literal buildLiteral(Duration duration) { return SimpleValueFactory.getInstance().createLiteral( duration.toString(), getDatatypeForDuration(duration) ); }
/** * Creates a new StatementCollector that stores reported statements in the supplied collection and that * uses a new LinkedHashMap to store the reported namespaces. */ public StatementCollector(Collection<Statement> statements) { super(statements, SimpleValueFactory.getInstance()); }
@Override public void handleNamespace(String prefix, String uri) throws RDFHandlerException { if (prefix.length() > 0) { SimpleValueFactory svf = SimpleValueFactory.getInstance(); handleStatement(svf.createStatement(svf.createIRI(uri), HALYARD.NAMESPACE_PREFIX_PROPERTY, svf.createLiteral(prefix))); } }
private Value getObjectFromCell(String cell) { Value object; String newCell = cell.trim(); if (RDFUtils.isAbsoluteIRI(newCell)) { object = SimpleValueFactory.getInstance().createIRI(newCell); } else { IRI datatype = XMLSchema.STRING; if (isInteger(newCell)) { datatype = XMLSchema.INTEGER; } else if(isFloat(newCell)) { datatype = XMLSchema.FLOAT; } object = SimpleValueFactory.getInstance().createLiteral(newCell, datatype); } return object; }
private Map<String, BNode> getBNodeMap() { Map<String, BNode> bNodeMap = new HashMap<>(); for(String name: bNodeNames) { bNodeMap.put(name, SimpleValueFactory.getInstance().createBNode(UUID.randomUUID().toString())); } return bNodeMap; }
@Override public void onValue(String subject, String predicate, String value, String valueType, String graph) { rdfWriter.handleStatement( valueFactory.createStatement( makeResource(subject), valueFactory.createIRI(predicate), valueFactory.createLiteral(value, valueFactory.createIRI(valueType)), makeResource(graph) ) ); }
@Override public void onRelation(String subject, String predicate, String object, String graph) { rdfWriter.handleStatement( valueFactory.createStatement( makeResource(subject), valueFactory.createIRI(predicate), makeResource(object), makeResource(graph) ) ); }
@Override public Value getValue() { return vf.createLiteral(Long.toString(count), XMLSchema.INTEGER); } }
@Override protected void setup(Context context) throws IOException, InterruptedException { this.conf = context.getConfiguration(); this.splitOutput = conf.get(TARGET).contains("{0}"); this.outputLimit = conf.getLong("mapreduce.input.fileinputformat.split.maxsize", Long.MAX_VALUE); String ng = conf.get(TARGET_GRAPH); this.namedGraph = ng == null ? null : SVF.createIRI(ng); this.decimationFactor = conf.getInt(DECIMATION_FACTOR, DEFAULT_DECIMATION_FACTOR); sail = new HBaseSail(conf, conf.get(SOURCE), false, 0, true, 0, null, null); sail.initialize(); setupOutput(); write(CARDINALITY, RDF.TYPE, RDF.PROPERTY); write(CARDINALITY, RDFS.LABEL, SVF.createLiteral("cardinality")); write(CARDINALITY, RDFS.COMMENT, SVF.createLiteral("cardinality is positive integer [0..63], it is a binary logarithm of the pattern occurences (2^63 is the maximum allowed number of occurences)")); write(CARDINALITY, RDFS.RANGE, XMLSchema.INTEGER); }
public EntityModelWriter( TagService<LabeledResource, LabeledResource> tagService, SimpleValueFactory valueFactory) { this.valueFactory = requireNonNull(valueFactory); this.tagService = requireNonNull(tagService); this.rdfTypePredicate = valueFactory.createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); }
private Resource makeResource(String input) { if (input.startsWith("_:")) { return valueFactory.createBNode(input.substring(2)); } else { return valueFactory.createIRI(input); } }
@Override public Statement createStatement(Resource subject, IRI predicate, Value object, Resource context) { return super.createStatement(subject, predicate, object, overrideRdfContext || context == null ? defaultRdfContext : context); } });
@Override protected boolean accept(BindingSet bindings) throws QueryEvaluationException { Binding b = bindings.getBinding(TIMESTAMP_BINDING_NAME); //push back actual time if the timestamp binding is not provided timestampBinding.v = b == null ? SimpleValueFactory.getInstance().createLiteral(System.currentTimeMillis()) : b.getValue(); return true; } };
/** * Creates a new StatementCollector that stores reported statements and namespaces in the supplied * containers. */ public StatementCollector(Collection<Statement> statements, Map<String, String> namespaces) { super(statements, namespaces, SimpleValueFactory.getInstance()); } }
@BeforeClass public static void setup() throws Exception { table = HalyardTableUtils.getTable(HBaseServerTestInstance.getInstanceConfig(), "testScan", true, 0); allStatements = new HashSet<>(); SimpleValueFactory vf = SimpleValueFactory.getInstance(); allStatements.add(vf.createStatement(vf.createIRI(SUBJ1), vf.createIRI(PRED1), vf.createLiteral(EXPL1), vf.createIRI(CTX1))); allStatements.add(vf.createStatement(vf.createIRI(SUBJ2), vf.createIRI(PRED2), vf.createLiteral(EXPL2), vf.createIRI(CTX2))); long timestamp = System.currentTimeMillis(); for (Statement st : allStatements) { for (KeyValue kv : HalyardTableUtils.toKeyValues(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext(), false, timestamp)) { table.put(new Put(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(), kv.getTimestamp()).add(kv)); } } table.flushCommits(); }
@Override public void readFields(DataInput in) throws IOException { String s = in.readUTF(); if (s.length() > 0) { if (s.startsWith("_")) { val = SimpleValueFactory.getInstance().createBNode(s.substring(2)); } else { val = SimpleValueFactory.getInstance().createIRI(s); } } key = in.readInt(); }