@Immutable public final class URN extends Object implements Comparable<URN>, Serializable
Usage is similar to URI or URL:
URN urn = new URN("urn:foo:A123,456");
assert urn.nid().equals("foo");
assert urn.nss().equals("A123,456");
NOTICE: the implementation is not fully compliant with RFC 2141. It will become compliant in one of our future versions. Once it becomes fully compliant this notice will be removed.
| Constructor and Description |
|---|
URN()
Public ctor (for JAXB mostly) that creates an "empty" URN.
|
URN(String text)
Public ctor.
|
URN(String nid,
String nss)
Public ctor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(URN urn) |
static URN |
create(String text)
Creates an instance of URN and throws a runtime exception if
its syntax is not valid.
|
boolean |
hasParams()
Whether this URN has params?
|
boolean |
isEmpty()
Is it empty?
|
static boolean |
isValid(String text)
Is it a valid URN?
|
boolean |
matches(String pattern)
Does it match the pattern?
|
String |
nid()
Get namespace ID.
|
String |
nss()
Get namespace specific string.
|
String |
param(String name)
Get query param by name.
|
URN |
param(String name,
Object value)
Add (overwrite) a query param and return a new URN.
|
Map<String,String> |
params()
Get all params.
|
URN |
pure()
Get just body of URN, without params.
|
String |
toString() |
URI |
toURI()
Convert it to URI.
|
public URN()
public URN(@NotNull String text) throws URISyntaxException
text - The text of the URNURISyntaxException - If syntax is not correctpublic static URN create(@NotNull String text)
text - The text of the URNpublic int compareTo(URN urn)
compareTo in interface Comparable<URN>public static boolean isValid(String text)
text - The text to validatepublic boolean matches(@NotNull String pattern)
pattern - The pattern to matchpublic boolean isEmpty()
public URI toURI()
public String nid()
public String nss()
public String param(@NotNull String name)
name - Name of parameterpublic URN param(@NotNull String name, @NotNull Object value)
name - Name of parametervalue - The value of parameterpublic URN pure()
public boolean hasParams()
Copyright © 2012-2013 jcabi.com. All Rights Reserved.