MCPcopy Create free account
hub / github.com/apache/tomcat / encode

Method encode

java/org/apache/catalina/ssi/SSIMediator.java:481–494  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 /**

Callers 1

getVariableValueMethod · 0.95

Calls 4

htmlElementContentMethod · 0.95
encodeMethod · 0.65
getStringMethod · 0.65
equalsIgnoreCaseMethod · 0.45

Tested by

no test coverage detected