Package org.openrdf.rio

Examples of org.openrdf.rio.RDFHandlerException


        predicateStack.push(pred);
        nodeStack.push(new Node(obj));
      }
    }
    catch (IOException e) {
      throw new RDFHandlerException(e);
    }
  }
View Full Code Here


        if (con.getNamespace(prefix) == null) {
          con.setNamespace(prefix, name);
        }
      }
      catch (RepositoryException e) {
        throw new RDFHandlerException(e);
      }
    }

    namespaceMap.clear();
    bNodesMap.clear();
View Full Code Here

      else {
        con.add(subj, pred, obj, ctxt);
      }
    }
    catch (RepositoryException e) {
      throw new RDFHandlerException(e);
    }
  }
View Full Code Here

      else {
        con.remove(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext());
      }
    }
    catch (RepositoryException e) {
      throw new RDFHandlerException(e);
    }
  }
View Full Code Here

      writeEndTag(RDF.NAMESPACE, "RDF");

      writer.flush();
    }
    catch (IOException e) {
      throw new RDFHandlerException(e);
    }
    finally {
      writingStarted = false;
      headerWritten = false;
    }
View Full Code Here

    // Verify that an XML namespace-qualified name can be created for the
    // predicate
    String predString = pred.toString();
    int predSplitIdx = XMLUtil.findURISplitIndex(predString);
    if (predSplitIdx == -1) {
      throw new RDFHandlerException("Unable to create XML namespace-qualified name for predicate: "
          + predString);
    }

    String predNamespace = predString.substring(0, predSplitIdx);
    String predLocalName = predString.substring(predSplitIdx);

    try {
      if (!headerWritten) {
        writeHeader();
      }

      // SUBJECT
      if (!subj.equals(lastWrittenSubject)) {
        flushPendingStatements();

        // Write new subject:
        writeNewLine();
        writeStartOfStartTag(RDF.NAMESPACE, "Description");
        if (subj instanceof BNode) {
          BNode bNode = (BNode)subj;
          writeAttribute(RDF.NAMESPACE, "nodeID", bNode.getID());
        }
        else {
          URI uri = (URI)subj;
          writeAttribute(RDF.NAMESPACE, "about", uri.toString());
        }
        writeEndOfStartTag();
        writeNewLine();

        lastWrittenSubject = subj;
      }

      // PREDICATE
      writeIndent();
      writeStartOfStartTag(predNamespace, predLocalName);

      // OBJECT
      if (obj instanceof Resource) {
        Resource objRes = (Resource)obj;

        if (objRes instanceof BNode) {
          BNode bNode = (BNode)objRes;
          writeAttribute(RDF.NAMESPACE, "nodeID", bNode.getID());
        }
        else {
          URI uri = (URI)objRes;
          writeAttribute(RDF.NAMESPACE, "resource", uri.toString());
        }

        writeEndOfEmptyTag();
      }
      else if (obj instanceof Literal) {
        Literal objLit = (Literal)obj;

        // language attribute
        if (objLit.getLanguage() != null) {
          writeAttribute("xml:lang", objLit.getLanguage());
        }

        // datatype attribute
        boolean isXMLLiteral = false;
        URI datatype = objLit.getDatatype();
        if (datatype != null) {
          // Check if datatype is rdf:XMLLiteral
          isXMLLiteral = datatype.equals(RDF.XMLLITERAL);

          if (isXMLLiteral) {
            writeAttribute(RDF.NAMESPACE, "parseType", "Literal");
          }
          else {
            writeAttribute(RDF.NAMESPACE, "datatype", datatype.toString());
          }
        }

        writeEndOfStartTag();

        // label
        if (isXMLLiteral) {
          // Write XML literal as plain XML
          writer.write(objLit.getLabel());
        }
        else {
          writeCharacterData(objLit.getLabel());
        }

        writeEndTag(predNamespace, predLocalName);
      }

      writeNewLine();

      // Don't write </rdf:Description> yet, maybe the next statement
      // has the same subject.
    }
    catch (IOException e) {
      throw new RDFHandlerException(e);
    }
  }
View Full Code Here

      writer.write(comment);
      writer.write(" -->");
      writeNewLine();
    }
    catch (IOException e) {
      throw new RDFHandlerException(e);
    }
  }
View Full Code Here

        if (solutionNode instanceof Resource) {
          reportSolution((Resource)solutionNode, bindingNames);
        }
        else {
          new RDFHandlerException("Value for " + SOLUTION + " is not a resource: " + solutionNode);
        }
      }

      tqrHandler.endQueryResult();
    }
    catch (GraphUtilException e) {
      throw new RDFHandlerException(e.getMessage(), e);
    }
    catch (TupleQueryResultHandlerException e) {
      throw new RDFHandlerException(e.getMessage(), e);
    }
  }
View Full Code Here

      if (varName instanceof Literal) {
        bindingNames.add(((Literal)varName).getLabel());
      }
      else {
        throw new RDFHandlerException("Value for " + RESULTVARIABLE + " is not a literal: " + varName);
      }
    }

    return bindingNames;
  }
View Full Code Here

      if (bindingNode instanceof Resource) {
        Binding binding = getBinding((Resource)bindingNode);
        bindingSet.addBinding(binding);
      }
      else {
        throw new RDFHandlerException("Value for " + BINDING + " is not a resource: " + bindingNode);
      }
    }

    try {
      tqrHandler.handleSolution(bindingSet);
    }
    catch (TupleQueryResultHandlerException e) {
      throw new RDFHandlerException(e.getMessage(), e);
    }
  }
View Full Code Here

TOP

Related Classes of org.openrdf.rio.RDFHandlerException

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.