コード例 #1
0
 public void parse(final SetCookie cookie, String value) throws MalformedCookieException {
   if (cookie == null) {
     throw new IllegalArgumentException("Cookie may not be null");
   }
   if (value == null || value.trim().length() == 0) {
     value = "/";
   }
   cookie.setPath(value);
 }
コード例 #2
0
 public void parse(final SetCookie cookie, final String value) throws MalformedCookieException {
   Args.notNull(cookie, "Cookie");
   if (value == null) {
     throw new MalformedCookieException("Missing value for max-age attribute");
   }
   final int age;
   try {
     age = Integer.parseInt(value);
   } catch (final NumberFormatException e) {
     throw new MalformedCookieException("Invalid max-age attribute: " + value);
   }
   if (age < 0) {
     throw new MalformedCookieException("Negative max-age attribute: " + value);
   }
   cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L));
 }
コード例 #3
0
 @Override
 public void parse(final SetCookie cookie, final String value) throws MalformedCookieException {
   Args.notNull(cookie, "Cookie");
   if (TextUtils.isBlank(value)) {
     return;
   }
   final Matcher matcher = MAX_AGE_PATTERN.matcher(value);
   if (matcher.matches()) {
     final int age;
     try {
       age = Integer.parseInt(value);
     } catch (final NumberFormatException e) {
       return;
     }
     final Date expiryDate =
         age >= 0 ? new Date(System.currentTimeMillis() + age * 1000L) : new Date(Long.MIN_VALUE);
     cookie.setExpiryDate(expiryDate);
   }
 }
コード例 #4
0
 @Override
 public void parse(final SetCookie cookie, final String value) throws MalformedCookieException {
   Args.notNull(cookie, "Cookie");
   cookie.setComment(value);
 }
コード例 #5
0
 public void parse(final SetCookie cookie, final String value) throws MalformedCookieException {
   if (cookie == null) {
     throw new IllegalArgumentException("Cookie may not be null");
   }
   cookie.setSecure(true);
 }