Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * The contents of this file are subject to the terms
   * of the Common Development and Distribution License
   * (the "License").  You may not use this file except
   * in compliance with the License.
   * 
   * You can obtain a copy of the license at
   * http://www.opensource.org/licenses/cddl1.php
   * See the License for the specific language governing
  * permissions and limitations under the License.
  */
 
 /*
  * EntityTag.java
  *
  * Created on March 21, 2007, 3:14 PM
  *
  */
 
 package javax.ws.rs.core;
 
An abstraction for the value of a HTTP Entity Tag, used as the value of an ETag response header.

See also:
HTTP/1.1 section 3.11
 
 public class EntityTag {
     
     private String value;
     private boolean weak;
     
     private static final HeaderDelegate<EntityTagdelegate = 
             RuntimeDelegate.getInstance().createHeaderDelegate(EntityTag.class);

    
Creates a new instance of a strong EntityTag.

Parameters:
value the value of the tag, quotes not included.
Throws:
java.lang.IllegalArgumentException if value is null
 
     public EntityTag(String value) {
         this(valuefalse);
     }
    
    
Creates a new instance of an EntityTag

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 is null
 
     public EntityTag(String valueboolean weak) {
         if (value == null)
             throw new IllegalArgumentException("value==null");
         this. = value;
         this. = weak;
     }
    
    
Creates a new instance of EntityTag by parsing the supplied string.

Parameters:
value the entity tag string
Returns:
the newly created EntityTag
Throws:
java.lang.IllegalArgumentException if the supplied string cannot be parsed or is null
 
     public static EntityTag valueOf(String valuethrows IllegalArgumentException {
         return .fromString(value);
     }
    
    
Check the strength of an EntityTag

Returns:
true if this represents a weak tag, false otherwise
 
     public boolean isWeak() {
         return ;
     }
    
    
Get the value of an EntityTag

Returns:
the value of the tag
 
     public String getValue() {
         return ;
     }
    
    
Compares obj to this tag to see if they are the same considering weakness and value.

Parameters:
obj the object to compare to
Returns:
true if the two tags are the same, false otherwise.
 
     @Override
     public boolean equals(Object obj) {
         if (obj == null)
             return false;
         if (!(obj instanceof EntityTag))
             return super.equals(obj);
         EntityTag other = (EntityTag)obj;
        if (.equals(other.getValue()) && ==other.isWeak())
            return true;
        return false;
    }

    
Generate hashCode based on value and weakness.

Returns:
the hashCode
    @Override
    public int hashCode() {
        int hash = 3;
        hash = 17 * hash + (this. != null ? this..hashCode() : 0);
        hash = 17 * hash + (this. ? 1 : 0);
        return hash;
    }

    
Convert the entity tag to a string suitable for use as the value of the corresponding HTTP header.

Returns:
a stringified entity tag
    @Override
    public String toString() {
        return .toString(this);
    }
New to GrepCode? Check out our FAQ X