public final class Uri extends 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 | Field and Description |
---|---|
static String |
PATH_SEPARATOR
This constant stands for a string identifying the path separator in the
DmTree ("/").
|
static char |
PATH_SEPARATOR_CHAR
This constant stands for a char identifying the path separator in the
DmTree ('/').
|
static String |
ROOT_NODE
This constant stands for a string identifying the root of the DmTree
(".").
|
static char |
ROOT_NODE_CHAR
This constant stands for a char identifying the root of the DmTree ('.').
|
Modifier and Type | Method and Description |
---|---|
static String |
decode(String nodeName)
Decode the node name so that back slash and forward slash are unescaped
from a back slash.
|
static String |
encode(String nodeName)
Encode the node name so that back slash and forward slash are escaped
with a back slash.
|
static boolean |
isAbsoluteUri(String uri)
Checks whether the specified URI is an absolute URI.
|
static boolean |
isValidUri(String uri)
Checks whether the specified URI is valid.
|
static String |
mangle(String nodeName)
Returns a node name that is valid for the tree operation methods, based
on the given node name.
|
static String[] |
toPath(String uri)
Split the specified URI along the path separator '/' characters and
return an array of URI segments.
|
static String |
toUri(String[] path)
Construct a URI from the specified URI segments.
|
public static final String ROOT_NODE
public static final char ROOT_NODE_CHAR
public static final String PATH_SEPARATOR
public static final char PATH_SEPARATOR_CHAR
public static String mangle(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 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 emptyNullPointerException
- if nodeName
is null
IllegalArgumentException
- if nodeName
is emptypublic static String toUri(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
NullPointerException
- if the specified path or any of its segments
are null
IllegalArgumentException
- if the specified path contains too many
or malformed segments or the resulting URI is too longpublic static String[] toPath(String uri)
uri
- the URI to be split, must not be null
NullPointerException
- if the specified URI is null
IllegalArgumentException
- if the specified URI is malformedpublic static boolean isAbsoluteUri(String uri)
uri
- the URI to be checked, must not be null
and must
contain a valid URINullPointerException
- if the specified URI is null
IllegalArgumentException
- if the specified URI is malformedpublic static String encode(String nodeName)
decode(String)
.nodeName
- the node name to be encodedpublic static String decode(String nodeName)
nodeName
- the node name to be decodedpublic static boolean isValidUri(String uri)
null
;getMaxUriLength()
and
getMaxSegmentNameLength()
methods.uri
- the URI to be validatedCopyright © Contributors to the Eclipse Foundation Licensed under the Eclipse Foundation Specification License – v1.0