/** * Appends a list of cookies as an HTTP header. * * @param cookies * The list of cookies to format. * @return This writer. */ public CookieWriter append(List<Cookie> cookies) { if ((cookies != null) && !cookies.isEmpty()) { Cookie cookie; for (int i = 0; i < cookies.size(); i++) { cookie = cookies.get(i); if (i == 0) { if (cookie.getVersion() > 0) { append("$Version=\"").append(cookie.getVersion()) .append("\"; "); } } else { append("; "); } append(cookie); } } return this; }
/** {@inheritDoc} */ @Override public int hashCode() { return Engine.hashCode(super.hashCode(), getVersion(), getPath(), getDomain()); }
/** {@inheritDoc} */ @Override public int hashCode() { return SystemUtils.hashCode(getName(), getValue(), getVersion(), getPath(), getDomain()); }
public CookieAdapter(org.restlet.data.Cookie target) { this.target = new CookieSetting( target.getVersion(), target.getName(), target.getValue(), target.getPath(), target.getDomain() ); }
/** {@inheritDoc} */ @Override public int hashCode() { return SystemUtils.hashCode(getName(), getValue(), getVersion(), getPath(), getDomain()); }
/** * Converts a Restlet Cookie to a JAX-RS Cookie * * @param restletCookie * the Restlet Cookie * @return the JAX-RS Cookie */ public static Cookie toJaxRsCookie(org.restlet.data.Cookie restletCookie) { if (restletCookie == null) { return null; } return new Cookie(restletCookie.getName(), restletCookie.getValue(), restletCookie.getPath(), restletCookie.getDomain(), restletCookie.getVersion()); }
@Override public CookieWriter append(Cookie cookie) throws IllegalArgumentException { String name = cookie.getName(); String value = cookie.getValue(); int version = cookie.getVersion(); if ((name == null) || (name.length() == 0)) { throw new IllegalArgumentException( "Can't write cookie. Invalid name detected"); } appendValue(name, 0).append('='); // Append the value if ((value != null) && (value.length() > 0)) { appendValue(value, version); } if (version > 0) { // Append the path String path = cookie.getPath(); if ((path != null) && (path.length() > 0)) { append("; $Path="); appendQuotedString(path); } // Append the domain String domain = cookie.getDomain(); if ((domain != null) && (domain.length() > 0)) { append("; $Domain="); appendQuotedString(domain); } } return this; }