Encodes the given value using the specified encoding type. @param value the value to encode @param encoding the encoding type (none, entity, url) @return the encoded value
(String value, String encoding)
| 479 | * @return the encoded value |
| 480 | */ |
| 481 | protected String encode(String value, String encoding) { |
| 482 | String retVal; |
| 483 | if (encoding.equalsIgnoreCase(ENCODING_URL)) { |
| 484 | retVal = URLEncoder.DEFAULT.encode(value, StandardCharsets.UTF_8); |
| 485 | } else if (encoding.equalsIgnoreCase(ENCODING_NONE)) { |
| 486 | retVal = value; |
| 487 | } else if (encoding.equalsIgnoreCase(ENCODING_ENTITY)) { |
| 488 | retVal = Escape.htmlElementContent(value); |
| 489 | } else { |
| 490 | // This shouldn't be possible |
| 491 | throw new IllegalArgumentException(sm.getString("ssiMediator.unknownEncoding", encoding)); |
| 492 | } |
| 493 | return retVal; |
| 494 | } |
| 495 | |
| 496 | |
| 497 | /** |
no test coverage detected