Class RDFLabels

java.lang.Object
org.topbraid.jenax.util.RDFLabels

public class RDFLabels extends Object
A singleton that is used to render resources into strings. By default this displays qnames (if possible). Can be changed, for example, to switch to displaying rdfs:labels instead of qnames etc.
Author:
Holger Knublauch
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    appendTemplateCallLabel(StringBuffer buffer, String labelTemplate, Map<String,org.apache.jena.rdf.model.RDFNode> args)
    Renders a template call's label template into a label by inserting the evaluated SPARQL expressions into appropriate spaces marked with {expression}.
    static RDFLabels
    get()
    Gets the singleton instance of this class.
    getBlankNodeLabel(org.apache.jena.rdf.model.Resource resource)
    Gets a "human-readable" label for a blank node, e.g.
    getCustomizedLabel(org.apache.jena.rdf.model.Resource resource)
    Gets a "human-readable" label for a given Resource.
    getLabel(org.apache.jena.rdf.model.Resource resource)
    Gets the label for a given Resource.
    getNodeLabel(org.apache.jena.rdf.model.RDFNode node)
     
    static void
    set(RDFLabels value)
    Replaces the singleton to a subclass with different behavior.
    static String
    unCamelCase(String camelCase)
    Takes a string that is (likely) in camelCase and attempts to produce an un-camel-cased version of that.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RDFLabels

      public RDFLabels()
  • Method Details

    • get

      public static RDFLabels get()
      Gets the singleton instance of this class.
      Returns:
      the singleton
    • set

      public static void set(RDFLabels value)
      Replaces the singleton to a subclass with different behavior. This is used by TopBraid, which has its own rendering engine.
      Parameters:
      value - the new engine
    • getBlankNodeLabel

      public String getBlankNodeLabel(org.apache.jena.rdf.model.Resource resource)
      Gets a "human-readable" label for a blank node, e.g. Manchester Syntax for OWL restrictions. The default implementation doesn't do much yet it's overloaded in TopBraid.
      Parameters:
      resource - the blank node resource to get the label for
      Returns:
      a label for the bnode
    • getCustomizedLabel

      public String getCustomizedLabel(org.apache.jena.rdf.model.Resource resource)
      Gets a "human-readable" label for a given Resource. This checks for any existing rdfs:label, otherwise falls back to getLabel().
      Parameters:
      resource - the resource to get the label for
      Returns:
      the label (never null)
    • getLabel

      public String getLabel(org.apache.jena.rdf.model.Resource resource)
      Gets the label for a given Resource.
      Parameters:
      resource - the Resource to get the label of
      Returns:
      the label (never null)
    • getNodeLabel

      public String getNodeLabel(org.apache.jena.rdf.model.RDFNode node)
    • appendTemplateCallLabel

      public static void appendTemplateCallLabel(StringBuffer buffer, String labelTemplate, Map<String,org.apache.jena.rdf.model.RDFNode> args)
      Renders a template call's label template into a label by inserting the evaluated SPARQL expressions into appropriate spaces marked with {expression}. Currently only simple variables are supported, e.g. {?test }.
      Parameters:
      buffer - the StringBuffer to write to
      labelTemplate - the labelTemplate
      args - the arguments a Map of pre-bound variables (supplied arguments)
    • unCamelCase

      public static String unCamelCase(String camelCase)
      Takes a string that is (likely) in camelCase and attempts to produce an un-camel-cased version of that. Useful to generate labels from local names.
      Parameters:
      camelCase - the input String
      Returns:
      the generated String