Class RdfSerializer.Builder<SELF extends RdfSerializer.Builder<SELF>>

Direct Known Subclasses:
RdfSerializer.DefaultBuilder
Enclosing class:
RdfSerializer

public abstract static class RdfSerializer.Builder<SELF extends RdfSerializer.Builder<SELF>> extends WriterSerializer.Builder<SELF>
Builder class.
  • Constructor Details

    • Builder

      protected Builder()
      Constructor, default settings.
    • Builder

      protected Builder(RdfSerializer.Builder<?> copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The builder to copy from.
      Cannot be null.
    • Builder

      protected Builder(RdfSerializer copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The bean to copy from.
      Cannot be null.
  • Method Details

    • addBeanTypesRdf

      Add "_type" properties when needed.

      If true, then "_type" properties will be added to beans if their type cannot be inferred through reflection.

      When present, this value overrides the Serializer.Builder#addBeanTypes() setting and is provided to customize the behavior of specific serializers in a SerializerSet.

      Returns:
      This object.
    • addBeanTypesRdf

      public SELF addBeanTypesRdf(boolean value)
      Same as addBeanTypesRdf() but allows you to explicitly specify the value.
      Parameters:
      value - The value for this setting.
      Returns:
      This object.
    • addLiteralTypes

      Add XSI data types to non-String literals.

      Shortcut for calling addLiteralTypes(true).

      Returns:
      This object.
    • addLiteralTypes

      public SELF addLiteralTypes(boolean value)
      Add XSI data types to non-String literals.

      Shortcut for calling addLiteralTypes(true).

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • addRootProperty

      Add RDF root identifier property to root node.

      When enabled an RDF property http://www.apache.org/juneau/root is added with a value of "true" to identify the root node in the graph.
      This helps locate the root node during parsing.

      If disabled, the parser has to search through the model to find any resources without incoming predicates to identify root notes, which can introduce a considerable performance degradation.

      Returns:
      This object.
    • addRootProperty

      public SELF addRootProperty(boolean value)
      Add RDF root identifier property to root node.

      When enabled an RDF property http://www.apache.org/juneau/root is added with a value of "true" to identify the root node in the graph.
      This helps locate the root node during parsing.

      If disabled, the parser has to search through the model to find any resources without incoming predicates to identify root notes, which can introduce a considerable performance degradation.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • build

      public RdfSerializer build()
      Description copied from class: Context.Builder
      Build the object.
      Overrides:
      build in class WriterSerializer.Builder<SELF extends RdfSerializer.Builder<SELF>>
      Returns:
      The built object.
    • collectionFormat

      RDF format for representing collections and arrays.
      • "DEFAULT" - Default format. The default is an RDF Sequence container.
      • "SEQ" - RDF Sequence container.
      • "BAG" - RDF Bag container.
      • "LIST" - RDF List container.
      • "MULTI_VALUED" - Multi-valued properties.
      Notes:
      • If you use "BAG" or "MULTI_VALUED", the order of the elements in the collection will get lost.
      Parameters:
      value - The new value for this setting.
      Cannot be null.
      Returns:
      This object.
    • copy

      public abstract SELF copy()
      Description copied from class: Context.Builder
      Copy creator.
      Specified by:
      copy in class WriterSerializer.Builder<SELF extends RdfSerializer.Builder<SELF>>
      Returns:
      A new mutable copy of this builder.
    • disableAutoDetectNamespaces

      Disable auto-detect namespace usage.

      Don't detect namespace usage before serialization.

      If enabled, then the data structure will first be crawled looking for namespaces that will be encountered before the root element is serialized.

      Returns:
      This object.
    • disableAutoDetectNamespaces

      public SELF disableAutoDetectNamespaces(boolean value)
      Disable auto-detect namespace usage.

      Don't detect namespace usage before serialization.

      If enabled, then the data structure will first be crawled looking for namespaces that will be encountered before the root element is serialized.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • disableUseXmlNamespaces

      Disable reuse of XML namespaces when RDF namespaces not specified.

      When enabled, namespaces defined using @XmlNs and Xml will not be inherited by the RDF serializers. Otherwise, namespaces will be defined using @RdfNs and @Rdf.

      Returns:
      This object.
    • disableUseXmlNamespaces

      public SELF disableUseXmlNamespaces(boolean value)
      Disable reuse of XML namespaces when RDF namespaces not specified.

      When enabled, namespaces defined using @XmlNs and Xml will not be inherited by the RDF serializers. Otherwise, namespaces will be defined using @RdfNs and @Rdf.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • hashKey

      public HashKey hashKey()
      Description copied from class: Context.Builder
      Returns the hashkey of this builder.

      Used to return previously instantiated context beans that have matching hashkeys. The HashKey object is suitable for use as a hashmap key of a map of context beans. A context bean is considered equivalent if the HashKey.equals(Object) method is the same.

      Overrides:
      hashKey in class WriterSerializer.Builder<SELF extends RdfSerializer.Builder<SELF>>
      Returns:
      The hashkey of this builder.
    • juneauBpNs

      public SELF juneauBpNs(Namespace value)
      Default XML namespace for bean properties.
      Parameters:
      value - The new value for this setting.
      The default is {j:'http://www.apache.org/juneaubp/'}.
      Cannot be null.
      Returns:
      This object.
    • juneauNs

      public SELF juneauNs(Namespace value)
      XML namespace for Juneau properties.
      Parameters:
      value - The new value for this setting.
      The default is {j:'http://www.apache.org/juneau/'}.
      Cannot be null.
      Returns:
      This object.
    • language

      public SELF language(String value)
      RDF language.

      Can be any of the following:

      • "RDF/XML"
      • "RDF/XML-ABBREV" (default)
      • "N-TRIPLE"
      • "N3" - General name for the N3 writer. Will make a decision on exactly which writer to use (pretty writer, plain writer or simple writer) when created. Default is the pretty writer but can be overridden with system property org.apache.jena.n3.N3JenaWriter.writer.
      • "N3-PP" - Name of the N3 pretty writer. The pretty writer uses a frame-like layout, with prefixing, clustering like properties and embedding one-referenced bNodes.
      • "N3-PLAIN" - Name of the N3 plain writer. The plain writer writes records by subject.
      • "N3-TRIPLES" - Name of the N3 triples writer. This writer writes one line per statement, like N-Triples, but does N3-style prefixing.
      • "TURTLE" - Turtle writer. http://www.dajobe.org/2004/01/turtle/
      See Also:
      Parameters:
      value - The new value for this setting.
      Cannot be null.
      Returns:
      This object.
    • looseCollections

      Collections should be serialized and parsed as loose collections.

      When specified, collections of resources are handled as loose collections of resources in RDF instead of resources that are children of an RDF collection (e.g. Sequence, Bag).

      Note that this setting is specialized for RDF syntax, and is incompatible with the concept of losslessly representing POJO models, since the tree structure of these POJO models are lost when serialized as loose collections.

      This setting is typically only useful if the beans being parsed into do not have a bean property annotated with @Rdf(beanUri=true).

      Example:

      WriterSerializer serializer = RdfSerializer .create() .xmlabbrev() .looseCollections() .build(); ReaderParser parser = RdfParser .create() .xml() .looseCollections() .build(); List<MyBean> list = createListOfMyBeans(); // Serialize to RDF/XML as loose resources String rdfXml = serializer.write(list); // Parse back into a Java collection list = parser.read(rdfXml, LinkedList.class, MyBean.class); MyBean[] beans = createArrayOfMyBeans(); // Serialize to RDF/XML as loose resources rdfXml = serializer.write(beans); // Parse back into a bean array beans = parser.read(rdfXml, MyBean[].class);

      Returns:
      This object.
    • looseCollections

      public SELF looseCollections(boolean value)
      Collections should be serialized and parsed as loose collections.

      When specified, collections of resources are handled as loose collections of resources in RDF instead of resources that are children of an RDF collection (e.g. Sequence, Bag).

      Note that this setting is specialized for RDF syntax, and is incompatible with the concept of losslessly representing POJO models, since the tree structure of these POJO models are lost when serialized as loose collections.

      This setting is typically only useful if the beans being parsed into do not have a bean property annotated with @Rdf(beanUri=true).

      Example:

      WriterSerializer serializer = RdfSerializer .create() .xmlabbrev() .looseCollections() .build(); ReaderParser parser = RdfParser .create() .xml() .looseCollections() .build(); List<MyBean> list = createListOfMyBeans(); // Serialize to RDF/XML as loose resources String rdfXml = serializer.write(list); // Parse back into a Java collection list = parser.read(rdfXml, LinkedList.class, MyBean.class); MyBean[] beans = createArrayOfMyBeans(); // Serialize to RDF/XML as loose resources rdfXml = serializer.write(beans); // Parse back into a bean array beans = parser.read(rdfXml, MyBean[].class);

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • n3

      public SELF n3()
      RDF language.

      Shortcut for calling language(LANG_N3)

      Returns:
      This object.
    • n3_disableAbbrevBaseUri

      N3/Turtle property: disableAbbrevBaseURI.

      Controls whether to use abbreviations <> or <#>.

      Returns:
      This object.
    • n3_disableAbbrevBaseUri

      public SELF n3_disableAbbrevBaseUri(boolean value)
      N3/Turtle property: disableAbbrevBaseURI.

      Controls whether to use abbreviations <> or <#>.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • n3_disableObjectLists

      N3/Turtle property: disableObjectLists.

      Don't print object lists as comma separated lists.

      Returns:
      This object.
    • n3_disableObjectLists

      public SELF n3_disableObjectLists(boolean value)
      N3/Turtle property: disableObjectLists.

      Don't print object lists as comma separated lists.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • n3_disableUseDoubles

      N3/Turtle property: disableUseDoubles.

      Disallow the use of doubles as 123.456.

      Returns:
      This object.
    • n3_disableUseDoubles

      public SELF n3_disableUseDoubles(boolean value)
      N3/Turtle property: disableUseDoubles.

      Disallow the use of doubles as 123.456.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • n3_disableUsePropertySymbols

      N3/Turtle property: disableUsePropertySymbols.

      Controls whether to use a, = and => in output

      Returns:
      This object.
    • n3_disableUsePropertySymbols

      public SELF n3_disableUsePropertySymbols(boolean value)
      N3/Turtle property: disableUsePropertySymbols.

      Controls whether to use a, = and => in output

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • n3_disableUseTripleQuotedStrings

      N3/Turtle property: disableUseTripleQuotedStrings.

      Disallow the use of """ to delimit long strings.

      Returns:
      This object.
    • n3_disableUseTripleQuotedStrings

      public SELF n3_disableUseTripleQuotedStrings(boolean value)
      N3/Turtle property: disableUseTripleQuotedStrings.

      Disallow the use of """ to delimit long strings.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • n3_indentProperty

      public SELF n3_indentProperty(int value)
      N3/Turtle property: indentProperty.

      Width to indent properties.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • n3_minGap

      public SELF n3_minGap(int value)
      N3/Turtle property: minGap.

      Minimum gap between items on a line.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • n3_propertyColumn

      public SELF n3_propertyColumn(int value)
      N3/Turtle property: propertyColumn.

      Width of the property column.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • n3_subjectColumn

      public SELF n3_subjectColumn(int value)
      N3/Turtle property: subjectColumn.

      If the subject is shorter than this value, the first property may go on the same line.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • n3_widePropertyLen

      public SELF n3_widePropertyLen(int value)
      N3/Turtle property: widePropertyLen.

      Width of the property column. Must be longer than propertyColumn.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • namespaces

      public SELF namespaces(Namespace... values)
      Default namespaces.

      The default list of namespaces associated with this serializer.

      Parameters:
      values - The new value for this setting.
      Cannot contain null values (will throw IllegalArgumentException).
      Returns:
      This object.
    • ntriple

      public SELF ntriple()
      RDF language.

      Shortcut for calling language(LANG_NTRIPLE)

      Returns:
      This object.
    • rdfxml_allowBadUris

      RDF/XML property: allowBadURIs.

      URIs in the graph are, by default, checked prior to serialization.

      Returns:
      This object.
    • rdfxml_allowBadUris

      public SELF rdfxml_allowBadUris(boolean value)
      RDF/XML property: allowBadURIs.

      URIs in the graph are, by default, checked prior to serialization.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_attributeQuoteChar

      public SELF rdfxml_attributeQuoteChar(char value)
      RDF/XML property: attributeQuoteChar.

      The XML attribute quote character.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_blockRules

      public SELF rdfxml_blockRules(String value)
      RDF/XML property: blockRules.

      A list of Resource or a String being a comma separated list of fragment IDs from {doc http://www.w3.org/TR/rdf-syntax-grammar RDF Syntax Grammar} indicating grammar rules that will not be used.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_disableShowDoctypeDeclaration

      RDF/XML property: disableShowDoctypeDeclaration.

      If disabled, an XML doctype declaration isn't included in the output. This declaration includes a !ENTITY declaration for each prefix mapping in the model, and any attribute value that starts with the URI of that mapping is written as starting with the corresponding entity invocation.

      Returns:
      This object.
    • rdfxml_disableShowDoctypeDeclaration

      RDF/XML property: disableShowDoctypeDeclaration.

      If disabled, an XML doctype declaration isn't included in the output. This declaration includes a !ENTITY declaration for each prefix mapping in the model, and any attribute value that starts with the URI of that mapping is written as starting with the corresponding entity invocation.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_embedding

      RDF/XML ARP property: error-mode.

      Sets ARP to look for RDF embedded within an enclosing XML document.

      See Also:
      • {doc ext.ARP/ARPOptions.html#setEmbedding(boolean) ARPOptions.setEmbedding(boolean)}
      Returns:
      This object.
    • rdfxml_embedding

      public SELF rdfxml_embedding(boolean value)
      RDF/XML ARP property: error-mode.

      Sets ARP to look for RDF embedded within an enclosing XML document.

      See Also:
      • {doc ext.ARP/ARPOptions.html#setEmbedding(boolean) ARPOptions.setEmbedding(boolean)}
      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_errorMode

      public SELF rdfxml_errorMode(String value)
      RDF/XML ARP property: error-mode.

      This allows a coarse-grained approach to control of error handling.

      • "default"
      • "lax"
      • "strict"
      • "strict-ignore"
      • "strict-warning"
      • "strict-error"
      • "strict-fatal"
      See Also:
      • {doc ext.ARP/ARPOptions.html#setDefaultErrorMode() ARPOptions.setDefaultErrorMode()}
      • {doc ext.ARP/ARPOptions.html#setLaxErrorMode() ARPOptions.setLaxErrorMode()}
      • {doc ext.ARP/ARPOptions.html#setStrictErrorMode() ARPOptions.setStrictErrorMode()}
      • {doc ext.ARP/ARPOptions.html#setStrictErrorMode(int) ARPOptions.setStrictErrorMode(int)}
      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_iriRules

      public SELF rdfxml_iriRules(String value)
      RDF/XML property: iri_rules.

      Set the engine for checking and resolving.

      • "lax" - The rules for RDF URI references only, which does permit spaces although the use of spaces is not good practice.
      • "strict" - Sets the IRI engine with rules for valid IRIs, XLink and RDF; it does not permit spaces in IRIs.
      • "iri" - Sets the IRI engine to IRI ({doc http://www.ietf.org/rfc/rfc3986.txt RFC 3986}, {doc http://www.ietf.org/rfc/rfc3987.txt RFC 3987}).
      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_longId

      public SELF rdfxml_longId()
      RDF/XML property: longId.

      Whether to use long ID's for anon resources. Short ID's are easier to read, but can run out of memory on very large models.

      Returns:
      This object.
    • rdfxml_longId

      public SELF rdfxml_longId(boolean value)
      RDF/XML property: longId.

      Whether to use long ID's for anon resources. Short ID's are easier to read, but can run out of memory on very large models.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_relativeUris

      RDF/XML property: relativeURIs.

      What sort of relative URIs should be used.

      A comma separate list of options:

      • "same-document" - Same-document references (e.g. "" or "#foo")
      • "network" - Network paths (e.g. "//example.org/foo" omitting the URI scheme)
      • "absolute" - Absolute paths (e.g. "/foo" omitting the scheme and authority)
      • "relative" - Relative path not beginning in "../"
      • "parent" - Relative path beginning in "../"
      • "grandparent" - Relative path beginning in "../../"

      The default value is "same-document, absolute, relative, parent". To switch off relative URIs use the value "". Relative URIs of any of these types are output where possible if and only if the option has been specified.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_showXmlDeclaration

      RDF/XML property: showXmlDeclaration.
      • "true" - Add XML Declaration to the output.
      • "false" - Don't add XML Declaration to the output.
      • "default" - Only add an XML Declaration when asked to write to an OutputStreamWriter that uses some encoding other than UTF-8 or UTF-16. In this case the encoding is shown in the XML declaration.
      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_tab

      public SELF rdfxml_tab(int value)
      RDF/XML property: tab.

      The number of spaces with which to indent XML child elements.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • rdfxml_xmlbase

      public SELF rdfxml_xmlbase(String value)
      RDF/XML property: xmlbase.

      The value to be included for an xml:base attribute on the root element in the file.

      Parameters:
      value - The new value for this setting.
      Returns:
      This object.
    • turtle

      public SELF turtle()
      RDF language.

      Shortcut for calling language(LANG_TURTLE)

      Returns:
      This object.
    • jsonLd

      public SELF jsonLd()
      RDF language.

      Shortcut for calling language(LANG_JSONLD)

      Returns:
      This object.
    • nQuads

      public SELF nQuads()
      RDF language.

      Shortcut for calling language(LANG_NQUADS)

      Returns:
      This object.
    • triG

      public SELF triG()
      RDF language.

      Shortcut for calling language(LANG_TRIG)

      Returns:
      This object.
    • triX

      public SELF triX()
      RDF language.

      Shortcut for calling language(LANG_TRIX)

      Returns:
      This object.
    • rdfJson

      public SELF rdfJson()
      RDF language.

      Shortcut for calling language(LANG_RDFJSON)

      Returns:
      This object.
    • xml

      public SELF xml()
      RDF language.

      Shortcut for calling language(LANG_RDF_XML)

      Returns:
      This object.
    • xmlabbrev

      public SELF xmlabbrev()
      RDF language.

      Shortcut for calling language(LANG_RDF_XML_ABBREV)

      Returns:
      This object.