Package javax.ws.rs.core
Class EntityTag
- java.lang.Object
-
- javax.ws.rs.core.EntityTag
-
public class EntityTag extends java.lang.Object
An abstraction for the value of a HTTP Entity Tag, used as the value of an ETag response header.- Since:
- 1.0
- See Also:
- HTTP/1.1 section 3.11
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Comparesobj
to this tag to see if they are the same considering weakness and value.java.lang.String
getValue()
Get the value of anEntityTag
.int
hashCode()
Generate hashCode based on value and weakness.boolean
isWeak()
Check the strength of anEntityTag
.java.lang.String
toString()
Convert the entity tag to a string suitable for use as the value of the corresponding HTTP header.static EntityTag
valueOf(java.lang.String value)
Creates a new instance ofEntityTag
by parsing the supplied string.
-
-
-
Constructor Detail
-
EntityTag
public EntityTag(java.lang.String value)
Creates a new instance of a strongEntityTag
.- Parameters:
value
- the value of the tag, quotes not included.- Throws:
java.lang.IllegalArgumentException
- if value isnull
.
-
EntityTag
public EntityTag(java.lang.String value, boolean weak)
Creates a new instance of anEntityTag
.- Parameters:
value
- the value of the tag, quotes not included.weak
-true
if this represents a weak tag,false
otherwise.- Throws:
java.lang.IllegalArgumentException
- if value isnull
.
-
-
Method Detail
-
valueOf
public static EntityTag valueOf(java.lang.String value)
Creates a new instance ofEntityTag
by parsing the supplied string.- Parameters:
value
- the entity tag string.- Returns:
- the newly created entity tag.
- Throws:
java.lang.IllegalArgumentException
- if the supplied string cannot be parsed or isnull
.
-
isWeak
public boolean isWeak()
Check the strength of anEntityTag
.- Returns:
true
if this represents a weak tag,false
otherwise.
-
getValue
public java.lang.String getValue()
Get the value of anEntityTag
.- Returns:
- the value of the tag.
-
equals
public boolean equals(java.lang.Object obj)
Comparesobj
to this tag to see if they are the same considering weakness and value.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to compare to.- Returns:
true
if the two tags are the same,false
otherwise.
-
hashCode
public int hashCode()
Generate hashCode based on value and weakness.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the entity tag hash code.
-
toString
public java.lang.String toString()
Convert the entity tag to a string suitable for use as the value of the corresponding HTTP header.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string version of the entity tag.
-
-