Example usage for org.apache.http.impl.cookie BasicClientCookie2 getClass

List of usage examples for org.apache.http.impl.cookie BasicClientCookie2 getClass

Introduction

In this page you can find the example usage for org.apache.http.impl.cookie BasicClientCookie2 getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.grendelscan.commons.http.apache_overrides.serializable.SerializableBasicCookie.java

public SerializableBasicCookie(final Cookie cookie) {
    cookieVersion = cookie.getVersion();
    cookieExpiryDate = cookie.getExpiryDate();
    cookiePath = cookie.getPath();/* w  ww  . j  ava 2  s .c o  m*/
    name = cookie.getName();
    value = cookie.getValue();
    cookieComment = cookie.getComment();
    cookieDomain = cookie.getDomain();
    isSecure = cookie.isSecure();
    ports = cookie.getPorts();

    try {
        if (cookie instanceof BasicClientCookie2) {
            BasicClientCookie2 b2c = (BasicClientCookie2) cookie;
            discard = b2c.getClass().getField("discard").getBoolean(b2c);
        }
        if (cookie instanceof BasicClientCookie) {
            BasicClientCookie bCookie = (BasicClientCookie) cookie;
            Field field = bCookie.getClass().getDeclaredField("attribs");
            field.setAccessible(true);
            attribs = (HashMap) field.get(bCookie);
        }
    } catch (Exception e) {
        System.err.println(e.toString());
        e.printStackTrace();
    } finally {
        if (attribs == null) {
            attribs = new HashMap<String, String>();
        }
    }
}