This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 1ceede3 org.apache.juneau.http improvements.
1ceede3 is described below
commit 1ceede33c13d1830d3cc6ea266ad32c976192d24
Author: JamesBognar <[email protected]>
AuthorDate: Tue Jul 14 14:19:33 2020 -0400
org.apache.juneau.http improvements.
---
.../org/apache/juneau/encoders/EncoderGroup.java | 10 +-
.../java/org/apache/juneau/http/MediaRange.java | 10 +-
.../java/org/apache/juneau/http/MediaRanges.java | 6 +-
.../java/org/apache/juneau/http/MediaType.java | 10 +-
.../http/{MediaRange.java => StringRange.java} | 336 ++++++++++++---------
.../http/{MediaRanges.java => StringRanges.java} | 138 ++++-----
.../apache/juneau/http/header/AcceptCharset.java | 7 +-
.../apache/juneau/http/header/AcceptEncoding.java | 7 +-
.../apache/juneau/http/header/AcceptLanguage.java | 7 +-
.../juneau/http/header/BasicRangeArrayHeader.java | 31 +-
.../org/apache/juneau/http/header/StringRange.java | 289 ------------------
.../java/org/apache/juneau/http/header/TE.java | 7 +-
12 files changed, 292 insertions(+), 566 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroup.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroup.java
index 4d89f2f..c7c7892 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroup.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroup.java
@@ -63,8 +63,7 @@ public final class EncoderGroup {
// Maps Accept-Encoding headers to matching encoders.
private final ConcurrentHashMap<String,EncoderMatch> cache = new
ConcurrentHashMap<>();
- private final String[] encodings;
- private final List<String> encodingsList;
+ private final List<String> encodings;
private final Encoder[] encodingsEncoders;
private final List<Encoder> encoders;
@@ -106,8 +105,7 @@ public final class EncoderGroup {
}
}
- this.encodings = lc.asArrayOf(String.class);
- this.encodingsList = lc.unmodifiable();
+ this.encodings = lc.unmodifiable();
this.encodingsEncoders = l.asArrayOf(Encoder.class);
}
@@ -133,7 +131,7 @@ public final class EncoderGroup {
int match = ae.findMatch(encodings);
if (match >= 0) {
- em = new EncoderMatch(encodings[match],
encodingsEncoders[match]);
+ em = new EncoderMatch(encodings.get(match),
encodingsEncoders[match]);
cache.putIfAbsent(acceptEncoding, em);
}
@@ -157,7 +155,7 @@ public final class EncoderGroup {
* @return An unmodifiable list of codings supported by all encoders in
this group. Never <jk>null</jk>.
*/
public List<String> getSupportedEncodings() {
- return encodingsList;
+ return encodings;
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRange.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRange.java
index 662aa09..812fdb3 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRange.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRange.java
@@ -34,7 +34,7 @@ public class MediaRange extends MediaType {
private final NameValuePair[] extensions;
private final Float qValue;
- private final String value;
+ private final String string;
/**
* Constructor.
@@ -85,7 +85,7 @@ public class MediaRange extends MediaType {
for (NameValuePair p : extensions)
sb.append(';').append(p.getName()).append('=').append(p.getValue());
}
- value = sb.toString();
+ string = sb.toString();
}
/**
@@ -124,7 +124,7 @@ public class MediaRange extends MediaType {
*/
@Override /* Object */
public boolean equals(Object o) {
- return (o instanceof MediaRange) && eq(this, (MediaRange)o,
(x,y)->eq(x.value, y.value));
+ return (o instanceof MediaRange) && eq(this, (MediaRange)o,
(x,y)->eq(x.string, y.string));
}
/**
@@ -134,11 +134,11 @@ public class MediaRange extends MediaType {
*/
@Override /* Object */
public int hashCode() {
- return value.hashCode();
+ return string.hashCode();
}
@Override /* Object */
public String toString() {
- return value;
+ return string;
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRanges.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRanges.java
index e94f06e..1cc6c44 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRanges.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRanges.java
@@ -52,7 +52,7 @@ public class MediaRanges {
private static final Cache<String,MediaRanges> CACHE = new
Cache<>(NOCACHE, CACHE_MAX_SIZE);
private final MediaRange[] ranges;
- private final String value;
+ private final String string;
/**
* Returns a parsed <c>Accept</c> header value.
@@ -93,7 +93,7 @@ public class MediaRanges {
l.sort(RANGE_COMPARATOR);
ranges = l.toArray(new MediaRange[l.size()]);
- this.value = ranges.length == 1 ? ranges[0].toString() :
StringUtils.join(l, ',');
+ this.string = ranges.length == 1 ? ranges[0].toString() :
StringUtils.join(l, ',');
}
/**
@@ -237,6 +237,6 @@ public class MediaRanges {
@Override /* Object */
public String toString() {
- return value;
+ return string;
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaType.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaType.java
index aafeef6..c08d11a 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaType.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaType.java
@@ -61,7 +61,7 @@ public class MediaType implements Comparable<MediaType> {
N3 = of("text/n3")
;
- private final String value; // The entire
unparsed value.
+ private final String string; // The entire
unparsed value.
private final String mediaType; // The
"type/subtype" portion of the media type..
private final String type; // The media type
(e.g. "text" for Accept, "utf-8" for Accept-Charset)
private final String subType; // The media
sub-type (e.g. "json" for Accept, not used for Accept-Charset)
@@ -157,7 +157,7 @@ public class MediaType implements Comparable<MediaType> {
sb.append(mediaType);
for (NameValuePair p : parameters)
sb.append(';').append(p.getName()).append('=').append(p.getValue());
- this.value = sb.toString();
+ this.string = sb.toString();
}
/**
@@ -329,17 +329,17 @@ public class MediaType implements Comparable<MediaType> {
@Override /* Object */
public String toString() {
- return value;
+ return string;
}
@Override /* Object */
public int hashCode() {
- return value.hashCode();
+ return string.hashCode();
}
@Override /* Object */
public boolean equals(Object o) {
- return (o instanceof MediaType) && eq(this, (MediaType)o,
(x,y)->eq(x.value, y.value));
+ return (o instanceof MediaType) && eq(this, (MediaType)o,
(x,y)->eq(x.string, y.string));
}
@Override
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRange.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRange.java
similarity index 66%
copy from
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRange.java
copy to
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRange.java
index 662aa09..5605340 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRange.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRange.java
@@ -1,144 +1,192 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.http;
-
-import static org.apache.juneau.internal.ObjectUtils.*;
-
-import java.util.*;
-
-import org.apache.http.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.collections.*;
-
-
-/**
- * Describes a single type used in content negotiation between an HTTP client
and server, as described in
- * Section 14.1 and 14.7 of RFC2616 (the HTTP/1.1 specification).
- *
- * <ul class='seealso'>
- * <li class='extlink'>{@doc RFC2616}
- * </ul>
- */
-@BeanIgnore
-public class MediaRange extends MediaType {
-
- private final NameValuePair[] extensions;
- private final Float qValue;
- private final String value;
-
- /**
- * Constructor.
- *
- * @param value The raw media range string.
- */
- public MediaRange(String value) {
- this(parse(value));
- }
-
- /**
- * Constructor.
- *
- * @param e The parsed media range element.
- */
- public MediaRange(HeaderElement e) {
- super(e);
-
- Float qValue = 1f;
-
- // The media type consists of everything up to the q parameter.
- // The q parameter and stuff after is part of the range.
- List<NameValuePair> extensions = AList.of();
- boolean foundQ = false;
- for (NameValuePair p : e.getParameters()) {
- if (p.getName().equals("q")) {
- qValue = Float.parseFloat(p.getValue());
- foundQ = true;
- } else if (foundQ) {
-
extensions.add(BasicNameValuePair.of(p.getName(), p.getValue()));
- }
- }
-
- this.qValue = qValue;
- this.extensions = extensions.toArray(new
NameValuePair[extensions.size()]);
-
- StringBuffer sb = new StringBuffer().append(super.toString());
-
- // '1' is equivalent to specifying no qValue. If there's no
extensions, then we won't include a qValue.
- if (qValue.floatValue() == 1.0) {
- if (this.extensions.length > 0) {
- sb.append(";q=").append(qValue);
- for (NameValuePair p : extensions)
-
sb.append(';').append(p.getName()).append('=').append(p.getValue());
- }
- } else {
- sb.append(";q=").append(qValue);
- for (NameValuePair p : extensions)
-
sb.append(';').append(p.getName()).append('=').append(p.getValue());
- }
- value = sb.toString();
- }
-
- /**
- * Returns the <js>'q'</js> (quality) value for this type, as described
in Section 3.9 of RFC2616.
- *
- * <p>
- * The quality value is a float between <c>0.0</c> (unacceptable) and
<c>1.0</c> (most acceptable).
- *
- * <p>
- * If 'q' value doesn't make sense for the context (e.g. this range was
extracted from a <js>"content-*"</js>
- * header, as opposed to <js>"accept-*"</js> header, its value will
always be <js>"1"</js>.
- *
- * @return The 'q' value for this type, never <jk>null</jk>.
- */
- public Float getQValue() {
- return qValue;
- }
-
- /**
- * Returns the optional set of custom extensions defined for this type.
- *
- * <p>
- * Values are lowercase and never <jk>null</jk>.
- *
- * @return The optional list of extensions, never <jk>null</jk>.
- */
- public List<NameValuePair> getExtensions() {
- return Collections.unmodifiableList(Arrays.asList(extensions));
- }
-
- /**
- * Returns <jk>true</jk> if the specified object is also a
<c>MediaType</c>, and has the same qValue, type,
- * parameters, and extensions.
- *
- * @return <jk>true</jk> if object is equivalent.
- */
- @Override /* Object */
- public boolean equals(Object o) {
- return (o instanceof MediaRange) && eq(this, (MediaRange)o,
(x,y)->eq(x.value, y.value));
- }
-
- /**
- * Returns a hash based on this instance's <c>media-type</c>.
- *
- * @return A hash based on this instance's <c>media-type</c>.
- */
- @Override /* Object */
- public int hashCode() {
- return value.hashCode();
- }
-
- @Override /* Object */
- public String toString() {
- return value;
- }
-}
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.http;
+
+import static org.apache.juneau.internal.ObjectUtils.*;
+import static org.apache.juneau.internal.StringUtils.*;
+
+import java.util.*;
+
+import org.apache.http.*;
+import org.apache.http.message.*;
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.collections.*;
+
+/**
+ * Represents a single value in a comma-delimited header value that optionally
contains a quality metric for
+ * comparison and extension parameters.
+ *
+ * <p>
+ * Similar in concept to {@link MediaRanges} except instead of media types
(e.g. <js>"text/json"</js>),
+ * it's a simple type (e.g. <js>"iso-8601"</js>).
+ *
+ * <p>
+ * An example of a type range is a value in an <c>Accept-Encoding</c> header.
+ *
+ * <ul class='seealso'>
+ * <li class='extlink'>{@doc RFC2616}
+ * </ul>
+ */
+@BeanIgnore
+public class StringRange {
+
+ private static final HeaderElement DEFAULT_ELEMENT = new
BasicHeaderElement("", "");
+
+ private final NameValuePair[] extensions;
+ private final Float qValue;
+ private final String name;
+ private final String string;
+
+ /**
+ * Constructor.
+ *
+ * @param value The raw string range string.
+ */
+ public StringRange(String value) {
+ this(parse(value));
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param e The parsed string range element.
+ */
+ public StringRange(HeaderElement e) {
+ Float qValue = 1f;
+
+ // The media type consists of everything up to the q parameter.
+ // The q parameter and stuff after is part of the range.
+ List<NameValuePair> extensions = AList.of();
+ for (NameValuePair p : e.getParameters()) {
+ if (p.getName().equals("q")) {
+ qValue = Float.parseFloat(p.getValue());
+ } else {
+
extensions.add(BasicNameValuePair.of(p.getName(), p.getValue()));
+ }
+ }
+
+ this.qValue = qValue;
+ this.extensions = extensions.toArray(new
NameValuePair[extensions.size()]);
+ this.name = e.getName();
+
+ StringBuffer sb = new StringBuffer();
+
+ // '1' is equivalent to specifying no qValue. If there's no
extensions, then we won't include a qValue.
+ if (qValue.floatValue() == 1.0) {
+ if (this.extensions.length > 0) {
+ sb.append(";q=").append(qValue);
+ for (NameValuePair p : extensions)
+
sb.append(';').append(p.getName()).append('=').append(p.getValue());
+ }
+ } else {
+ sb.append(";q=").append(qValue);
+ for (NameValuePair p : extensions)
+
sb.append(';').append(p.getName()).append('=').append(p.getValue());
+ }
+ string = sb.toString();
+ }
+
+ /**
+ * Parses the specified header element part.
+ *
+ * @param value The header element part.
+ * @return Thew parsed header element part. Never <jk>null</jk>.
+ */
+ protected static HeaderElement parse(String value) {
+ HeaderElement[] elements =
BasicHeaderValueParser.parseElements(emptyIfNull(trim(value)), null);
+ return (elements.length > 0 ? elements[0] : DEFAULT_ELEMENT);
+ }
+
+ /**
+ * Returns the name of this string range.
+ *
+ * <p>
+ * This is the primary value minus the quality or other parameters.
+ *
+ * @return The name of this string range.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the <js>'q'</js> (quality) value for this type, as described
in Section 3.9 of RFC2616.
+ *
+ * <p>
+ * The quality value is a float between <c>0.0</c> (unacceptable) and
<c>1.0</c> (most acceptable).
+ *
+ * <p>
+ * If 'q' value doesn't make sense for the context (e.g. this range was
extracted from a <js>"content-*"</js>
+ * header, as opposed to <js>"accept-*"</js> header, its value will
always be <js>"1"</js>.
+ *
+ * @return The 'q' value for this type, never <jk>null</jk>.
+ */
+ public Float getQValue() {
+ return qValue;
+ }
+
+ /**
+ * Returns the optional set of custom extensions defined for this type.
+ *
+ * <p>
+ * Values are lowercase and never <jk>null</jk>.
+ *
+ * @return The optional list of extensions, never <jk>null</jk>.
+ */
+ public List<NameValuePair> getExtensions() {
+ return Collections.unmodifiableList(Arrays.asList(extensions));
+ }
+
+ /**
+ * Returns <jk>true</jk> if the specified object is also a
<c>MediaType</c>, and has the same qValue, type,
+ * parameters, and extensions.
+ *
+ * @return <jk>true</jk> if object is equivalent.
+ */
+ @Override /* Object */
+ public boolean equals(Object o) {
+ return (o instanceof StringRange) && eq(this, (StringRange)o,
(x,y)->eq(x.string, y.string));
+ }
+
+ /**
+ * Returns a hash based on this instance's <c>media-type</c>.
+ *
+ * @return A hash based on this instance's <c>media-type</c>.
+ */
+ @Override /* Object */
+ public int hashCode() {
+ return string.hashCode();
+ }
+
+ /**
+ * Performs a match of this string range against the specified name.
+ *
+ * @param name The name being compared against.
+ * @return
+ * 0 = no match, 100 = perfect match, 50 = meta-match.
+ */
+ public int match(String name) {
+ if (qValue == 0)
+ return 0;
+ if (this.name.equals(name))
+ return 100;
+ if (this.name.equals("*"))
+ return 50;
+ return 0;
+ }
+
+ @Override /* Object */
+ public String toString() {
+ return string;
+ }
+}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRanges.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRanges.java
similarity index 54%
copy from
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRanges.java
copy to
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRanges.java
index e94f06e..b87838f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaRanges.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRanges.java
@@ -24,93 +24,95 @@ import org.apache.juneau.collections.*;
import org.apache.juneau.internal.*;
/**
- * A parsed <c>Accept</c> or similar header value.
+ * A parsed <c>Accept-Encoding</c> or similar header value.
*
* <p>
- * The returned media ranges are sorted such that the most acceptable media is
available at ordinal position
+ * The returned ranges are sorted such that the most acceptable value is
available at ordinal position
* <js>'0'</js>, and the least acceptable at position n-1.
*
- * <p>
- * The syntax expected to be found in the referenced <c>value</c> complies
with the syntax described in
- * RFC2616, Section 14.1, as described below:
+ * <h5 class='topic'>RFC2616 Specification</h5>
+ *
+ * The Accept-Encoding request-header field is similar to Accept, but
restricts the content-codings (section 3.5) that
+ * are acceptable in the response.
+ *
* <p class='bcode w800'>
- * Accept = "Accept" ":"
- * #( media-range [ accept-params ] )
+ * Accept-Encoding = "Accept-Encoding" ":"
+ * 1#( codings [ ";" "q" "=" qvalue ] )
+ * codings = ( content-coding | "*" )
+ * </p>
*
- * media-range = ( "*\/*"
- * | ( type "/" "*" )
- * | ( type "/" subtype )
- * ) *( ";" parameter )
- * accept-params = ";" "q" "=" qvalue *( accept-extension )
- * accept-extension = ";" token [ "=" ( token | quoted-string ) ]
+ * <p>
+ * Examples of its use are:
+ * <p class='bcode w800'>
+ * Accept-Encoding: compress, gzip
+ * Accept-Encoding:
+ * Accept-Encoding: *
+ * Accept-Encoding: compress;q=0.5, gzip;q=1.0
+ * Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0
* </p>
*/
@BeanIgnore
-public class MediaRanges {
+public class StringRanges {
- private static final MediaRanges DEFAULT = new MediaRanges("*/*");
- private static final Cache<String,MediaRanges> CACHE = new
Cache<>(NOCACHE, CACHE_MAX_SIZE);
+ private static final StringRanges DEFAULT = new StringRanges("*");
+ private static final Cache<String,StringRanges> CACHE = new
Cache<>(NOCACHE, CACHE_MAX_SIZE);
- private final MediaRange[] ranges;
+ private final StringRange[] ranges;
private final String value;
/**
- * Returns a parsed <c>Accept</c> header value.
+ * Returns a parsed string range header value.
*
- * @param value The raw <c>Accept</c> header value.
- * @return A parsed <c>Accept</c> header value.
+ * @param value The raw string range header value.
+ * @return A parsed string range header value.
*/
- public static MediaRanges of(String value) {
+ public static StringRanges of(String value) {
if (value == null || value.length() == 0)
return DEFAULT;
- MediaRanges mr = CACHE.get(value);
+ StringRanges mr = CACHE.get(value);
if (mr == null)
- mr = CACHE.put(value, new MediaRanges(value));
+ mr = CACHE.put(value, new StringRanges(value));
return mr;
}
/**
* Constructor.
*
- * @param value The <c>Accept</c> header value.
+ * @param value The string range header value.
*/
- public MediaRanges(String value) {
+ public StringRanges(String value) {
this(parse(value));
}
/**
* Constructor.
*
- * @param e The parsed <c>Accept</c> header value.
+ * @param e The parsed string range header value.
*/
- public MediaRanges(HeaderElement[] e) {
+ public StringRanges(HeaderElement[] e) {
- List<MediaRange> l = AList.of();
+ List<StringRange> l = AList.of();
for (HeaderElement e2 : e)
- l.add(new MediaRange(e2));
+ l.add(new StringRange(e2));
l.sort(RANGE_COMPARATOR);
- ranges = l.toArray(new MediaRange[l.size()]);
+ ranges = l.toArray(new StringRange[l.size()]);
this.value = ranges.length == 1 ? ranges[0].toString() :
StringUtils.join(l, ',');
}
/**
- * Compares two MediaRanges for equality.
+ * Compares two StringRanges for equality.
*
* <p>
* The values are first compared according to <c>qValue</c> values.
* Should those values be equal, the <c>type</c> is then
lexicographically compared (case-insensitive) in
* ascending order, with the <js>"*"</js> type demoted last in that
order.
- * <c>MediaRanges</c> with the same type but different sub-types are
compared - a more specific subtype is
- * promoted over the 'wildcard' subtype.
- * <c>MediaRanges</c> with the same types but with extensions are
promoted over those same types with no
- * extensions.
*/
- private static final Comparator<MediaRange> RANGE_COMPARATOR = new
Comparator<MediaRange>() {
+ private static final Comparator<StringRange> RANGE_COMPARATOR = new
Comparator<StringRange>() {
@Override
- public int compare(MediaRange o1, MediaRange o2) {
+ public int compare(StringRange o1, StringRange o2) {
// Compare q-values.
int qCompare = Float.compare(o2.getQValue(),
o1.getQValue());
if (qCompare != 0)
@@ -124,12 +126,12 @@ public class MediaRanges {
};
/**
- * Given a list of media types, returns the best match for this
<c>Accept</c> header.
+ * Given a list of media types, returns the best match for this string
range header.
*
* <p>
- * Note that fuzzy matching is allowed on the media types where the
<c>Accept</c> header may
+ * Note that fuzzy matching is allowed on the media types where the
string range header may
* contain additional subtype parts.
- * <br>For example, given identical q-values and an <c>Accept</c> value
of <js>"text/json+activity"</js>,
+ * <br>For example, given identical q-values and an string range value
of <js>"text/json+activity"</js>,
* the media type <js>"text/json"</js> will match if
<js>"text/json+activity"</js> or <js>"text/activity+json"</js>
* isn't found.
* <br>The purpose for this is to allow serializers to match when
artifacts such as <c>id</c> properties are
@@ -138,24 +140,24 @@ public class MediaRanges {
* <p>
* See {@doc https://www.w3.org/TR/activitypub/#retrieving-objects
ActivityPub / Retrieving Objects}
*
- * @param mediaTypes The media types to match against.
+ * @param names The names to match against.
* @return The index into the array of the best match, or <c>-1</c> if
no suitable matches could be found.
*/
- public int findMatch(List<? extends MediaType> mediaTypes) {
+ public int findMatch(List<String> names) {
int matchQuant = 0, matchIndex = -1;
float q = 0f;
// Media ranges are ordered by 'q'.
// So we only need to search until we've found a match.
- for (MediaRange mr : ranges) {
+ for (StringRange mr : ranges) {
float q2 = mr.getQValue();
if (q2 < q || q2 == 0)
break;
- for (int i = 0; i < mediaTypes.size(); i++) {
- MediaType mt = mediaTypes.get(i);
- int matchQuant2 = mr.match(mt, false);
+ for (int i = 0; i < names.size(); i++) {
+ String mt = names.get(i);
+ int matchQuant2 = mr.match(mt);
if (matchQuant2 > matchQuant) {
matchIndex = i;
@@ -169,54 +171,18 @@ public class MediaRanges {
}
/**
- * Same as {@link #findMatch(List)} but matching against media type
ranges.
- *
- * <p>
- * Note that the q-types on both the <c>mediaTypeRanges</c> parameter
and this header
- * are taken into account when trying to find the best match.
- * <br>When both this header and the matching range have q-values, the
q-value for the match is the result of multiplying them.
- * <br>(e.g. Accept=<js>"text/html;q=0.9"</js> and
mediaTypeRange=<js>"text/html;q=0.9"</js> ==>, q-value=<c>0.81</c>).
- *
- * @param mediaRanges The media type ranges to match against.
- * @return The index into the array of the best match, or <c>-1</c> if
no suitable matches could be found.
- */
- public int findMatch(MediaRanges mediaRanges) {
- return findMatch(mediaRanges.getRanges());
- }
-
- /**
* Returns the {@link MediaRange} at the specified index.
*
* @param index The index position of the media range.
* @return The {@link MediaRange} at the specified index or
<jk>null</jk> if the index is out of range.
*/
- public MediaRange getRange(int index) {
+ public StringRange getRange(int index) {
if (index < 0 || index >= ranges.length)
return null;
return ranges[index];
}
/**
- * Convenience method for searching through all of the subtypes of all
the media ranges in this header for the
- * presence of a subtype fragment.
- *
- * <p>
- * For example, given the header <js>"text/json+activity"</js>, calling
- * <code>hasSubtypePart(<js>"activity"</js>)</code> returns
<jk>true</jk>.
- *
- * @param part The media type subtype fragment.
- * @return <jk>true</jk> if subtype fragment exists.
- */
- public boolean hasSubtypePart(String part) {
-
- for (MediaRange mr : ranges)
- if (mr.getQValue() > 0 &&
mr.getSubTypes().indexOf(part) >= 0)
- return true;
-
- return false;
- }
-
- /**
* Parses the specified header element part.
*
* @param value The header element part.
@@ -227,11 +193,11 @@ public class MediaRanges {
}
/**
- * Returns the media ranges that make up this object.
+ * Returns the string ranges that make up this object.
*
- * @return The media ranges that make up this object.
+ * @return The string ranges that make up this object.
*/
- public List<MediaRange> getRanges() {
+ public List<StringRange> getRanges() {
return Collections.unmodifiableList(Arrays.asList(ranges));
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptCharset.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptCharset.java
index 9c05ee8..d2607ae 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptCharset.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptCharset.java
@@ -16,6 +16,7 @@ import static org.apache.juneau.http.Constants.*;
import java.util.function.*;
+import org.apache.juneau.http.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.internal.*;
@@ -102,7 +103,7 @@ public class AcceptCharset extends BasicRangeArrayHeader {
* The parameter value.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* </ul>
@@ -122,7 +123,7 @@ public class AcceptCharset extends BasicRangeArrayHeader {
* The parameter value supplier.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* </ul>
@@ -139,7 +140,7 @@ public class AcceptCharset extends BasicRangeArrayHeader {
* The parameter value.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* <li>A {@link Supplier} of anything on this list.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptEncoding.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptEncoding.java
index f38b356..3c92dfa 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptEncoding.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptEncoding.java
@@ -16,6 +16,7 @@ import static org.apache.juneau.http.Constants.*;
import java.util.function.*;
+import org.apache.juneau.http.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.internal.*;
@@ -122,7 +123,7 @@ public class AcceptEncoding extends BasicRangeArrayHeader {
* The parameter value.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* </ul>
@@ -142,7 +143,7 @@ public class AcceptEncoding extends BasicRangeArrayHeader {
* The parameter value supplier.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* </ul>
@@ -159,7 +160,7 @@ public class AcceptEncoding extends BasicRangeArrayHeader {
* The parameter value.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* <li>A {@link Supplier} of anything on this list.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptLanguage.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptLanguage.java
index 31e94eb..d8f5bcf 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptLanguage.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/AcceptLanguage.java
@@ -16,6 +16,7 @@ import static org.apache.juneau.http.Constants.*;
import java.util.function.*;
+import org.apache.juneau.http.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.internal.*;
@@ -134,7 +135,7 @@ public class AcceptLanguage extends BasicRangeArrayHeader {
* The parameter value.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* </ul>
@@ -154,7 +155,7 @@ public class AcceptLanguage extends BasicRangeArrayHeader {
* The parameter value supplier.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* </ul>
@@ -171,7 +172,7 @@ public class AcceptLanguage extends BasicRangeArrayHeader {
* The parameter value.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* <li>A {@link Supplier} of anything on this list.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicRangeArrayHeader.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicRangeArrayHeader.java
index 8ee8795..3376f45 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicRangeArrayHeader.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicRangeArrayHeader.java
@@ -35,7 +35,7 @@ public class BasicRangeArrayHeader extends BasicHeader {
private static final long serialVersionUID = 1L;
- private List<StringRange> parsed;
+ private StringRanges ranges;
/**
* Convenience creator.
@@ -44,7 +44,7 @@ public class BasicRangeArrayHeader extends BasicHeader {
* The parameter value.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* </ul>
@@ -64,7 +64,7 @@ public class BasicRangeArrayHeader extends BasicHeader {
* The parameter value supplier.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* </ul>
* @return A new {@link BasicLongHeader} object.
@@ -81,7 +81,7 @@ public class BasicRangeArrayHeader extends BasicHeader {
* The parameter value.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* <li>A {@link Supplier} of anything on this list.
* </ul>
@@ -89,7 +89,7 @@ public class BasicRangeArrayHeader extends BasicHeader {
public BasicRangeArrayHeader(String name, Object value) {
super(name, value);
if (! isSupplier(value))
- parsed = getParsedValue();
+ ranges = getRanges();
}
@Override /* Header */
@@ -108,13 +108,13 @@ public class BasicRangeArrayHeader extends BasicHeader {
* @param types The types to match against.
* @return The index into the array of the best match, or <c>-1</c> if
no suitable matches could be found.
*/
- public int findMatch(String[] types) {
+ public int findMatch(List<String> types) {
// Type ranges are ordered by 'q'.
// So we only need to search until we've found a match.
- for (StringRange mr : getParsedValue())
- for (int i = 0; i < types.length; i++)
- if (mr.matches(types[i]))
+ for (StringRange mr : getRanges().getRanges())
+ for (int i = 0; i < types.size(); i++)
+ if (mr.match(types.get(i)) > 0)
return i;
return -1;
@@ -128,17 +128,16 @@ public class BasicRangeArrayHeader extends BasicHeader {
*
* @return An unmodifiable list of type ranges.
*/
- public List<StringRange> asRanges() {
- return getParsedValue();
+ public StringRanges asRanges() {
+ return getRanges();
}
- private List<StringRange> getParsedValue() {
- if (parsed != null)
- return parsed;
+ private StringRanges getRanges() {
+ if (ranges != null)
+ return ranges;
Object o = getRawValue();
if (o == null)
return null;
- return
Collections.unmodifiableList(Arrays.asList(StringRange.parse(o.toString())));
+ return StringRanges.of(o.toString());
}
-
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/StringRange.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/StringRange.java
deleted file mode 100644
index 49bbcb7..0000000
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/StringRange.java
+++ /dev/null
@@ -1,289 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.http.header;
-
-import static org.apache.juneau.internal.ObjectUtils.*;
-
-import java.util.*;
-import java.util.Map.*;
-
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.collections.*;
-import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
-
-/**
- * Represents a single value in a comma-delimited header value that optionally
contains a quality metric for
- * comparison and extension parameters.
- *
- * <p>
- * Similar in concept to {@link MediaRanges} except instead of media types
(e.g. <js>"text/json"</js>),
- * it's a simple type (e.g. <js>"iso-8601"</js>).
- *
- * <p>
- * An example of a type range is a value in an <c>Accept-Encoding</c> header.
- *
- * <ul class='seealso'>
- * <li class='extlink'>{@doc RFC2616}
- * </ul>
- */
-@BeanIgnore
-public class StringRange implements Comparable<StringRange> {
-
- private static final StringRange[] DEFAULT = new StringRange[]{new
StringRange("*")};
-
- private final String type;
- private final Float qValue;
- private final Map<String,Set<String>> extensions;
-
- /**
- * Parses a header such as an <c>Accept-Encoding</c> header value into
an array of type ranges.
- *
- * <p>
- * The syntax expected to be found in the referenced <c>value</c>
complies with the syntax described in
- * RFC2616, Section 14.1, as described below:
- * <p class='bcode w800'>
- * Accept-Encoding = "Accept-Encoding" ":"
- * 1#( codings [ ";" "q" "=" qvalue ] )
- * codings = ( content-coding | "*" )
- * </p>
- *
- * <p>
- * Examples of its use are:
- * <p class='bcode w800'>
- * Accept-Encoding: compress, gzip
- * Accept-Encoding:
- * Accept-Encoding: *
- * Accept-Encoding: compress;q=0.5, gzip;q=1.0
- * Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0
- * </p>
- *
- * @param value
- * The value to parse.
- * If <jk>null</jk> or empty, returns a single <c>TypeRange</c> is
returned that represents all types.
- * @return
- * The type ranges described by the string.
- * <br>The ranges are sorted such that the most acceptable type is
available at ordinal position <js>'0'</js>, and
- * the least acceptable at position n-1.
- */
- public static StringRange[] parse(String value) {
-
- if (value == null || value.length() == 0)
- return DEFAULT;
-
- if (value.indexOf(',') == -1)
- return new StringRange[]{new StringRange(value)};
-
- Set<StringRange> ranges = new TreeSet<>();
-
- for (String r : StringUtils.split(value)) {
- r = r.trim();
-
- if (r.isEmpty())
- continue;
-
- ranges.add(new StringRange(r));
- }
-
- return ranges.toArray(new StringRange[ranges.size()]);
- }
-
- private StringRange(String token) {
- Builder b = new Builder(token);
- this.type = b.type;
- this.qValue = b.qValue;
- this.extensions = AMap.unmodifiable(b.extensions);
- }
-
- static final class Builder {
- String type;
- Float qValue = 1f;
- Map<String,Set<String>> extensions;
-
- Builder(String token) {
-
- token = token.trim();
-
- int i = token.indexOf(";q=");
-
- if (i == -1) {
- type = token;
- return;
- }
-
- type = token.substring(0, i);
-
- String[] tokens = token.substring(i+1).split(";");
-
- // Only the type of the range is specified
- if (tokens.length > 0) {
- boolean isInExtensions = false;
- for (int j = 0; j < tokens.length; j++) {
- String[] parm = tokens[j].split("=");
- if (parm.length == 2) {
- String k = parm[0], v = parm[1];
- if (isInExtensions) {
- if (extensions == null)
- extensions =
new TreeMap<>();
- if (!
extensions.containsKey(k))
-
extensions.put(k, new TreeSet<String>());
-
extensions.get(k).add(v);
- } else if (k.equals("q")) {
- qValue = new Float(v);
- isInExtensions = true;
- }
- }
- }
- }
- }
- }
-
- /**
- * Returns the type enclosed by this type range.
- *
- * <h5 class='section'>Examples:</h5>
- * <ul>
- * <li><js>"compress"</js>
- * <li><js>"gzip"</js>
- * <li><js>"*"</js>
- * </ul>
- *
- * @return The type of this type range, lowercased, never <jk>null</jk>.
- */
- public String getType() {
- return type;
- }
-
- /**
- * Returns the <js>'q'</js> (quality) value for this type, as described
in Section 3.9 of RFC2616.
- *
- * <p>
- * The quality value is a float between <c>0.0</c> (unacceptable) and
<c>1.0</c> (most acceptable).
- *
- * <p>
- * If 'q' value doesn't make sense for the context (e.g. this range was
extracted from a <js>"content-*"</js>
- * header, as opposed to <js>"accept-*"</js> header, its value will
always be <js>"1"</js>.
- *
- * @return The 'q' value for this type, never <jk>null</jk>.
- */
- public Float getQValue() {
- return qValue;
- }
-
- /**
- * Returns the optional set of custom extensions defined for this type.
- *
- * <p>
- * Values are lowercase and never <jk>null</jk>.
- *
- * @return The optional list of extensions, never <jk>null</jk>.
- */
- public Map<String,Set<String>> getExtensions() {
- return extensions;
- }
-
- /**
- * Provides a string representation of this media range, suitable for
use as an <c>Accept</c> header value.
- *
- * <p>
- * The literal text generated will be all lowercase.
- *
- * @return A media range suitable for use as an Accept header value,
never <c>null</c>.
- */
- @Override /* Object */
- public String toString() {
- StringBuffer sb = new StringBuffer().append(type);
-
- // '1' is equivalent to specifying no qValue. If there's no
extensions, then we won't include a qValue.
- if (qValue.floatValue() == 1.0) {
- if (! extensions.isEmpty()) {
- sb.append(";q=").append(qValue);
- for (Entry<String,Set<String>> e :
extensions.entrySet()) {
- String k = e.getKey();
- for (String v : e.getValue())
-
sb.append(';').append(k).append('=').append(v);
- }
- }
- } else {
- sb.append(";q=").append(qValue);
- for (Entry<String,Set<String>> e :
extensions.entrySet()) {
- String k = e.getKey();
- for (String v : e.getValue())
-
sb.append(';').append(k).append('=').append(v);
- }
- }
- return sb.toString();
- }
-
- /**
- * Returns <jk>true</jk> if the specified object is also a
<c>MediaType</c>, and has the same qValue, type,
- * parameters, and extensions.
- *
- * @return <jk>true</jk> if object is equivalent.
- */
- @Override /* Object */
- public boolean equals(Object o) {
- return (o instanceof StringRange) && eq(this, (StringRange)o,
(x,y)->eq(x.qValue, y.qValue) && eq(x.type, y.type) && eq(x.extensions,
y.extensions));
- }
-
- /**
- * Returns a hash based on this instance's <c>media-type</c>.
- *
- * @return A hash based on this instance's <c>media-type</c>.
- */
- @Override /* Object */
- public int hashCode() {
- return type.hashCode();
- }
-
- /**
- * Compares two MediaRanges for equality.
- *
- * <p>
- * The values are first compared according to <c>qValue</c> values.
- * Should those values be equal, the <c>type</c> is then
lexicographically compared (case-insensitive) in
- * ascending order, with the <js>"*"</js> type demoted last in that
order.
- * <c>TypeRanges</c> with the same types but with extensions are
promoted over those same types with no
- * extensions.
- *
- * @param o The range to compare to. Never <jk>null</jk>.
- */
- @Override /* Comparable */
- public int compareTo(StringRange o) {
-
- // Compare q-values.
- int qCompare = Float.compare(o.qValue, qValue);
- if (qCompare != 0)
- return qCompare;
-
- // Compare media-types.
- // Note that '*' comes alphabetically before letters, so just
do a reverse-alphabetical comparison.
- int i = o.type.toString().compareTo(type.toString());
- return i;
- }
-
- /**
- * Checks if the specified type matches this range.
- *
- * <p>
- * The type will match this range if the range type string is the same
or <js>"*"</js>.
- *
- * @param type The type to match against this range.
- * @return <jk>true</jk> if the specified type matches this range.
- */
- public boolean matches(String type) {
- if (qValue == 0)
- return false;
- return this.type.equals(type) || this.type.equals("*");
- }
-}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/TE.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/TE.java
index d757bfb..f0616b0 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/TE.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/TE.java
@@ -16,6 +16,7 @@ import static org.apache.juneau.http.Constants.*;
import java.util.function.*;
+import org.apache.juneau.http.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.internal.*;
@@ -119,7 +120,7 @@ public class TE extends BasicRangeArrayHeader {
* The parameter value.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* </ul>
@@ -139,7 +140,7 @@ public class TE extends BasicRangeArrayHeader {
* The parameter value supplier.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* </ul>
@@ -156,7 +157,7 @@ public class TE extends BasicRangeArrayHeader {
* The parameter value.
* <br>Can be any of the following:
* <ul>
- * <li>{@link String} - Converted using {@link
StringRange#parse(String)}.
+ * <li>{@link String} - Converted using {@link
StringRanges#of(String)}.
* <li><c>StringRange[]</c> - Left as-is.
* <li>Anything else - Converted to <c>String</c> then
parsed.
* <li>A {@link Supplier} of anything on this list.