Skip to content

Commit

Permalink
Address Norman's comment
Browse files Browse the repository at this point in the history
  • Loading branch information
franz1981 committed Sep 19, 2023
1 parent 4515b60 commit 329d1d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Expand Up @@ -234,7 +234,7 @@ public <C> void decodeParameters(ParameterCollector<? super C> collector, C accu
for (Entry<String, List<String>> param : params.entrySet()) {
final List<String> values = param.getValue();
for (int i = 0; i < values.size(); i++) {
collector.accept(param.getKey(), values.get(i), accumulator);
collector.collect(param.getKey(), values.get(i), accumulator);
}
}
} else {
Expand Down Expand Up @@ -416,7 +416,7 @@ private static <C> void decodeParams(String s, int from, Charset charset,
}
}

private static int indexOf(String s, int from, int to, int ch) {
private static int indexOf(CharSequence s, int from, int to, int ch) {
for (int i = from; i < to; i++) {
if (s.charAt(i) == ch) {
return i;
Expand All @@ -425,7 +425,7 @@ private static int indexOf(String s, int from, int to, int ch) {
return -1;
}

private static int skipIf(String s, int from, int to, int ch) {
private static int skipIf(CharSequence s, int from, int to, int ch) {
for (int i = from; i < to; i++) {
if (s.charAt(i) != ch) {
return i;
Expand All @@ -437,7 +437,7 @@ private static int skipIf(String s, int from, int to, int ch) {
private static final ParameterCollector<Map<String, List<String>>> MAP_PARAMETER_COLLECTOR =
new ParameterCollector<Map<String, List<String>>>() {
@Override
public void accept(String name, String value, Map<String, List<String>> accumulator) {
public void collect(String name, String value, Map<String, List<String>> accumulator) {
List<String> values = accumulator.get(name);
if (values == null) {
values = new ArrayList<String>(1);
Expand All @@ -448,7 +448,7 @@ public void accept(String name, String value, Map<String, List<String>> accumula
};

/**
* @return {@link ParameterCollector} which behave as its {@link ParameterCollector#accept} is defined as:
* @return {@link ParameterCollector} which behave as its {@link ParameterCollector#collect} is defined as:
*
* <pre>
* {@code
Expand All @@ -470,7 +470,7 @@ public static ParameterCollector<Map<String, List<String>>> mapCollector() {

/**
* This interface is used to accumulate Query decoded parameters.<br>
* The {@link #accept} method receive the query parameters in the same order are
* The {@link #collect} method receive the query parameters in the same order are
* decoded from the provided {@code uri}
* <p>
* eg "a=1&b=2&c=3"
Expand All @@ -480,11 +480,11 @@ public static ParameterCollector<Map<String, List<String>>> mapCollector() {
* <p>
* to be called.
* <p>
* Order of calling {@link #accept} is an implementation details users shouldn't rely on, anyway,
* Order of calling {@link #collect} is an implementation details users shouldn't rely on, anyway,
* and just store/report/filter them assuming random ordering, instead.
*/
public interface ParameterCollector<C> {
void accept(String name, String value, C accumulator);
void collect(String name, String value, C accumulator);
}

private static <C> void addParam(String s, int nameStart, int valueStart, int valueEnd,
Expand All @@ -497,7 +497,7 @@ private static <C> void addParam(String s, int nameStart, int valueStart, int va
}
String name = decodeComponent(s, nameStart, valueStart - 1, charset, false);
String value = decodeComponent(s, valueStart, valueEnd, charset, false);
collector.accept(name, value, accumulator);
collector.collect(name, value, accumulator);
}

/**
Expand Down Expand Up @@ -557,8 +557,8 @@ private static String decodeComponent(String s, int from, int toExcluded, Charse
return decodeEscapedComponent(s, from, toExcluded, charset, isPath, firstEscaped, len);
}

private static int getFirstEscaped(String s, int from, int toExcluded, boolean isPath) {
int cutOff = !isPath? '+' : '%';
private static int getFirstEscaped(CharSequence s, int from, int toExcluded, boolean isPath) {
int cutOff = isPath? '%' : '+';
for (int i = from; i < toExcluded; i++) {
int c = s.charAt(i);
if (c <= cutOff) {
Expand Down Expand Up @@ -602,7 +602,7 @@ private static String decodeEscapedComponent(String s, int from, int toExcluded,
return strBuf.toString();
}

private static int findPathEndIndex(String uri) {
private static int findPathEndIndex(CharSequence uri) {
int len = uri.length();
for (int i = 0; i < len; i++) {
char c = uri.charAt(i);
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class QueryStringDecoderBenchmark extends AbstractMicrobenchmark {
private String nonStandardDecodingUri;
private static final ParameterCollector<Blackhole> BH_COLLECTOR = new ParameterCollector<Blackhole>() {
@Override
public void accept(String name, String value, Blackhole accumulator) {
public void collect(String name, String value, Blackhole accumulator) {
accumulator.consume(name);
accumulator.consume(value);
}
Expand Down

0 comments on commit 329d1d5

Please sign in to comment.