GeoPubby
Version 0.1.0.0
|
IRI rewriter that implements special behaviour for Pubby: Any IRI within a certain namespace (the namespace that Pubby is serving) will have characters that interfer with IRI derferencing %-escaped. More...
Public Member Functions | |
PubbyIRIEscaper (String namespace, boolean encodeURIsToIRIs) | |
String | rewrite (String absoluteIRI) |
Rewrites an IRI. More... | |
String | unrewrite (String absoluteIRI) |
Rewrites an IRI. More... | |
Property | rewrite (Property original) |
Resource | rewrite (Resource original) |
Model | rewrite (Model original) |
Rewrites the RDF graph in a Jena model by returning a new in-memory model that contains all statements from the original with any IRIs rewritten. More... | |
Map< Property, Integer > | rewrite (Map< Property, Integer > original) |
Property | unrewrite (Property rewritten) |
Resource | unrewrite (Resource rewritten) |
Static Public Member Functions | |
static String | escapeSpecialCharacters (String absoluteIRI) |
Escapes any characters that have special meaning in IRIs so that they are safe for use in a Pubby path. More... | |
static String | unescapeSpecialCharacters (String absoluteIRI) |
Reverses the escaping done by unescapeSpecialCharacters(String). More... | |
static IRIRewriter | createNamespaceBased (final String originalNamespace, final String rewrittenNamespace) |
Creates a new rewriter that rewrites all IRIs starting with a given namespace by replacing that namespace with another namespace. More... | |
static IRIRewriter | chain (final IRIRewriter rewriter1, final IRIRewriter rewriter2) |
Creates an IRIRewriter that applies two existing IRIRewriters. More... | |
Static Public Attributes | |
static final IRIRewriter | identity |
The trivial IRI rewriter that returns IRIs unmodified. More... | |
Private Attributes | |
final boolean | encodeURIsToIRIs |
IRI rewriter that implements special behaviour for Pubby: Any IRI within a certain namespace (the namespace that Pubby is serving) will have characters that interfer with IRI derferencing %-escaped.
Any IRI outside that namespace is left alone. The escaped characters are '#' and '?'.
This rewriter can also encode URIs to IRIs as part of the rewriting process. Pubby always wants to work on IRIs. Most data sources use IRIs. Some don't, and all characters outside US-ASCII appear %-encoded in their IRIs. If configured to encode URIs to IRIs, then in the rewritten identifiers we will see proper Unicode characters instead of %-encoded sequences. Note that we do this only within the namespace.
TODO: The URI-to-IRI rewriting should probably be a separate class.
PubbyIRIEscaper | ( | String | namespace, |
boolean | encodeURIsToIRIs | ||
) |
References PubbyIRIEscaper.encodeURIsToIRIs.
|
staticinherited |
Creates an IRIRewriter that applies two existing IRIRewriters.
References IRIRewriter.identity, IRIRewriter.rewrite(), and IRIRewriter.unrewrite().
Referenced by Dataset.buildDataSource().
|
staticinherited |
Creates a new rewriter that rewrites all IRIs starting with a given namespace by replacing that namespace with another namespace.
Any IRIs that don't start with theat namespace are returned unchanged. For example, if original namespace is https://example.com/
and replacement namespace is http://localhost:8080/
, then the IRI https://example.com/foo/bar
will be rewritten to http://localhost:8080/foo/bar
, and the IRI https://foo.example.org/bar
will be rewritten to itself as it doesn't start with the original namespace.
originalNamespace | The namespace to be replaced |
rewrittenNamespace | The replacement namespace |
References IRIRewriter.identity, IRIRewriter.rewrite(), and IRIRewriter.unrewrite().
Referenced by Dataset.buildDataSource().
|
static |
Escapes any characters that have special meaning in IRIs so that they are safe for use in a Pubby path.
Referenced by HypermediaControls.getPathURL(), HypermediaControls.getPubbyPath(), and PubbyIRIEscaper.rewrite().
|
inherited |
References IRIRewriter.rewrite().
|
inherited |
Rewrites the RDF graph in a Jena model by returning a new in-memory model that contains all statements from the original with any IRIs rewritten.
It rewrites IRIs in subject, predicate, and object position. Also rewrites the namespace prefix mappings, if any are present.
original | An RDF graph in Jena model form |
References IRIRewriter.rewrite().
|
inherited |
References IRIRewriter.rewrite().
|
inherited |
References IRIRewriter.rewrite().
String rewrite | ( | String | absoluteIRI | ) |
Rewrites an IRI.
Any | absolute IRI |
Reimplemented from IRIRewriter.
References PubbyIRIEscaper.encodeURIsToIRIs, PubbyIRIEscaper.escapeSpecialCharacters(), and IRIEncoder.toIRI().
|
static |
Reverses the escaping done by unescapeSpecialCharacters(String).
Referenced by HypermediaControls.createFromPubbyPath(), ValuesBaseServlet.doGet(), and PubbyIRIEscaper.unrewrite().
|
inherited |
References IRIRewriter.unrewrite().
|
inherited |
References IRIRewriter.unrewrite().
String unrewrite | ( | String | absoluteIRI | ) |
Rewrites an IRI.
For any valid IRI,
Any | absolute IRI |
Reimplemented from IRIRewriter.
References PubbyIRIEscaper.encodeURIsToIRIs, IRIEncoder.toURI(), and PubbyIRIEscaper.unescapeSpecialCharacters().
|
private |
Referenced by PubbyIRIEscaper.PubbyIRIEscaper(), PubbyIRIEscaper.rewrite(), and PubbyIRIEscaper.unrewrite().
|
staticinherited |
The trivial IRI rewriter that returns IRIs unmodified.
We override all methods for efficiency.
Referenced by Dataset.buildDataSource(), IRIRewriter.chain(), and IRIRewriter.createNamespaceBased().