Package org.openrdf.model.impl

Examples of org.openrdf.model.impl.ValueFactoryImpl


  }

  private TupleExpr buildQueryModel(ASTQueryContainer qc)
    throws MalformedQueryException
  {
    TupleExprBuilder tupleExprBuilder = new TupleExprBuilder(new ValueFactoryImpl());
    try {
      return (TupleExpr)qc.jjtAccept(tupleExprBuilder, null);
    }
    catch (VisitorException e) {
      throw new MalformedQueryException(e.getMessage(), e);
View Full Code Here


      qc.jjtAccept(new ProjectionAliasProcessor(), null);
      qc.jjtAccept(new AnonymousVarGenerator(), null);

      // TODO: check use of unbound variables?

      TupleExpr tupleExpr = QueryModelBuilder.buildQueryModel(qc, new ValueFactoryImpl());

      ASTQuery queryNode = qc.getQuery();
      ParsedQuery query;
      if (queryNode instanceof ASTTupleQuery) {
        query = new ParsedTupleQuery(tupleExpr);
View Full Code Here

  /*--------------*
   * Constructors *
   *--------------*/

  public DAWGTestResultSetWriter(RDFHandler rdfHandler) {
    this(rdfHandler, new ValueFactoryImpl());
  }
View Full Code Here

   * Constructors *
   *--------------*/

  private HTTPRepository() {
    httpClient = new HTTPClient();
    httpClient.setValueFactory(new ValueFactoryImpl());
  }
View Full Code Here

            for(Map.Entry<String,String> ns : getNamespaceMappings().entrySet()) {
                namespaces.add(Namespace.getNamespace(ns.getKey(), ns.getValue()));
            }


            ValueFactory vf = new ValueFactoryImpl();

            Resource subject = vf.createURI(resource);

            for(Map.Entry<String,XPathValueMapper> mapping : getXPathMappings(requestUrl).entrySet()) {
                XPathExpression<Object> xpath = mapping.getValue().getCompiled();

                org.openrdf.model.URI predicate = triples.getValueFactory().createURI(mapping.getKey());
                for(Object value : xpath.evaluate(doc)) {
                    String str_value;
                    if(value instanceof Element) {
                        str_value = ((Element) value).getValue();
                    } else if(value instanceof Text) {
                        str_value = ((Text) value).getValue();
                    } else if(value instanceof Attribute) {
                        str_value = ((Attribute) value).getValue();
                    } else if(value instanceof CDATA) {
                        str_value = ((CDATA) value).getValue();
                    } else if(value instanceof Comment) {
                        str_value = ((Comment) value).getValue();
                    } else {
                        str_value = value.toString();
                    }
                    List<Value> objects = mapping.getValue().map(resource, str_value,triples.getValueFactory());
                    for(Value object : objects) {
                        Statement stmt = triples.getValueFactory().createStatement(subject,predicate,object);
                        triples.add(stmt);
                    }
                }
            }

            org.openrdf.model.URI ptype = triples.getValueFactory().createURI(Namespaces.NS_RDF + "type");

            for(String typeUri : getTypes(vf.createURI(resource))) {
                Resource type_resource = vf.createURI(typeUri);
                triples.add(vf.createStatement(subject, ptype, type_resource));
            }

            return Collections.emptyList();

        } catch (JDOMException e) {
View Full Code Here

    ValueFactory valueFactory;

    @Before
    public void setup() {
        valueFactory = new ValueFactoryImpl();

        Resource s1 = randomURI();
        URI p1 = randomURI();
        URI p2 = randomURI();
        Value o1 = randomObject();
View Full Code Here

    /**
     * Creates a new RDFParserBase that will use a {@link org.openrdf.model.impl.ValueFactoryImpl} to
     * create RDF model objects.
     */
    public ICalParser() {
        this(new ValueFactoryImpl());
    }
View Full Code Here

    @Override
    public boolean isCached(String resource) throws RepositoryException {
        try {
            final File dataFile = FileBackendUtils.getMetaFile(resource, storageDir);
            if (!(dataFile.exists())) return false;
            final CacheEntry ce = FileBackendUtils.readCacheEntry(dataFile, new ValueFactoryImpl());
            //return ce != null && !FileBackendUtils.isExpired(ce) && ce.getTripleCount() > 0;
            return ce != null && ce.getTripleCount() > 0;
        } catch (IOException e) {
            throw new RepositoryException(e);
        }
View Full Code Here

    @Override
    public void createServiceDescription(RDFWriter writer, String requestURL, boolean isUpdate) throws RDFHandlerException {
        try {
            writer.startRDF();
            final ValueFactory vf = new ValueFactoryImpl();
            writer.handleNamespace(SPARQL_SD.PREFIX, SPARQL_SD.NAMESPACE);
            writer.handleNamespace("formats", "http://www.w3.org/ns/formats/");
            writer.handleNamespace("void", "http://rdfs.org/ns/void#");

            final BNode sd = vf.createBNode();
            writer.handleStatement(vf.createStatement(sd, RDF.TYPE, SPARQL_SD.Service));
            writer.handleStatement(vf.createStatement(sd, SPARQL_SD.endpoint, vf.createURI(requestURL)));
            writer.handleStatement(vf.createStatement(sd, SPARQL_SD.supportedLanguage, isUpdate?SPARQL_SD.SPARQL11Update:SPARQL_SD.SPARQL11Query));

            if (!isUpdate) {
                // FIXME: really? these types?
                final Set<FileFormat> formats = new HashSet<>();
                formats.addAll(RDFWriterRegistry.getInstance().getKeys());
                formats.addAll(TupleQueryResultFormat.values());
                for (FileFormat f: formats) {
                    final String formatUri = w3cFormatID.get(f);
                    if (StringUtils.isNotBlank(formatUri)) {
                        writer.handleStatement(vf.createStatement(sd, SPARQL_SD.resultFormat, vf.createURI(formatUri)));
                    } else {
                        final BNode fNode = vf.createBNode();
                        writer.handleStatement(vf.createStatement(sd, SPARQL_SD.resultFormat, fNode));
                        writer.handleStatement(vf.createStatement(fNode, RDF.TYPE, vf.createURI("http://www.w3.org/ns/formats/Format")));
                        writer.handleStatement(vf.createStatement(fNode, vf.createURI("http://www.w3.org/ns/formats/media_type"), vf.createLiteral(f.getDefaultMIMEType())));
                        writer.handleStatement(vf.createStatement(fNode, vf.createURI("http://www.w3.org/ns/formats/preferred_suffix"), vf.createLiteral("."+f.getDefaultFileExtension())));
                    }
                }
            }

            final BNode dataset = vf.createBNode();
            writer.handleStatement(vf.createStatement(sd, SPARQL_SD.defaultDataset, dataset));
            writer.handleStatement(vf.createStatement(dataset, RDF.TYPE, SPARQL_SD.Dataset));

            final RepositoryConnection kiwiCon = sesameService.getConnection();
            try {
                kiwiCon.begin();
                // FIXME: Default graph, in KiWi this is all - is it not?
                final BNode defaultGraph = vf.createBNode();
                writer.handleStatement(vf.createStatement(dataset, SPARQL_SD.defaultGraph, defaultGraph));
                writer.handleStatement(vf.createStatement(defaultGraph, RDF.TYPE, SPARQL_SD.Graph));
                // TODO: Number of triples here? This can be expensive!
                writer.handleStatement(vf.createStatement(defaultGraph, vf.createURI("http://rdfs.org/ns/void#triples"), vf.createLiteral(kiwiCon.size())));

                final RepositoryResult<Resource> cID = kiwiCon.getContextIDs();
                try {
                    while (cID.hasNext()) {
                        final Resource c = cID.next();
                        if (c instanceof URI) {
                            // A named graph
                            final BNode ng = vf.createBNode();
                            writer.handleStatement(vf.createStatement(dataset, SPARQL_SD.namedGraph, ng));
                            writer.handleStatement(vf.createStatement(ng, RDF.TYPE, SPARQL_SD.NamedGraph));
                            writer.handleStatement(vf.createStatement(ng, SPARQL_SD.name, c));
                            final BNode g = vf.createBNode();
                            writer.handleStatement(vf.createStatement(ng, SPARQL_SD.graph, g));
                            writer.handleStatement(vf.createStatement(g, RDF.TYPE, SPARQL_SD.Graph));
                            // TODO: Number of triples here? This can be expensive!
                            writer.handleStatement(vf.createStatement(g, vf.createURI("http://rdfs.org/ns/void#triples"), vf.createLiteral(kiwiCon.size(c))));

                        }
                    }
                } finally {
                    cID.close();
View Full Code Here

    /**
     * Creates a new RDFParserBase that will use a {@link org.openrdf.model.impl.ValueFactoryImpl} to
     * create RDF model objects.
     */
    public ICalParser() {
        this(new ValueFactoryImpl());
    }
View Full Code Here

TOP

Related Classes of org.openrdf.model.impl.ValueFactoryImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.