Package org.topbraid.jenax.util
Class RDFLabels
java.lang.Object
org.topbraid.jenax.util.RDFLabels
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendTemplateCallLabel(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 RDFLabelsget()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 voidReplaces the singleton to a subclass with different behavior.static StringunCamelCase(String camelCase) Takes a string that is (likely) in camelCase and attempts to produce an un-camel-cased version of that.
-
Constructor Details
-
RDFLabels
public RDFLabels()
-
-
Method Details
-
get
Gets the singleton instance of this class.- Returns:
- the singleton
-
set
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
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
Gets a "human-readable" label for a given Resource. This checks for any existing rdfs:label, otherwise falls back togetLabel().- Parameters:
resource- the resource to get the label for- Returns:
- the label (never null)
-
getLabel
Gets the label for a given Resource.- Parameters:
resource- the Resource to get the label of- Returns:
- the label (never null)
-
getNodeLabel
-
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 tolabelTemplate- the labelTemplateargs- the arguments a Map of pre-bound variables (supplied arguments)
-
unCamelCase
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
-