Package anvil.core.net

Source Code of anvil.core.net.AnyCookie

/*
* $Id: AnyCookie.java,v 1.5 2002/09/16 08:05:03 jkl Exp $
*
* Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
*
* Use is subject to license terms, as defined in
* Anvil Sofware License, Version 1.1. See LICENSE
* file, or http://njet.org/license-1.1.txt
*/
package anvil.core.net;

import anvil.Log;
import anvil.core.Any;
import anvil.core.AnyTuple;
import anvil.core.AnyAbstractClass;
import anvil.script.Context;
import anvil.server.OperationFailedException;
import anvil.java.util.BindingEnumeration;
import javax.servlet.http.Cookie;

///
/// @class Cookie
/// Cookie is a small amount of information sent by server to
/// web browser, saved by browser and later sent back to server
/// when the client accesses the same web page.
///
/**
* class AnyCookie
*/
public class AnyCookie extends AnyAbstractClass
{

  ///
  /// @constructor Cookie
  /// Creates and returns a new Cookie.
  /// @synopsis Cookie(string name, string value)
  public static final Object[] newInstance = { "name", "value" };
  public static final Any newInstance(Any name, Any value)
  {
    return new AnyCookie(new Cookie(name.toString(), value.toString()));
  }
  

  private Cookie _cookie;
 
 
  public AnyCookie(Cookie cookie)
  {
    _cookie = cookie;
  }
 
 
  public final anvil.script.ClassType classOf()
  {
    return __class__;
  }
 

  public Object clone()
  {
    return new AnyCookie((Cookie)_cookie.clone());
  }


  public Any copy()
  {
    return new AnyCookie((Cookie)_cookie.clone());
  }


  public String toString()
  {
    return "Cookie("+_cookie.getName()+"="+_cookie.getValue()+")";
  }


  public Object toObject()
  {
    return _cookie;
  }


  /// @method getComment
  /// Returns the comment the describing purpose of this cookie.
  /// @synopsis string getComment()
  public Any m_getComment()
  {
    return Any.create(_cookie.getComment());
  }
 
  /// @method getPath
  /// Returns the paths (that is, URIs) on the server to which the
  /// browser returns this cookie.
  /// @synopsis string getPath()
  public Any m_getPath()
  {
    return Any.create(_cookie.getPath());
 

  /// @method getDomain
  /// Returns the domain name set for this cookie.
  /// @synopsis string getDomain()
  public Any m_getDomain()
  {
    return Any.create(_cookie.getDomain());
  }

  /// @method getMaxAge
  /// Returns the maximum age of the cookie, specified in seconds.
  /// @synopsis int getMaxAge()
  public Any m_getMaxAge()
  {
    return Any.create(_cookie.getMaxAge());
  }
 
  /// @method getSecure
  /// Returns <code>true</code> is the browser is sending cookies
  /// only over secure protocol.
  /// @synopsis boolean getSecure()
  public Any m_getSecure()
  {
    return Any.create(_cookie.getSecure());
 


  /// @method getName
  /// Returns the name of cookie.
  /// @synopsis string getName()
  public Any m_getName()
  {
    return Any.create(_cookie.getName());
 

  /// @method getValue
  /// Returns the value of cookie.
  /// @synopsis string getValue()
  public Any m_getValue()
  {
    return Any.create(_cookie.getValue());
 

  /// @method getVersion
  /// Returns the version of the protocol this cookie complies with.
  /// @synopsis int getVersion()
  public Any m_getVersion()
  {
    return Any.create(_cookie.getVersion());
 


  /// @method setComment
  /// Specifies a comment that describes a cookie's purpose.
  /// The comment is useful if the browser presents the cookie to
  /// the user. Comments are not supported by Netscape Version 0 cookies.
  /// @synopsis Cookie setComment(string comment)
  public static final Object[] p_setComment = { "comment" };
  public Any m_setComment(String comment)
  {
    _cookie.setComment(comment);
    return this;
  }

  /// @method setDomain
  /// <p>Specifies the domain within which this cookie should be presented.</p>
  /// <p>The form of the domain name is specified by RFC 2109. A domain name
  /// begins with a dot (.foo.com) and means that the cookie is visible
  /// to servers in a specified Domain Name System (DNS) zone (for example,
  /// www.foo.com, but not a.b.foo.com). By default, cookies are only
  /// returned to the server that sent them.</p>
  /// @synopsis Cookie setDomain(string domain)
  public static final Object[] p_setDomain = { "domain" };
  public Any m_setDomain(String domain)
  {
    _cookie.setDomain(domain);
    return this;
  }

  /// @method setMaxAge
  /// <p>Sets the maximum age of the cookie in seconds.</p>
  /// <p>A positive value indicates that the cookie will expire after
  /// that many seconds have passed. Note that the value is the
  /// maximum age when the cookie will expire, not the cookie's current age.</p>
  /// <p>A negative value means that the cookie is not stored persistently and will be deleted when the Web browser exits. A
  ///  zero value causes the cookie to be deleted.</p>
  /// @synopsis Cookie setMaxAge(int maxage)
  public static final Object[] p_setMaxAge = { "maxAge" };
  public Any m_setMaxAge(int maxage)
  {
    _cookie.setMaxAge(maxage);
    return this;
  }

  /// @method setPath
  /// Specifies a path for the cookie, which is the set of URIs
  /// (Universal Resource Identifiers, the part of an URL that represents
  /// the server path) to which the client should return the cookie.
  /// @synopsis Cookie setPath(string path)
  public static final Object[] p_setPath = { "path" };
  public Any m_setPath(String path)
  {
    _cookie.setPath(path);
    return this;
  }

  /// @method setSecure
  /// Indicates to the browser whether the cookie should only be sent
  /// using a secure protocol, such as HTTPS or SSL.
  /// @synopsis Cookie setSecure(boolean secure)
  public static final Object[] p_setSecure = { "secure" };
  public Any m_setSecure(boolean secure)
  {
    _cookie.setSecure(secure);
    return this;
  }

  /// @method setValue
  /// Assigns a new value to a cookie after it is created.
  /// Stored value should be encoded with, for instance, BASE64
  /// or URL encoding.
  /// @synopsis Cookie setValue(string value)
  public static final Object[] p_setValue = { "value" };
  public Any m_setValue(String value)
  {
    _cookie.setValue(value);
    return this;
  }
 
  /// @method setVersion
  /// <p>Sets the version of the cookie protocol this cookie complies with.
  /// Version 0 complies with the original
  /// Netscape cookie specification. Version 1 complies with RFC 2109. </p>
  /// <p>Since RFC 2109 is still somewhat new, consider version 1 as experimental;
  /// do not use it yet on production sites.</p>
  /// @synopsis Cookie setVersion(int version)
  public static final Object[] p_setVersion = { "version" };
  public Any m_setVersion(int version)
  {
    _cookie.setVersion(version);
    return this;
  }



  public static final anvil.script.compiler.NativeClass __class__ =
    new anvil.script.compiler.NativeClass("Cookie", AnyCookie.class,
    //DOC{{
    ""+
      "\n" +
      " @class Cookie\n" +
      " Cookie is a small amount of information sent by server to\n" +
      " web browser, saved by browser and later sent back to server\n" +
      " when the client accesses the same web page.\n" +
      "\n" +
      "\n" +
      " @constructor Cookie\n" +
      " Creates and returns a new Cookie.\n" +
      " @synopsis Cookie(string name, string value)\n" +
      " @method getComment\n" +
      " Returns the comment the describing purpose of this cookie.\n" +
      " @synopsis string getComment()\n" +
      " @method getPath\n" +
      " Returns the paths (that is, URIs) on the server to which the \n" +
      " browser returns this cookie.\n" +
      " @synopsis string getPath()\n" +
      " @method getDomain\n" +
      " Returns the domain name set for this cookie.\n" +
      " @synopsis string getDomain()\n" +
      " @method getMaxAge\n" +
      " Returns the maximum age of the cookie, specified in seconds.\n" +
      " @synopsis int getMaxAge()\n" +
      " @method getSecure\n" +
      " Returns <code>true</code> is the browser is sending cookies\n" +
      " only over secure protocol.\n" +
      " @synopsis boolean getSecure()\n" +
      " @method getName\n" +
      " Returns the name of cookie.\n" +
      " @synopsis string getName()\n" +
      " @method getValue\n" +
      " Returns the value of cookie.\n" +
      " @synopsis string getValue()\n" +
      " @method getVersion\n" +
      " Returns the version of the protocol this cookie complies with.\n" +
      " @synopsis int getVersion()\n" +
      " @method setComment\n" +
      " Specifies a comment that describes a cookie's purpose. \n" +
      " The comment is useful if the browser presents the cookie to\n" +
      " the user. Comments are not supported by Netscape Version 0 cookies.\n" +
      " @synopsis Cookie setComment(string comment)\n" +
      " @method setDomain\n" +
      " <p>Specifies the domain within which this cookie should be presented.</p> \n" +
      " <p>The form of the domain name is specified by RFC 2109. A domain name \n" +
      " begins with a dot (.foo.com) and means that the cookie is visible \n" +
      " to servers in a specified Domain Name System (DNS) zone (for example, \n" +
      " www.foo.com, but not a.b.foo.com). By default, cookies are only \n" +
      " returned to the server that sent them.</p>\n" +
      " @synopsis Cookie setDomain(string domain)\n" +
      " @method setMaxAge\n" +
      " <p>Sets the maximum age of the cookie in seconds.</p>\n" +
      " <p>A positive value indicates that the cookie will expire after \n" +
      " that many seconds have passed. Note that the value is the\n" +
      " maximum age when the cookie will expire, not the cookie's current age.</p>\n" +
      " <p>A negative value means that the cookie is not stored persistently and will be deleted when the Web browser exits. A\n" +
      "  zero value causes the cookie to be deleted.</p>\n" +
      " @synopsis Cookie setMaxAge(int maxage)\n" +
      " @method setPath\n" +
      " Specifies a path for the cookie, which is the set of URIs \n" +
      " (Universal Resource Identifiers, the part of an URL that represents \n" +
      " the server path) to which the client should return the cookie. \n" +
      " @synopsis Cookie setPath(string path)\n" +
      " @method setSecure\n" +
      " Indicates to the browser whether the cookie should only be sent \n" +
      " using a secure protocol, such as HTTPS or SSL. \n" +
      " @synopsis Cookie setSecure(boolean secure)\n" +
      " @method setValue\n" +
      " Assigns a new value to a cookie after it is created.\n" +
      " Stored value should be encoded with, for instance, BASE64 \n" +
      " or URL encoding.\n" +
      " @synopsis Cookie setValue(string value)\n" +
      " @method setVersion\n" +
      " <p>Sets the version of the cookie protocol this cookie complies with. \n" +
      " Version 0 complies with the original\n" +
      " Netscape cookie specification. Version 1 complies with RFC 2109. </p>\n" +
      " <p>Since RFC 2109 is still somewhat new, consider version 1 as experimental; \n" +
      " do not use it yet on production sites.</p>\n" +
      " @synopsis Cookie setVersion(int version)\n"
    //}}DOC
    );
  static {
    NetModule.class.getName();
  }


}
TOP

Related Classes of anvil.core.net.AnyCookie

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.