private Term getSmtIdentifier( final String id, final DeclarationInformation declInfo, final boolean isOldContext, final BoogieASTNode boogieASTNode) { if (mQuantifiedVariables.containsKey(id)) { return mQuantifiedVariables.get(id); } else { for (final IdentifierTranslator it : mSmtIdentifierProviders) { final Term term = it.getSmtIdentifier(id, declInfo, isOldContext, boogieASTNode); if (term != null) { return term; } } throw new AssertionError("found no translation for id " + id); } }
/** * Create a JCR value from an RDF node with the given JCR type * * @param valueFactory * @param data * @param type * @return * @throws RepositoryException */ public Value createValue(final ValueFactory valueFactory, final RDFNode data, final int type) throws RepositoryException { assert (valueFactory != null); if (data.isURIResource() && (type == REFERENCE || type == WEAKREFERENCE)) { // reference to another node (by path) final Node nodeFromGraphSubject = session.getNode(graphSubjects.getPathFromSubject(data.asResource())); return valueFactory.createValue(nodeFromGraphSubject, type == WEAKREFERENCE); } else if (data.isURIResource() || type == URI) { // some random opaque URI return valueFactory.createValue(data.toString(), PropertyType.URI); } else if (data.isResource()) { // a non-URI resource (e.g. a blank node) return valueFactory.createValue(data.toString(), UNDEFINED); } else if (data.isLiteral() && type == UNDEFINED) { // the JCR schema doesn't know what this should be; so introspect // the RDF and try to figure it out final Literal literal = data.asLiteral(); final RDFDatatype dataType = literal.getDatatype(); final Object rdfValue = literal.getValue(); if (rdfValue instanceof Boolean) { return valueFactory.createValue((Boolean) rdfValue); } else if (rdfValue instanceof Byte || (dataType != null && dataType.getJavaClass() == Byte.class)) { return valueFactory.createValue(literal.getByte()); } else if (rdfValue instanceof Double) { return valueFactory.createValue((Double) rdfValue); } else if (rdfValue instanceof Float) { return valueFactory.createValue((Float) rdfValue); } else if (rdfValue instanceof Long || (dataType != null && dataType.getJavaClass() == Long.class)) { return valueFactory.createValue(literal.getLong()); } else if (rdfValue instanceof Short || (dataType != null && dataType.getJavaClass() == Short.class)) { return valueFactory.createValue(literal.getShort()); } else if (rdfValue instanceof Integer) { return valueFactory.createValue((Integer) rdfValue); } else if (rdfValue instanceof XSDDateTime) { return valueFactory.createValue(((XSDDateTime) rdfValue).asCalendar()); } else { return valueFactory.createValue(literal.getString(), STRING); } } else { LOGGER.debug("Using default JCR value creation for RDF literal: {}", data); return valueFactory.createValue(data.asLiteral().getString(), type); } }
/** * Get an {@link RdfStream} for the given JCR NodeIterator * * @param nodeIterator * @param iteratorSubject * @return * @throws RepositoryException */ public RdfStream getJcrPropertiesModel( final Iterator<Node> nodeIterator, final Resource iteratorSubject) throws RepositoryException { final RdfStream results = new RdfStream(); while (nodeIterator.hasNext()) { final Node node = nodeIterator.next(); results.concat(new PropertiesRdfContext(node, graphSubjects, llstore)); if (iteratorSubject != null) { results.concat( singleton( create( iteratorSubject.asNode(), HAS_MEMBER_OF_RESULT.asNode(), graphSubjects.getSubject(node.getPath()).asNode()))); } } return results; }