Beispiel #1
0
 /**
  * Get just body of URN, without params.
  *
  * @return Clean version of it
  */
 public URN pure() {
   String urn = this.toString();
   if (this.hasParams()) {
     urn = urn.substring(0, urn.indexOf('?'));
   }
   return URN.create(urn);
 }
Beispiel #2
0
 /**
  * Add (overwrite) a query param and return a new URN.
  *
  * @param name Name of parameter
  * @param value The value of parameter
  * @return New URN
  */
 public URN param(final String name, final Object value) {
   if (name == null || value == null) {
     throw new IllegalArgumentException("Parameter name and value must be non-null.");
   }
   final Map<String, String> params = this.params();
   params.put(name, value.toString());
   return URN.create(String.format("%s%s", this.toString().split("\\?")[0], URN.enmap(params)));
 }