Java Code Examples for org.openrdf.model.Value

The following examples show how to use org.openrdf.model.Value. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: GeoTriples   Source File: AbstractRMLProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Collection<Statement> processSubjectTypeMap(SesameDataSet dataset, Resource subject,
		SubjectMap subjectMap, Object node) {
	List<Statement> statements=new LinkedList<>();
	ValueFactory myFactory = ValueFactoryImpl.getInstance();
	
	// Add the type triples
	Set<org.openrdf.model.URI> classIRIs = subjectMap.getClassIRIs();
	if (subject != null)
		for (org.openrdf.model.URI classIRI : classIRIs) {
			Statement st = myFactory.createStatement((Resource) subject, RDF.TYPE,
       				(Value) classIRI);
               //dataset.add(subject, predicate, object);
               dataset.addStatement(st);
               
               statements.add(st);
			
			//dataset.add(subject, RDF.TYPE, classIRI);
		}
	
	return statements;
}
 
Example 2
Source Project: fcrepo-camel-toolbox   Source File: LDPathWrapper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create an LDPathWrapper Object
 * @param backend the linkeddata backend
 */
public LDPathWrapper(final LDCacheBackend backend) {

    // Register the Sesame RDF Parsers manually
    // TODO: use the OSGi service registry as described in:
    // http://blog.osgi.org/2013/02/javautilserviceloader-in-osgi.html
    RDFParserRegistry.getInstance().add(new RDFXMLParserFactory());
    RDFParserRegistry.getInstance().add(new NTriplesParserFactory());
    RDFParserRegistry.getInstance().add(new TurtleParserFactory());
    RDFParserRegistry.getInstance().add(new N3ParserFactory());
    RDFParserRegistry.getInstance().add(new SesameJSONLDParserFactory());
    RDFParserRegistry.getInstance().add(new RDFJSONParserFactory());
    RDFParserRegistry.getInstance().add(new SesameRDFaParserFactory());
    RDFParserRegistry.getInstance().add(new TriGParserFactory());
    BooleanQueryResultParserRegistry.getInstance().add(new SPARQLBooleanXMLParserFactory());
    TupleQueryResultParserRegistry.getInstance().add(new SPARQLResultsXMLParserFactory());

    ldpath = new LDPath<Value>(backend);
}
 
Example 3
Source Project: anthelion   Source File: BasicTripleHandler.java    License: Apache License 2.0 6 votes vote down vote up
public void receiveTriple(Resource s, URI p, Value o, URI g, ExtractionContext context)
		throws TripleHandlerException {
	// if uri is in negative namespace which has to be filtered out and not
	// in the positive list - return directly
	for (String negativeFilterNamespace : negativeFilterNamespaces) {
		if (p.toString().startsWith(negativeFilterNamespace)) {
			for (String positiveFilterNamespace : positiveFilterNamespaces) {
				if (!p.toString().startsWith(positiveFilterNamespace)) {
					// log.debug("Namespace filtered: "
					// + s.toString() + " , " + p.toString() + ", "
					// + o.toString());
					return;
				}
			}
		}
	}
	extractorNames.add(context.getExtractorName());
	totalTriples++;
	wrapped.receiveTriple(s, p, o, g, context);

}
 
Example 4
Source Project: database   Source File: GPO.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * A new value is only added if it does not already exist, ensuring the
 * GPO maintains semantics with the underlying TripleStore.
 * 
 * @return true if value was added
 */
public boolean add(final GPO owner, final Value value) {
	final Iterator<Value> values = values();
	while (values.hasNext()) {
		if (values.next().equals(value)) {
			return false;
		}
	}

	final LinkValue nv = new LinkValue(value);
	nv.m_next = m_addedValues;
	m_addedValues = nv;

	m_size++;

	return true;
}
 
Example 5
Source Project: cumulusrdf   Source File: DeletionTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Adds and then removes triples.
 * 
 * @throws Exception never, otherwise the tests fail.
 */
@Test
public void testAddAndRemove() throws Exception {

	_tripleStore.addData(parseNX(
			"<http://izeus1.scc.kit.edu/id/i1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gridpedia.org/id/TestType> . ")
			.iterator());
	_tripleStore.addData(parseNX(
			"<http://izeus1.scc.kit.edu/id/i2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://gridpedia.org/id/TestType> . ")
			.iterator());

	assertEquals(2, numOfRes(_tripleStore.query(new Value[] { null, RDF.TYPE, buildResource("http://gridpedia.org/id/TestType") })));

	_tripleStore.removeData(_tripleStore.query(new Value[] { buildResource("http://izeus1.scc.kit.edu/id/i1"), null, null }));

	assertEquals(1, numOfRes(_tripleStore.query(new Value[] { null, RDF.TYPE, buildResource("http://gridpedia.org/id/TestType") })));
}
 
Example 6
Source Project: semweb4j   Source File: RepositoryModel.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public ClosableIterator<org.ontoware.rdf2go.model.Statement> findStatements(
        ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
        throws ModelRuntimeException {
	assertModel();
	// convert parameters to OpenRDF data types
	org.openrdf.model.Resource openRdfSubject = (org.openrdf.model.Resource)ConversionUtil
	        .toOpenRDF(subject, this.valueFactory);
	org.openrdf.model.URI openRdfPredicate = (org.openrdf.model.URI)ConversionUtil.toOpenRDF(
	        predicate, this.valueFactory);
	Value openRdfObject = ConversionUtil.toOpenRDF(object, this.valueFactory);
	
	try {
		// find the matching statements
		CloseableIteration<? extends org.openrdf.model.Statement,? extends OpenRDFException> statements = this.connection
		        .getStatements(openRdfSubject, openRdfPredicate, openRdfObject, true,
		                this.openRdfContext);
		// wrap them in a StatementIterable
		return new StatementIterator(statements, this);
	} catch(RepositoryException e) {
		throw new ModelRuntimeException(e);
	}
}
 
Example 7
Source Project: cumulusrdf   Source File: TripleStore.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Iterator<byte[][]> rangeDateTimeAsIDs(
		final Value[] query,
		final Literal lower,
		final boolean equalsLower,
		final Literal upper,
		final boolean equalsUpper,
		final boolean reverse,
		final int limit) throws DataAccessLayerException {

	if (query == null || query.length != 2 || isVariable(query[1])) {
		return Iterators.emptyIterator();
	}

	final long lowerBound = lower == null ? Long.MIN_VALUE : Util.parseXMLSchemaDateTimeAsMSecs(lower), upperBound = upper == null ? Long.MAX_VALUE
			: Util.parseXMLSchemaDateTimeAsMSecs(upper);

	return _rdfIndexDAO.dateRangeQuery(query, lowerBound, equalsLower, upperBound, equalsUpper, reverse, limit);
}
 
Example 8
Source Project: cumulusrdf   Source File: TransientValueDictionary.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Value getValueInternal(final byte[] id, final boolean p) throws DataAccessLayerException {
	switch (id[0]) {
	case THRESHOLD_EXCEEDED:
		RUNTIME_CONTEXTS.get().isFirstLevelResult = false;
		return _longLiteralsDictionary.getValue(subarray(id, 1, id.length - 1), p);
	default:
		RUNTIME_CONTEXTS.get().isFirstLevelResult = true;
		final String n3 = new String(id, 2, id.length - 2, CHARSET_UTF8);
		if (id[1] == RESOURCE_BYTE_FLAG) {
			return NTriplesUtil.parseResource(n3, SESAME_VALUE_FACTORY);
		} else if (id[1] == LITERAL_BYTE_FLAG) {
			return NTriplesUtil.parseLiteral(n3, SESAME_VALUE_FACTORY);
		} else {
			return NTriplesUtil.parseBNode(n3, SESAME_VALUE_FACTORY);
		}
	}
}
 
Example 9
/**
 * Wrap a {@link BigdataValue}[] with a chunked iterator.
 * <p>
 * Note: This resolves inline {@link IV}s and filters them out of the
 * visited {@link BigdataValue}s as a side-effect.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
static <V extends BigdataValue> IChunkedIterator<V> newValuesIterator(
        final LexiconRelation r,
        final Iterator<V> itr, final int chunkSize) {

    return new ChunkedWrappedIterator(new Striterator(itr)
            .addFilter(new Filter() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isValid(final Object obj) {
                    /*
                     * Assigns the IV as a side effect iff the RDF Value can
                     * be inlined according to the governing lexicon
                     * configuration and returns true iff the value CAN NOT
                     * be inlined. Thus, inlining is done as a side effect
                     * while the caller sees only those Values which need to
                     * be written onto the TERM2ID/BLOBS index.
                     */
                    return r.getInlineIV((Value) obj) == null;
                }
            }), chunkSize, BigdataValue.class);

}
 
Example 10
Source Project: anno4j   Source File: RDFList.java    License: Apache License 2.0 6 votes vote down vote up
Value getFirst(Resource list) {
	if (list == null)
		return null;
	try {
		CloseableIteration<Value, RepositoryException> stmts;
		stmts = getValues(list, RDF.FIRST, null);
		try {
			if (stmts.hasNext())
				return stmts.next();
			return null;
		} finally {
			stmts.close();
		}
	} catch (RepositoryException e) {
		throw new ObjectStoreException(e);
	}
}
 
Example 11
@Override
    protected long doDeleteWithAccessPath(//
//          final String servlet,//
          final URI s,//
          final URI p,//
          final Value o,//
          final URI... c//
          ) throws Exception {

		final long start = getExactSize();
		
		cxn.remove(s, p, o, c);
		
		return start - getExactSize();
		
	}
 
Example 12
Source Project: database   Source File: BasicSkin.java    License: GNU General Public License v2.0 5 votes vote down vote up
public boolean getBooleanValue(final URI key) {
	final Value v = m_gpo.getValue(key);
	
	if (v instanceof Literal) {
		return ((Literal) v).booleanValue();
	} else {	
		return false;
	}
}
 
Example 13
Source Project: tinkerpop3   Source File: SparqlGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
private String sparql(final Value val) {
    if (val instanceof Literal) {
        return val.toString();
    } else if (val instanceof URI) {
        return '<' + val.stringValue() + '>';
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example 14
Source Project: database   Source File: BigdataRDFContext.java    License: GNU General Public License v2.0 5 votes vote down vote up
public AskQueryTask(final BigdataSailRepositoryConnection cxn, 
		final String namespace, final long timestamp,
        final String baseURI, final boolean includeInferred,
        final Map<String, Value> bindings,
        final ASTContainer astContainer, final QueryType queryType,
        final BooleanQueryResultFormat format,
        final HttpServletRequest req, final HttpServletResponse resp,
        final OutputStream os) {

    super(cxn, namespace, timestamp, baseURI, includeInferred, bindings, astContainer, queryType,
            format.getDefaultMIMEType(), format.getCharset(), format
                    .getDefaultFileExtension(), req, resp, os);

}
 
Example 15
Source Project: cumulusrdf   Source File: QuadsDeletionTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Tests if the deletion of queries using the triple indexes works.
 * @throws CumulusStoreException If the deletion fails.
 */
@Test
// different triple indexes
public void testDeleteTripleIndexes() throws CumulusStoreException {

	/*
	 * s ?p ?o ?c
	 */
	Value[] query = new Value[] {buildResource("a5"), null, null, null};
	assertEquals(Arrays.toString(query), 2, TestUtils.numOfRes(_quadStore.query(query)));

	_quadStore.removeData(query);
	assertEmptyIterator(Arrays.toString(query), _quadStore.query(query));

	query = new Value[] {buildResource("a1"), null, null, null};
	assertEquals(Arrays.toString(query), 3, TestUtils.numOfRes(_quadStore.query(query)));

	_quadStore.removeData(query);
	assertEmptyIterator(Arrays.toString(query), _quadStore.query(query));

	TestUtils.numOfRes(_quadStore.query(SELECT_ALL_QUADS_PATTERN));

	/*
	 * ?s p ?o ?c
	 */
	query = new Value[] {null, buildResource("b2"), null, null};
	assertEquals(Arrays.toString(query), 1, TestUtils.numOfRes(_quadStore.query(query)));

	_quadStore.removeData(query);
	assertEmptyIterator(Arrays.toString(query), _quadStore.query(query));

	/*
	 * ?s ?p o ?c
	 */
	query = new Value[] {null, null, buildResource("c1"), null};
	assertEquals(Arrays.toString(query), 1, TestUtils.numOfRes(_quadStore.query(query)));

	_quadStore.removeData(query);
	assertEmptyIterator(Arrays.toString(query), _quadStore.query(query));
}
 
Example 16
Source Project: database   Source File: GPO.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
	public void setValue(final URI property, final Value newValue) {

		if (property == null)
			throw new IllegalArgumentException();

		if (newValue == null)
			throw new IllegalArgumentException();

//		final Lock writeLock = m_lock.writeLock();
//		writeLock.lock();
//		try {
			materialize();
			
			// calls reverse removeLinkSetMembers
			removeValues(property);

			final GPOEntry entry = establishEntry(property);

			entry.set(this, newValue);
			
			if (newValue instanceof Resource) {
				// add to LinkSet of target
				((GPO) m_om.getGPO((Resource) newValue)).addLinkSetMember(property, m_id);
			}

			dirty();
//		} finally {
//			writeLock.unlock();
//		}
	}
 
Example 17
Source Project: mustard   Source File: RDFSingleDataSet.java    License: MIT License 5 votes vote down vote up
@Override
public List<Statement> getStatements(Resource subject, URI predicate, Value object, boolean allowInference) {
	List<Statement> resGraph = new ArrayList<Statement>();

	try {
		RepositoryConnection repCon = rdfRep.getConnection();

		try {
			
			
			RepositoryResult<Statement> statements = repCon.getStatements(subject, predicate, object, allowInference);

			try {
				while (statements.hasNext()) {
					resGraph.add(statements.next());
				}
			}
			finally {
				statements.close();
			}
		} finally {
			repCon.close();
		}

	} catch (Exception e) {
		e.printStackTrace();
	}

	return resGraph;		
}
 
Example 18
Source Project: cumulusrdf   Source File: CacheValueDictionary.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Builds and initializes a cache capability on top of a given dictionary.
 * 
 * @param id the dictionary identifier.
 * @param decoratee the decorated dictionary.
 * @param idCacheSize the identifier cache size. In case <=0 It defaults to {@link #DEFAULT_CACHE_SIZE}
 * @param valueCacheSize the value cache size. In case <=0 It defaults to {@link #DEFAULT_CACHE_SIZE}
 * @param isFirstLevelCache a boolean that marks this cache as first level (or cumulative).
 */
public CacheValueDictionary(
		final String id, 
		final ITopLevelDictionary decoratee, 
		final int idCacheSize, 
		final int valueCacheSize, 			
		final boolean isFirstLevelCache) {
	super(id);
	if (decoratee == null) {
		throw new IllegalArgumentException(MessageCatalog._00091_NULL_DECORATEE_DICT);
	}
	_decoratee = decoratee;
	_idCacheMaxSize = cacheSize(idCacheSize);
	_valueCacheMaxSize = cacheSize(valueCacheSize);
	
	_id2node_cache = new ConcurrentLinkedHashMap
			.Builder<ByteBuffer, Value>()
			.maximumWeightedCapacity(_idCacheMaxSize)
			.listener(_idEvictionListener)
			.build();
	_node2id_cache = new ConcurrentLinkedHashMap
			.Builder<Value, byte[]>()
			.maximumWeightedCapacity(_valueCacheMaxSize)
			.listener(_valueEvictionListener)
			.build();
	_cacheStrategy = isFirstLevelCache ? new FirstLevelCacheStrategy() : new CumulativeCacheStrategy();
}
 
Example 19
@Override
   public void exportStatements(final Resource s, final URI p, final Value o,
           final boolean includeInferred, final RDFHandler handler,
           final Resource... c) throws RepositoryException,
           RDFHandlerException {

       try {

           final RemoteRepository remote = repo.getRemoteRepository();

           final GraphQueryResult src = remote.getStatements(s, p, o,
                   includeInferred, c);
           try {
               handler.startRDF();
               while (src.hasNext()) {
                   handler.handleStatement(src.next());
               }
               handler.endRDF();
           } finally {
               src.close();
           }
		
	} catch (Exception ex) {
		
		throw new RepositoryException(ex);

	}
	
}
 
Example 20
Source Project: attic-polygene-java   Source File: TupleQueryExecutor.java    License: Apache License 2.0 5 votes vote down vote up
private Map<String, Value> getBindings(Map<String, Object> variables)
{
    Map<String, Value> bindings = new HashMap<>();
    for (Map.Entry<String, Object> stringObjectEntry : variables.entrySet())
    {
        if (!stringObjectEntry.getValue().getClass().equals(Object.class))
            bindings.put(stringObjectEntry.getKey(), ValueFactoryImpl.getInstance().createLiteral(stringObjectEntry.getValue().toString()));
    }
    return bindings;
}
 
Example 21
Source Project: database   Source File: BasicSkin.java    License: GNU General Public License v2.0 5 votes vote down vote up
public int getIntValue(final URI key) {
	final Value v = m_gpo.getValue(key);
	
	if (v instanceof Literal) {
		return ((Literal) v).intValue();
	} else {	
		return 0;
	}
}
 
Example 22
/**
	 * aaa xxx bbb 
	 * xxx nrl:inverseProperty yyy
	 * -->
	 * bbb yyy aaa
	 * @return
	 * @throws SailException
	 */
	private int applyRuleN1b()
	throws SailException
{
	int nofInferred = 0;
	
	Iterator<Statement> ntIter = this.newThisIteration.match(null, null, null);

	while (ntIter.hasNext()) {
		Statement nt = ntIter.next();

		Resource xxx = nt.getPredicate();

		CloseableIteration<? extends Statement, SailException> t1Iter;
		t1Iter = getWrappedConnection().getStatements(xxx,NRL_InverseProperty, null, true);

		while (t1Iter.hasNext()) {
			Statement t1 = t1Iter.next();

			Value yyy = t1.getObject();
			if (yyy instanceof URI) {
				Resource aaa = 	nt.getSubject();
				Value bbb = nt.getObject();
				boolean added = addInferredStatement((Resource)bbb, (URI) yyy, aaa);
				if (added) {
					nofInferred++;
				}
			}
		}
		t1Iter.close();
	}

	return nofInferred;
}
 
Example 23
@Test
public void testValuesInOptional()
	throws Exception
{
	loadTestData("/testdata-query/dataset-ses1692.trig");
	StringBuilder query = new StringBuilder();
	query.append(" PREFIX : <http://example.org/>\n");
	query.append(" SELECT DISTINCT ?a ?name ?isX WHERE { ?b :p1 ?a . ?a :name ?name. OPTIONAL { ?a a :X . VALUES(?isX) { (:X) } } } ");

	TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, query.toString());

	TupleQueryResult result = tq.evaluate();
	assertNotNull(result);
	assertTrue(result.hasNext());

	int count = 0;
	while (result.hasNext()) {
		count++;
		BindingSet bs = result.next();
		System.out.println(bs);
		URI a = (URI)bs.getValue("a");
		assertNotNull(a);
		Value isX = bs.getValue("isX");
		Literal name = (Literal)bs.getValue("name");
		assertNotNull(name);
		if (a.stringValue().endsWith("a1")) {
			assertNotNull(isX);
		}
		else if (a.stringValue().endsWith(("a2"))) {
			assertNull(isX);
		}
	}
	assertEquals(2, count);
}
 
Example 24
Source Project: database   Source File: ObjectMgrModel.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Deprecated // no need for explicit recall.
public IGPO recallAsGPO(final URI key) {
	
    final Value val = recall(key);
	
	if (val instanceof Resource) {
		return getGPO((Resource) val);
	} else {
		return null;
	}
}
 
Example 25
Source Project: anno4j   Source File: RDFClass.java    License: Apache License 2.0 5 votes vote down vote up
private boolean isRDFSOrOWL(Value sup) {
	if (self instanceof URI && sup instanceof URI) {
		String ns = ((URI) self).getNamespace();
		return ns.equals(RDF.NAMESPACE) || ns.equals(RDFS.NAMESPACE)
				|| ns.equals(OWL.NAMESPACE);
	}
	return false;
}
 
Example 26
Source Project: cumulusrdf   Source File: CumulusRDFValueFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a CumulusRDF native value from a given {@link Value}.
 * 
 * @param value the incoming {@link Value}.
 * @return a CumulusRDF native value.
 */
public static Value makeNativeValue(final Value value) {
	if (value == null || value instanceof INativeCumulusValue) {
		return value;
	}

	if (value instanceof URI) {
		return new NativeCumulusURI(value.stringValue());
	} else if (value instanceof Literal) {
		
		final Literal lit = (Literal) value;
		final String label = lit.getLabel(), language = lit.getLanguage();
		final URI datatype = lit.getDatatype();

		if (language != null) {
			return new NativeCumulusLiteral(label, language);
		} else if (datatype != null) {
			return new NativeCumulusLiteral(label, datatype);
		} else {
			return new NativeCumulusLiteral(label);
		}
		
	} else if (value instanceof BNode) {
		return new NativeCumulusBNode(value.stringValue());
	}

	return value;
}
 
Example 27
Source Project: database   Source File: GPO.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * initValue is called by ObjectManager materialize and resets the GPO
 * to its read state. Therefore the value is added to the m_values list
 * and not m_addedValues.
 */
public void initValue(final GPO owner, final Value value) {
	final LinkValue newValue = new LinkValue(value);
	newValue.m_next = m_values;
	m_values = newValue;

	m_size++;
}
 
Example 28
Source Project: anno4j   Source File: RDFSContainer.java    License: Apache License 2.0 5 votes vote down vote up
private Object[] loadBlock(int b) throws RepositoryException, QueryEvaluationException {
	TupleQuery query = createBlockQuery(b);
	TupleQueryResult result = query.evaluate();
	BindingSet bindings = result.next();
	ObjectConnection con = getObjectConnection();
	Object[] list = new Object[BSIZE];
	while (bindings != null) {
		URI pred = (URI) bindings.getValue("pred");
		int idx = getIndex(pred);
		Value value = bindings.getValue("value");
		Set<URI> types = new HashSet<URI>(4);
		do {
			Value c = bindings.getValue("value_class");
			if (c instanceof URI) {
				types.add((URI) c);
			}
			bindings = result.hasNext() ? result.next() : null;
		} while (bindings != null && pred.equals(bindings.getValue("pred")));
		int i = idx % BSIZE;
		if (value instanceof Literal) {
			list[i] = con.getObject((Literal) value);
		} else {
			list[i] = con.getObject(types, (Resource) value);
		}
	}
	return list;
}
 
Example 29
Source Project: cumulusrdf   Source File: QuadStore.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Iterator<byte[][]> queryAsIDs(final Value[] query, final int limit) throws CumulusStoreException {
	try {
		return queryWithIDs(_dictionary.getIDs(query[0], query[1], query[2], query.length > 3 ? query[3] : null), limit);
	} catch (final DataAccessLayerException exception) {
		_log.error(MessageCatalog._00093_DATA_ACCESS_LAYER_FAILURE, exception);
		throw new CumulusStoreException(exception);
	}	
}
 
Example 30
/**
 * Return a (Mock) IV for a Value.
 * 
 * @param v
 *            The value.
 * 
 * @return The Mock IV.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private IV makeIV(final Value v) {
    final BigdataValueFactory valueFactory = BigdataValueFactoryImpl
            .getInstance(namespace);
    final BigdataValue bv = valueFactory.asValue(v);
    final IV iv = new TermId(VTE.valueOf(v), nextId++);
    iv.setValue(bv);
    return iv;
}