本文整理汇总了Java中javax.ws.rs.core.Form.asMap方法的典型用法代码示例。如果您正苦于以下问题:Java Form.asMap方法的具体用法?Java Form.asMap怎么用?Java Form.asMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.Form
的用法示例。
在下文中一共展示了Form.asMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeMultipartForm
import javax.ws.rs.core.Form; //导入方法依赖的package包/类
public static InputStream serializeMultipartForm(final Form form) {
final String boundary = "------Boundary" + UUID.randomUUID().toString();
final StringBuilder b = new StringBuilder();
final MultivaluedMap<String, String> map = form.asMap();
for (final Entry<String, List<String>> entry : map.entrySet()) {
for (final String value : entry.getValue()) {
b.append(boundary);
b.append("\nContent-Disposition: form-data; name=\"");
b.append(entry.getKey());
b.append("\"\n\n");
b.append(value);
b.append("\n");
}
}
b.append(boundary);
return new ByteArrayInputStream(b.toString().getBytes(StandardCharsets.UTF_8));
}
示例2: getFilteredForm
import javax.ws.rs.core.Form; //导入方法依赖的package包/类
/**
* Returns a filtered Form object.
*
* @param entity
* requires a Form object for specific entity
* @param entityName
* specify the entity name for fetching read only fields.
* @return Form object.
*/
public static Form getFilteredForm(Form entity, String entityName) {
if (entityName == null || entityName.isEmpty()) {
return null;
}
MultivaluedMap<String, String> multiValMap = entity.asMap();
String readOnlyFields = T1Service.getEntityReadOnlyFields().getProperty(entityName);
if(readOnlyFields!=null){
List<String> readOnlyFieldList = Utility.getList(readOnlyFields);
if(readOnlyFieldList!=null){
for (String str : readOnlyFieldList) {
if (multiValMap.containsKey(str)) {
multiValMap.remove(str);
}
}
}
}
return new Form(multiValMap);
}