public class TemplateBasedRandomIdGenerator extends Object implements RandomIdGenerator
RandomIdGenerator
contract. Its identifier is
"http://art.uniroma2.it/coda/converters/templateBasedRandIdGen".Modifier and Type | Class and Description |
---|---|
static class |
TemplateBasedRandomIdGenerator.RandCode |
RandomIdGenerator.PARAMETERS, RandomIdGenerator.XRoles
Modifier and Type | Field and Description |
---|---|
static String |
CONVERTER_URI |
static Properties |
defaultPropertyDescriptions |
static Properties |
defaultPropertyValues |
private static int |
MAX_GENERATION_ATTEMPTS |
static String |
PARAM_URI_RND_CODE_GENERATOR |
private static Pattern |
PLACEHOLDER_PATTERN |
private static Pattern |
PLACEHOLDER_START_PATTERN |
private static String |
RAND_REGEX |
private static String |
XROLE |
CONTRACT_URI
OSGI_SERVICE_PROPERTY_CONTRACT, OSGI_SERVICE_PROPERTY_CONVERTER, STATIC_FIELD_CONTRACT_URI, STATIC_FIELD_CONVERTER_URI
Constructor and Description |
---|
TemplateBasedRandomIdGenerator() |
Modifier and Type | Method and Description |
---|---|
private String |
escapeValue(String rawString) |
private String |
getPlaceholderValue(String ph,
Map<String,org.eclipse.rdf4j.model.Value> args) |
private String |
getRandomPart(CODAContext ctx,
String placheholder) |
private String |
getTemplate(CODAContext ctx,
String xRole)
Returns the template associated with the given
xRole . |
private String |
object2string(Object obj) |
private List<org.eclipse.rdf4j.model.Value> |
parseCollectionString(String collectionString) |
org.eclipse.rdf4j.model.IRI |
produceURI(CODAContext ctx,
String value)
An overload of
RandomIdGenerator.produceURI(CODAContext, String, String, Map) without an explicit xRole and
parameter map. |
org.eclipse.rdf4j.model.IRI |
produceURI(CODAContext ctx,
String value,
String xRole)
An overload of
RandomIdGenerator.produceURI(CODAContext, String, String, Map) without an explicit parameter map. |
org.eclipse.rdf4j.model.IRI |
produceURI(CODAContext ctx,
String value,
String xRole,
Map<String,org.eclipse.rdf4j.model.Value> args)
Returns a resource identifier produced randomly from the given inputs.
|
public static final String CONVERTER_URI
public static final Properties defaultPropertyValues
public static final Properties defaultPropertyDescriptions
public static final String PARAM_URI_RND_CODE_GENERATOR
private static final String RAND_REGEX
private static final String XROLE
private static final Pattern PLACEHOLDER_PATTERN
private static final Pattern PLACEHOLDER_START_PATTERN
private static final int MAX_GENERATION_ATTEMPTS
private String getRandomPart(CODAContext ctx, String placheholder)
public org.eclipse.rdf4j.model.IRI produceURI(CODAContext ctx, String value, String xRole, Map<String,org.eclipse.rdf4j.model.Value> args) throws ConversionException
RandomIdGenerator
xRole
holds the nature of the resource that will be identified with the given URI. Depending on the value of
the parameter xRole
, a conforming converter may generate differently shaped URIs, possibly
using specific arguments passed via the map args
.
For each specific xRole
, the client should provide some agreed-upon parameters to the
converters. This contract defines the following parameters:
concept
(for skos:Concept
s)
label
(optional): the accompanying preferred label of the skos:Concept (or
literal form of the accompanying xLabel)schemes
(optional): the concept schemes to which the concept is being
attached at the moment of its creation (serialized as a Turtle collection)conceptScheme
(for skos:ConceptScheme
s)
label
(optional): the accompanying preferred label of the skos:Concept (or
literal form of the accompanying xLabel)skosCollection
(for skos:Collection
s)
label
(optional): the accompanying preferred label of the skos:Collection (or
literal form of the accompanying xLabel)xLabel
(for skosxl:Labels
s)
lexicalForm
: the lexical form of the skosxl:LabellexicalizedResource
: the resource to which the skosxl:Label will be attached to
lexicalizationProperty
: the property used for attaching the labelxNote
skos:note
s)
value
: the content of the noteannotatedResource
: the resource being annotatednoteProperty
: the property used for annotationxRole
s are defined elsewhere by the party defining
that xRole
.
Users of this contract should always supply values for the required parameters associated with an
xRole
; therefore, they should not attempt to generate a URI for an xRole
unless they known what arguments are requested.
Conversely, it is a duty of the specific converter implementing this contract to verify that all
relevant information has been provided by the client. In fact, it is suggested that converters are
implemented defensively, that is to say they should:
xRole
s gracefully, by means some fallback strategyproduceURI
in interface RandomIdGenerator
ctx
- the conversion contextvalue
- the value seeding the generation of the identifier (ignored in this case)xRole
- an extension of the notion of role (see RDFResourceRolesEnum
), allowing for finer
grained distinctionsargs
- additional arguments, depending on the specific type of identifierConversionException
private String getPlaceholderValue(String ph, Map<String,org.eclipse.rdf4j.model.Value> args)
private List<org.eclipse.rdf4j.model.Value> parseCollectionString(String collectionString)
private String getTemplate(CODAContext ctx, String xRole)
xRole
.ctx
- xRole
- public org.eclipse.rdf4j.model.IRI produceURI(CODAContext ctx, String value, String xRole) throws ConverterException
RandomIdGenerator
RandomIdGenerator.produceURI(CODAContext, String, String, Map)
without an explicit parameter map.produceURI
in interface RandomIdGenerator
ConverterException
public org.eclipse.rdf4j.model.IRI produceURI(CODAContext ctx, String value) throws ConverterException
RandomIdGenerator
RandomIdGenerator.produceURI(CODAContext, String, String, Map)
without an explicit xRole and
parameter map.produceURI
in interface RandomIdGenerator
ConverterException
Copyright © 2022 ART Group, University of Rome, Tor Vergata. All rights reserved.