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

Method setAttribute

java/jakarta/servlet/http/Cookie.java:397–416  ·  view source on GitHub ↗

Sets the value for the given cookie attribute. When a value is set via this method, the value returned by the attribute specific getter (if any) must be consistent with the value set via this method. @param name Name of attribute to set @param value Value of attribute @throws IllegalArgumentExcep

(String name, String value)

Source from the content-addressed store, hash-verified

395 * @since Servlet 6.0
396 */
397 public void setAttribute(String name, String value) {
398 if (name == null) {
399 throw new IllegalArgumentException(LSTRINGS.getString("cookie.attribute.invalidName.null"));
400 }
401 if (!validation.isToken(name)) {
402 String msg = LSTRINGS.getString("cookie.attribute.invalidName.notToken");
403 throw new IllegalArgumentException(MessageFormat.format(msg, name));
404 }
405
406 if (name.equalsIgnoreCase(MAX_AGE)) {
407 if (value == null) {
408 setAttributeInternal(MAX_AGE, null);
409 } else {
410 // Integer.parseInt throws NFE if required
411 setMaxAge(Integer.parseInt(value));
412 }
413 } else {
414 setAttributeInternal(name, value);
415 }
416 }
417
418
419 private void setAttributeInternal(String name, String value) {

Callers 9

valueNullMethod · 0.95
testAttribute01Method · 0.95
createSessionCookieMethod · 0.95
registerMethod · 0.95
invokeMethod · 0.95

Calls 7

setAttributeInternalMethod · 0.95
setMaxAgeMethod · 0.95
getStringMethod · 0.65
formatMethod · 0.65
isTokenMethod · 0.45
equalsIgnoreCaseMethod · 0.45
parseIntMethod · 0.45

Tested by 6

valueNullMethod · 0.76
testAttribute01Method · 0.76