All Downloads are FREE. Search and download functionalities are using the official Maven repository.

play.data.parsing.DataParsers Maven / Gradle / Ivy

There is a newer version: 2.6.3
Show newest version
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