public static String decode(String s)
  {
    final int n = s.length();
    StringBuilder result = new StringBuilder(n);
    for (int i = 0; i < n; i++)
    {
      char c = s.charAt(i);
      if (c == '%')
      {
        int numCharsConsumed = decodeConsecutiveOctets(result, s, i);
        i += numCharsConsumed - 1;
      }
      else
      {
        result.append(c);
      }
    }
    return result.toString();
  }
@Test(dataProvider = "invalidEncodedText")
  public void testDecodeInvalidStrings(String encoded, String expectedErrorMessage)
  {
    IllegalArgumentException exception = null;

    try
    {
      URIDecoderUtils.decode(encoded);
    }
    catch (IllegalArgumentException e)
    {
      exception = e;
    }

    Assert.assertNotNull(exception, "Expected exception when decoding string \"" + encoded + "\".");
    Assert.assertEquals(exception.getMessage(), expectedErrorMessage, "Unexpected error message during decoding.");
  }