Class RdfWriter

java.lang.Object
org.wikidata.wdtk.rdf.RdfWriter

public class RdfWriter extends Object
This class provides methods for writing RDF data to an output stream. It encapsulates many details of the RDF library we use. It also provides a unique point at which statistics about the number of triples etc. can be gathered.
Author:
Markus Kroetzsch
  • Field Details

    • RDF_TYPE

      public static final org.eclipse.rdf4j.model.IRI RDF_TYPE
    • RDFS_LABEL

      public static final org.eclipse.rdf4j.model.IRI RDFS_LABEL
    • RDFS_SEE_ALSO

      public static final org.eclipse.rdf4j.model.IRI RDFS_SEE_ALSO
    • RDFS_LITERAL

      public static final org.eclipse.rdf4j.model.IRI RDFS_LITERAL
    • RDFS_SUBCLASS_OF

      public static final org.eclipse.rdf4j.model.IRI RDFS_SUBCLASS_OF
    • RDFS_SUBPROPERTY_OF

      public static final org.eclipse.rdf4j.model.IRI RDFS_SUBPROPERTY_OF
    • OWL_THING

      public static final org.eclipse.rdf4j.model.IRI OWL_THING
    • OWL_CLASS

      public static final org.eclipse.rdf4j.model.IRI OWL_CLASS
    • OWL_OBJECT_PROPERTY

      public static final org.eclipse.rdf4j.model.IRI OWL_OBJECT_PROPERTY
    • OWL_DATATYPE_PROPERTY

      public static final org.eclipse.rdf4j.model.IRI OWL_DATATYPE_PROPERTY
    • OWL_RESTRICTION

      public static final org.eclipse.rdf4j.model.IRI OWL_RESTRICTION
    • OWL_SOME_VALUES_FROM

      public static final org.eclipse.rdf4j.model.IRI OWL_SOME_VALUES_FROM
    • OWL_ON_PROPERTY

      public static final org.eclipse.rdf4j.model.IRI OWL_ON_PROPERTY
    • OWL_COMPLEMENT_OF

      public static final org.eclipse.rdf4j.model.IRI OWL_COMPLEMENT_OF
    • XSD_DOUBLE

      public static final org.eclipse.rdf4j.model.IRI XSD_DOUBLE
    • XSD_DECIMAL

      public static final org.eclipse.rdf4j.model.IRI XSD_DECIMAL
    • XSD_INT

      public static final org.eclipse.rdf4j.model.IRI XSD_INT
    • XSD_DATE

      public static final org.eclipse.rdf4j.model.IRI XSD_DATE
    • XSD_G_YEAR

      public static final org.eclipse.rdf4j.model.IRI XSD_G_YEAR
    • XSD_G_YEAR_MONTH

      public static final org.eclipse.rdf4j.model.IRI XSD_G_YEAR_MONTH
    • XSD_DATETIME

      public static final org.eclipse.rdf4j.model.IRI XSD_DATETIME
    • XSD_STRING

      public static final org.eclipse.rdf4j.model.IRI XSD_STRING
    • SKOS_ALT_LABEL

      public static final org.eclipse.rdf4j.model.IRI SKOS_ALT_LABEL
    • SCHEMA_ABOUT

      public static final org.eclipse.rdf4j.model.IRI SCHEMA_ABOUT
    • SCHEMA_ARTICLE

      public static final org.eclipse.rdf4j.model.IRI SCHEMA_ARTICLE
    • SCHEMA_DESCRIPTION

      public static final org.eclipse.rdf4j.model.IRI SCHEMA_DESCRIPTION
    • SCHEMA_IN_LANGUAGE

      public static final org.eclipse.rdf4j.model.IRI SCHEMA_IN_LANGUAGE
    • PROV_WAS_DERIVED_FROM

      public static final org.eclipse.rdf4j.model.IRI PROV_WAS_DERIVED_FROM
    • WB_ITEM

      public static final org.eclipse.rdf4j.model.IRI WB_ITEM
    • WB_REFERENCE

      public static final org.eclipse.rdf4j.model.IRI WB_REFERENCE
    • WB_PROPERTY

      public static final org.eclipse.rdf4j.model.IRI WB_PROPERTY
    • WB_STATEMENT

      public static final org.eclipse.rdf4j.model.IRI WB_STATEMENT
    • WB_QUANTITY_VALUE

      public static final org.eclipse.rdf4j.model.IRI WB_QUANTITY_VALUE
    • WB_TIME_VALUE

      public static final org.eclipse.rdf4j.model.IRI WB_TIME_VALUE
    • WB_GLOBE_COORDINATES_VALUE

      public static final org.eclipse.rdf4j.model.IRI WB_GLOBE_COORDINATES_VALUE
    • WB_PROPERTY_TYPE

      public static final org.eclipse.rdf4j.model.IRI WB_PROPERTY_TYPE
    • WB_GEO_GLOBE

      public static final org.eclipse.rdf4j.model.IRI WB_GEO_GLOBE
    • WB_GEO_LATITUDE

      public static final org.eclipse.rdf4j.model.IRI WB_GEO_LATITUDE
    • WB_GEO_LONGITUDE

      public static final org.eclipse.rdf4j.model.IRI WB_GEO_LONGITUDE
    • WB_GEO_PRECISION

      public static final org.eclipse.rdf4j.model.IRI WB_GEO_PRECISION
    • WB_TIME

      public static final org.eclipse.rdf4j.model.IRI WB_TIME
    • WB_TIME_PRECISION

      public static final org.eclipse.rdf4j.model.IRI WB_TIME_PRECISION
    • WB_TIME_TIMEZONE

      public static final org.eclipse.rdf4j.model.IRI WB_TIME_TIMEZONE
    • WB_TIME_CALENDAR_MODEL

      public static final org.eclipse.rdf4j.model.IRI WB_TIME_CALENDAR_MODEL
    • WB_QUANTITY_AMOUNT

      public static final org.eclipse.rdf4j.model.IRI WB_QUANTITY_AMOUNT
    • WB_QUANTITY_LOWER_BOUND

      public static final org.eclipse.rdf4j.model.IRI WB_QUANTITY_LOWER_BOUND
    • WB_QUANTITY_UPPER_BOUND

      public static final org.eclipse.rdf4j.model.IRI WB_QUANTITY_UPPER_BOUND
    • WB_QUANTITY_UNIT

      public static final org.eclipse.rdf4j.model.IRI WB_QUANTITY_UNIT
    • OGC_LOCATION

      public static final org.eclipse.rdf4j.model.IRI OGC_LOCATION
    • WB_RANK

      public static final org.eclipse.rdf4j.model.IRI WB_RANK
    • WB_BEST_RANK

      public static final org.eclipse.rdf4j.model.IRI WB_BEST_RANK
    • WB_BADGE

      public static final org.eclipse.rdf4j.model.IRI WB_BADGE
  • Constructor Details

    • RdfWriter

      public RdfWriter(org.eclipse.rdf4j.rio.RDFFormat format, OutputStream output) throws org.eclipse.rdf4j.rio.UnsupportedRDFormatException
      Throws:
      org.eclipse.rdf4j.rio.UnsupportedRDFormatException
    • RdfWriter

      public RdfWriter(org.eclipse.rdf4j.rio.RDFWriter writer)
  • Method Details

    • getTripleCount

      public long getTripleCount()
    • start

      public void start() throws org.eclipse.rdf4j.rio.RDFHandlerException
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException
    • finish

      public void finish() throws org.eclipse.rdf4j.rio.RDFHandlerException
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException
    • getFreshBNode

      public org.eclipse.rdf4j.model.BNode getFreshBNode()
    • getUri

      public org.eclipse.rdf4j.model.IRI getUri(String uri)
      Creates a IRI object for the given IRI string. Callers who use this with user-provided data should check for exceptions.
      Parameters:
      uri - the IRI string
      Returns:
      the IRI object
      Throws:
      IllegalArgumentException - if the string is not a valid absolute URI.
    • getLiteral

      public org.eclipse.rdf4j.model.Literal getLiteral(String value)
    • getLiteral

      public org.eclipse.rdf4j.model.Literal getLiteral(String value, String languageCode)
    • getLiteral

      public org.eclipse.rdf4j.model.Literal getLiteral(String value, org.eclipse.rdf4j.model.IRI datatypeUri)
    • writeNamespaceDeclaration

      public void writeNamespaceDeclaration(String prefix, String uri) throws org.eclipse.rdf4j.rio.RDFHandlerException
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException
    • writeTripleStringObject

      public void writeTripleStringObject(org.eclipse.rdf4j.model.Resource subject, org.eclipse.rdf4j.model.IRI predicate, String objectLiteral) throws org.eclipse.rdf4j.rio.RDFHandlerException
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException
    • writeTripleIntegerObject

      public void writeTripleIntegerObject(org.eclipse.rdf4j.model.Resource subject, org.eclipse.rdf4j.model.IRI predicate, int objectLiteral) throws org.eclipse.rdf4j.rio.RDFHandlerException
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException
    • writeTripleUriObject

      public void writeTripleUriObject(String subjectUri, org.eclipse.rdf4j.model.IRI predicate, String objectUri) throws org.eclipse.rdf4j.rio.RDFHandlerException
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException
    • writeTripleUriObject

      public void writeTripleUriObject(org.eclipse.rdf4j.model.Resource subject, org.eclipse.rdf4j.model.IRI predicate, String objectUri) throws org.eclipse.rdf4j.rio.RDFHandlerException
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException
    • writeTripleValueObject

      public void writeTripleValueObject(String subjectUri, org.eclipse.rdf4j.model.IRI predicate, org.eclipse.rdf4j.model.Value object) throws org.eclipse.rdf4j.rio.RDFHandlerException
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException
    • writeTripleValueObject

      public void writeTripleValueObject(org.eclipse.rdf4j.model.Resource subject, org.eclipse.rdf4j.model.IRI predicate, org.eclipse.rdf4j.model.Value object) throws org.eclipse.rdf4j.rio.RDFHandlerException
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException
    • writeTripleLiteralObject

      public void writeTripleLiteralObject(org.eclipse.rdf4j.model.Resource subject, org.eclipse.rdf4j.model.IRI predicate, String objectLexicalValue, org.eclipse.rdf4j.model.IRI datatype) throws org.eclipse.rdf4j.rio.RDFHandlerException
      Throws:
      org.eclipse.rdf4j.rio.RDFHandlerException