test_class.file: jaxrs-delegates/src/test/java/org/wso2/msf4j/delegates/CookieHeaderProviderTest.java
test_class.identifier: CookieHeaderProviderTest
test_case.body: @Test
      public void testFromString() throws Exception {
          Cookie cookie = Cookie.valueOf("JSESSIONID=3508015E4EF0ECA8C4B761FCC4BC1718");
          assertEquals(cookie.getName(), "JSESSIONID");
          assertEquals(cookie.getValue(), "3508015E4EF0ECA8C4B761FCC4BC1718");
      }
test_case.class_method_signature: CookieHeaderProviderTest.testFromString()
test_case.full_signature: @Test public void testFromString()
test_case.identifier: testFromString
test_case.invocations: valueOf assertEquals getName assertEquals getValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFromString()
focal_class.declarator: DATE_FORMAT_PATTERN = "EEE, dd MMM yyyy HH:mm:ss zzz"
focal_class.modifier: private static final
focal_class.original_string: private static final String DATE_FORMAT_PATTERN = "EEE, dd MMM yyyy HH:mm:ss zzz";
focal_class.type: String
focal_class.var_name: DATE_FORMAT_PATTERN
focal_class.declarator: GMT_TIMEZONE = "GMT"
focal_class.modifier: private static final
focal_class.original_string: private static final String GMT_TIMEZONE = "GMT";
focal_class.type: String
focal_class.var_name: GMT_TIMEZONE
focal_class.declarator: VERSION = "Version"
focal_class.modifier: private static final
focal_class.original_string: private static final String VERSION = "Version";
focal_class.type: String
focal_class.var_name: VERSION
focal_class.declarator: PATH = "Path"
focal_class.modifier: private static final
focal_class.original_string: private static final String PATH = "Path";
focal_class.type: String
focal_class.var_name: PATH
focal_class.declarator: DOMAIN = "Domain"
focal_class.modifier: private static final
focal_class.original_string: private static final String DOMAIN = "Domain";
focal_class.type: String
focal_class.var_name: DOMAIN
focal_class.declarator: SECURE = "Secure"
focal_class.modifier: private static final
focal_class.original_string: private static final String SECURE = "Secure";
focal_class.type: String
focal_class.var_name: SECURE
focal_class.declarator: EXPIRES = "Expires"
focal_class.modifier: private static final
focal_class.original_string: private static final String EXPIRES = "Expires";
focal_class.type: String
focal_class.var_name: EXPIRES
focal_class.declarator: COMMENT = "Comment"
focal_class.modifier: private static final
focal_class.original_string: private static final String COMMENT = "Comment";
focal_class.type: String
focal_class.var_name: COMMENT
focal_class.declarator: HTTP_ONLY = "HttpOnly"
focal_class.modifier: private static final
focal_class.original_string: private static final String HTTP_ONLY = "HttpOnly";
focal_class.type: String
focal_class.var_name: HTTP_ONLY
focal_class.declarator: MAX_AGE = "MaxAge"
focal_class.modifier: private static final
focal_class.original_string: private static final String MAX_AGE = "MaxAge";
focal_class.type: String
focal_class.var_name: MAX_AGE
focal_class.declarator: log = LoggerFactory.getLogger(CookieHeaderProvider.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(CookieHeaderProvider.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: dateFormat = new SimpleDateFormat(DATE_FORMAT_PATTERN, Locale.ENGLISH)
focal_class.modifier: private
focal_class.original_string: private SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_PATTERN, Locale.ENGLISH);
focal_class.type: SimpleDateFormat
focal_class.var_name: dateFormat
focal_class.file: jaxrs-delegates/src/main/java/org/wso2/msf4j/delegates/CookieHeaderProvider.java
focal_class.identifier: CookieHeaderProvider
focal_class.interfaces: implements RuntimeDelegate.HeaderDelegate<Cookie>
focal_class.class_method_signature: CookieHeaderProvider.fromString(String cookieValue)
focal_class.full_signature: @Override public Cookie fromString(String cookieValue)
focal_class.identifier: fromString
focal_class.modifiers: @Override public
focal_class.parameters: (String cookieValue)
focal_class.return: Cookie
focal_class.signature: Cookie fromString(String cookieValue)
focal_class.class_method_signature: CookieHeaderProvider.toString(Cookie cookie)
focal_class.full_signature: @Override public String toString(Cookie cookie)
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: (Cookie cookie)
focal_class.return: String
focal_class.signature: String toString(Cookie cookie)
focal_method.body: @Override
      public Cookie fromString(String cookieValue) {
          if (cookieValue == null) {
              throw new IllegalArgumentException("Cookie value can not be null");
          }
  
          int version = NewCookie.DEFAULT_VERSION;
          int maxAge = NewCookie.DEFAULT_MAX_AGE;
          String name = null;
          String value = null;
          String path = null;
          String domain = null;
          String comment = null;
          Date expiry = null;
          boolean secure = false;
          boolean httpOnly = false;
  
          String[] parts = cookieValue.split(";");
          for (String part : parts) {
              String token = part.trim();
              if (token.startsWith(VERSION)) {
                  version = Integer.parseInt(token.substring(VERSION.length() + 1));
              } else if (token.startsWith(PATH)) {
                  path = token.substring(PATH.length() + 1);
              } else if (token.startsWith(DOMAIN)) {
                  domain = token.substring(DOMAIN.length() + 1);
              } else if (token.startsWith(SECURE)) {
                  secure = Boolean.TRUE;
              } else if (token.startsWith(HTTP_ONLY)) {
                  httpOnly = Boolean.TRUE;
              } else if (token.startsWith(COMMENT)) {
                  comment = token.substring(COMMENT.length() + 1);
              } else if (token.startsWith(MAX_AGE)) {
                  maxAge = Integer.parseInt(token.substring(MAX_AGE.length() + 1));
              } else if (token.startsWith(EXPIRES)) {
                  try {
                      //All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT)
                      dateFormat.setTimeZone(TimeZone.getTimeZone(GMT_TIMEZONE));
                      expiry = dateFormat.parse(token.substring(EXPIRES.length() + 1));
                  } catch (ParseException e) {
                      log.error("Error while parsing the Date value. Hence return null", e);
                  }
              } else {
                  int i = token.indexOf('=');
                  if (i != -1) {
                      name = token.substring(0, i);
                      value = i == token.length()  + 1 ? "" : token.substring(i + 1);
                  }
              }
          }
  
          if (name == null) {
              throw new IllegalArgumentException("Cookie is malformed : " + cookieValue);
          }
  
          return new NewCookie(name, value, path, domain, version, comment, maxAge, expiry, secure, httpOnly);
      }
focal_method.class_method_signature: CookieHeaderProvider.fromString(String cookieValue)
focal_method.full_signature: @Override public Cookie fromString(String cookieValue)
focal_method.identifier: fromString
focal_method.invocations: split trim startsWith parseInt substring length startsWith substring length startsWith substring length startsWith startsWith startsWith substring length startsWith parseInt substring length startsWith setTimeZone getTimeZone parse substring length error indexOf substring length substring
focal_method.modifiers: @Override public
focal_method.parameters: (String cookieValue)
focal_method.return: Cookie
focal_method.signature: Cookie fromString(String cookieValue)