public class Namespaces
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_NS
The default namespace.
|
static java.lang.String |
owl_ns
Standard OWL namespace ("http://www.w3.org/2002/07/owl#")
|
static java.lang.String |
rdf_ns
Standard RDF namespace ("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
|
static java.lang.String |
rdfs_ns
Standard RDFS namespace ("http://www.w3.org/2000/01/rdf-schema#")
|
static java.lang.String |
xsd_ns
Standard XML Schema namespace ("http://www.w3.org/2001/XMLSchema#")
|
Constructor and Description |
---|
Namespaces() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
addDefault(java.lang.String resource)
Add the default namespace to a resource.
This method is really naive: it will prefix a string with the default namespace if the string does not contain the characters ":" or "#". If the URI already contains a prefix, the URI is returned as it. |
static java.lang.String |
contract(java.lang.String uri)
Try to replace a complete namespace by its prefix (if known) or remove the namespace if it's the default one.
|
static java.lang.String |
expand(java.lang.String uri)
Replace the namespace prefix with its expanded form, when known.
For instance, "xsd:boolean" will be returned as "http://www.w3.org/2001/XMLSchema#boolean" .If the URI doesn't contain any prefix or if the prefix is unknow, the URI is returned as it. |
static java.lang.String |
format(java.lang.String resource)
Formats a resource's namespace, adding the default one if none is specified.
This method is actually a simple shortcut for a call to both addDefault(String) and expand(String) . |
static com.hp.hpl.jena.util.iterator.Filter<com.hp.hpl.jena.ontology.OntProperty> |
getDefaultNsFilter()
Returns a filter to keep only properties in the default ORO namespace,
thus removing properties inferred from RDF or OWL models.
|
static java.lang.String |
getNamespace(java.lang.String ns)
Convert namespace shortcut in their expanded form (which includes a
trailing
# ).For instance: Namespaces.getNamespace("oro") returns http://www.owl-ontologies.com/openrobots.owl# |
static java.lang.String |
getPrefix(java.lang.String ns)
Convert expanded namespace to their shortcut (prefix) followed by ":" or to nothing if the namespace is the default namespace.
For instance: Namespaces.getPrefix("http://www.owl-ontologies.com/openrobots.owl#") returns oro |
static void |
loadNamespaces(java.util.Properties parameters) |
static java.lang.String |
prefixes()
Returns a list of commons namespace prefixes (currently, OWL, RDF, RDFS,
XSD, LAAS OpenRobots), in SPARQL format, to be included in SPARQL queries.
|
static void |
setDefault(java.lang.String defaultNS)
Set the default namespace.
This method is meant to be called at least once at application startup, to define a default namespace (from a configuration file, for instance). |
static java.lang.String |
toLightString(com.hp.hpl.jena.rdf.model.RDFNode res)
Convert a resource to its string representation and try to replace the namespace by its prefix (or remove it if it's the default one).
It uses contract(String) to replace or remove the namespace.If the prefix for the namespace is unknown, complete URI is returned. |
static java.lang.String |
toLightString(com.hp.hpl.jena.rdf.model.Statement stmt)
Applies
toLightString(RDFNode) to each members of a statement. |
public static final java.lang.String owl_ns
public static final java.lang.String rdf_ns
public static final java.lang.String rdfs_ns
public static final java.lang.String xsd_ns
public static java.lang.String DEFAULT_NS
public static java.lang.String prefixes()
PREFIX
part of a SPARQL request.public static java.lang.String getNamespace(java.lang.String ns)
#
).Namespaces.getNamespace("oro")
returns http://www.owl-ontologies.com/openrobots.owl#
ns
- One of the known namespace shortcut ("owl" for OWL namespace, "rdf" and "rdfs" for RDF, "xsd" for XML Schema, "oro" for OpenRobots)getPrefix(String)
public static java.lang.String getPrefix(java.lang.String ns)
Namespaces.getPrefix("http://www.owl-ontologies.com/openrobots.owl#")
returns oro
ns
- One of the known namespace (ending with "#").getNamespace(String)
public static java.lang.String expand(java.lang.String uri)
"xsd:boolean"
will be returned as "http://www.w3.org/2001/XMLSchema#boolean"
."true^^xsd:boolean"
will be transformed into true^^http://www.w3.org/2001/XMLSchema#boolean"
uri
- The resource URI with (or without) a namespace prefix, or the string representation of a literal.public static java.lang.String contract(java.lang.String uri)
expand(String)
.uri
- The resource to output as a string.public static java.lang.String toLightString(com.hp.hpl.jena.rdf.model.RDFNode res)
contract(String)
to replace or remove the namespace.res
- The RDFNode which is to output as a string.public static java.lang.String toLightString(com.hp.hpl.jena.rdf.model.Statement stmt)
toLightString(RDFNode)
to each members of a statement.stmt
- The statement to output as a string.public static java.lang.String addDefault(java.lang.String resource)
resource
- The resource URI with (or without) a namespace prefix, or the string representation of a literal.DEFAULT_NS
,
setDefault(String)
public static java.lang.String format(java.lang.String resource)
addDefault(String)
and expand(String)
.resource
- A string representating a resource (its lexical form).addDefault(String)
,
expand(String)
public static void setDefault(java.lang.String defaultNS)
defaultNS
- The expanded namespace.addDefault(String)
,
DEFAULT_NS
public static void loadNamespaces(java.util.Properties parameters)
public static com.hp.hpl.jena.util.iterator.Filter<com.hp.hpl.jena.ontology.OntProperty> getDefaultNsFilter()
ORO is a part of the OpenRobots framework.
openrobots@laas.fr
LAAS-CNRS 2009-2011