WebRequestCookie cookie = new WebRequestCookie();
cookie.setName(masterCookie.getName());
cookie.setDomain(masterCookie.getDomain());
cookie.setPath(masterCookie.getPath());
Cookie altCookie = (Cookie) alternative;
if (masterCookie.getValue() != null) {
cookie.setValue(masterCookie.getValue());
} else {
cookie.setValue(altCookie.getValue());
}
if (masterCookie.getComment() != null) {
cookie.setComment(masterCookie.getComment());
} else {
cookie.setComment(altCookie.getComment());
}
if (masterCookie.secureHasBeenSet()) {
cookie.setSecure(masterCookie.isSecure());
} else {
cookie.setSecure(altCookie.isSecure());
}
if (masterCookie.maxAgeHasBeenSet()) {
cookie.setMaxAge(masterCookie.getMaxAge());
} else {
cookie.setMaxAge(altCookie.getMaxAge());
}
// Set the version to that of the master if the master has been set
// otherwise set to the value of the alternate.
if (masterCookie.versionHasBeenSet()) {
cookie.setVersion(masterCookie.getVersion());
} else {
cookie.setVersion(altCookie.getVersion());
}
return cookie;
}