本文整理汇总了Java中enkan.collection.Parameters.empty方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.empty方法的具体用法?Java Parameters.empty怎么用?Java Parameters.empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enkan.collection.Parameters
的用法示例。
在下文中一共展示了Parameters.empty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import enkan.collection.Parameters; //导入方法依赖的package包/类
public static Parameters parse(InputStream in, Long contentLength, String contentType, int bufferSize) throws IOException {
if (contentLength != null && contentLength == 0) return Parameters.empty();
String boundary = parseBoundary(contentType);
if (boundary == null) return Parameters.empty();
if (bufferSize == 0) bufferSize = DEFAULT_BUFFER_SIZE;
byte[] buffer = new byte[bufferSize];
MultipartParser parser = new MultipartParser(boundary, bufferSize);
int readed = in.read(buffer);
parser.onRead(buffer, readed);
while (true) {
if (parser.state == ParseState.DONE) break;
readed = in.read(buffer, 0, parser.buf.remaining());
parser.onRead(buffer, readed);
}
return parser.result();
}
示例2: testNestedParams
import enkan.collection.Parameters; //导入方法依赖的package包/类
@Test
public void testNestedParams() {
Parameters params = Parameters.empty();
assocNested(params,
new String[]{"val", ""},
new ArrayList<String>(){{ add("hoge"); }});
assertEquals("hoge", params.getIn("val", 0));
params = Parameters.empty();
assocNested(params,
new String[]{"foo", "bar"},
new ArrayList<String>(){{ add("baz"); }});
assertEquals("baz", params.getIn("foo", "bar"));
params = Parameters.empty();
assocNested(params,
new String[]{"foo", "bar"},
new ArrayList<String>(){{ add("baz"); add("bay"); }});
assertEquals("bay", params.getIn("foo", "bar", 1));
}
示例3: nestedParamsRequest
import enkan.collection.Parameters; //导入方法依赖的package包/类
public HttpRequest nestedParamsRequest(HttpRequest request, Function<String, String[]> keyParser) {
Parameters params = request.getParams();
Parameters nestedParams = Parameters.empty();
params.keySet().forEach(key -> assocNested(nestedParams, keyParser.apply(key), params.getList(key)));
request.setParams(nestedParams);
return request;
}
示例4: formDecode
import enkan.collection.Parameters; //导入方法依赖的package包/类
public static Parameters formDecode(String encoded, String encoding) {
Parameters m = Parameters.empty();
for(String param : encoded.split("&")) {
String[] kv = param.split("=", 2);
if (kv.length == 1) {
m.put(formDecodeStr(kv[0], encoding), null);
} else if (kv.length == 2) {
m.put(formDecodeStr(kv[0], encoding),
formDecodeStr(kv[1], encoding));
}
}
return m;
}
示例5: parseParams
import enkan.collection.Parameters; //导入方法依赖的package包/类
protected Parameters parseParams(String urlencodedParams, String encoding) {
Parameters params = formDecode(urlencodedParams, encoding);
return params == null ? Parameters.empty() : params;
}
示例6: result
import enkan.collection.Parameters; //导入方法依赖的package包/类
public Parameters result() {
Parameters params = Parameters.empty();
collector.stream()
.forEach(part -> params.putAll(part.getData()));
return params;
}
示例7: assocNested
import enkan.collection.Parameters; //导入方法依赖的package包/类
protected Object assocNested(Parameters map, String[] keys, List<String> values) {
if (keys.length > 0) {
String[] ks = new String[keys.length - 1];
if (ks.length > 0) {
System.arraycopy(keys, 1, ks, 0, ks.length);
String j = ks[0];
if (j.isEmpty()) {
// Array
String[] js = new String[keys.length - 2];
if (js.length > 0) {
System.arraycopy(keys, 2, js, 0, js.length);
}
List<Object> nestedList = map.getList(keys[0]);
for (int i = nestedList.size(); i < values.size(); i++) nestedList.add(null);
for (int i = 0; i < values.size(); i++) {
List<String> vs = new ArrayList<>();
vs.add(values.get(i));
if (js.length > 0) {
nestedList.set(i,
assocNested((Parameters) Optional.ofNullable(nestedList.get(i)).orElse(Parameters.empty())
, js, vs));
} else {
nestedList.set(i, vs.get(0));
}
}
if (map.containsKey(keys[0])) {
map.replace(keys[0], nestedList);
} else {
map.put(keys[0], nestedList);
}
return map;
} else {
// Map
Parameters submap = (Parameters) map.getRawType(keys[0]);
if (submap == null) submap = Parameters.empty();
map.put(keys[0], assocNested(submap, ks, values));
return map;
}
} else {
return assocConj(map, keys[0], values);
}
} else {
return values;
}
}