@Test public void testToString() throws Exception { NewCookie cookie = new NewCookie("foo", "bar", "/aaa", "andrew.com", 1, "comment", 300, date(2010, 1, 8, 2, 5, 0, "EET"), true, true); assertEquals("foo=bar;Version=1;Comment=comment;Domain=andrew.com;Path=/aaa;Max-Age=300;Expires=Fri, 08 Jan 2010 00:05:00 GMT;Secure;HttpOnly", newCookieHeaderDelegate.toString(cookie)); }
@Override public String toString(NewCookie cookie) { checkArgument(cookie != null); StringBuilder sb = new StringBuilder(); sb.append(cookie.getName()).append('=').append(addQuotesIfHasWhitespace(cookie.getValue())); sb.append(';').append("Version=").append(cookie.getVersion()); if (cookie.getComment() != null) { sb.append(';').append("Comment=").append(addQuotesIfHasWhitespace(cookie.getComment())); } if (cookie.getDomain() != null) { sb.append(';').append("Domain=").append(addQuotesIfHasWhitespace(cookie.getDomain())); } if (cookie.getPath() != null) { sb.append(';').append("Path=").append(addQuotesIfHasWhitespace(cookie.getPath())); } if (cookie.getMaxAge() != -1) { sb.append(';').append("Max-Age=").append(addQuotesIfHasWhitespace(Integer.toString(cookie.getMaxAge()))); } if (cookie.getExpiry() != null) { sb.append(';').append("Expires="); sb.append(HeaderHelper.formatDate(cookie.getExpiry())); } if (cookie.isSecure()) { sb.append(';').append("Secure"); } if (cookie.isHttpOnly()) { sb.append(';').append("HttpOnly"); } return sb.toString(); }
NewCookieHeaderDelegate implements RuntimeDelegate.HeaderDelegate<NewCookie> { @Override public String toString(NewCookie cookie) { checkArgument(cookie != null); StringBuilder sb = new StringBuilder(); sb.append(cookie.getName()).append('=').append(addQuotesIfHasWhitespace(cookie.getValue())); sb.append(';').append("Version=").append(cookie.getVersion()); if (cookie.getComment() != null) { sb.append(';').append("Comment=").append(addQuotesIfHasWhitespace(cookie.getComment())); } if (cookie.getDomain() != null) { sb.append(';').append("Domain=").append(addQuotesIfHasWhitespace(cookie.getDomain())); } if (cookie.getPath() != null) { sb.append(';').append("Path=").append(addQuotesIfHasWhitespace(cookie.getPath())); } if (cookie.getMaxAge() != -1) { sb.append(';').append("Max-Age=").append(addQuotesIfHasWhitespace(Integer.toString(cookie.getMaxAge()))); } if (cookie.getExpiry() != null) { sb.append(';').append("Expires="); sb.append(HeaderHelper.formatDate(cookie.getExpiry())); } if (cookie.isSecure()) { sb.append(';').append("Secure"); } if (cookie.isHttpOnly()) { sb.append(';').append("HttpOnly"); } return sb.toString(); } }
NewCookieHeaderDelegate implements RuntimeDelegate.HeaderDelegate<NewCookie> { @Override public String toString(NewCookie cookie) { checkArgument(cookie != null); StringBuilder sb = new StringBuilder(); sb.append(cookie.getName()).append('=').append(addQuotesIfHasWhitespace(cookie.getValue())); sb.append(';').append("Version=").append(cookie.getVersion()); if (cookie.getComment() != null) { sb.append(';').append("Comment=").append(addQuotesIfHasWhitespace(cookie.getComment())); } if (cookie.getDomain() != null) { sb.append(';').append("Domain=").append(addQuotesIfHasWhitespace(cookie.getDomain())); } if (cookie.getPath() != null) { sb.append(';').append("Path=").append(addQuotesIfHasWhitespace(cookie.getPath())); } if (cookie.getMaxAge() != -1) { sb.append(';').append("Max-Age=").append(addQuotesIfHasWhitespace(Integer.toString(cookie.getMaxAge()))); } if (cookie.getExpiry() != null) { sb.append(';').append("Expires="); sb.append(HeaderHelper.formatDate(cookie.getExpiry())); } if (cookie.isSecure()) { sb.append(';').append("Secure"); } if (cookie.isHttpOnly()) { sb.append(';').append("HttpOnly"); } return sb.toString(); }  }
NewCookieHeaderDelegate implements RuntimeDelegate.HeaderDelegate<NewCookie> { @Override public String toString(NewCookie cookie) { checkArgument(cookie != null); StringBuilder sb = new StringBuilder(); sb.append(cookie.getName()).append('=').append(addQuotesIfHasWhitespace(cookie.getValue())); sb.append(';').append("Version=").append(cookie.getVersion()); if (cookie.getComment() != null) { sb.append(';').append("Comment=").append(addQuotesIfHasWhitespace(cookie.getComment())); } if (cookie.getDomain() != null) { sb.append(';').append("Domain=").append(addQuotesIfHasWhitespace(cookie.getDomain())); } if (cookie.getPath() != null) { sb.append(';').append("Path=").append(addQuotesIfHasWhitespace(cookie.getPath())); } if (cookie.getMaxAge() != -1) { sb.append(';').append("Max-Age=").append(addQuotesIfHasWhitespace(Integer.toString(cookie.getMaxAge()))); } if (cookie.getExpiry() != null) { sb.append(';').append("Expires="); sb.append(HeaderHelper.formatDate(cookie.getExpiry())); } if (cookie.isSecure()) { sb.append(';').append("Secure"); } if (cookie.isHttpOnly()) { sb.append(';').append("HttpOnly"); } return sb.toString(); }  @Override NewCookie fromString(String header); @Override String toString(NewCookie cookie); }
NewCookieHeaderDelegate implements RuntimeDelegate.HeaderDelegate<NewCookie> { @Override public String toString(NewCookie cookie) { checkArgument(cookie != null); StringBuilder sb = new StringBuilder(); sb.append(cookie.getName()).append('=').append(addQuotesIfHasWhitespace(cookie.getValue())); sb.append(';').append("Version=").append(cookie.getVersion()); if (cookie.getComment() != null) { sb.append(';').append("Comment=").append(addQuotesIfHasWhitespace(cookie.getComment())); } if (cookie.getDomain() != null) { sb.append(';').append("Domain=").append(addQuotesIfHasWhitespace(cookie.getDomain())); } if (cookie.getPath() != null) { sb.append(';').append("Path=").append(addQuotesIfHasWhitespace(cookie.getPath())); } if (cookie.getMaxAge() != -1) { sb.append(';').append("Max-Age=").append(addQuotesIfHasWhitespace(Integer.toString(cookie.getMaxAge()))); } if (cookie.getExpiry() != null) { sb.append(';').append("Expires="); sb.append(HeaderHelper.formatDate(cookie.getExpiry())); } if (cookie.isSecure()) { sb.append(';').append("Secure"); } if (cookie.isHttpOnly()) { sb.append(';').append("HttpOnly"); } return sb.toString(); }  @Override NewCookie fromString(String header); @Override String toString(NewCookie cookie);  }