IriUtils
Utilities for working with IRIs (Internationalized Resource Identifiers) in the context of the Solid protocol.
Java's URI class only handles a subset of valid IRIs (ASCII-range). These helpers provide basic normalization and validation aligned with the Solid Protocol's IRI requirements.
Spec: https://solidproject.org/TR/protocol — IRI handling
Functions
Returns the canonical form of iri for equivalence comparison: lower-cases the scheme and host, removes ./.. dot-segments, and normalizes percent-encoding via URI. Path case, the trailing slash, and any fragment are preserved — a file x and a container x/, or two different #fragments, are genuinely distinct resources/agents and must NOT be unified. Falls back to the raw string if iri doesn't parse.
Escapes iri for safe emission inside <...> angle brackets in N-Triples / Turtle / N3. The IRIREF production forbids control characters (U+0000–U+0020) and < > " { } | ^ \` unescaped; we replace each with a \\uXXXX UCHAR so a hostile or merely unusual IRI can't break out of the term and corrupt the serialized document. Returns the input unchanged when it contains none of those characters.
Returns true if iri identifies an LDP container (URI ends with /). Per the Solid Protocol, the / character indicates a hierarchical container relationship.
Returns the last path segment of iri (the resource name), excluding any trailing slash.
Strips the trailing slash from iri if present.
Appends a trailing slash to iri if absent, returning a container IRI.