public class ShortNameRenderer extends Object
ShortnameService
to add the
capability of consistently generating new short names for URIs that do
not yet have declared short names.Constructor and Description |
---|
ShortNameRenderer(ShortnameService sns,
Iterable<Binding<com.hp.hpl.jena.rdf.model.Resource>> bindings)
Construct a short name renderer using an existing short name service as a
provider of pre-existing short names.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addBindings(Iterable<Binding<com.hp.hpl.jena.rdf.model.Resource>> bindings)
Initialise the local short names map with the given bindings
|
protected void |
addShortName(String shortName,
String uri)
Add a single local binding.
|
com.hp.hpl.jena.rdf.model.Resource |
asResource(com.hp.hpl.jena.rdf.model.RDFNode r)
If r is a resource, answer r; if it is a literal with lexical form l,
answer normaliseResource(l); otherwise throw an API exception.
|
com.hp.hpl.jena.rdf.model.Resource |
asResource(String s)
Answer a resource with uri = expand(s).
|
String |
expand(String shortName)
Return the expansion of
shortName to a URI. |
boolean |
hasShortNameService() |
boolean |
isDatatype(String type)
Answer true iff the named type has been declared (or is by default)
to be a datatype (rather than an object type).
|
boolean |
isKnownShortnamePath(String path) |
protected String |
lookupShortName(String shortName)
Look up an existing short name with no side effects.
|
protected String |
lookupURI(String uri)
Look to see if we have an existing short name for a given URI, or
return null
|
protected com.hp.hpl.jena.shared.PrefixMapping |
prefixMapping()
Return a prefix mapping, defaulting to the prefix mapping of the
wrapped short name service.
|
String |
shorten(String uri)
Return a short name, memoising by default.
|
String |
shorten(String uri,
boolean memoise)
Return the shortened name for the given
uri . |
protected String |
shortForm(String uri)
Return the short-form of a URI, delegating the work to
Transcoding |
ShortnameService |
shortNameService()
Return the wrapped short name service, or throw an exception
|
ShortnameService |
shortNameService(boolean required)
Return the wrapped short name service; only throw an exception
if
required is true. |
protected void |
storeShortName(String shortName,
String uri)
Add a new shortname - URI pair
|
public ShortNameRenderer(ShortnameService sns, Iterable<Binding<com.hp.hpl.jena.rdf.model.Resource>> bindings)
sns
- Existing short name service, or nullpublic ShortnameService shortNameService()
public ShortnameService shortNameService(boolean required)
required
is true.required
- If true, wrapped service must be presentEldaException
public boolean isDatatype(String type)
public com.hp.hpl.jena.rdf.model.Resource asResource(com.hp.hpl.jena.rdf.model.RDFNode r)
public com.hp.hpl.jena.rdf.model.Resource asResource(String s)
public String expand(String shortName)
shortName
to a URI. If
shortName
is not a recognised short name, it is
return unchanged.shortName
- The name to expandpublic String shorten(String uri, boolean memoise)
uri
. If a short name
exists in the wrapped short name service, use that by preference. Otherwise,
compress using the usual approach, and remember the shortening locally
if memoise
is true.uri
- The URI to be shortenedmemoise
- If true, remember any newly created short formpublic String shorten(String uri)
shorten(String, boolean)
public boolean hasShortNameService()
public boolean isKnownShortnamePath(String path)
protected void addBindings(Iterable<Binding<com.hp.hpl.jena.rdf.model.Resource>> bindings)
bindings
- An initial list of bindings, e.g. from the page objectprotected void addShortName(String shortName, String uri)
shortName
- uri
- protected String lookupShortName(String shortName)
shortName
- The shortname key to look upprotected String lookupURI(String uri)
uri
- The URI to contractprotected void storeShortName(String shortName, String uri)
protected String shortForm(String uri)
Transcoding
protected com.hp.hpl.jena.shared.PrefixMapping prefixMapping()
Copyright © 2014. All Rights Reserved.