Пример #1
0
 /**
  * Escapes the specified token.
  *
  * @param token token
  * @return escaped token
  */
 public static byte[] escape(final byte[] token) {
   final TokenBuilder tb = new TokenBuilder();
   for (final byte t : token) {
     if (t >= 0x20 && t <= 0x7e) tb.addByte(t);
     else hex(tb, t);
   }
   return tb.finish();
 }
Пример #2
0
 /**
  * Returns a URI encoded token.
  *
  * @param token token
  * @param iri input
  * @return encoded token
  */
 public static byte[] uri(final byte[] token, final boolean iri) {
   final TokenBuilder tb = new TokenBuilder();
   for (final byte t : token) {
     if (letterOrDigit(t) || contains(iri ? IRIRES : RES, t)) tb.addByte(t);
     else hex(tb, t);
   }
   return tb.finish();
 }