play.data.parsing.DataParsers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
RePlay is a fork of the Play1 framework, created by Codeborne.
package play.data.parsing;
import java.util.HashMap;
import java.util.Map;
public class DataParsers {
private static final Map parsers = new HashMap<>();
// These are our injected Parser. Maybe we later want to allow dynamic injection
static {
parsers.put("application/x-www-form-urlencoded", new UrlEncodedParser());
parsers.put("multipart/form-data", new ApacheMultipartParser());
parsers.put("multipart/mixed", new ApacheMultipartParser());
parsers.put("application/xml", new TextParser());
parsers.put("application/json", new TextParser());
}
public static DataParser forContentType(String contentType) {
DataParser dataParser = parsers.get(contentType);
if (dataParser != null) {
return dataParser;
} else if (contentType.startsWith("text/")) {
return new TextParser();
}
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy