- java.lang.Object
-
- javax.ws.rs.core.Cookie
-
- Direct Known Subclasses:
- NewCookie
public class Cookie extends Object
Represents the value of a HTTP cookie, transferred in a request. RFC 2109 specifies the legal characters for name, value, path and domain. The default version of 1 corresponds to RFC 2109.- Since:
- 1.0
- Author:
- Paul Sandoz, Marc Hadley
- See Also:
- IETF RFC 2109
-
-
Field Summary
Fields Modifier and Type Field and Description static int
DEFAULT_VERSION
Cookies using the default version correspond to RFC 2109.
-
Constructor Summary
Constructors Constructor and Description Cookie(String name, String value)
Create a new instance.Cookie(String name, String value, String path, String domain)
Create a new instance.Cookie(String name, String value, String path, String domain, int version)
Create a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean
equals(Object obj)
Compare for equality.String
getDomain()
Get the domain of the cookie.String
getName()
Get the name of the cookie.String
getPath()
Get the path of the cookie.String
getValue()
Get the value of the cookie.int
getVersion()
Get the version of the cookie.int
hashCode()
Generate a hash code by hashing all of the cookies properties.String
toString()
Convert the cookie to a string suitable for use as the value of the corresponding HTTP header.static Cookie
valueOf(String value)
Creates a new instance ofCookie
by parsing the supplied string.
-
-
-
Field Detail
-
DEFAULT_VERSION
public static final int DEFAULT_VERSION
Cookies using the default version correspond to RFC 2109.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Cookie
public Cookie(String name, String value, String path, String domain, int version) throws IllegalArgumentException
Create a new instance.- Parameters:
name
- the name of the cookie.value
- the value of the cookie.path
- the URI path for which the cookie is valid.domain
- the host domain for which the cookie is valid.version
- the version of the specification to which the cookie complies.- Throws:
IllegalArgumentException
- if name isnull
.
-
Cookie
public Cookie(String name, String value, String path, String domain) throws IllegalArgumentException
Create a new instance.- Parameters:
name
- the name of the cookie.value
- the value of the cookie.path
- the URI path for which the cookie is valid.domain
- the host domain for which the cookie is valid.- Throws:
IllegalArgumentException
- if name isnull
.
-
Cookie
public Cookie(String name, String value) throws IllegalArgumentException
Create a new instance.- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Throws:
IllegalArgumentException
- if name isnull
.
-
-
Method Detail
-
valueOf
public static Cookie valueOf(String value)
Creates a new instance ofCookie
by parsing the supplied string.- Parameters:
value
- the cookie string.- Returns:
- the newly created
Cookie
. - Throws:
IllegalArgumentException
- if the supplied string cannot be parsed or isnull
.
-
getName
public String getName()
Get the name of the cookie.- Returns:
- the cookie name.
-
getValue
public String getValue()
Get the value of the cookie.- Returns:
- the cookie value.
-
getVersion
public int getVersion()
Get the version of the cookie.- Returns:
- the cookie version.
-
getDomain
public String getDomain()
Get the domain of the cookie.- Returns:
- the cookie domain.
-
getPath
public String getPath()
Get the path of the cookie.- Returns:
- the cookie path.
-
toString
public String toString()
Convert the cookie to a string suitable for use as the value of the corresponding HTTP header.
-
hashCode
public int hashCode()
Generate a hash code by hashing all of the cookies properties.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/ws/rs/core/Cookie.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.