/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @param checkWeakness * The equality test takes care or not of the weakness. * * @return True if both tags are equal. */ public boolean equals(final Object object, boolean checkWeakness) { if (!(object instanceof Tag)) { return false; } final Tag that = (Tag) object; if (checkWeakness && that.isWeak() != isWeak()) { return false; } return Objects.equals(getName(), that.getName()); }
/** * Writes a tag. * * @param tag * The tag to write. * @return This writer. */ public static String write(Tag tag) { return tag.format(); }
/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @return True if both tags are equal. */ @Override public boolean equals(final Object object) { return equals(object, true); }
/** * Returns the name. * * @return The name. */ @Override public String toString() { return getName(); } }
@Override public Tag readValue() throws IOException { return Tag.parse(readRawValue()); }
/** * Parses a tag formatted as defined by the HTTP standard. * * @param httpTag * The HTTP tag string; if it starts with 'W/' the tag will be * marked as weak and the data following the 'W/' used as the * tag; otherwise it should be surrounded with quotes (e.g., * "sometag"). * @return A new tag instance. * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP Entity Tags</a> */ public static Tag parse(final String httpTag) { Tag result = null; boolean weak = false; String httpTagCopy = httpTag; if (httpTagCopy.startsWith("W/")) { weak = true; httpTagCopy = httpTagCopy.substring(2); } if (httpTagCopy.startsWith("\"") && httpTagCopy.endsWith("\"")) { result = new Tag( httpTagCopy.substring(1, httpTagCopy.length() - 1), weak); } else if (httpTagCopy.equals("*")) { result = new Tag("*", weak); } else { Context.getCurrentLogger().log(Level.WARNING, "Invalid tag format detected: " + httpTagCopy); } return result; }
/** * Returns the name. * * @return The name. */ @Override public String toString() { return getName(); } }
/** * Parse the supplied value and create an instance of <code>T</code>. * * @param value * the string value * @return the newly created instance of <code>T</code> * @throws IllegalArgumentException * if the supplied string cannot be parsed * @see javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate#fromString(java.lang.String) */ public EntityTag fromString(String string) throws IllegalArgumentException { return Converter.toJaxRsEntityTag(Tag.parse(string)); }
/** * Parses a tag formatted as defined by the HTTP standard. * * @param httpTag * The HTTP tag string; if it starts with 'W/' the tag will be * marked as weak and the data following the 'W/' used as the * tag; otherwise it should be surrounded with quotes (e.g., * "sometag"). * @return A new tag instance. * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP Entity Tags</a> */ public static Tag parse(String httpTag) { Tag result = null; boolean weak = false; String httpTagCopy = httpTag; if (httpTagCopy.startsWith("W/")) { weak = true; httpTagCopy = httpTagCopy.substring(2); } if (httpTagCopy.startsWith("\"") && httpTagCopy.endsWith("\"")) { result = new Tag( httpTagCopy.substring(1, httpTagCopy.length() - 1), weak); } else if (httpTagCopy.equals("*")) { result = new Tag("*", weak); } else { Context.getCurrentLogger().log(Level.WARNING, "Invalid tag format detected: " + httpTagCopy); } return result; }
/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @param checkWeakness * the equality test takes care or not of the weakness. * * @return True if both tags are equal. */ public boolean equals(final Object object, boolean checkWeakness) { boolean result = (object != null) && (object instanceof Tag); if (result) { final Tag that = (Tag) object; if (checkWeakness) { result = (that.isWeak() == isWeak()); } if (result) { if (getName() == null) { result = (that.getName() == null); } else { result = getName().equals(that.getName()); } } } return result; }
CacheInfo( Instant lastModified, Tag tag ) { this.lastModified = lastModified; entity = tag.getName().split( "/" )[ 0 ]; }
/** {@inheritDoc} */ @Override public int hashCode() { return format().hashCode(); }
/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @return True if both tags are equal. */ @Override public boolean equals(final Object object) { return equals(object, true); }
entityHeaderFound = true; } else if (HEADER_ETAG.equalsIgnoreCase(header.getName())) { result.setTag(Tag.parse(header.getValue())); entityHeaderFound = true; } else if (HEADER_CONTENT_LOCATION.equalsIgnoreCase(header.getName())) {
/** * Converts a JAX-RS-EntityTag to a Restlet-EntityTag * * @param jaxRsEntityTag * the JAX-RS-EntityTag to convert. * @return The corresponding Restlet-Entity-Tag */ public static Tag toRestletTag(EntityTag jaxRsEntityTag) { if (jaxRsEntityTag == null) { return null; } return new Tag(jaxRsEntityTag.getValue(), jaxRsEntityTag.isWeak()); }
/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @param checkWeakness * The equality test takes care or not of the weakness. * * @return True if both tags are equal. */ public boolean equals(final Object object, boolean checkWeakness) { boolean result = (object != null) && (object instanceof Tag); if (result) { final Tag that = (Tag) object; if (checkWeakness) { result = (that.isWeak() == isWeak()); } if (result) { if (getName() == null) { result = (that.getName() == null); } else { result = getName().equals(that.getName()); } } } return result; }
/** {@inheritDoc} */ @Override public int hashCode() { return format().hashCode(); }
/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @return True if both tags are equal. */ @Override public boolean equals(final Object object) { return equals(object, true); }