public final class Uri
extends java.lang.Object
Syntax of valid DMT URIs:
'/'
\u002F) is the separator of the node names.
Slashes used in node name must therefore be escaped using a backslash slash (
"\/"
). The backslash must be escaped with a double backslash sequence. A
backslash found must be ignored when it is not followed by a slash or
backslash.
[-a-zA-Z0-9_.!~*'()]
are most efficient.
'/'
\u002F). This implies that the root node must be denoted as
"."
and not "./"
.
"../"
to traverse the tree upwards.
"./"
must not be used
anywhere else but in the beginning of a URI.
Modifier and Type | Class and Description |
---|---|
private static class |
Uri.ImplHolder |
Modifier and Type | Field and Description |
---|---|
private static char[] |
BASE_64_TABLE |
private static int |
MINIMAL_SEGMENT_LENGTH_LIMIT |
private static java.lang.String |
SEGMENT_LENGTH_LIMIT_PROPERTY |
private static int |
segmentLengthLimit |
Modifier | Constructor and Description |
---|---|
private |
Uri()
A private constructor to suppress the default public constructor.
|
Modifier and Type | Method and Description |
---|---|
private static byte[] |
digestMessage(byte[] byteStream) |
private static java.lang.String |
getHash(java.lang.String from) |
static int |
getMaxSegmentNameLength()
Returns the maximum allowed length of a URI segment.
|
static int |
getMaxUriLength()
Returns the maximum allowed length of a URI.
|
static int |
getMaxUriSegments()
Returns the maximum allowed number of URI segments.
|
private static int |
getSegmentLength(java.lang.String segment)
This method returns the length of a URI segment.
|
static boolean |
isAbsoluteUri(java.lang.String uri)
Checks whether the specified URI is an absolute URI.
|
static boolean |
isValidUri(java.lang.String uri)
Checks whether the specified URI is valid.
|
static java.lang.String |
mangle(java.lang.String nodeName)
Returns a node name that is valid for the tree operation methods, based
on the given node name.
|
(package private) static java.lang.String |
mangle(java.lang.String nodeName,
int limit) |
static java.lang.String[] |
toPath(java.lang.String uri)
Split the specified URI along the path separator '/' charaters and return
an array of URI segments.
|
static java.lang.String |
toUri(java.lang.String[] path)
Construct a URI from the specified URI segments.
|
private static final java.lang.String SEGMENT_LENGTH_LIMIT_PROPERTY
private static final int MINIMAL_SEGMENT_LENGTH_LIMIT
private static final int segmentLengthLimit
private static final char[] BASE_64_TABLE
private Uri()
public static java.lang.String mangle(java.lang.String nodeName)
mangle
method call.
Node name mangling is needed in the following cases:
A node name that does not suffer from either of these problems is guaranteed to remain unchanged by this method. Therefore the client may skip the mangling if the node name is known to be valid (though it is always safe to call this method).
The method returns the normalized nodeName
as described
below. Invalid node names are normalized in different ways, depending on
the cause. If the length of the name does not exceed the limit, but the
name contains '/' or '\' characters, then these are simply escaped by
inserting an additional '\' before each occurrence. If the length of the
name does exceed the limit, the following mechanism is used to normalize
it:
nodeName
- the node name to be mangled (if necessary), must not be
null
or emptyjava.lang.NullPointerException
- if nodeName
is
null
java.lang.IllegalArgumentException
- if nodeName
is emptypublic static java.lang.String toUri(java.lang.String[] path)
If the specified path is an empty array then an empty URI
(""
) is returned.
path
- a possibly empty array of URI segments, must not be
null
java.lang.NullPointerException
- if the specified path or any of its
segments are null
java.lang.IllegalArgumentException
- if the specified path contains too many
or malformed segments or the resulting URI is too longprivate static int getSegmentLength(java.lang.String segment)
The method verifies that the URI segment is well-formed.
segment
- the URI segmentjava.lang.NullPointerException
- if the specified segment is
null
java.lang.IllegalArgumentException
- if the specified URI segment is
malformedpublic static java.lang.String[] toPath(java.lang.String uri)
uri
- the URI to be split, must not be null
java.lang.NullPointerException
- if the specified URI is null
java.lang.IllegalArgumentException
- if the specified URI is malformedpublic static int getMaxUriSegments()
The return value of Integer.MAX_VALUE
indicates that there
is no upper limit on the number of URI segments.
public static int getMaxUriLength()
The return value of Integer.MAX_VALUE
indicates that there
is no upper limit on the length of URIs.
public static int getMaxSegmentNameLength()
The return value of Integer.MAX_VALUE
indicates that there
is no upper limit on the length of segment names.
public static boolean isAbsoluteUri(java.lang.String uri)
uri
- the URI to be checked, must not be null
and must
contain a valid URIjava.lang.NullPointerException
- if the specified URI is null
java.lang.IllegalArgumentException
- if the specified URI is malformedpublic static boolean isValidUri(java.lang.String uri)
null
;
getMaxUriLength()
;
getMaxUriSegments()
segments;
getMaxSegmentNameLength()
.
getMaxUriLength()
and
getMaxSegmentNameLength()
methods.uri
- the URI to be validatedstatic java.lang.String mangle(java.lang.String nodeName, int limit)
private static java.lang.String getHash(java.lang.String from)
private static byte[] digestMessage(byte[] byteStream)