diff --git a/README.md b/README.md index eb36c4d..6e4744d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -![Alt logo](https://raw.githubusercontent.com/noboomu/proteus/master/src/main/resources/io/sinistral/proteus/server/tools/swagger/proteus-logo.svg?sanitize=true) +![Alt logo](https://raw.githubusercontent.com/noboomu/proteus/master/core/src/main/resources/io/sinistral/proteus/proteus-logo.svg?sanitize=true) -An extremely __lightweight, flexible, and high performance__ [Undertow](http://undertow.io) based Java framework for developing RESTful web applications and microservices. +An extremely __lightweight, flexible, and high performance__ [Undertow](http://undertow.io) based Java framework for developing RESTful web applications and microservices - __NO MAGIC__ - Incredibly easy to use and get started @@ -9,7 +9,7 @@ An extremely __lightweight, flexible, and high performance__ [Undertow](http://u - JAX-RS compliant - Easy on the developer and the metal - Blazing fast!!! -[The latest Techempower benchmarks](https://www.techempower.com/benchmarks/) demonstrate __proteus__ outperforming 99% of all other web frameworks. +[The latest Techempower benchmarks](https://www.techempower.com/benchmarks/) demonstrate __proteus__ outperforming 99% of all other web frameworks ![Top 5 in Java Frameworks for Fortunes](https://github.com/noboomu/proteus-example/blob/master/src/main/resources/images/benchmark1.png?raw=true) diff --git a/core/pom.xml b/core/pom.xml index e92f85b..49a4c5a 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -241,48 +241,48 @@ - - - + + + - - - + + + - - - + + + - - - - + + + + - + + + + + + + + + + + + + + + + + diff --git a/core/src/main/java/io/sinistral/proteus/ProteusApplication.java b/core/src/main/java/io/sinistral/proteus/ProteusApplication.java index 335533c..a6d11d7 100644 --- a/core/src/main/java/io/sinistral/proteus/ProteusApplication.java +++ b/core/src/main/java/io/sinistral/proteus/ProteusApplication.java @@ -1,33 +1,5 @@ package io.sinistral.proteus; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.InputStream; -import java.net.SocketAddress; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.security.KeyStore; -import java.time.Duration; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import javax.ws.rs.core.MediaType; - -import org.apache.commons.lang3.time.DurationFormatUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.util.concurrent.MoreExecutors; @@ -41,7 +13,6 @@ import com.google.inject.Module; import com.google.inject.name.Named; import com.typesafe.config.Config; - import io.sinistral.proteus.modules.ConfigModule; import io.sinistral.proteus.server.endpoints.EndpointInfo; import io.sinistral.proteus.server.handlers.HandlerGenerator; @@ -58,544 +29,535 @@ import io.undertow.server.session.SessionAttachmentHandler; import io.undertow.util.Headers; import io.undertow.util.Methods; +import org.apache.commons.lang3.time.DurationFormatUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.core.MediaType; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.InputStream; +import java.net.SocketAddress; +import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.KeyStore; +import java.time.Duration; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collectors; /** * The base class for proteus applications. + * * @author jbauer */ + public class ProteusApplication { - private static Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ProteusApplication.class.getCanonicalName()); + private static Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ProteusApplication.class.getCanonicalName()); + + @Inject + @Named("registeredControllers") + public Set> registeredControllers; + + @Inject + @Named("registeredEndpoints") + public Set registeredEndpoints; + + @Inject + @Named("registeredServices") + public Set> registeredServices; + + @Inject + public RoutingHandler router; + + @Inject + public Config config; + + + public List> registeredModules = new ArrayList<>(); + + public Injector injector; + + public ServiceManager serviceManager = null; + + public Undertow undertow = null; + + public Class rootHandlerClass; + + public HttpHandler rootHandler; + + public AtomicBoolean running = new AtomicBoolean(false); + + public List ports = new ArrayList<>(); + + public Function serverConfigurationFunction = null; + + public Duration startupDuration; + + public ProteusApplication() + { + + injector = Guice.createInjector(new ConfigModule()); + injector.injectMembers(this); + + } + + public ProteusApplication(String configFile) + { + + injector = Guice.createInjector(new ConfigModule(configFile)); + injector.injectMembers(this); + + } + + public ProteusApplication(URL configURL) + { + + injector = Guice.createInjector(new ConfigModule(configURL)); + injector.injectMembers(this); + + } + + public void start() + { + if (this.isRunning()) { + log.warn("Server has already started..."); + return; + } + + final long startTime = System.currentTimeMillis(); + + log.info("Configuring modules: " + registeredModules); + + Set modules = registeredModules.stream().map(mc -> injector.getInstance(mc)).collect(Collectors.toSet()); + + injector = injector.createChildInjector(modules); + + if (rootHandlerClass == null && rootHandler == null) { + log.warn("No root handler class or root HttpHandler was specified, using default ServerDefaultHttpHandler."); + rootHandlerClass = ServerDefaultHttpHandler.class; + } + + log.info("Starting services..."); + + Set services = registeredServices.stream().map(sc -> injector.getInstance(sc)).collect(Collectors.toSet()); + + injector = injector.createChildInjector(services); + + serviceManager = new ServiceManager(services); + + serviceManager.addListener(new Listener() + { + public void stopped() + { + undertow.stop(); + running.set(false); + } + + public void healthy() + { + startupDuration = Duration.ofMillis(System.currentTimeMillis() - startTime); + + for (ListenerInfo info : undertow.getListenerInfo()) { + log.debug("listener info: " + info); + SocketAddress address = info.getAddress(); + + if (address != null) { + ports.add(((java.net.InetSocketAddress) address).getPort()); + } + } + + printStatus(); + + + running.set(true); + } + + public void failure(Service service) + { + log.error("Service failure: " + service); + } + + }, MoreExecutors.directExecutor()); + + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + try { + shutdown(); + } catch (TimeoutException timeout) { + log.error(timeout.getMessage(), timeout); + } + })); + + buildServer(); + + undertow.start(); + + serviceManager.startAsync(); + } + + public void shutdown() throws TimeoutException + { + if (!this.isRunning()) { + log.warn("Server is not running..."); + return; + } + + log.info("Shutting down..."); + + serviceManager.stopAsync().awaitStopped(1, TimeUnit.SECONDS); + + log.info("Shutdown complete."); + } - @Inject - @Named("registeredControllers") - public Set> registeredControllers; + public boolean isRunning() + { + return this.running.get(); + } - @Inject - @Named("registeredEndpoints") - public Set registeredEndpoints; + public void buildServer() + { - @Inject - @Named("registeredServices") - public Set> registeredServices; + for (Class controllerClass : registeredControllers) { + HandlerGenerator generator = new HandlerGenerator("io.sinistral.proteus.controllers.handlers", controllerClass); - @Inject - public RoutingHandler router; + injector.injectMembers(generator); - @Inject - public Config config; - + try { + Supplier generatedRouteSupplier = injector.getInstance(generator.compileClass()); - public List> registeredModules = new ArrayList<>(); + router.addAll(generatedRouteSupplier.get()); - public Injector injector; + } catch (Exception e) { + log.error("Exception creating handlers for " + controllerClass.getName() + "!!!\n" + e.getMessage(), e); + } - public ServiceManager serviceManager = null; + } - public Undertow undertow = null; + this.addDefaultRoutes(router); - public Class rootHandlerClass; + HttpHandler handler; - public HttpHandler rootHandler; + if (rootHandlerClass != null) { + handler = injector.getInstance(rootHandlerClass); + } else { + handler = rootHandler; + } - public AtomicBoolean running = new AtomicBoolean(false); + SessionAttachmentHandler sessionAttachmentHandler = null; - public List ports = new ArrayList<>(); + try { + sessionAttachmentHandler = injector.getInstance(SessionAttachmentHandler.class); + } catch (Exception e) { + log.info("No session attachment handler found."); + } - public Function serverConfigurationFunction = null; - - public Duration startupDuration; + if (sessionAttachmentHandler != null) { + log.info("Using session attachment handler."); - public ProteusApplication() - { + sessionAttachmentHandler.setNext(handler); + handler = sessionAttachmentHandler; + } - injector = Guice.createInjector(new ConfigModule()); - injector.injectMembers(this); + int httpPort = config.getInt("application.ports.http"); - } + if (System.getProperty("http.port") != null) { + httpPort = Integer.parseInt(System.getProperty("http.port")); + } - public ProteusApplication(String configFile) - { + Undertow.Builder undertowBuilder = Undertow.builder().addHttpListener(httpPort, config.getString("application.host")) - injector = Guice.createInjector(new ConfigModule(configFile)); - injector.injectMembers(this); + .setBufferSize(Long.valueOf(config.getMemorySize("undertow.bufferSize").toBytes()).intValue()) + .setIoThreads(Runtime.getRuntime().availableProcessors() * config.getInt("undertow.ioThreadsMultiplier")) + .setWorkerThreads(Runtime.getRuntime().availableProcessors() * config.getInt("undertow.workerThreadMultiplier")) + .setDirectBuffers(config.getBoolean("undertow.directBuffers")) + .setSocketOption(org.xnio.Options.BACKLOG, config.getInt("undertow.socket.backlog")) + .setSocketOption(org.xnio.Options.REUSE_ADDRESSES, config.getBoolean("undertow.socket.reuseAddresses")) + .setServerOption(UndertowOptions.ENABLE_HTTP2, config.getBoolean("undertow.server.enableHttp2")) + .setServerOption(UndertowOptions.ALWAYS_SET_DATE, config.getBoolean("undertow.server.alwaysSetDate")) + .setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, config.getBoolean("undertow.server.alwaysSetKeepAlive")) + .setServerOption(UndertowOptions.RECORD_REQUEST_START_TIME, config.getBoolean("undertow.server.recordRequestStartTime")) + .setServerOption(UndertowOptions.MAX_ENTITY_SIZE, config.getBytes("undertow.server.maxEntitySize")) + .setHandler(handler); - } - public ProteusApplication(URL configURL) - { + if (config.getBoolean("undertow.ssl.enabled")) { + try { + int httpsPort = config.getInt("application.ports.https"); - injector = Guice.createInjector(new ConfigModule(configURL)); - injector.injectMembers(this); + if (System.getProperty("https.port") != null) { + httpsPort = Integer.parseInt(System.getProperty("https.port")); + } - } + KeyStore keyStore = SecurityOps.loadKeyStore(config.getString("undertow.ssl.keystorePath"), config.getString("undertow.ssl.keystorePassword")); + KeyStore trustStore = SecurityOps.loadKeyStore(config.getString("undertow.ssl.truststorePath"), config.getString("undertow.ssl.truststorePassword")); - public void start() - { - if (this.isRunning()) - { - log.warn("Server has already started..."); - return; - } - - final long startTime = System.currentTimeMillis(); + undertowBuilder.addHttpsListener(httpsPort, config.getString("application.host"), SecurityOps.createSSLContext(keyStore, trustStore, config.getString("undertow.ssl.keystorePassword"))); - log.info("Configuring modules: " + registeredModules); - Set modules = registeredModules.stream().map(mc -> injector.getInstance(mc)).collect(Collectors.toSet()); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } - injector = injector.createChildInjector(modules); + if (serverConfigurationFunction != null) { + undertowBuilder = serverConfigurationFunction.apply(undertowBuilder); + } + + this.undertow = undertowBuilder.build(); + + } + + /** + * Add a service class to the application + * + * @param serviceClass + * @return the application + */ + public ProteusApplication addService(Class serviceClass) + { + registeredServices.add(serviceClass); + return this; + } + + /** + * Add a controller class to the application + * + * @param controllerClass + * @return the application + */ + public ProteusApplication addController(Class controllerClass) + { + registeredControllers.add(controllerClass); + return this; + } + + + /** + * Add a module class to the application + * + * @param moduleClass + * @return the application + */ + public ProteusApplication addModule(Class moduleClass) + { + registeredModules.add(moduleClass); + return this; + } + + + /** + * Add utility routes the router + * + * @param router + */ + public ProteusApplication addDefaultRoutes(RoutingHandler router) + { + + if (config.hasPath("health.statusPath")) { + try { + final String statusPath = config.getString("health.statusPath"); + + router.add(Methods.GET, statusPath, (final HttpServerExchange exchange) -> + { + exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, MediaType.TEXT_PLAIN); + exchange.getResponseSender().send("OK"); + }); + + this.registeredEndpoints.add(EndpointInfo.builder().withConsumes("*/*").withProduces("text/plain").withPathTemplate(statusPath).withControllerName("Internal").withMethod(Methods.GET).build()); + + } catch (Exception e) { + log.error("Error adding health status route.", e.getMessage()); + } + } + + if (config.hasPath("application.favicon")) { + try { + + final ByteBuffer faviconImageBuffer; + + final File faviconFile = new File(config.getString("application.favicon")); + + if (!faviconFile.exists()) { + try (final InputStream stream = this.getClass().getResourceAsStream(config.getString("application.favicon"))) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + byte[] buffer = new byte[4096]; + int read = 0; + while (read != -1) { + read = stream.read(buffer); + if (read > 0) { + baos.write(buffer, 0, read); + } + } + + faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray()); + } + + } else { + try (final InputStream stream = Files.newInputStream(Paths.get(config.getString("application.favicon")))) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + byte[] buffer = new byte[4096]; + int read = 0; + while (read != -1) { + read = stream.read(buffer); + if (read > 0) { + baos.write(buffer, 0, read); + } + } + + faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray()); + } + } + + router.add(Methods.GET, "favicon.ico", (final HttpServerExchange exchange) -> + { + exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, io.sinistral.proteus.server.MediaType.IMAGE_X_ICON.toString()); + exchange.getResponseSender().send(faviconImageBuffer); + }); + + } catch (Exception e) { + log.error("Error adding favicon route.", e.getMessage()); + } + } + + return this; + } + + /** + * Set the root HttpHandler class + * + * @param rootHandlerClass + * @return the application + */ + public ProteusApplication setRootHandlerClass(Class rootHandlerClass) + { + this.rootHandlerClass = rootHandlerClass; + return this; + } + + /** + * Set the root HttpHandler + * + * @param rootHandler + * @return the application + */ + public ProteusApplication setRootHandler(HttpHandler rootHandler) + { + this.rootHandler = rootHandler; + return this; + } + + /** + * Allows direct access to the Undertow.Builder for custom configuration + * + * @param serverConfigurationFunction the serverConfigurationFunction + */ + public ProteusApplication setServerConfigurationFunction(Function serverConfigurationFunction) + { + this.serverConfigurationFunction = serverConfigurationFunction; + return this; + } + + /** + * @return the serviceManager + */ + public ServiceManager getServiceManager() + { + return serviceManager; + } + + /** + * @return the config + */ + public Config getConfig() + { + return config; + } + + /** + * @return the router + */ + public RoutingHandler getRouter() + { + return router; + } + + + /** + * @return a list of used ports + */ + public List getPorts() + { + return ports; + } + + + /** + * @return The Undertow server + */ + public Undertow getUndertow() + { + return undertow; + } + + + public void printStatus() + { + Config globalHeaders = config.getConfig("globalHeaders"); + + Map globalHeadersParameters = globalHeaders.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().render())); + + StringBuilder sb = new StringBuilder(); + + sb.append("\nUsing global headers: \n"); + + List tableHeaders = Arrays.asList("Header", "Value"); + + List> tableRows = globalHeadersParameters.entrySet().stream().map(e -> Arrays.asList(e.getKey(), e.getValue())) + .collect(Collectors.toList()); + + TablePrinter printer = new TablePrinter(tableHeaders, tableRows); + + sb.append(printer.toString()); - if (rootHandlerClass == null && rootHandler == null) - { - log.warn("No root handler class or root HttpHandler was specified, using default ServerDefaultHttpHandler."); - rootHandlerClass = ServerDefaultHttpHandler.class; - } + sb.append("\nRegistered endpoints: \n"); + + tableHeaders = Arrays.asList("Method", "Path", "Consumes", "Produces", "Controller"); + + tableRows = this.registeredEndpoints.stream().sorted().map(e -> + Arrays.asList(e.getMethod().toString(), e.getPathTemplate(), String.format("[%s]", e.getConsumes()), String.format("[%s]", e.getProduces()), String.format("(%s.%s)", e.getControllerName(), e.getControllerMethod()))) + .collect(Collectors.toList()); - log.info("Starting services..."); + printer = new TablePrinter(tableHeaders, tableRows); - Set services = registeredServices.stream().map(sc -> injector.getInstance(sc)).collect(Collectors.toSet()); + sb.append(printer.toString()).append("\nRegistered services: \n"); - injector = injector.createChildInjector(services); + ImmutableMultimap serviceStateMap = this.serviceManager.servicesByState(); - serviceManager = new ServiceManager(services); + ImmutableMap serviceStartupTimeMap = this.serviceManager.startupTimes(); - serviceManager.addListener(new Listener() - { - public void stopped() - { - undertow.stop(); - running.set(false); - } + tableHeaders = Arrays.asList("Service", "State", "Startup Time"); - public void healthy() - { - startupDuration = Duration.ofMillis(System.currentTimeMillis() - startTime); - - for(ListenerInfo info : undertow.getListenerInfo()) - { - log.debug("listener info: " + info); - SocketAddress address = info.getAddress(); - - if(address != null) - { - ports.add( ((java.net.InetSocketAddress) address).getPort()); - } - } + tableRows = serviceStateMap.asMap().entrySet().stream().flatMap(e -> + e.getValue().stream().map(s -> + Arrays.asList(s.getClass().getSimpleName(), e.getKey().toString(), DurationFormatUtils.formatDurationHMS(serviceStartupTimeMap.get(s))))) + .collect(Collectors.toList()); - printStatus(); - + printer = new TablePrinter(tableHeaders, tableRows); - running.set(true); - } - - public void failure(Service service) - { - log.error("Service failure: " + service); - } - - }, MoreExecutors.directExecutor()); - - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - try - { - shutdown(); - } catch (TimeoutException timeout) - { - log.error(timeout.getMessage(),timeout); - } - })); - - buildServer(); - - undertow.start(); - - serviceManager.startAsync(); - } - - public void shutdown() throws TimeoutException - { - if (!this.isRunning()) - { - log.warn("Server is not running..."); - return; - } - - log.info("Shutting down..."); - - serviceManager.stopAsync().awaitStopped(1, TimeUnit.SECONDS); - - log.info("Shutdown complete."); - } - - public boolean isRunning() - { - return this.running.get(); - } - - public void buildServer() - { - - for (Class controllerClass : registeredControllers) - { - HandlerGenerator generator = new HandlerGenerator("io.sinistral.proteus.controllers.handlers", controllerClass); - - injector.injectMembers(generator); - - try - { - Supplier generatedRouteSupplier = injector.getInstance(generator.compileClass()); - - router.addAll(generatedRouteSupplier.get()); - - } catch (Exception e) - { - log.error("Exception creating handlers for " + controllerClass.getName() + "!!!\n" + e.getMessage(), e); - } - - } - - this.addDefaultRoutes(router); - - HttpHandler handler; - - if (rootHandlerClass != null) - { - handler = injector.getInstance(rootHandlerClass); - } - else - { - handler = rootHandler; - } - - SessionAttachmentHandler sessionAttachmentHandler = null; - - try - { - sessionAttachmentHandler = injector.getInstance(SessionAttachmentHandler.class); - } catch (Exception e) - { - log.info("No session attachment handler found."); - } - - if(sessionAttachmentHandler != null) - { - log.info("Using session attachment handler."); - - sessionAttachmentHandler.setNext(handler); - handler = sessionAttachmentHandler; - } - - int httpPort = config.getInt("application.ports.http"); - - if(System.getProperty("http.port") != null) - { - httpPort = Integer.parseInt(System.getProperty("http.port")); - } - - Undertow.Builder undertowBuilder = Undertow.builder().addHttpListener(httpPort, config.getString("application.host")) - - .setBufferSize(Long.valueOf(config.getMemorySize("undertow.bufferSize").toBytes()).intValue()) - .setIoThreads(Runtime.getRuntime().availableProcessors() * config.getInt("undertow.ioThreadsMultiplier")) - .setWorkerThreads(Runtime.getRuntime().availableProcessors() * config.getInt("undertow.workerThreadMultiplier")) - .setDirectBuffers(config.getBoolean("undertow.directBuffers")) - .setSocketOption(org.xnio.Options.BACKLOG, config.getInt("undertow.socket.backlog")) - .setSocketOption(org.xnio.Options.REUSE_ADDRESSES, config.getBoolean("undertow.socket.reuseAddresses")) - .setServerOption(UndertowOptions.ENABLE_HTTP2, config.getBoolean("undertow.server.enableHttp2")) - .setServerOption(UndertowOptions.ALWAYS_SET_DATE, config.getBoolean("undertow.server.alwaysSetDate")) - .setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, config.getBoolean("undertow.server.alwaysSetKeepAlive")) - .setServerOption(UndertowOptions.RECORD_REQUEST_START_TIME, config.getBoolean("undertow.server.recordRequestStartTime")) - .setServerOption(UndertowOptions.MAX_ENTITY_SIZE, config.getBytes("undertow.server.maxEntitySize")) - .setHandler(handler); - - - if (config.getBoolean("undertow.ssl.enabled")) - { - try - { - int httpsPort = config.getInt("application.ports.https"); - - if(System.getProperty("https.port") != null) - { - httpsPort = Integer.parseInt(System.getProperty("https.port")); - } - - KeyStore keyStore = SecurityOps.loadKeyStore(config.getString("undertow.ssl.keystorePath"), config.getString("undertow.ssl.keystorePassword")); - KeyStore trustStore = SecurityOps.loadKeyStore(config.getString("undertow.ssl.truststorePath"), config.getString("undertow.ssl.truststorePassword")); - - undertowBuilder.addHttpsListener(httpsPort, config.getString("application.host"), SecurityOps.createSSLContext(keyStore, trustStore, config.getString("undertow.ssl.keystorePassword"))); - - - } catch (Exception e) - { - log.error(e.getMessage(), e); - } - } - - if (serverConfigurationFunction != null) - { - undertowBuilder = serverConfigurationFunction.apply(undertowBuilder); - } - - this.undertow = undertowBuilder.build(); - - } - - /** - * Add a service class to the application - * @param serviceClass - * @return the application - */ - public ProteusApplication addService(Class serviceClass) - { - registeredServices.add(serviceClass); - return this; - } - - /** - * Add a controller class to the application - * @param controllerClass - * @return the application - */ - public ProteusApplication addController(Class controllerClass) - { - registeredControllers.add(controllerClass); - return this; - } - - - /** - * Add a module class to the application - * @param moduleClass - * @return the application - */ - public ProteusApplication addModule(Class moduleClass) - { - registeredModules.add(moduleClass); - return this; - } - - - /** - * Add utility routes the router - * @param router - */ - public ProteusApplication addDefaultRoutes(RoutingHandler router) - { - - if (config.hasPath("health.statusPath")) - { - try - { - final String statusPath = config.getString("health.statusPath"); - - router.add(Methods.GET, statusPath, (final HttpServerExchange exchange) -> - { - exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, MediaType.TEXT_PLAIN); - exchange.getResponseSender().send("OK"); - }); - - this.registeredEndpoints.add(EndpointInfo.builder().withConsumes("*/*").withProduces("text/plain").withPathTemplate(statusPath).withControllerName("Internal").withMethod(Methods.GET).build()); - - } catch (Exception e) - { - log.error("Error adding health status route.", e.getMessage()); - } - } - - if (config.hasPath("application.favicon")) - { - try - { - - final ByteBuffer faviconImageBuffer; - - final File faviconFile = new File(config.getString("application.favicon")); - - if (!faviconFile.exists()) - { - try (final InputStream stream = this.getClass().getResourceAsStream(config.getString("application.favicon"))) - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - byte[] buffer = new byte[4096]; - int read = 0; - while (read != -1) - { - read = stream.read(buffer); - if (read > 0) - { - baos.write(buffer, 0, read); - } - } - - faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray()); - } - - } - else - { - try (final InputStream stream = Files.newInputStream(Paths.get(config.getString("application.favicon")))) - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - byte[] buffer = new byte[4096]; - int read = 0; - while (read != -1) - { - read = stream.read(buffer); - if (read > 0) - { - baos.write(buffer, 0, read); - } - } - - faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray()); - } - } - - router.add(Methods.GET, "favicon.ico", (final HttpServerExchange exchange) -> - { - exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, io.sinistral.proteus.server.MediaType.IMAGE_X_ICON.toString()); - exchange.getResponseSender().send(faviconImageBuffer); - }); - - } catch (Exception e) - { - log.error("Error adding favicon route.", e.getMessage()); - } - } - - return this; - } - - /** - * Set the root HttpHandler class - * @param rootHandlerClass - * @return the application - */ - public ProteusApplication setRootHandlerClass(Class rootHandlerClass) - { - this.rootHandlerClass = rootHandlerClass; - return this; - } - - /** - * Set the root HttpHandler - * @param rootHandler - * @return the application - */ - public ProteusApplication setRootHandler(HttpHandler rootHandler) - { - this.rootHandler = rootHandler; - return this; - } - - /** - * Allows direct access to the Undertow.Builder for custom configuration - * - * @param serverConfigurationFunction - * the serverConfigurationFunction - */ - public ProteusApplication setServerConfigurationFunction(Function serverConfigurationFunction) - { - this.serverConfigurationFunction = serverConfigurationFunction; - return this; - } - - /** - * @return the serviceManager - */ - public ServiceManager getServiceManager() - { - return serviceManager; - } - - /** - * @return the config - */ - public Config getConfig() - { - return config; - } - - /** - * @return the router - */ - public RoutingHandler getRouter() - { - return router; - } - - - /** - * @return a list of used ports - */ - public List getPorts() - { - return ports; - } - - - /** - * @return The Undertow server - */ - public Undertow getUndertow() - { - return undertow; - } - - - public void printStatus() - { - Config globalHeaders = config.getConfig("globalHeaders"); - - Map globalHeadersParameters = globalHeaders.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().render())); - - StringBuilder sb = new StringBuilder(); - - sb.append("\nUsing global headers: \n"); - - List tableHeaders = Arrays.asList("Header","Value"); - - List> tableRows = globalHeadersParameters.entrySet().stream().map( e -> Arrays.asList( e.getKey(), e.getValue() )) - .collect(Collectors.toList()); - - TablePrinter printer = new TablePrinter(tableHeaders, tableRows); - - sb.append(printer.toString()); - - sb.append("\nRegistered endpoints: \n"); - - tableHeaders = Arrays.asList("Method","Path","Consumes","Produces","Controller"); - - tableRows = this.registeredEndpoints.stream().sorted().map( e -> - Arrays.asList( e.getMethod().toString(), e.getPathTemplate(), String.format("[%s]", e.getConsumes()), String.format("[%s]", e.getProduces()), String.format("(%s.%s)", e.getControllerName() , e.getControllerMethod() ) )) - .collect(Collectors.toList()); - - printer = new TablePrinter(tableHeaders, tableRows); - - sb.append(printer.toString()).append("\nRegistered services: \n"); - - ImmutableMultimap serviceStateMap = this.serviceManager.servicesByState(); - - ImmutableMap serviceStartupTimeMap = this.serviceManager.startupTimes(); - - tableHeaders = Arrays.asList("Service","State","Startup Time"); - - tableRows = serviceStateMap.asMap().entrySet().stream().flatMap(e -> - e.getValue().stream().map(s -> - Arrays.asList(s.getClass().getSimpleName() , e.getKey().toString(), DurationFormatUtils.formatDurationHMS(serviceStartupTimeMap.get(s)) ))) - .collect(Collectors.toList()); - - printer = new TablePrinter(tableHeaders, tableRows); - - sb.append(printer.toString()).append("\nListening On: " + this.ports ).append("\nApplication Startup Time: " + DurationFormatUtils.formatDurationHMS(this.startupDuration.toMillis()) + "\n"); - - log.info(sb.toString()); - } + sb.append(printer.toString()).append("\nListening On: " + this.ports).append("\nApplication Startup Time: " + DurationFormatUtils.formatDurationHMS(this.startupDuration.toMillis()) + "\n"); + log.info(sb.toString()); + } } diff --git a/core/src/main/java/io/sinistral/proteus/annotations/Blocking.java b/core/src/main/java/io/sinistral/proteus/annotations/Blocking.java index 62e65d2..359818f 100644 --- a/core/src/main/java/io/sinistral/proteus/annotations/Blocking.java +++ b/core/src/main/java/io/sinistral/proteus/annotations/Blocking.java @@ -1,4 +1,3 @@ - /** * */ @@ -15,7 +14,7 @@ * Indicates that this route should use a BlockingHandler */ @Retention(RUNTIME) -@Target({ TYPE, METHOD }) +@Target({TYPE, METHOD}) public @interface Blocking { boolean value() default true; diff --git a/core/src/main/java/io/sinistral/proteus/annotations/Chain.java b/core/src/main/java/io/sinistral/proteus/annotations/Chain.java index c83eb6f..1b6af2d 100644 --- a/core/src/main/java/io/sinistral/proteus/annotations/Chain.java +++ b/core/src/main/java/io/sinistral/proteus/annotations/Chain.java @@ -1,9 +1,10 @@ - /** * */ package io.sinistral.proteus.annotations; +import io.undertow.server.HandlerWrapper; + import java.lang.annotation.Retention; import java.lang.annotation.Target; @@ -11,13 +12,11 @@ import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; -import io.undertow.server.HandlerWrapper; - /** * Decorates all methods of a controller or a single controller method with one or more HandlerWrapper classes. */ @Retention(RUNTIME) -@Target({ TYPE, METHOD }) +@Target({TYPE, METHOD}) public @interface Chain { Class[] value(); diff --git a/core/src/main/java/io/sinistral/proteus/annotations/Debug.java b/core/src/main/java/io/sinistral/proteus/annotations/Debug.java index ee84c01..32123e2 100644 --- a/core/src/main/java/io/sinistral/proteus/annotations/Debug.java +++ b/core/src/main/java/io/sinistral/proteus/annotations/Debug.java @@ -1,4 +1,3 @@ - /** * */ @@ -15,7 +14,7 @@ * Indicates that this route should use a RequestDumpingHandler */ @Retention(RUNTIME) -@Target({ TYPE, METHOD }) +@Target({TYPE, METHOD}) public @interface Debug { boolean value() default true; diff --git a/core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java b/core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java index fa0f25c..787417b 100644 --- a/core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java +++ b/core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java @@ -1,15 +1,5 @@ - package io.sinistral.proteus.modules; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; @@ -17,24 +7,23 @@ import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.module.afterburner.AfterburnerModule; - -import com.google.common.util.concurrent.Service; import com.google.inject.AbstractModule; import com.google.inject.Singleton; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; - import com.typesafe.config.Config; - import io.sinistral.proteus.server.Extractors; import io.sinistral.proteus.server.ServerResponse; import io.sinistral.proteus.server.endpoints.EndpointInfo; import io.sinistral.proteus.services.BaseService; - import io.undertow.server.DefaultResponseListener; import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.RoutingHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.*; /** * @author jbauer @@ -66,7 +55,7 @@ public void bindMappers() XmlMapper xmlMapper = new XmlMapper(xmlModule); xmlMapper.enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION); - + this.bind(XmlMapper.class).toInstance(xmlMapper); ObjectMapper objectMapper = new ObjectMapper(); @@ -79,7 +68,7 @@ public void bindMappers() objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true); objectMapper.registerModule(new AfterburnerModule()); objectMapper.registerModule(new Jdk8Module()); - + this.bind(ObjectMapper.class).toInstance(objectMapper); this.requestStaticInjection(Extractors.class); this.requestStaticInjection(ServerResponse.class); @@ -131,11 +120,19 @@ protected void configure() this.bind(RoutingHandler.class).toInstance(router); this.bind(ApplicationModule.class).toInstance(this); - - this.bind(new TypeLiteral>>(){}) .annotatedWith(Names.named("registeredControllers")).toInstance(registeredControllers); - this.bind(new TypeLiteral>(){}) .annotatedWith(Names.named("registeredEndpoints")).toInstance(registeredEndpoints); - this.bind(new TypeLiteral>>(){}).annotatedWith(Names.named("registeredServices")).toInstance(registeredServices); - this.bind(new TypeLiteral>(){}).annotatedWith(Names.named("registeredHandlerWrappers")).toInstance(registeredHandlerWrappers); + + this.bind(new TypeLiteral>>() + { + }).annotatedWith(Names.named("registeredControllers")).toInstance(registeredControllers); + this.bind(new TypeLiteral>() + { + }).annotatedWith(Names.named("registeredEndpoints")).toInstance(registeredEndpoints); + this.bind(new TypeLiteral>>() + { + }).annotatedWith(Names.named("registeredServices")).toInstance(registeredServices); + this.bind(new TypeLiteral>() + { + }).annotatedWith(Names.named("registeredHandlerWrappers")).toInstance(registeredHandlerWrappers); } } diff --git a/core/src/main/java/io/sinistral/proteus/modules/ConfigModule.java b/core/src/main/java/io/sinistral/proteus/modules/ConfigModule.java index 71ec00f..09a5a26 100644 --- a/core/src/main/java/io/sinistral/proteus/modules/ConfigModule.java +++ b/core/src/main/java/io/sinistral/proteus/modules/ConfigModule.java @@ -1,21 +1,8 @@ - /** * */ package io.sinistral.proteus.modules; -import java.io.File; - -import java.lang.reflect.Type; - -import java.net.URL; - -import java.util.List; -import java.util.Map.Entry; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Key; @@ -23,11 +10,18 @@ import com.google.inject.name.Named; import com.google.inject.name.Names; import com.google.inject.util.Types; - import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; import com.typesafe.config.ConfigObject; import com.typesafe.config.ConfigValue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.lang.reflect.Type; +import java.net.URL; +import java.util.List; +import java.util.Map.Entry; /** * Much of this is taken with reverence from Jooby @@ -38,7 +32,7 @@ public class ConfigModule extends AbstractModule { private static Logger log = LoggerFactory.getLogger(ConfigModule.class.getCanonicalName()); - + protected String configFile = null; protected URL configURL = null; protected Config config = null; @@ -47,8 +41,7 @@ public ConfigModule() { this.configFile = System.getProperty("config.file"); - if (this.configFile == null) - { + if (this.configFile == null) { this.configFile = "application.conf"; } } @@ -68,24 +61,20 @@ private void bindConfig(final Config config) { traverse(this.binder(), "", config.root()); - for (Entry entry : config.entrySet()) - { + for (Entry entry : config.entrySet()) { String name = entry.getKey(); Named named = Names.named(name); Object value = entry.getValue().unwrapped(); - if (value instanceof List) - { + if (value instanceof List) { List values = (List) value; Type listType = (values.size() == 0) - ? String.class - : Types.listOf(values.iterator().next().getClass()); + ? String.class + : Types.listOf(values.iterator().next().getClass()); Key key = (Key) Key.get(listType, Names.named(name)); this.binder().bind(key).toInstance(values); - } - else - { + } else { this.binder().bindConstant().annotatedWith(named).to(value.toString()); } } @@ -95,7 +84,7 @@ private void bindConfig(final Config config) this.config = ConfigFactory.load(config).withFallback(referenceConfig); log.debug(this.config.toString()); - + this.binder().bind(Config.class).toInstance(config); } @@ -107,17 +96,14 @@ protected void configure() config = ConfigFactory.load(config).withFallback(referenceConfig); - if (configURL != null) - { + if (configURL != null) { config = ConfigFactory.load(ConfigFactory.parseURL(configURL)).withFallback(config); - } - else if (configFile != null) - { + } else if (configFile != null) { config = fileConfig(configFile).withFallback(config); } this.bindConfig(config); - + install(new ApplicationModule(this.config)); } @@ -126,16 +112,12 @@ private static Config fileConfig(final String fileName) File userDirectory = new File(System.getProperty("user.dir")); File fileRoot = new File(userDirectory, fileName); - if (fileRoot.exists()) - { + if (fileRoot.exists()) { return ConfigFactory.load(ConfigFactory.parseFile(fileRoot)); - } - else - { + } else { File fileConfig = new File(new File(userDirectory, "conf"), fileName); - if (fileConfig.exists()) - { + if (fileConfig.exists()) { return ConfigFactory.load(ConfigFactory.parseFile(fileConfig)); } } @@ -146,25 +128,24 @@ private static Config fileConfig(final String fileName) private static void traverse(final Binder binder, final String nextPath, final ConfigObject rootConfig) { rootConfig.forEach( - (key, value) -> { - if (value instanceof ConfigObject) - { - try { - - ConfigObject child = (ConfigObject) value; - String path = nextPath + key; - - Named named = Names.named(path); - - binder.bind(Config.class).annotatedWith(named).toInstance(child.toConfig()); - - traverse(binder, path + ".", child); - - } catch (Exception e) { - log.error("Error binding " + value, e); + (key, value) -> { + if (value instanceof ConfigObject) { + try { + + ConfigObject child = (ConfigObject) value; + String path = nextPath + key; + + Named named = Names.named(path); + + binder.bind(Config.class).annotatedWith(named).toInstance(child.toConfig()); + + traverse(binder, path + ".", child); + + } catch (Exception e) { + log.error("Error binding " + value, e); + } } - } - } ); + }); } } diff --git a/core/src/main/java/io/sinistral/proteus/server/Extractors.java b/core/src/main/java/io/sinistral/proteus/server/Extractors.java index af4f0a9..9952c63 100644 --- a/core/src/main/java/io/sinistral/proteus/server/Extractors.java +++ b/core/src/main/java/io/sinistral/proteus/server/Extractors.java @@ -1,5 +1,5 @@ /** - * + * */ package io.sinistral.proteus.server; @@ -37,482 +37,441 @@ */ public class Extractors { - private static Logger log = LoggerFactory.getLogger(Extractors.class.getCanonicalName()); - - @Inject - public static XmlMapper XML_MAPPER; - - @Inject - public static ObjectMapper OBJECT_MAPPER; - - public static JsonNode parseJson(byte[] bytes) { - try { - return OBJECT_MAPPER.readTree(bytes); - } catch (Exception e) { - log.error(e.getMessage(), e); - return null; + private static Logger log = LoggerFactory.getLogger(Extractors.class.getCanonicalName()); + + @Inject + public static XmlMapper XML_MAPPER; + + @Inject + public static ObjectMapper OBJECT_MAPPER; + + public static JsonNode parseJson(byte[] bytes) + { + try { + return OBJECT_MAPPER.readTree(bytes); + } catch (Exception e) { + log.error(e.getMessage(), e); + return null; + } } - } - - public static class Optional - { - - public static java.util.Optional extractWithFunction(final HttpServerExchange exchange, final String name, Function function) - { - return string(exchange, name).map(function); - } - - public static java.util.Optional jsonNode(final HttpServerExchange exchange) - { - return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(ByteBuffer::array).map( o -> parseJson(o)); - } - - public static java.util.Optional model(final HttpServerExchange exchange, final TypeReference type ) - { - if( ServerPredicates.XML_PREDICATE.resolve(exchange) ) - { - - return xmlModel(exchange,type); - } - else - { - return jsonModel(exchange,type); - } - } - - public static java.util.Optional model(final HttpServerExchange exchange, final Class type ) - { - if( ServerPredicates.XML_PREDICATE.resolve(exchange) ) - { - - return xmlModel(exchange,type); - } - else - { - return jsonModel(exchange,type); - } - } - - - public static java.util.Optional jsonModel(final HttpServerExchange exchange, final TypeReference type ) - { - return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(ByteBuffer::array).map( b -> { - try - { - return OBJECT_MAPPER.readValue(b, type); - } catch (Exception e) - { - log.error(e.getMessage(),e); - return null; - } - }); - } - - public static java.util.Optional jsonModel(final HttpServerExchange exchange, final Class type ) - { - return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(ByteBuffer::array).map( b -> { - try - { - return OBJECT_MAPPER.readValue(b, type); - } catch (Exception e) - { - log.error(e.getMessage(),e); - return null; - } - }); - } - - public static java.util.Optional xmlModel(final HttpServerExchange exchange, final TypeReference type ) - { - return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(ByteBuffer::array).map( b -> { - try - { - return XML_MAPPER.readValue(b,XML_MAPPER.getTypeFactory().constructType(type.getType())); - } catch (Exception e) - { - log.error(e.getMessage(),e); - return null; - } - }); - } - - public static java.util.Optional xmlModel(final HttpServerExchange exchange, final Class type ) - { - return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(ByteBuffer::array).map( b -> { - try - { - return XML_MAPPER.readValue(b,type); - } catch (Exception e) - { - log.error(e.getMessage(),e); - return null; - } - }); - - } - - - public static java.util.Optional date(final HttpServerExchange exchange,final String name) { - - return string(exchange, name).map( OffsetDateTime::parse ).map(OffsetDateTime::toInstant).map(Date::from); - - } - - public static java.util.Optional offsetDateTime(final HttpServerExchange exchange,final String name) { - - return string(exchange, name).map( OffsetDateTime::parse ); - - } - - - public static java.util.Optional zonedDateTime(final HttpServerExchange exchange,final String name) { - - return string(exchange, name).map( ZonedDateTime::parse ); - } - - public static java.util.Optional instant(final HttpServerExchange exchange,final String name) { - - return string(exchange, name).map( Instant::parse ); - } - - public static java.util.Optional any(final HttpServerExchange exchange ) - { - return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map( b -> parseJson(b.array())); - } - - public static java.util.Optional integerValue(final HttpServerExchange exchange, final String name) - { - return string(exchange, name).map(Integer::parseInt); - } - - public static java.util.Optional shortValue(final HttpServerExchange exchange, final String name) - { - return string(exchange, name).map(Short::parseShort); - } - - public static java.util.Optional floatValue(final HttpServerExchange exchange, final String name) - { - return string(exchange, name).map(Float::parseFloat); - } - - public static java.util.Optional doubleValue(final HttpServerExchange exchange, final String name) - { - return string(exchange, name).map(Double::parseDouble); - } - - - public static java.util.Optional longValue(final HttpServerExchange exchange, final String name) - { - return string(exchange, name).map(Long::parseLong); - } - - public static java.util.Optional booleanValue(final HttpServerExchange exchange, final String name) - { - return string(exchange, name).map(Boolean::parseBoolean); - } + + public static class Optional + { + + public static java.util.Optional extractWithFunction(final HttpServerExchange exchange, final String name, Function function) + { + return string(exchange, name).map(function); + } + + public static java.util.Optional jsonNode(final HttpServerExchange exchange) + { + return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(ByteBuffer::array).map(o -> parseJson(o)); + } + + public static java.util.Optional model(final HttpServerExchange exchange, final TypeReference type) + { + if (ServerPredicates.XML_PREDICATE.resolve(exchange)) { + + return xmlModel(exchange, type); + } else { + return jsonModel(exchange, type); + } + } + + public static java.util.Optional model(final HttpServerExchange exchange, final Class type) + { + if (ServerPredicates.XML_PREDICATE.resolve(exchange)) { + + return xmlModel(exchange, type); + } else { + return jsonModel(exchange, type); + } + } + + + public static java.util.Optional jsonModel(final HttpServerExchange exchange, final TypeReference type) + { + return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(ByteBuffer::array).map(b -> { + try { + return OBJECT_MAPPER.readValue(b, type); + } catch (Exception e) { + log.error(e.getMessage(), e); + return null; + } + }); + } + + public static java.util.Optional jsonModel(final HttpServerExchange exchange, final Class type) + { + return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(ByteBuffer::array).map(b -> { + try { + return OBJECT_MAPPER.readValue(b, type); + } catch (Exception e) { + log.error(e.getMessage(), e); + return null; + } + }); + } + + public static java.util.Optional xmlModel(final HttpServerExchange exchange, final TypeReference type) + { + return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(ByteBuffer::array).map(b -> { + try { + return XML_MAPPER.readValue(b, XML_MAPPER.getTypeFactory().constructType(type.getType())); + } catch (Exception e) { + log.error(e.getMessage(), e); + return null; + } + }); + } + + public static java.util.Optional xmlModel(final HttpServerExchange exchange, final Class type) + { + return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(ByteBuffer::array).map(b -> { + try { + return XML_MAPPER.readValue(b, type); + } catch (Exception e) { + log.error(e.getMessage(), e); + return null; + } + }); + + } + + + public static java.util.Optional date(final HttpServerExchange exchange, final String name) + { + + return string(exchange, name).map(OffsetDateTime::parse).map(OffsetDateTime::toInstant).map(Date::from); + + } + + public static java.util.Optional offsetDateTime(final HttpServerExchange exchange, final String name) + { + + return string(exchange, name).map(OffsetDateTime::parse); + + } + + + public static java.util.Optional zonedDateTime(final HttpServerExchange exchange, final String name) + { + + return string(exchange, name).map(ZonedDateTime::parse); + } + + public static java.util.Optional instant(final HttpServerExchange exchange, final String name) + { + + return string(exchange, name).map(Instant::parse); + } + + public static java.util.Optional any(final HttpServerExchange exchange) + { + return java.util.Optional.ofNullable(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY)).map(b -> parseJson(b.array())); + } + + public static java.util.Optional integerValue(final HttpServerExchange exchange, final String name) + { + return string(exchange, name).map(Integer::parseInt); + } + + public static java.util.Optional shortValue(final HttpServerExchange exchange, final String name) + { + return string(exchange, name).map(Short::parseShort); + } + + public static java.util.Optional floatValue(final HttpServerExchange exchange, final String name) + { + return string(exchange, name).map(Float::parseFloat); + } + + public static java.util.Optional doubleValue(final HttpServerExchange exchange, final String name) + { + return string(exchange, name).map(Double::parseDouble); + } + + + public static java.util.Optional longValue(final HttpServerExchange exchange, final String name) + { + return string(exchange, name).map(Long::parseLong); + } + + public static java.util.Optional booleanValue(final HttpServerExchange exchange, final String name) + { + return string(exchange, name).map(Boolean::parseBoolean); + } // public static > java.util.Optional enumValue(final HttpServerExchange exchange, final Class clazz, final String name) // { // return string(exchange, name).map(e -> Enum.valueOf(clazz, name)); // } - public static java.util.Optional string(final HttpServerExchange exchange, final String name) - { - return java.util.Optional.ofNullable(exchange.getQueryParameters().get(name)).map(Deque::getFirst); - } - - - public static java.util.Optional filePath(final HttpServerExchange exchange, final String name) - { - return java.util.Optional.ofNullable(exchange.getAttachment(FormDataParser.FORM_DATA).get(name)).map(Deque::getFirst).map( fv -> fv.getFileItem().getFile()); - } - - public static java.util.Optional file(final HttpServerExchange exchange, final String name) - { - return java.util.Optional.ofNullable(exchange.getAttachment(FormDataParser.FORM_DATA).get(name)).map(Deque::getFirst).map( fv -> fv.getFileItem().getFile().toFile()); - } - - public static java.util.Optional byteBuffer(final HttpServerExchange exchange, final String name) - { - return Optional.filePath(exchange,name).map( fp -> { - - try(final FileChannel fileChannel = FileChannel.open(fp, StandardOpenOption.READ)) - { - final ByteBuffer buffer = ByteBuffer.allocate((int)fileChannel.size()); - - fileChannel.read(buffer); - - buffer.flip(); - - return buffer; - - } catch(Exception e) - { - return null; - } - }); - } - } - - public static class Header - { - public static String string(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - try - { - return exchange.getRequestHeaders().get(name).getFirst(); - } catch(NullPointerException e) - { - throw new IllegalArgumentException("Missing parameter " + name, e); - } - } - - public static class Optional - { - - public static java.util.Optional string(final HttpServerExchange exchange, final String name) - { - return java.util.Optional.ofNullable(exchange.getRequestHeaders().get(name)).map(Deque::getFirst); - } - } - - - } - - public static Date date(final HttpServerExchange exchange,final String name) throws IllegalArgumentException { - - return Date.from( OffsetDateTime.parse( string(exchange,name) ).toInstant() ); - } - - - public static ZonedDateTime zonedDateTime(final HttpServerExchange exchange,final String name) throws IllegalArgumentException { - - return ZonedDateTime.parse( string(exchange,name) ); - - } - - public static OffsetDateTime offsetDateTime(final HttpServerExchange exchange,final String name) throws IllegalArgumentException { - - return OffsetDateTime.parse( string(exchange,name) ); - - } - - public static T jsonModel(final HttpServerExchange exchange, final TypeReference type ) throws IllegalArgumentException, IOException - { - final byte[] attachment = exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array(); - - return OBJECT_MAPPER.readValue(attachment, type); - } - - public static T jsonModel(final HttpServerExchange exchange, final Class type ) throws IllegalArgumentException, IOException - { - final byte[] attachment = exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array(); - - return OBJECT_MAPPER.readValue(attachment, type); - } - - - public static T xmlModel(final HttpServerExchange exchange, final Class type ) throws IllegalArgumentException, IOException - { - final byte[] attachment = exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array(); - - return XML_MAPPER.readValue(attachment, type); - } - - public static T xmlModel(final HttpServerExchange exchange, final TypeReference type ) throws IllegalArgumentException, IOException - { - final byte[] attachment = exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array(); - - return XML_MAPPER.readValue(attachment, XML_MAPPER.getTypeFactory().constructType(type.getType())); - } - - public static JsonNode any(final HttpServerExchange exchange ) - { - try - { - return parseJson( exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array() ); - } catch (Exception e) - { - log.warn(e.getMessage(),e); - return OBJECT_MAPPER.createObjectNode(); - } - } - - public static JsonNode jsonNode(final HttpServerExchange exchange ) - { - return parseJson(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array()); - } - - public static Path filePath(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - try - { - return exchange.getAttachment(FormDataParser.FORM_DATA).get(name).getFirst().getFileItem().getFile(); - } catch(NullPointerException e) - { - throw new IllegalArgumentException("Missing parameter " + name, e); - } - } - - public static File file(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - try - { - return exchange.getAttachment(FormDataParser.FORM_DATA).get(name).getFirst().getFileItem().getFile().toFile(); - } catch(NullPointerException e) - { - throw new IllegalArgumentException("Missing parameter " + name, e); - } - } - - public static ByteBuffer byteBuffer(final HttpServerExchange exchange, final String name) throws IOException - { - final Path filePath = filePath(exchange,name); - - try(final FileChannel fileChannel = FileChannel.open(filePath, StandardOpenOption.READ)) - { - final ByteBuffer buffer = ByteBuffer.allocate((int)fileChannel.size()); - - fileChannel.read(buffer); - - buffer.flip(); - - return buffer; - } - - } - - - public static String string(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - try - { - return exchange.getQueryParameters().get(name).getFirst(); - } catch (NullPointerException e) - { - throw new IllegalArgumentException("Missing parameter " + name, e); - } - } - - public static T extractWithFunction(final HttpServerExchange exchange, final String name, Function function) throws IllegalArgumentException - { - return function.apply(string(exchange, name)); - } - - public static Float floatValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - return Float.parseFloat(string(exchange, name)); - } - - public static Double doubleValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - return Double.parseDouble(string(exchange, name)); - } - - - public static Long longValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - return Long.parseLong( string(exchange, name) ); - } - - public static Instant instant(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - return Instant.parse( string(exchange, name) ); - } - - public static Integer integerValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - return Integer.parseInt(string(exchange, name)); - - } - - public static Short shortValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - return Short.parseShort(string(exchange, name)); - - } - - public static Boolean booleanValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException - { - return Boolean.parseBoolean(string(exchange, name)); - } - - public static T model(final HttpServerExchange exchange, final TypeReference type ) throws IllegalArgumentException,IOException - { - if( ServerPredicates.XML_PREDICATE.resolve(exchange) ) - { - return xmlModel(exchange,type); - } - else - { - return jsonModel(exchange,type); - } - } - - public static T model(final HttpServerExchange exchange, final Class type ) throws IllegalArgumentException,IOException - { - if( ServerPredicates.XML_PREDICATE.resolve(exchange) ) - { - return xmlModel(exchange,type); - } - else - { - return jsonModel(exchange,type); - } - } - - - - public static Function httpMethodFromMethod = (m) -> - Arrays.stream(m.getDeclaredAnnotations()).map( a -> { - - - if( a instanceof javax.ws.rs.POST) - { - return Methods.POST; + public static java.util.Optional string(final HttpServerExchange exchange, final String name) + { + return java.util.Optional.ofNullable(exchange.getQueryParameters().get(name)).map(Deque::getFirst); + } + + + public static java.util.Optional filePath(final HttpServerExchange exchange, final String name) + { + return java.util.Optional.ofNullable(exchange.getAttachment(FormDataParser.FORM_DATA).get(name)).map(Deque::getFirst).map(fv -> fv.getFileItem().getFile()); + } + + public static java.util.Optional file(final HttpServerExchange exchange, final String name) + { + return java.util.Optional.ofNullable(exchange.getAttachment(FormDataParser.FORM_DATA).get(name)).map(Deque::getFirst).map(fv -> fv.getFileItem().getFile().toFile()); + } + + public static java.util.Optional byteBuffer(final HttpServerExchange exchange, final String name) + { + return Optional.filePath(exchange, name).map(fp -> { + + try (final FileChannel fileChannel = FileChannel.open(fp, StandardOpenOption.READ)) { + final ByteBuffer buffer = ByteBuffer.allocate((int) fileChannel.size()); + + fileChannel.read(buffer); + + buffer.flip(); + + return buffer; + + } catch (Exception e) { + return null; } - else if( a instanceof javax.ws.rs.GET) - { + }); + } + } + + public static class Header + { + public static String string(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + try { + return exchange.getRequestHeaders().get(name).getFirst(); + } catch (NullPointerException e) { + throw new IllegalArgumentException("Missing parameter " + name, e); + } + } + + public static class Optional + { + + public static java.util.Optional string(final HttpServerExchange exchange, final String name) + { + return java.util.Optional.ofNullable(exchange.getRequestHeaders().get(name)).map(Deque::getFirst); + } + } + + + } + + public static Date date(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + + return Date.from(OffsetDateTime.parse(string(exchange, name)).toInstant()); + } + + + public static ZonedDateTime zonedDateTime(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + + return ZonedDateTime.parse(string(exchange, name)); + + } + + public static OffsetDateTime offsetDateTime(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + + return OffsetDateTime.parse(string(exchange, name)); + + } + + public static T jsonModel(final HttpServerExchange exchange, final TypeReference type) throws IllegalArgumentException, IOException + { + final byte[] attachment = exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array(); + + return OBJECT_MAPPER.readValue(attachment, type); + } + + public static T jsonModel(final HttpServerExchange exchange, final Class type) throws IllegalArgumentException, IOException + { + final byte[] attachment = exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array(); + + return OBJECT_MAPPER.readValue(attachment, type); + } + + + public static T xmlModel(final HttpServerExchange exchange, final Class type) throws IllegalArgumentException, IOException + { + final byte[] attachment = exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array(); + + return XML_MAPPER.readValue(attachment, type); + } + + public static T xmlModel(final HttpServerExchange exchange, final TypeReference type) throws IllegalArgumentException, IOException + { + final byte[] attachment = exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array(); + + return XML_MAPPER.readValue(attachment, XML_MAPPER.getTypeFactory().constructType(type.getType())); + } + + public static JsonNode any(final HttpServerExchange exchange) + { + try { + return parseJson(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array()); + } catch (Exception e) { + log.warn(e.getMessage(), e); + return OBJECT_MAPPER.createObjectNode(); + } + } + + public static JsonNode jsonNode(final HttpServerExchange exchange) + { + return parseJson(exchange.getAttachment(ServerRequest.BYTE_BUFFER_KEY).array()); + } + + public static Path filePath(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + try { + return exchange.getAttachment(FormDataParser.FORM_DATA).get(name).getFirst().getFileItem().getFile(); + } catch (NullPointerException e) { + throw new IllegalArgumentException("Missing parameter " + name, e); + } + } + + public static File file(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + try { + return exchange.getAttachment(FormDataParser.FORM_DATA).get(name).getFirst().getFileItem().getFile().toFile(); + } catch (NullPointerException e) { + throw new IllegalArgumentException("Missing parameter " + name, e); + } + } + + public static ByteBuffer byteBuffer(final HttpServerExchange exchange, final String name) throws IOException + { + final Path filePath = filePath(exchange, name); + + try (final FileChannel fileChannel = FileChannel.open(filePath, StandardOpenOption.READ)) { + final ByteBuffer buffer = ByteBuffer.allocate((int) fileChannel.size()); + + fileChannel.read(buffer); + + buffer.flip(); + + return buffer; + } + + } + + + public static String string(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + try { + return exchange.getQueryParameters().get(name).getFirst(); + } catch (NullPointerException e) { + throw new IllegalArgumentException("Missing parameter " + name, e); + } + } + + public static T extractWithFunction(final HttpServerExchange exchange, final String name, Function function) throws IllegalArgumentException + { + return function.apply(string(exchange, name)); + } + + public static Float floatValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + return Float.parseFloat(string(exchange, name)); + } + + public static Double doubleValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + return Double.parseDouble(string(exchange, name)); + } + + + public static Long longValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + return Long.parseLong(string(exchange, name)); + } + + public static Instant instant(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + return Instant.parse(string(exchange, name)); + } + + public static Integer integerValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + return Integer.parseInt(string(exchange, name)); + + } + + public static Short shortValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + return Short.parseShort(string(exchange, name)); + + } + + public static Boolean booleanValue(final HttpServerExchange exchange, final String name) throws IllegalArgumentException + { + return Boolean.parseBoolean(string(exchange, name)); + } + + public static T model(final HttpServerExchange exchange, final TypeReference type) throws IllegalArgumentException, IOException + { + if (ServerPredicates.XML_PREDICATE.resolve(exchange)) { + return xmlModel(exchange, type); + } else { + return jsonModel(exchange, type); + } + } + + public static T model(final HttpServerExchange exchange, final Class type) throws IllegalArgumentException, IOException + { + if (ServerPredicates.XML_PREDICATE.resolve(exchange)) { + return xmlModel(exchange, type); + } else { + return jsonModel(exchange, type); + } + } + + + public static Function httpMethodFromMethod = (m) -> + Arrays.stream(m.getDeclaredAnnotations()).map(a -> { + + + if (a instanceof javax.ws.rs.POST) { + return Methods.POST; + } else if (a instanceof javax.ws.rs.GET) { return Methods.GET; - } - else if( a instanceof javax.ws.rs.PUT) - { + } else if (a instanceof javax.ws.rs.PUT) { return Methods.PUT; - } - else if( a instanceof javax.ws.rs.DELETE) - { + } else if (a instanceof javax.ws.rs.DELETE) { return Methods.DELETE; - } - else if( a instanceof javax.ws.rs.OPTIONS) - { + } else if (a instanceof javax.ws.rs.OPTIONS) { return Methods.OPTIONS; - } - else if( a instanceof javax.ws.rs.HEAD) - { + } else if (a instanceof javax.ws.rs.HEAD) { return Methods.HEAD; - } - - else - { + } else { return null; } }).filter(Objects::nonNull).findFirst().get(); - - - public static Function pathTemplateFromMethod = (m) -> - { - javax.ws.rs.Path childPath = m.getDeclaredAnnotation(javax.ws.rs.Path.class); - - javax.ws.rs.Path parentPath = m.getDeclaringClass().getDeclaredAnnotation(javax.ws.rs.Path.class); - - if(!childPath.value().equals("/")) - { - return (parentPath.value() + '/' + childPath.value()).replaceAll("\\/\\/", "\\/") ; - } - - return (parentPath.value() ) ; - - }; + + + public static Function pathTemplateFromMethod = (m) -> + { + javax.ws.rs.Path childPath = m.getDeclaredAnnotation(javax.ws.rs.Path.class); + + javax.ws.rs.Path parentPath = m.getDeclaringClass().getDeclaredAnnotation(javax.ws.rs.Path.class); + + if (!childPath.value().equals("/")) { + return (parentPath.value() + '/' + childPath.value()).replaceAll("\\/\\/", "\\/"); + } + + return (parentPath.value()); + + }; } diff --git a/core/src/main/java/io/sinistral/proteus/server/MediaType.java b/core/src/main/java/io/sinistral/proteus/server/MediaType.java index 338d033..cf8a13c 100644 --- a/core/src/main/java/io/sinistral/proteus/server/MediaType.java +++ b/core/src/main/java/io/sinistral/proteus/server/MediaType.java @@ -1,5 +1,5 @@ /** - * + * */ package io.sinistral.proteus.server; @@ -7,1289 +7,1305 @@ * @author jbauer * lifted from Nikolche Mihajlovski's Rapidoid */ - + import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.stream.Collectors; - -public class MediaType { - private static final Map FILE_EXTENSIONS = new LinkedHashMap<>(); - private static final String[] NO_ATTR = new String[0]; - private static final String[] UTF8_ATTR = {"charset=utf-8"}; +public class MediaType +{ + + private static final Map FILE_EXTENSIONS = new LinkedHashMap<>(); + private static final String[] NO_ATTR = new String[0]; + private static final String[] UTF8_ATTR = {"charset=utf-8"}; + + /*******************************************************/ + + public static final MediaType ANY = create("*/*"); + public static final MediaType TEXT_ANY = create("text/*"); + public static final MediaType APPLICATION_ANY = create("application/*"); + public static final MediaType IMAGE_ANY = create("image/*"); + public static final MediaType VIDEO_ANY = create("video/*"); + public static final MediaType AUDIO_ANY = create("audio/*"); + + /*******************************************************/ + + public static final MediaType TEXT_YAML = create("text/yaml", "yaml"); + + public static final MediaType APPLICATION_ANDREW_INSET = create("application/andrew-inset", "ez"); + public static final MediaType APPLICATION_ANNODEX = create("application/annodex", "anx"); + public static final MediaType APPLICATION_APPLIXWARE = create("application/applixware", "aw"); + public static final MediaType APPLICATION_ATOMCAT_XML_UTF8 = createUTF8("application/atomcat+xml", "atomcat"); + public static final MediaType APPLICATION_ATOMSERV_XML_UTF8 = createUTF8("application/atomserv+xml", "atomsrv"); + public static final MediaType APPLICATION_ATOMSVC_XML_UTF8 = createUTF8("application/atomsvc+xml", "atomsvc"); + public static final MediaType APPLICATION_ATOM_XML_UTF8 = createUTF8("application/atom+xml", "atom"); + public static final MediaType APPLICATION_BBOLIN = create("application/bbolin", "lin"); + public static final MediaType APPLICATION_CAP = create("application/cap", "cap", "pcap"); + public static final MediaType APPLICATION_CCXML_XML = create("application/ccxml+xml", "ccxml"); + public static final MediaType APPLICATION_CDMI_CAPABILITY = create("application/cdmi-capability", "cdmia"); + public static final MediaType APPLICATION_CDMI_CONTAINER = create("application/cdmi-container", "cdmic"); + public static final MediaType APPLICATION_CDMI_DOMAIN = create("application/cdmi-domain", "cdmid"); + public static final MediaType APPLICATION_CDMI_OBJECT = create("application/cdmi-object", "cdmio"); + public static final MediaType APPLICATION_CDMI_QUEUE = create("application/cdmi-queue", "cdmiq"); + public static final MediaType APPLICATION_CU_SEEME = create("application/cu-seeme", "cu"); + public static final MediaType APPLICATION_DAVMOUNT_XML = create("application/davmount+xml", "davmount"); + public static final MediaType APPLICATION_DOCBOOK_XML = create("application/docbook+xml", "dbk"); + public static final MediaType APPLICATION_DSPTYPE = create("application/dsptype", "tsp"); + public static final MediaType APPLICATION_DSSC_DER = create("application/dssc+der", "dssc"); + public static final MediaType APPLICATION_DSSC_XML = create("application/dssc+xml", "xdssc"); + public static final MediaType APPLICATION_ECMASCRIPT_UTF8 = createUTF8("application/ecmascript", "ecma", "es"); + public static final MediaType APPLICATION_EMMA_XML = create("application/emma+xml", "emma"); + public static final MediaType APPLICATION_EPUB_ZIP = create("application/epub+zip", "epub"); + public static final MediaType APPLICATION_EXI = create("application/exi", "exi"); + public static final MediaType APPLICATION_FONT_TDPFR = create("application/font-tdpfr", "pfr"); + public static final MediaType APPLICATION_FUTURESPLASH = create("application/futuresplash", "spl"); + public static final MediaType APPLICATION_GML_XML = create("application/gml+xml", "gml"); + public static final MediaType APPLICATION_GPX_XML = create("application/gpx+xml", "gpx"); + public static final MediaType APPLICATION_GXF = create("application/gxf", "gxf"); + public static final MediaType APPLICATION_HTA = create("application/hta", "hta"); + public static final MediaType APPLICATION_HYPERSTUDIO = create("application/hyperstudio", "stk"); + public static final MediaType APPLICATION_INKML_XML = create("application/inkml+xml", "ink", "inkml"); + public static final MediaType APPLICATION_IPFIX = create("application/ipfix", "ipfix"); + public static final MediaType APPLICATION_JAVA_ARCHIVE = create("application/java-archive", "jar"); + public static final MediaType APPLICATION_JAVASCRIPT_UTF8 = createUTF8("application/javascript", "js"); + public static final MediaType APPLICATION_JAVA_SERIALIZED_OBJECT = create("application/java-serialized-object", + "ser"); + public static final MediaType APPLICATION_JAVA_VM = create("application/java-vm", "class"); + public static final MediaType APPLICATION_JSON = create("application/json", "json", "map"); + public static final MediaType APPLICATION_JSONML_JSON = create("application/jsonml+json", "jsonml"); + public static final MediaType APPLICATION_LOST_XML = create("application/lost+xml", "lostxml"); + public static final MediaType APPLICATION_M3G = create("application/m3g", "m3g"); + public static final MediaType APPLICATION_MAC_BINHEX40 = create("application/mac-binhex40", "hqx"); + public static final MediaType APPLICATION_MAC_COMPACTPRO = create("application/mac-compactpro", "cpt"); + public static final MediaType APPLICATION_MADS_XML = create("application/mads+xml", "mads"); + public static final MediaType APPLICATION_MARC = create("application/marc", "mrc"); + public static final MediaType APPLICATION_MARCXML_XML = create("application/marcxml+xml", "mrcx"); + public static final MediaType APPLICATION_MATHEMATICA = create("application/mathematica", "ma", "mb", "nb", "nbp"); + public static final MediaType APPLICATION_MATHML_XML = create("application/mathml+xml", "mathml"); + public static final MediaType APPLICATION_MBOX = create("application/mbox", "mbox"); + public static final MediaType APPLICATION_MEDIASERVERCONTROL_XML = create("application/mediaservercontrol+xml", + "MSCML"); + public static final MediaType APPLICATION_METALINK4_XML = create("application/metalink4+xml", "meta4"); + public static final MediaType APPLICATION_METALINK_XML = create("application/metalink+xml", "metalink"); + public static final MediaType APPLICATION_METS_XML = create("application/mets+xml", "mets"); + public static final MediaType APPLICATION_MODS_XML = create("application/mods+xml", "mods"); + public static final MediaType APPLICATION_MP21 = create("application/mp21", "m21", "mp21"); + public static final MediaType APPLICATION_MP4 = create("application/mp4", "mp4s"); + public static final MediaType APPLICATION_MSACCESS = create("application/msaccess", "mdb"); + public static final MediaType APPLICATION_MSWORD = create("application/msword", "doc", "dot"); + public static final MediaType APPLICATION_MXF = create("application/mxf", "mxf"); + public static final MediaType APPLICATION_OCTET_STREAM = create("application/octet-stream", "bin", "dms", "lrf", + "MAR", "SO", "DIST", "DISTZ", "PKG", "BPK", "DUMP", "ELC", "DEPLOY"); + public static final MediaType APPLICATION_ODA = create("application/oda", "oda"); + public static final MediaType APPLICATION_OEBPS_PACKAGE_XML = create("application/oebps-package+xml", "opf"); + public static final MediaType APPLICATION_OGG = create("application/ogg", "ogx"); + public static final MediaType APPLICATION_OMDOC_XML = create("application/omdoc+xml", "omdoc"); + public static final MediaType APPLICATION_ONENOTE = create("application/onenote", "one", "onetoc", "onetoc2", + "ONETMP", "ONEPKG"); + public static final MediaType APPLICATION_OXPS = create("application/oxps", "oxps"); + public static final MediaType APPLICATION_PATCH_OPS_ERROR_XML = create("application/patch-ops-error+xml", "xer"); + public static final MediaType APPLICATION_PDF = create("application/pdf", "pdf"); + public static final MediaType APPLICATION_PGP_ENCRYPTED = create("application/pgp-encrypted", "pgp"); + public static final MediaType APPLICATION_PGP_KEYS = create("application/pgp-keys", "key"); + public static final MediaType APPLICATION_PGP_SIGNATURE = create("application/pgp-signature", "asc", "pgp", "sig"); + public static final MediaType APPLICATION_PICS_RULES = create("application/pics-rules", "prf"); + public static final MediaType APPLICATION_PKCS10 = create("application/pkcs10", "p10"); + public static final MediaType APPLICATION_PKCS7_MIME = create("application/pkcs7-mime", "p7m", "p7c"); + public static final MediaType APPLICATION_PKCS7_SIGNATURE = create("application/pkcs7-signature", "p7s"); + public static final MediaType APPLICATION_PKCS8 = create("application/pkcs8", "p8"); + public static final MediaType APPLICATION_PKIX_ATTR_CERT = create("application/pkix-attr-cert", "ac"); + public static final MediaType APPLICATION_PKIX_CERT = create("application/pkix-cert", "cer"); + public static final MediaType APPLICATION_PKIXCMP = create("application/pkixcmp", "pki"); + public static final MediaType APPLICATION_PKIX_CRL = create("application/pkix-crl", "crl"); + public static final MediaType APPLICATION_PKIX_PKIPATH = create("application/pkix-pkipath", "pkipath"); + public static final MediaType APPLICATION_PLS_XML = create("application/pls+xml", "pls"); + public static final MediaType APPLICATION_POSTSCRIPT = create("application/postscript", "ps", "ai", "eps", "epsi", + "EPSF", "EPS2", "EPS3"); + public static final MediaType APPLICATION_PRS_CWW = create("application/prs.cww", "cww"); + public static final MediaType APPLICATION_PSKC_XML = create("application/pskc+xml", "pskcxml"); + public static final MediaType APPLICATION_RAR = create("application/rar", "rar"); + public static final MediaType APPLICATION_RDF_XML = create("application/rdf+xml", "rdf"); + public static final MediaType APPLICATION_REGINFO_XML = create("application/reginfo+xml", "rif"); + public static final MediaType APPLICATION_RELAX_NG_COMPACT_SYNTAX = create("application/relax-ng-compact-syntax", + "RNC"); + public static final MediaType APPLICATION_RESOURCE_LISTS_DIFF_XML = create("application/resource-lists-diff+xml", + "RLD"); + public static final MediaType APPLICATION_RESOURCE_LISTS_XML = create("application/resource-lists+xml", "rl"); + public static final MediaType APPLICATION_RLS_SERVICES_XML = create("application/rls-services+xml", "rs"); + public static final MediaType APPLICATION_RPKI_GHOSTBUSTERS = create("application/rpki-ghostbusters", "gbr"); + public static final MediaType APPLICATION_RPKI_MANIFEST = create("application/rpki-manifest", "mft"); + public static final MediaType APPLICATION_RPKI_ROA = create("application/rpki-roa", "roa"); + public static final MediaType APPLICATION_RSD_XML_UTF8 = createUTF8("application/rsd+xml", "rsd"); + public static final MediaType APPLICATION_RSS_XML_UTF8 = createUTF8("application/rss+xml", "rss"); + public static final MediaType APPLICATION_RTF = create("application/rtf", "rtf"); + public static final MediaType APPLICATION_SBML_XML = create("application/sbml+xml", "sbml"); + public static final MediaType APPLICATION_SCVP_CV_REQUEST = create("application/scvp-cv-request", "scq"); + public static final MediaType APPLICATION_SCVP_CV_RESPONSE = create("application/scvp-cv-response", "scs"); + public static final MediaType APPLICATION_SCVP_VP_REQUEST = create("application/scvp-vp-request", "spq"); + public static final MediaType APPLICATION_SCVP_VP_RESPONSE = create("application/scvp-vp-response", "spp"); + public static final MediaType APPLICATION_SDP = create("application/sdp", "sdp"); + public static final MediaType APPLICATION_SET_PAYMENT_INITIATION = create("application/set-payment-initiation", + "SETPAY"); + public static final MediaType APPLICATION_SET_REGISTRATION_INITIATION = create( + "APPLICATION/SET-REGISTRATION-INITIATION", "SETREG"); + public static final MediaType APPLICATION_SHF_XML = create("application/shf+xml", "shf"); + public static final MediaType APPLICATION_SLA = create("application/sla", "stl"); + public static final MediaType APPLICATION_SMIL = create("application/smil", "smi", "smil"); + public static final MediaType APPLICATION_SMIL_XML = create("application/smil+xml", "smi", "smil"); + public static final MediaType APPLICATION_SPARQL_QUERY = create("application/sparql-query", "rq"); + public static final MediaType APPLICATION_SPARQL_RESULTS_XML = create("application/sparql-results+xml", "srx"); + public static final MediaType APPLICATION_SRGS = create("application/srgs", "gram"); + public static final MediaType APPLICATION_SRGS_XML = create("application/srgs+xml", "grxml"); + public static final MediaType APPLICATION_SRU_XML = create("application/sru+xml", "sru"); + public static final MediaType APPLICATION_SSDL_XML = create("application/ssdl+xml", "ssdl"); + public static final MediaType APPLICATION_SSML_XML = create("application/ssml+xml", "ssml"); + public static final MediaType APPLICATION_TEI_XML = create("application/tei+xml", "tei", "teicorpus"); + public static final MediaType APPLICATION_THRAUD_XML = create("application/thraud+xml", "tfi"); + public static final MediaType APPLICATION_TIMESTAMPED_DATA = create("application/timestamped-data", "tsd"); + public static final MediaType APPLICATION_VND_3GPP2_TCAP = create("application/vnd.3gpp2.tcap", "tcap"); + public static final MediaType APPLICATION_VND_3GPP_PIC_BW_LARGE = create("application/vnd.3gpp.pic-bw-large", "plb"); + public static final MediaType APPLICATION_VND_3GPP_PIC_BW_SMALL = create("application/vnd.3gpp.pic-bw-small", "psb"); + public static final MediaType APPLICATION_VND_3GPP_PIC_BW_VAR = create("application/vnd.3gpp.pic-bw-var", "pvb"); + public static final MediaType APPLICATION_VND_3M_POST_IT_NOTES = create("application/vnd.3m.post-it-notes", "pwn"); + public static final MediaType APPLICATION_VND_ACCPAC_SIMPLY_ASO = create("application/vnd.accpac.simply.aso", "aso"); + public static final MediaType APPLICATION_VND_ACCPAC_SIMPLY_IMP = create("application/vnd.accpac.simply.imp", "imp"); + public static final MediaType APPLICATION_VND_ACUCOBOL = create("application/vnd.acucobol", "acu"); + public static final MediaType APPLICATION_VND_ACUCORP = create("application/vnd.acucorp", "atc", "acutc"); + public static final MediaType APPLICATION_VND_ADOBE_AIR_APPLICATION_INSTALLER_PACKAGE_ZIP = create( + "APPLICATION/VND.ADOBE.AIR-APPLICATION-INSTALLER-PACKAGE+ZIP", "AIR"); + public static final MediaType APPLICATION_VND_ADOBE_FORMSCENTRAL_FCDT = create( + "APPLICATION/VND.ADOBE.FORMSCENTRAL.FCDT", "FCDT"); + public static final MediaType APPLICATION_VND_ADOBE_FXP = create("application/vnd.adobe.fxp", "fxp", "fxpl"); + public static final MediaType APPLICATION_VND_ADOBE_XDP_XML = create("application/vnd.adobe.xdp+xml", "xdp"); + public static final MediaType APPLICATION_VND_ADOBE_XFDF = create("application/vnd.adobe.xfdf", "xfdf"); + public static final MediaType APPLICATION_VND_AHEAD_SPACE = create("application/vnd.ahead.space", "ahead"); + public static final MediaType APPLICATION_VND_AIRZIP_FILESECURE_AZF = create( + "application/vnd.airzip.filesecure.azf", "AZF"); + public static final MediaType APPLICATION_VND_AIRZIP_FILESECURE_AZS = create( + "application/vnd.airzip.filesecure.azs", "AZS"); + public static final MediaType APPLICATION_VND_AMAZON_EBOOK = create("application/vnd.amazon.ebook", "azw"); + public static final MediaType APPLICATION_VND_AMERICANDYNAMICS_ACC = create("application/vnd.americandynamics.acc", + "ACC"); + public static final MediaType APPLICATION_VND_AMIGA_AMI = create("application/vnd.amiga.ami", "ami"); + public static final MediaType APPLICATION_VND_ANDROID_PACKAGE_ARCHIVE = create( + "APPLICATION/VND.ANDROID.PACKAGE-ARCHIVE", "APK"); + public static final MediaType APPLICATION_VND_ANSER_WEB_CERTIFICATE_ISSUE_INITIATION = create( + "APPLICATION/VND.ANSER-WEB-CERTIFICATE-ISSUE-INITIATION", "CII"); + public static final MediaType APPLICATION_VND_ANSER_WEB_FUNDS_TRANSFER_INITIATION = create( + "APPLICATION/VND.ANSER-WEB-FUNDS-TRANSFER-INITIATION", "FTI"); + public static final MediaType APPLICATION_VND_ANTIX_GAME_COMPONENT = create("application/vnd.antix.game-component", + "ATX"); + public static final MediaType APPLICATION_VND_APPLE_INSTALLER_XML = create("application/vnd.apple.installer+xml", + "MPKG"); + public static final MediaType APPLICATION_VND_APPLE_MPEGURL = create("application/vnd.apple.mpegurl", "m3u8"); + public static final MediaType APPLICATION_VND_ARISTANETWORKS_SWI = create("application/vnd.aristanetworks.swi", + "swi"); + public static final MediaType APPLICATION_VND_ASTRAEA_SOFTWARE_IOTA = create( + "application/vnd.astraea-software.iota", "IOTA"); + public static final MediaType APPLICATION_VND_AUDIOGRAPH = create("application/vnd.audiograph", "aep"); + public static final MediaType APPLICATION_VND_BLUEICE_MULTIPASS = create("application/vnd.blueice.multipass", "mpm"); + public static final MediaType APPLICATION_VND_BMI = create("application/vnd.bmi", "bmi"); + public static final MediaType APPLICATION_VND_BUSINESSOBJECTS = create("application/vnd.businessobjects", "rep"); + public static final MediaType APPLICATION_VND_CHEMDRAW_XML = create("application/vnd.chemdraw+xml", "cdxml"); + public static final MediaType APPLICATION_VND_CHIPNUTS_KARAOKE_MMD = create("application/vnd.chipnuts.karaoke-mmd", + "MMD"); + public static final MediaType APPLICATION_VND_CINDERELLA = create("application/vnd.cinderella", "cdy"); + public static final MediaType APPLICATION_VND_CLAYMORE = create("application/vnd.claymore", "cla"); + public static final MediaType APPLICATION_VND_CLOANTO_RP9 = create("application/vnd.cloanto.rp9", "rp9"); + public static final MediaType APPLICATION_VND_CLONK_C4GROUP = create("application/vnd.clonk.c4group", "c4g", "c4d", + "C4F", "C4P", "C4U"); + public static final MediaType APPLICATION_VND_CLUETRUST_CARTOMOBILE_CONFIG = create( + "APPLICATION/VND.CLUETRUST.CARTOMOBILE-CONFIG", "C11AMC"); + public static final MediaType APPLICATION_VND_CLUETRUST_CARTOMOBILE_CONFIG_PKG = create( + "APPLICATION/VND.CLUETRUST.CARTOMOBILE-CONFIG-PKG", "C11AMZ"); + public static final MediaType APPLICATION_VND_COMMONSPACE = create("application/vnd.commonspace", "csp"); + public static final MediaType APPLICATION_VND_CONTACT_CMSG = create("application/vnd.contact.cmsg", "cdbcmsg"); + public static final MediaType APPLICATION_VND_COSMOCALLER = create("application/vnd.cosmocaller", "cmc"); + public static final MediaType APPLICATION_VND_CRICK_CLICKER = create("application/vnd.crick.clicker", "clkx"); + public static final MediaType APPLICATION_VND_CRICK_CLICKER_KEYBOARD = create( + "APPLICATION/VND.CRICK.CLICKER.KEYBOARD", "CLKK"); + public static final MediaType APPLICATION_VND_CRICK_CLICKER_PALETTE = create( + "application/vnd.crick.clicker.palette", "CLKP"); + public static final MediaType APPLICATION_VND_CRICK_CLICKER_TEMPLATE = create( + "APPLICATION/VND.CRICK.CLICKER.TEMPLATE", "CLKT"); + public static final MediaType APPLICATION_VND_CRICK_CLICKER_WORDBANK = create( + "APPLICATION/VND.CRICK.CLICKER.WORDBANK", "CLKW"); + public static final MediaType APPLICATION_VND_CRITICALTOOLS_WBS_XML = create( + "application/vnd.criticaltools.wbs+xml", "WBS"); + public static final MediaType APPLICATION_VND_CTC_POSML = create("application/vnd.ctc-posml", "pml"); + public static final MediaType APPLICATION_VND_CUPS_PPD = create("application/vnd.cups-ppd", "ppd"); + public static final MediaType APPLICATION_VND_CURL_CAR = create("application/vnd.curl.car", "car"); + public static final MediaType APPLICATION_VND_CURL_PCURL = create("application/vnd.curl.pcurl", "pcurl"); + public static final MediaType APPLICATION_VND_DART = create("application/vnd.dart", "dart"); + public static final MediaType APPLICATION_VND_DATA_VISION_RDZ = create("application/vnd.data-vision.rdz", "rdz"); + public static final MediaType APPLICATION_VND_DECE_DATA = create("application/vnd.dece.data", "uvf", "uvvf", "uvd", + "UVVD"); + public static final MediaType APPLICATION_VND_DECE_TTML_XML = create("application/vnd.dece.ttml+xml", "uvt", "uvvt"); + public static final MediaType APPLICATION_VND_DECE_UNSPECIFIED = create("application/vnd.dece.unspecified", "uvx", + "UVVX"); + public static final MediaType APPLICATION_VND_DECE_ZIP = create("application/vnd.dece.zip", "uvz", "uvvz"); + public static final MediaType APPLICATION_VND_DENOVO_FCSELAYOUT_LINK = create( + "APPLICATION/VND.DENOVO.FCSELAYOUT-LINK", "FE_LAUNCH"); + public static final MediaType APPLICATION_VND_DNA = create("application/vnd.dna", "dna"); + public static final MediaType APPLICATION_VND_DOLBY_MLP = create("application/vnd.dolby.mlp", "mlp"); + public static final MediaType APPLICATION_VND_DPGRAPH = create("application/vnd.dpgraph", "dpg"); + public static final MediaType APPLICATION_VND_DREAMFACTORY = create("application/vnd.dreamfactory", "dfac"); + public static final MediaType APPLICATION_VND_DS_KEYPOINT = create("application/vnd.ds-keypoint", "kpxx"); + public static final MediaType APPLICATION_VND_DVB_AIT = create("application/vnd.dvb.ait", "ait"); + public static final MediaType APPLICATION_VND_DVB_SERVICE = create("application/vnd.dvb.service", "svc"); + public static final MediaType APPLICATION_VND_DYNAGEO = create("application/vnd.dynageo", "geo"); + public static final MediaType APPLICATION_VND_ECOWIN_CHART = create("application/vnd.ecowin.chart", "mag"); + public static final MediaType APPLICATION_VND_ENLIVEN = create("application/vnd.enliven", "nml"); + public static final MediaType APPLICATION_VND_EPSON_ESF = create("application/vnd.epson.esf", "esf"); + public static final MediaType APPLICATION_VND_EPSON_MSF = create("application/vnd.epson.msf", "msf"); + public static final MediaType APPLICATION_VND_EPSON_QUICKANIME = create("application/vnd.epson.quickanime", "qam"); + public static final MediaType APPLICATION_VND_EPSON_SALT = create("application/vnd.epson.salt", "slt"); + public static final MediaType APPLICATION_VND_EPSON_SSF = create("application/vnd.epson.ssf", "ssf"); + public static final MediaType APPLICATION_VND_ESZIGNO3_XML = create("application/vnd.eszigno3+xml", "es3", "et3"); + public static final MediaType APPLICATION_VND_EZPIX_ALBUM = create("application/vnd.ezpix-album", "ez2"); + public static final MediaType APPLICATION_VND_EZPIX_PACKAGE = create("application/vnd.ezpix-package", "ez3"); + public static final MediaType APPLICATION_VND_FDF = create("application/vnd.fdf", "fdf"); + public static final MediaType APPLICATION_VND_FDSN_MSEED = create("application/vnd.fdsn.mseed", "mseed"); + public static final MediaType APPLICATION_VND_FDSN_SEED = create("application/vnd.fdsn.seed", "seed", "dataless"); + public static final MediaType APPLICATION_VND_FLOGRAPHIT = create("application/vnd.flographit", "gph"); + public static final MediaType APPLICATION_VND_FLUXTIME_CLIP = create("application/vnd.fluxtime.clip", "ftc"); + public static final MediaType APPLICATION_VND_FRAMEMAKER = create("application/vnd.framemaker", "fm", "frame", + "MAKER", "BOOK"); + public static final MediaType APPLICATION_VND_FROGANS_FNC = create("application/vnd.frogans.fnc", "fnc"); + public static final MediaType APPLICATION_VND_FROGANS_LTF = create("application/vnd.frogans.ltf", "ltf"); + public static final MediaType APPLICATION_VND_FSC_WEBLAUNCH = create("application/vnd.fsc.weblaunch", "fsc"); + public static final MediaType APPLICATION_VND_FUJITSU_OASYS2 = create("application/vnd.fujitsu.oasys2", "oa2"); + public static final MediaType APPLICATION_VND_FUJITSU_OASYS3 = create("application/vnd.fujitsu.oasys3", "oa3"); + public static final MediaType APPLICATION_VND_FUJITSU_OASYSGP = create("application/vnd.fujitsu.oasysgp", "fg5"); + public static final MediaType APPLICATION_VND_FUJITSU_OASYS = create("application/vnd.fujitsu.oasys", "oas"); + public static final MediaType APPLICATION_VND_FUJITSU_OASYSPRS = create("application/vnd.fujitsu.oasysprs", "bh2"); + public static final MediaType APPLICATION_VND_FUJIXEROX_DDD = create("application/vnd.fujixerox.ddd", "ddd"); + public static final MediaType APPLICATION_VND_FUJIXEROX_DOCUWORKS_BINDER = create( + "APPLICATION/VND.FUJIXEROX.DOCUWORKS.BINDER", "XBD"); + public static final MediaType APPLICATION_VND_FUJIXEROX_DOCUWORKS = create("application/vnd.fujixerox.docuworks", + "XDW"); + public static final MediaType APPLICATION_VND_FUZZYSHEET = create("application/vnd.fuzzysheet", "fzs"); + public static final MediaType APPLICATION_VND_GENOMATIX_TUXEDO = create("application/vnd.genomatix.tuxedo", "txd"); + public static final MediaType APPLICATION_VND_GEOGEBRA_FILE = create("application/vnd.geogebra.file", "ggb"); + public static final MediaType APPLICATION_VND_GEOGEBRA_TOOL = create("application/vnd.geogebra.tool", "ggt"); + public static final MediaType APPLICATION_VND_GEOMETRY_EXPLORER = create("application/vnd.geometry-explorer", + "gex", "GRE"); + public static final MediaType APPLICATION_VND_GEONEXT = create("application/vnd.geonext", "gxt"); + public static final MediaType APPLICATION_VND_GEOPLAN = create("application/vnd.geoplan", "g2w"); + public static final MediaType APPLICATION_VND_GEOSPACE = create("application/vnd.geospace", "g3w"); + public static final MediaType APPLICATION_VND_GMX = create("application/vnd.gmx", "gmx"); + public static final MediaType APPLICATION_VND_GOOGLE_EARTH_KML_XML = create("application/vnd.google-earth.kml+xml", + "KML"); + public static final MediaType APPLICATION_VND_GOOGLE_EARTH_KMZ = create("application/vnd.google-earth.kmz", "kmz"); + public static final MediaType APPLICATION_VND_GRAFEQ = create("application/vnd.grafeq", "gqf", "gqs"); + public static final MediaType APPLICATION_VND_GROOVE_ACCOUNT = create("application/vnd.groove-account", "gac"); + public static final MediaType APPLICATION_VND_GROOVE_HELP = create("application/vnd.groove-help", "ghf"); + public static final MediaType APPLICATION_VND_GROOVE_IDENTITY_MESSAGE = create( + "APPLICATION/VND.GROOVE-IDENTITY-MESSAGE", "GIM"); + public static final MediaType APPLICATION_VND_GROOVE_INJECTOR = create("application/vnd.groove-injector", "grv"); + public static final MediaType APPLICATION_VND_GROOVE_TOOL_MESSAGE = create("application/vnd.groove-tool-message", + "GTM"); + public static final MediaType APPLICATION_VND_GROOVE_TOOL_TEMPLATE = create("application/vnd.groove-tool-template", + "TPL"); + public static final MediaType APPLICATION_VND_GROOVE_VCARD = create("application/vnd.groove-vcard", "vcg"); + public static final MediaType APPLICATION_VND_HAL_XML = create("application/vnd.hal+xml", "hal"); + public static final MediaType APPLICATION_VND_HANDHELD_ENTERTAINMENT_XML = create( + "APPLICATION/VND.HANDHELD-ENTERTAINMENT+XML", "ZMM"); + public static final MediaType APPLICATION_VND_HBCI = create("application/vnd.hbci", "hbci"); + public static final MediaType APPLICATION_VND_HHE_LESSON_PLAYER = create("application/vnd.hhe.lesson-player", "les"); + public static final MediaType APPLICATION_VND_HP_HPGL = create("application/vnd.hp-hpgl", "hpgl"); + public static final MediaType APPLICATION_VND_HP_HPID = create("application/vnd.hp-hpid", "hpid"); + public static final MediaType APPLICATION_VND_HP_HPS = create("application/vnd.hp-hps", "hps"); + public static final MediaType APPLICATION_VND_HP_JLYT = create("application/vnd.hp-jlyt", "jlt"); + public static final MediaType APPLICATION_VND_HP_PCL = create("application/vnd.hp-pcl", "pcl"); + public static final MediaType APPLICATION_VND_HP_PCLXL = create("application/vnd.hp-pclxl", "pclxl"); + public static final MediaType APPLICATION_VND_HYDROSTATIX_SOF_DATA = create("application/vnd.hydrostatix.sof-data", + "SFD-HDSTX"); + public static final MediaType APPLICATION_VND_IBM_MINIPAY = create("application/vnd.ibm.minipay", "mpy"); + public static final MediaType APPLICATION_VND_IBM_MODCAP = create("application/vnd.ibm.modcap", "afp", "listafp", + "LIST3820"); + public static final MediaType APPLICATION_VND_IBM_RIGHTS_MANAGEMENT = create( + "application/vnd.ibm.rights-management", "IRM"); + public static final MediaType APPLICATION_VND_IBM_SECURE_CONTAINER = create("application/vnd.ibm.secure-container", + "SC"); + public static final MediaType APPLICATION_VND_ICCPROFILE = create("application/vnd.iccprofile", "icc", "icm"); + public static final MediaType APPLICATION_VND_IGLOADER = create("application/vnd.igloader", "igl"); + public static final MediaType APPLICATION_VND_IMMERVISION_IVP = create("application/vnd.immervision-ivp", "ivp"); + public static final MediaType APPLICATION_VND_IMMERVISION_IVU = create("application/vnd.immervision-ivu", "ivu"); + public static final MediaType APPLICATION_VND_INSORS_IGM = create("application/vnd.insors.igm", "igm"); + public static final MediaType APPLICATION_VND_INTERCON_FORMNET = create("application/vnd.intercon.formnet", "xpw", + "XPX"); + public static final MediaType APPLICATION_VND_INTERGEO = create("application/vnd.intergeo", "i2g"); + public static final MediaType APPLICATION_VND_INTU_QBO = create("application/vnd.intu.qbo", "qbo"); + public static final MediaType APPLICATION_VND_INTU_QFX = create("application/vnd.intu.qfx", "qfx"); + public static final MediaType APPLICATION_VND_IPUNPLUGGED_RCPROFILE = create( + "application/vnd.ipunplugged.rcprofile", "RCPROFILE"); + public static final MediaType APPLICATION_VND_IREPOSITORY_PACKAGE_XML = create( + "APPLICATION/VND.IREPOSITORY.PACKAGE+XML", "IRP"); + public static final MediaType APPLICATION_VND_ISAC_FCS = create("application/vnd.isac.fcs", "fcs"); + public static final MediaType APPLICATION_VND_IS_XPR = create("application/vnd.is-xpr", "xpr"); + public static final MediaType APPLICATION_VND_JAM = create("application/vnd.jam", "jam"); + public static final MediaType APPLICATION_VND_JCP_JAVAME_MIDLET_RMS = create( + "application/vnd.jcp.javame.midlet-rms", "RMS"); + public static final MediaType APPLICATION_VND_JISP = create("application/vnd.jisp", "jisp"); + public static final MediaType APPLICATION_VND_JOOST_JODA_ARCHIVE = create("application/vnd.joost.joda-archive", + "joda"); + public static final MediaType APPLICATION_VND_KAHOOTZ = create("application/vnd.kahootz", "ktz", "ktr"); + public static final MediaType APPLICATION_VND_KDE_KARBON = create("application/vnd.kde.karbon", "karbon"); + public static final MediaType APPLICATION_VND_KDE_KCHART = create("application/vnd.kde.kchart", "chrt"); + public static final MediaType APPLICATION_VND_KDE_KFORMULA = create("application/vnd.kde.kformula", "kfo"); + public static final MediaType APPLICATION_VND_KDE_KIVIO = create("application/vnd.kde.kivio", "flw"); + public static final MediaType APPLICATION_VND_KDE_KONTOUR = create("application/vnd.kde.kontour", "kon"); + public static final MediaType APPLICATION_VND_KDE_KPRESENTER = create("application/vnd.kde.kpresenter", "kpr", + "kpt"); + public static final MediaType APPLICATION_VND_KDE_KSPREAD = create("application/vnd.kde.kspread", "ksp"); + public static final MediaType APPLICATION_VND_KDE_KWORD = create("application/vnd.kde.kword", "kwd", "kwt"); + public static final MediaType APPLICATION_VND_KENAMEAAPP = create("application/vnd.kenameaapp", "htke"); + public static final MediaType APPLICATION_VND_KIDSPIRATION = create("application/vnd.kidspiration", "kia"); + public static final MediaType APPLICATION_VND_KINAR = create("application/vnd.kinar", "kne", "knp"); + public static final MediaType APPLICATION_VND_KOAN = create("application/vnd.koan", "skp", "skd", "skt", "skm"); + public static final MediaType APPLICATION_VND_KODAK_DESCRIPTOR = create("application/vnd.kodak-descriptor", "sse"); + public static final MediaType APPLICATION_VND_LAS_LAS_XML = create("application/vnd.las.las+xml", "lasxml"); + public static final MediaType APPLICATION_VND_LLAMAGRAPHICS_LIFE_BALANCE_DESKTOP = create( + "APPLICATION/VND.LLAMAGRAPHICS.LIFE-BALANCE.DESKTOP", "LBD"); + public static final MediaType APPLICATION_VND_LLAMAGRAPHICS_LIFE_BALANCE_EXCHANGE_XML = create( + "APPLICATION/VND.LLAMAGRAPHICS.LIFE-BALANCE.EXCHANGE+XML", "LBE"); + public static final MediaType APPLICATION_VND_LOTUS_1_2_3 = create("application/vnd.lotus-1-2-3", "123"); + public static final MediaType APPLICATION_VND_LOTUS_APPROACH = create("application/vnd.lotus-approach", "apr"); + public static final MediaType APPLICATION_VND_LOTUS_FREELANCE = create("application/vnd.lotus-freelance", "pre"); + public static final MediaType APPLICATION_VND_LOTUS_NOTES = create("application/vnd.lotus-notes", "nsf"); + public static final MediaType APPLICATION_VND_LOTUS_ORGANIZER = create("application/vnd.lotus-organizer", "org"); + public static final MediaType APPLICATION_VND_LOTUS_SCREENCAM = create("application/vnd.lotus-screencam", "scm"); + public static final MediaType APPLICATION_VND_LOTUS_WORDPRO = create("application/vnd.lotus-wordpro", "lwp"); + public static final MediaType APPLICATION_VND_MACPORTS_PORTPKG = create("application/vnd.macports.portpkg", + "portpkg"); + public static final MediaType APPLICATION_VND_MCD = create("application/vnd.mcd", "mcd"); + public static final MediaType APPLICATION_VND_MEDCALCDATA = create("application/vnd.medcalcdata", "mc1"); + public static final MediaType APPLICATION_VND_MEDIASTATION_CDKEY = create("application/vnd.mediastation.cdkey", + "CDKEY"); + public static final MediaType APPLICATION_VND_MFER = create("application/vnd.mfer", "mwf"); + public static final MediaType APPLICATION_VND_MFMP = create("application/vnd.mfmp", "mfm"); + public static final MediaType APPLICATION_VND_MICROGRAFX_FLO = create("application/vnd.micrografx.flo", "flo"); + public static final MediaType APPLICATION_VND_MICROGRAFX_IGX = create("application/vnd.micrografx.igx", "igx"); + public static final MediaType APPLICATION_VND_MIF = create("application/vnd.mif", "mif"); + public static final MediaType APPLICATION_VND_MOBIUS_DAF = create("application/vnd.mobius.daf", "daf"); + public static final MediaType APPLICATION_VND_MOBIUS_DIS = create("application/vnd.mobius.dis", "dis"); + public static final MediaType APPLICATION_VND_MOBIUS_MBK = create("application/vnd.mobius.mbk", "mbk"); + public static final MediaType APPLICATION_VND_MOBIUS_MQY = create("application/vnd.mobius.mqy", "mqy"); + public static final MediaType APPLICATION_VND_MOBIUS_MSL = create("application/vnd.mobius.msl", "msl"); + public static final MediaType APPLICATION_VND_MOBIUS_PLC = create("application/vnd.mobius.plc", "plc"); + public static final MediaType APPLICATION_VND_MOBIUS_TXF = create("application/vnd.mobius.txf", "txf"); + public static final MediaType APPLICATION_VND_MOPHUN_APPLICATION = create("application/vnd.mophun.application", + "mpn"); + public static final MediaType APPLICATION_VND_MOPHUN_CERTIFICATE = create("application/vnd.mophun.certificate", + "mpc"); + public static final MediaType APPLICATION_VND_MOZILLA_XUL_XML = create("application/vnd.mozilla.xul+xml", "xul"); + public static final MediaType APPLICATION_VND_MS_ARTGALRY = create("application/vnd.ms-artgalry", "cil"); + public static final MediaType APPLICATION_VND_MS_CAB_COMPRESSED = create("application/vnd.ms-cab-compressed", "cab"); + public static final MediaType APPLICATION_VND_MSEQ = create("application/vnd.mseq", "mseq"); + public static final MediaType APPLICATION_VND_MS_EXCEL_ADDIN_MACROENABLED_12 = create( + "APPLICATION/VND.MS-EXCEL.ADDIN.MACROENABLED.12", "XLAM"); + public static final MediaType APPLICATION_VND_MS_EXCEL_SHEET_BINARY_MACROENABLED_12 = create( + "APPLICATION/VND.MS-EXCEL.SHEET.BINARY.MACROENABLED.12", "XLSB"); + public static final MediaType APPLICATION_VND_MS_EXCEL_SHEET_MACROENABLED_12 = create( + "APPLICATION/VND.MS-EXCEL.SHEET.MACROENABLED.12", "XLSM"); + public static final MediaType APPLICATION_VND_MS_EXCEL_TEMPLATE_MACROENABLED_12 = create( + "APPLICATION/VND.MS-EXCEL.TEMPLATE.MACROENABLED.12", "XLTM"); + public static final MediaType APPLICATION_VND_MS_EXCEL = create("application/vnd.ms-excel", "xls", "xlm", "xla", + "XLB", "XLC", "XLT", "XLW"); + public static final MediaType APPLICATION_VND_MS_FONTOBJECT = create("application/vnd.ms-fontobject", "eot"); + public static final MediaType APPLICATION_VND_MS_HTMLHELP = create("application/vnd.ms-htmlhelp", "chm"); + public static final MediaType APPLICATION_VND_MS_IMS = create("application/vnd.ms-ims", "ims"); + public static final MediaType APPLICATION_VND_MS_LRM = create("application/vnd.ms-lrm", "lrm"); + public static final MediaType APPLICATION_VND_MS_OFFICETHEME = create("application/vnd.ms-officetheme", "thmx"); + public static final MediaType APPLICATION_VND_MS_PKI_SECCAT = create("application/vnd.ms-pki.seccat", "cat"); + public static final MediaType APPLICATION_VND_MS_PKI_STL = create("application/vnd.ms-pki.stl", "stl"); + public static final MediaType APPLICATION_VND_MS_POWERPOINT_ADDIN_MACROENABLED_12 = create( + "APPLICATION/VND.MS-POWERPOINT.ADDIN.MACROENABLED.12", "PPAM"); + public static final MediaType APPLICATION_VND_MS_POWERPOINT = create("application/vnd.ms-powerpoint", "ppt", "pps", + "POT"); + public static final MediaType APPLICATION_VND_MS_POWERPOINT_PRESENTATION_MACROENABLED_12 = create( + "APPLICATION/VND.MS-POWERPOINT.PRESENTATION.MACROENABLED.12", "PPTM"); + public static final MediaType APPLICATION_VND_MS_POWERPOINT_SLIDE_MACROENABLED_12 = create( + "APPLICATION/VND.MS-POWERPOINT.SLIDE.MACROENABLED.12", "SLDM"); + public static final MediaType APPLICATION_VND_MS_POWERPOINT_SLIDESHOW_MACROENABLED_12 = create( + "APPLICATION/VND.MS-POWERPOINT.SLIDESHOW.MACROENABLED.12", "PPSM"); + public static final MediaType APPLICATION_VND_MS_POWERPOINT_TEMPLATE_MACROENABLED_12 = create( + "APPLICATION/VND.MS-POWERPOINT.TEMPLATE.MACROENABLED.12", "POTM"); + public static final MediaType APPLICATION_VND_MS_PROJECT = create("application/vnd.ms-project", "mpp", "mpt"); + public static final MediaType APPLICATION_VND_MS_WORD_DOCUMENT_MACROENABLED_12 = create( + "APPLICATION/VND.MS-WORD.DOCUMENT.MACROENABLED.12", "DOCM"); + public static final MediaType APPLICATION_VND_MS_WORD_TEMPLATE_MACROENABLED_12 = create( + "APPLICATION/VND.MS-WORD.TEMPLATE.MACROENABLED.12", "DOTM"); + public static final MediaType APPLICATION_VND_MS_WORKS = create("application/vnd.ms-works", "wps", "wks", "wcm", + "wdb"); + public static final MediaType APPLICATION_VND_MS_WPL = create("application/vnd.ms-wpl", "wpl"); + public static final MediaType APPLICATION_VND_MS_XPSDOCUMENT = create("application/vnd.ms-xpsdocument", "xps"); + public static final MediaType APPLICATION_VND_MUSICIAN = create("application/vnd.musician", "mus"); + public static final MediaType APPLICATION_VND_MUVEE_STYLE = create("application/vnd.muvee.style", "msty"); + public static final MediaType APPLICATION_VND_MYNFC = create("application/vnd.mynfc", "taglet"); + public static final MediaType APPLICATION_VND_NEUROLANGUAGE_NLU = create("application/vnd.neurolanguage.nlu", "nlu"); + public static final MediaType APPLICATION_VND_NITF = create("application/vnd.nitf", "ntf", "nitf"); + public static final MediaType APPLICATION_VND_NOBLENET_DIRECTORY = create("application/vnd.noblenet-directory", + "nnd"); + public static final MediaType APPLICATION_VND_NOBLENET_SEALER = create("application/vnd.noblenet-sealer", "nns"); + public static final MediaType APPLICATION_VND_NOBLENET_WEB = create("application/vnd.noblenet-web", "nnw"); + public static final MediaType APPLICATION_VND_NOKIA_N_GAGE_DATA = create("application/vnd.nokia.n-gage.data", + "ngdat"); + public static final MediaType APPLICATION_VND_NOKIA_N_GAGE_SYMBIAN_INSTALL = create( + "APPLICATION/VND.NOKIA.N-GAGE.SYMBIAN.INSTALL", "N-GAGE"); + public static final MediaType APPLICATION_VND_NOKIA_RADIO_PRESET = create("application/vnd.nokia.radio-preset", + "rpst"); + public static final MediaType APPLICATION_VND_NOKIA_RADIO_PRESETS = create("application/vnd.nokia.radio-presets", + "RPSS"); + public static final MediaType APPLICATION_VND_NOVADIGM_EDM = create("application/vnd.novadigm.edm", "edm"); + public static final MediaType APPLICATION_VND_NOVADIGM_EDX = create("application/vnd.novadigm.edx", "edx"); + public static final MediaType APPLICATION_VND_NOVADIGM_EXT = create("application/vnd.novadigm.ext", "ext"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_CHART = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.CHART", "ODC"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_CHART_TEMPLATE = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.CHART-TEMPLATE", "OTC"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_DATABASE = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.DATABASE", "ODB"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_FORMULA = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.FORMULA", "ODF"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_FORMULA_TEMPLATE = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.FORMULA-TEMPLATE", "ODFT"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_GRAPHICS = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.GRAPHICS", "ODG"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_GRAPHICS_TEMPLATE = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.GRAPHICS-TEMPLATE", "OTG"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_IMAGE = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.IMAGE", "ODI"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_IMAGE_TEMPLATE = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.IMAGE-TEMPLATE", "OTI"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.PRESENTATION", "ODP"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.PRESENTATION-TEMPLATE", "OTP"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.SPREADSHEET", "ODS"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET_TEMPLATE = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.SPREADSHEET-TEMPLATE", "OTS"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT_MASTER = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.TEXT-MASTER", "ODM"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.TEXT", "ODT"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT_TEMPLATE = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.TEXT-TEMPLATE", "OTT"); + public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT_WEB = create( + "APPLICATION/VND.OASIS.OPENDOCUMENT.TEXT-WEB", "OTH"); + public static final MediaType APPLICATION_VND_OLPC_SUGAR = create("application/vnd.olpc-sugar", "xo"); + public static final MediaType APPLICATION_VND_OMA_DD2_XML = create("application/vnd.oma.dd2+xml", "dd2"); + public static final MediaType APPLICATION_VND_OPENOFFICEORG_EXTENSION = create( + "APPLICATION/VND.OPENOFFICEORG.EXTENSION", "OXT"); + public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION = create( + "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.PRESENTATIONML.PRESENTATION", "PPTX"); + public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_SLIDESHOW = create( + "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.PRESENTATIONML.SLIDESHOW", "PPSX"); + public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_SLIDE = create( + "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.PRESENTATIONML.SLIDE", "SLDX"); + public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_TEMPLATE = create( + "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.PRESENTATIONML.TEMPLATE", "POTX"); + public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET = create( + "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.SPREADSHEETML.SHEET", "XLSX"); + public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_TEMPLATE = create( + "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.SPREADSHEETML.TEMPLATE", "XLTX"); + public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT = create( + "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.WORDPROCESSINGML.DOCUMENT", "DOCX"); + public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_TEMPLATE = create( + "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.WORDPROCESSINGML.TEMPLATE", "DOTX"); + public static final MediaType APPLICATION_VND_OSGEO_MAPGUIDE_PACKAGE = create( + "APPLICATION/VND.OSGEO.MAPGUIDE.PACKAGE", "MGP"); + public static final MediaType APPLICATION_VND_OSGI_DP = create("application/vnd.osgi.dp", "dp"); + public static final MediaType APPLICATION_VND_OSGI_SUBSYSTEM = create("application/vnd.osgi.subsystem", "esa"); + public static final MediaType APPLICATION_VND_PALM = create("application/vnd.palm", "pdb", "pqa", "oprc"); + public static final MediaType APPLICATION_VND_PAWAAFILE = create("application/vnd.pawaafile", "paw"); + public static final MediaType APPLICATION_VND_PG_FORMAT = create("application/vnd.pg.format", "str"); + public static final MediaType APPLICATION_VND_PG_OSASLI = create("application/vnd.pg.osasli", "ei6"); + public static final MediaType APPLICATION_VND_PICSEL = create("application/vnd.picsel", "efif"); + public static final MediaType APPLICATION_VND_PMI_WIDGET = create("application/vnd.pmi.widget", "wg"); + public static final MediaType APPLICATION_VND_POCKETLEARN = create("application/vnd.pocketlearn", "plf"); + public static final MediaType APPLICATION_VND_POWERBUILDER6 = create("application/vnd.powerbuilder6", "pbd"); + public static final MediaType APPLICATION_VND_PREVIEWSYSTEMS_BOX = create("application/vnd.previewsystems.box", + "box"); + public static final MediaType APPLICATION_VND_PROTEUS_MAGAZINE = create("application/vnd.proteus.magazine", "mgz"); + public static final MediaType APPLICATION_VND_PUBLISHARE_DELTA_TREE = create( + "application/vnd.publishare-delta-tree", "QPS"); + public static final MediaType APPLICATION_VND_PVI_PTID1 = create("application/vnd.pvi.ptid1", "ptid"); + public static final MediaType APPLICATION_VND_QUARK_QUARKXPRESS = create("application/vnd.quark.quarkxpress", + "qxd", "QXT", "QWD", "QWT", "QXL", "QXB"); + public static final MediaType APPLICATION_VND_REALVNC_BED = create("application/vnd.realvnc.bed", "bed"); + public static final MediaType APPLICATION_VND_RECORDARE_MUSICXML = create("application/vnd.recordare.musicxml", + "mxl"); + public static final MediaType APPLICATION_VND_RECORDARE_MUSICXML_XML = create( + "APPLICATION/VND.RECORDARE.MUSICXML+XML", "MUSICXML"); + public static final MediaType APPLICATION_VND_RIG_CRYPTONOTE = create("application/vnd.rig.cryptonote", + "cryptonote"); + public static final MediaType APPLICATION_VND_RIM_COD = create("application/vnd.rim.cod", "cod"); + public static final MediaType APPLICATION_VND_RN_REALMEDIA = create("application/vnd.rn-realmedia", "rm"); + public static final MediaType APPLICATION_VND_RN_REALMEDIA_VBR = create("application/vnd.rn-realmedia-vbr", "rmvb"); + public static final MediaType APPLICATION_VND_ROUTE66_LINK66_XML = create("application/vnd.route66.link66+xml", + "LINK66"); + public static final MediaType APPLICATION_VND_SAILINGTRACKER_TRACK = create("application/vnd.sailingtracker.track", + "ST"); + public static final MediaType APPLICATION_VND_SEEMAIL = create("application/vnd.seemail", "see"); + public static final MediaType APPLICATION_VND_SEMA = create("application/vnd.sema", "sema"); + public static final MediaType APPLICATION_VND_SEMD = create("application/vnd.semd", "semd"); + public static final MediaType APPLICATION_VND_SEMF = create("application/vnd.semf", "semf"); + public static final MediaType APPLICATION_VND_SHANA_INFORMED_FORMDATA = create( + "APPLICATION/VND.SHANA.INFORMED.FORMDATA", "IFM"); + public static final MediaType APPLICATION_VND_SHANA_INFORMED_FORMTEMPLATE = create( + "APPLICATION/VND.SHANA.INFORMED.FORMTEMPLATE", "ITP"); + public static final MediaType APPLICATION_VND_SHANA_INFORMED_INTERCHANGE = create( + "APPLICATION/VND.SHANA.INFORMED.INTERCHANGE", "IIF"); + public static final MediaType APPLICATION_VND_SHANA_INFORMED_PACKAGE = create( + "APPLICATION/VND.SHANA.INFORMED.PACKAGE", "IPK"); + public static final MediaType APPLICATION_VND_SIMTECH_MINDMAPPER = create("application/vnd.simtech-mindmapper", + "twd", "TWDS"); + public static final MediaType APPLICATION_VND_SMAF = create("application/vnd.smaf", "mmf"); + public static final MediaType APPLICATION_VND_SMART_TEACHER = create("application/vnd.smart.teacher", "teacher"); + public static final MediaType APPLICATION_VND_SOLENT_SDKM_XML = create("application/vnd.solent.sdkm+xml", "sdkm", + "SDKD"); + public static final MediaType APPLICATION_VND_SPOTFIRE_DXP = create("application/vnd.spotfire.dxp", "dxp"); + public static final MediaType APPLICATION_VND_SPOTFIRE_SFS = create("application/vnd.spotfire.sfs", "sfs"); + public static final MediaType APPLICATION_VND_STARDIVISION_CALC = create("application/vnd.stardivision.calc", "sdc"); + public static final MediaType APPLICATION_VND_STARDIVISION_CHART = create("application/vnd.stardivision.chart", + "sds"); + public static final MediaType APPLICATION_VND_STARDIVISION_DRAW = create("application/vnd.stardivision.draw", "sda"); + public static final MediaType APPLICATION_VND_STARDIVISION_IMPRESS = create("application/vnd.stardivision.impress", + "SDD"); + public static final MediaType APPLICATION_VND_STARDIVISION_MATH = create("application/vnd.stardivision.math", + "smf", "SDF"); + public static final MediaType APPLICATION_VND_STARDIVISION_WRITER_GLOBAL = create( + "APPLICATION/VND.STARDIVISION.WRITER-GLOBAL", "SGL"); + public static final MediaType APPLICATION_VND_STARDIVISION_WRITER = create("application/vnd.stardivision.writer", + "SDW", "VOR"); + public static final MediaType APPLICATION_VND_STEPMANIA_PACKAGE = create("application/vnd.stepmania.package", + "smzip"); + public static final MediaType APPLICATION_VND_STEPMANIA_STEPCHART = create("application/vnd.stepmania.stepchart", + "sm"); + public static final MediaType APPLICATION_VND_SUN_XML_CALC = create("application/vnd.sun.xml.calc", "sxc"); + public static final MediaType APPLICATION_VND_SUN_XML_CALC_TEMPLATE = create( + "application/vnd.sun.xml.calc.template", "STC"); + public static final MediaType APPLICATION_VND_SUN_XML_DRAW = create("application/vnd.sun.xml.draw", "sxd"); + public static final MediaType APPLICATION_VND_SUN_XML_DRAW_TEMPLATE = create( + "application/vnd.sun.xml.draw.template", "STD"); + public static final MediaType APPLICATION_VND_SUN_XML_IMPRESS = create("application/vnd.sun.xml.impress", "sxi"); + public static final MediaType APPLICATION_VND_SUN_XML_IMPRESS_TEMPLATE = create( + "APPLICATION/VND.SUN.XML.IMPRESS.TEMPLATE", "STI"); + public static final MediaType APPLICATION_VND_SUN_XML_MATH = create("application/vnd.sun.xml.math", "sxm"); + public static final MediaType APPLICATION_VND_SUN_XML_WRITER_GLOBAL = create( + "application/vnd.sun.xml.writer.global", "SXG"); + public static final MediaType APPLICATION_VND_SUN_XML_WRITER = create("application/vnd.sun.xml.writer", "sxw"); + public static final MediaType APPLICATION_VND_SUN_XML_WRITER_TEMPLATE = create( + "APPLICATION/VND.SUN.XML.WRITER.TEMPLATE", "STW"); + public static final MediaType APPLICATION_VND_SUS_CALENDAR = create("application/vnd.sus-calendar", "sus", "susp"); + public static final MediaType APPLICATION_VND_SVD = create("application/vnd.svd", "svd"); + public static final MediaType APPLICATION_VND_SYMBIAN_INSTALL = create("application/vnd.symbian.install", "sis", + "SISX"); + public static final MediaType APPLICATION_VND_SYNCML_DM_WBXML = create("application/vnd.syncml.dm+wbxml", "bdm"); + public static final MediaType APPLICATION_VND_SYNCML_DM_XML = create("application/vnd.syncml.dm+xml", "xdm"); + public static final MediaType APPLICATION_VND_SYNCML_XML = create("application/vnd.syncml+xml", "xsm"); + public static final MediaType APPLICATION_VND_TAO_INTENT_MODULE_ARCHIVE = create( + "APPLICATION/VND.TAO.INTENT-MODULE-ARCHIVE", "TAO"); + public static final MediaType APPLICATION_VND_TCPDUMP_PCAP = create("application/vnd.tcpdump.pcap", "pcap", "cap", + "DMP"); + public static final MediaType APPLICATION_VND_TMOBILE_LIVETV = create("application/vnd.tmobile-livetv", "tmo"); + public static final MediaType APPLICATION_VND_TRID_TPT = create("application/vnd.trid.tpt", "tpt"); + public static final MediaType APPLICATION_VND_TRISCAPE_MXS = create("application/vnd.triscape.mxs", "mxs"); + public static final MediaType APPLICATION_VND_TRUEAPP = create("application/vnd.trueapp", "tra"); + public static final MediaType APPLICATION_VND_UFDL = create("application/vnd.ufdl", "ufd", "ufdl"); + public static final MediaType APPLICATION_VND_UIQ_THEME = create("application/vnd.uiq.theme", "utz"); + public static final MediaType APPLICATION_VND_UMAJIN = create("application/vnd.umajin", "umj"); + public static final MediaType APPLICATION_VND_UNITY = create("application/vnd.unity", "unityweb"); + public static final MediaType APPLICATION_VND_UOML_XML = create("application/vnd.uoml+xml", "uoml"); + public static final MediaType APPLICATION_VND_VCX = create("application/vnd.vcx", "vcx"); + public static final MediaType APPLICATION_VND_VISIONARY = create("application/vnd.visionary", "vis"); + public static final MediaType APPLICATION_VND_VISIO = create("application/vnd.visio", "vsd", "vst", "vss", "vsw"); + public static final MediaType APPLICATION_VND_VSF = create("application/vnd.vsf", "vsf"); + public static final MediaType APPLICATION_VND_WAP_WBXML = create("application/vnd.wap.wbxml", "wbxml"); + public static final MediaType APPLICATION_VND_WAP_WMLC = create("application/vnd.wap.wmlc", "wmlc"); + public static final MediaType APPLICATION_VND_WAP_WMLSCRIPTC = create("application/vnd.wap.wmlscriptc", "wmlsc"); + public static final MediaType APPLICATION_VND_WEBTURBO = create("application/vnd.webturbo", "wtb"); + public static final MediaType APPLICATION_VND_WOLFRAM_PLAYER = create("application/vnd.wolfram.player", "nbp"); + public static final MediaType APPLICATION_VND_WORDPERFECT5_1 = create("application/vnd.wordperfect5.1", "wp5"); + public static final MediaType APPLICATION_VND_WORDPERFECT = create("application/vnd.wordperfect", "wpd"); + public static final MediaType APPLICATION_VND_WQD = create("application/vnd.wqd", "wqd"); + public static final MediaType APPLICATION_VND_WT_STF = create("application/vnd.wt.stf", "stf"); + public static final MediaType APPLICATION_VND_XARA = create("application/vnd.xara", "xar"); + public static final MediaType APPLICATION_VND_XFDL = create("application/vnd.xfdl", "xfdl"); + public static final MediaType APPLICATION_VND_YAMAHA_HV_DIC = create("application/vnd.yamaha.hv-dic", "hvd"); + public static final MediaType APPLICATION_VND_YAMAHA_HV_SCRIPT = create("application/vnd.yamaha.hv-script", "hvs"); + public static final MediaType APPLICATION_VND_YAMAHA_HV_VOICE = create("application/vnd.yamaha.hv-voice", "hvp"); + public static final MediaType APPLICATION_VND_YAMAHA_OPENSCOREFORMAT = create( + "APPLICATION/VND.YAMAHA.OPENSCOREFORMAT", "OSF"); + public static final MediaType APPLICATION_VND_YAMAHA_OPENSCOREFORMAT_OSFPVG_XML = create( + "APPLICATION/VND.YAMAHA.OPENSCOREFORMAT.OSFPVG+XML", "OSFPVG"); + public static final MediaType APPLICATION_VND_YAMAHA_SMAF_AUDIO = create("application/vnd.yamaha.smaf-audio", "saf"); + public static final MediaType APPLICATION_VND_YAMAHA_SMAF_PHRASE = create("application/vnd.yamaha.smaf-phrase", + "spf"); + public static final MediaType APPLICATION_VND_YELLOWRIVER_CUSTOM_MENU = create( + "APPLICATION/VND.YELLOWRIVER-CUSTOM-MENU", "CMP"); + public static final MediaType APPLICATION_VND_ZUL = create("application/vnd.zul", "zir", "zirz"); + public static final MediaType APPLICATION_VND_ZZAZZ_DECK_XML = create("application/vnd.zzazz.deck+xml", "zaz"); + public static final MediaType APPLICATION_VOICEXML_XML = create("application/voicexml+xml", "vxml"); + public static final MediaType APPLICATION_WIDGET = create("application/widget", "wgt"); + public static final MediaType APPLICATION_WINHLP = create("application/winhlp", "hlp"); + public static final MediaType APPLICATION_WSDL_XML = create("application/wsdl+xml", "wsdl"); + public static final MediaType APPLICATION_WSPOLICY_XML = create("application/wspolicy+xml", "wspolicy"); + public static final MediaType APPLICATION_X_123 = create("application/x-123", "wk"); + public static final MediaType APPLICATION_X_7Z_COMPRESSED = create("application/x-7z-compressed", "7z"); + public static final MediaType APPLICATION_X_ABIWORD = create("application/x-abiword", "abw"); + public static final MediaType APPLICATION_X_ACE_COMPRESSED = create("application/x-ace-compressed", "ace"); + public static final MediaType APPLICATION_XAML_XML = create("application/xaml+xml", "xaml"); + public static final MediaType APPLICATION_X_APPLE_DISKIMAGE = create("application/x-apple-diskimage", "dmg"); + public static final MediaType APPLICATION_X_AUTHORWARE_BIN = create("application/x-authorware-bin", "aab", "x32", + "U32", "VOX"); + public static final MediaType APPLICATION_X_AUTHORWARE_MAP = create("application/x-authorware-map", "aam"); + public static final MediaType APPLICATION_X_AUTHORWARE_SEG = create("application/x-authorware-seg", "aas"); + public static final MediaType APPLICATION_X_BCPIO = create("application/x-bcpio", "bcpio"); + public static final MediaType APPLICATION_X_BITTORRENT = create("application/x-bittorrent", "torrent"); + public static final MediaType APPLICATION_X_BLORB = create("application/x-blorb", "blb", "blorb"); + public static final MediaType APPLICATION_X_BZIP2 = create("application/x-bzip2", "bz2", "boz"); + public static final MediaType APPLICATION_X_BZIP = create("application/x-bzip", "bz"); + public static final MediaType APPLICATION_X_CAB = create("application/x-cab", "cab"); + public static final MediaType APPLICATION_XCAP_DIFF_XML = create("application/xcap-diff+xml", "xdf"); + public static final MediaType APPLICATION_X_CBR = create("application/x-cbr", "cbr", "cba", "cbt", "cbz", "cb7"); + public static final MediaType APPLICATION_X_CBZ = create("application/x-cbz", "cbz"); + public static final MediaType APPLICATION_X_CDF = create("application/x-cdf", "cdf", "cda"); + public static final MediaType APPLICATION_X_CDLINK = create("application/x-cdlink", "vcd"); + public static final MediaType APPLICATION_X_CFS_COMPRESSED = create("application/x-cfs-compressed", "cfs"); + public static final MediaType APPLICATION_X_CHAT = create("application/x-chat", "chat"); + public static final MediaType APPLICATION_X_CHESS_PGN = create("application/x-chess-pgn", "pgn"); + public static final MediaType APPLICATION_X_COMSOL = create("application/x-comsol", "mph"); + public static final MediaType APPLICATION_X_CONFERENCE = create("application/x-conference", "nsc"); + public static final MediaType APPLICATION_X_CPIO = create("application/x-cpio", "cpio"); + public static final MediaType APPLICATION_X_CSH = create("application/x-csh", "csh"); + public static final MediaType APPLICATION_X_DEBIAN_PACKAGE = create("application/x-debian-package", "deb", "udeb"); + public static final MediaType APPLICATION_X_DGC_COMPRESSED = create("application/x-dgc-compressed", "dgc"); + public static final MediaType APPLICATION_X_DIRECTOR = create("application/x-director", "dir", "dcr", "dxr", "cst", + "CCT", "CXT", "W3D", "FGD", "SWA"); + public static final MediaType APPLICATION_X_DMS = create("application/x-dms", "dms"); + public static final MediaType APPLICATION_X_DOOM = create("application/x-doom", "wad"); + public static final MediaType APPLICATION_X_DTBNCX_XML = create("application/x-dtbncx+xml", "ncx"); + public static final MediaType APPLICATION_X_DTBOOK_XML = create("application/x-dtbook+xml", "dtb"); + public static final MediaType APPLICATION_X_DTBRESOURCE_XML = create("application/x-dtbresource+xml", "res"); + public static final MediaType APPLICATION_X_DVI = create("application/x-dvi", "dvi"); + public static final MediaType APPLICATION_XENC_XML = create("application/xenc+xml", "xenc"); + public static final MediaType APPLICATION_X_ENVOY = create("application/x-envoy", "evy"); + public static final MediaType APPLICATION_X_EVA = create("application/x-eva", "eva"); + public static final MediaType APPLICATION_X_FONT_BDF = create("application/x-font-bdf", "bdf"); + public static final MediaType APPLICATION_X_FONT_GHOSTSCRIPT = create("application/x-font-ghostscript", "gsf"); + public static final MediaType APPLICATION_X_FONT_LINUX_PSF = create("application/x-font-linux-psf", "psf"); + public static final MediaType APPLICATION_X_FONT_OTF = create("application/x-font-otf", "otf"); + public static final MediaType APPLICATION_X_FONT_PCF = create("application/x-font-pcf", "pcf"); + public static final MediaType APPLICATION_X_FONT = create("application/x-font", "pfa", "pfb", "gsf", "pcf", "pcf.z"); + public static final MediaType APPLICATION_X_FONT_SNF = create("application/x-font-snf", "snf"); + public static final MediaType APPLICATION_X_FONT_TTF = create("application/x-font-ttf", "ttf", "ttc"); + public static final MediaType APPLICATION_X_FONT_TYPE1 = create("application/x-font-type1", "pfa", "pfb", "pfm", + "afm"); + public static final MediaType APPLICATION_X_FONT_WOFF = create("application/x-font-woff", "woff", "woff2"); + public static final MediaType APPLICATION_X_FREEARC = create("application/x-freearc", "arc"); + public static final MediaType APPLICATION_X_FREEMIND = create("application/x-freemind", "mm"); + public static final MediaType APPLICATION_X_FUTURESPLASH = create("application/x-futuresplash", "spl"); + public static final MediaType APPLICATION_X_GANTTPROJECT = create("application/x-ganttproject", "gan"); + public static final MediaType APPLICATION_X_GCA_COMPRESSED = create("application/x-gca-compressed", "gca"); + public static final MediaType APPLICATION_X_GLULX = create("application/x-glulx", "ulx"); + public static final MediaType APPLICATION_X_GNUMERIC = create("application/x-gnumeric", "gnumeric"); + public static final MediaType APPLICATION_X_GO_SGF = create("application/x-go-sgf", "sgf"); + public static final MediaType APPLICATION_X_GRAMPS_XML = create("application/x-gramps-xml", "gramps"); + public static final MediaType APPLICATION_X_GRAPHING_CALCULATOR = create("application/x-graphing-calculator", "gcf"); + public static final MediaType APPLICATION_X_GTAR_COMPRESSED = create("application/x-gtar-compressed", "tgz", "taz"); + public static final MediaType APPLICATION_X_GTAR = create("application/x-gtar", "gtar"); + public static final MediaType APPLICATION_X_HDF = create("application/x-hdf", "hdf"); + public static final MediaType APPLICATION_XHTML_XML_UTF8 = createUTF8("application/xhtml+xml", "xhtml", "xht"); + public static final MediaType APPLICATION_X_HTTPD_ERUBY = create("application/x-httpd-eruby", "rhtml"); + public static final MediaType APPLICATION_X_HTTPD_PHP3 = create("application/x-httpd-php3", "php3"); + public static final MediaType APPLICATION_X_HTTPD_PHP3_PREPROCESSED = create( + "application/x-httpd-php3-preprocessed", "PHP3P"); + public static final MediaType APPLICATION_X_HTTPD_PHP4 = create("application/x-httpd-php4", "php4"); + public static final MediaType APPLICATION_X_HTTPD_PHP5 = create("application/x-httpd-php5", "php5"); + public static final MediaType APPLICATION_X_HTTPD_PHP = create("application/x-httpd-php", "phtml", "pht", "php"); + public static final MediaType APPLICATION_X_HTTPD_PHP_SOURCE = create("application/x-httpd-php-source", "phps"); + public static final MediaType APPLICATION_X_ICA = create("application/x-ica", "ica"); + public static final MediaType APPLICATION_X_INFO = create("application/x-info", "info"); + public static final MediaType APPLICATION_X_INSTALL_INSTRUCTIONS = create("application/x-install-instructions", + "INSTALL"); + public static final MediaType APPLICATION_X_INTERNET_SIGNUP = create("application/x-internet-signup", "ins", "isp"); + public static final MediaType APPLICATION_X_IPHONE = create("application/x-iphone", "iii"); + public static final MediaType APPLICATION_X_ISO9660_IMAGE = create("application/x-iso9660-image", "iso"); + public static final MediaType APPLICATION_X_JAM = create("application/x-jam", "jam"); + public static final MediaType APPLICATION_X_JAVA_JNLP_FILE = create("application/x-java-jnlp-file", "jnlp"); + public static final MediaType APPLICATION_X_JMOL = create("application/x-jmol", "jmz"); + public static final MediaType APPLICATION_X_KCHART = create("application/x-kchart", "chrt"); + public static final MediaType APPLICATION_X_KILLUSTRATOR = create("application/x-killustrator", "kil"); + public static final MediaType APPLICATION_X_KOAN = create("application/x-koan", "skp", "skd", "skt", "skm"); + public static final MediaType APPLICATION_X_KPRESENTER = create("application/x-kpresenter", "kpr", "kpt"); + public static final MediaType APPLICATION_X_KSPREAD = create("application/x-kspread", "ksp"); + public static final MediaType APPLICATION_X_KWORD = create("application/x-kword", "kwd", "kwt"); + public static final MediaType APPLICATION_X_LATEX = create("application/x-latex", "latex"); + public static final MediaType APPLICATION_X_LHA = create("application/x-lha", "lha"); + public static final MediaType APPLICATION_X_LYX = create("application/x-lyx", "lyx"); + public static final MediaType APPLICATION_X_LZH_COMPRESSED = create("application/x-lzh-compressed", "lzh", "lha"); + public static final MediaType APPLICATION_X_LZH = create("application/x-lzh", "lzh"); + public static final MediaType APPLICATION_X_LZX = create("application/x-lzx", "lzx"); + public static final MediaType APPLICATION_X_MAKER = create("application/x-maker", "frm", "maker", "frame", "fm", + "fb", "BOOK", "FBDOC"); + public static final MediaType APPLICATION_X_MIE = create("application/x-mie", "mie"); + public static final MediaType APPLICATION_X_MIF = create("application/x-mif", "mif"); + public static final MediaType APPLICATION_XML_DTD_UTF8 = createUTF8("application/xml-dtd", "dtd"); + public static final MediaType APPLICATION_XML = create("application/xml", "xml", "xsl", "xsd"); + public static final MediaType APPLICATION_XML_UTF8 = createUTF8("application/xml", "xml", "xsl", "xsd"); + public static final MediaType APPLICATION_X_MOBIPOCKET_EBOOK = create("application/x-mobipocket-ebook", "prc", + "mobi"); + public static final MediaType APPLICATION_X_MPEGURL = create("application/x-mpegurl", "m3u8"); + public static final MediaType APPLICATION_X_MSACCESS = create("application/x-msaccess", "mdb"); + public static final MediaType APPLICATION_X_MS_APPLICATION = create("application/x-ms-application", "application"); + public static final MediaType APPLICATION_X_MSBINDER = create("application/x-msbinder", "obd"); + public static final MediaType APPLICATION_X_MSCARDFILE = create("application/x-mscardfile", "crd"); + public static final MediaType APPLICATION_X_MSCLIP = create("application/x-msclip", "clp"); + public static final MediaType APPLICATION_X_MSDOS_PROGRAM = create("application/x-msdos-program", "com", "exe", + "bat", "DLL"); + public static final MediaType APPLICATION_X_MSDOWNLOAD = create("application/x-msdownload", "exe", "dll", "com", + "BAT", "MSI"); + public static final MediaType APPLICATION_X_MSI = create("application/x-msi", "msi"); + public static final MediaType APPLICATION_X_MSMEDIAVIEW = create("application/x-msmediaview", "mvb", "m13", "m14"); + public static final MediaType APPLICATION_X_MSMETAFILE = create("application/x-msmetafile", "wmf", "wmz", "emf", + "emz"); + public static final MediaType APPLICATION_X_MSMONEY = create("application/x-msmoney", "mny"); + public static final MediaType APPLICATION_X_MSPUBLISHER = create("application/x-mspublisher", "pub"); + public static final MediaType APPLICATION_X_MSSCHEDULE = create("application/x-msschedule", "scd"); + public static final MediaType APPLICATION_X_MS_SHORTCUT = create("application/x-ms-shortcut", "lnk"); + public static final MediaType APPLICATION_X_MSTERMINAL = create("application/x-msterminal", "trm"); + public static final MediaType APPLICATION_X_MS_WMD = create("application/x-ms-wmd", "wmd"); + public static final MediaType APPLICATION_X_MS_WMZ = create("application/x-ms-wmz", "wmz"); + public static final MediaType APPLICATION_X_MSWRITE = create("application/x-mswrite", "wri"); + public static final MediaType APPLICATION_X_MS_XBAP = create("application/x-ms-xbap", "xbap"); + public static final MediaType APPLICATION_X_NETCDF = create("application/x-netcdf", "nc", "cdf"); + public static final MediaType APPLICATION_X_NS_PROXY_AUTOCONFIG = create("application/x-ns-proxy-autoconfig", + "pac", "DAT"); + public static final MediaType APPLICATION_X_NWC = create("application/x-nwc", "nwc"); + public static final MediaType APPLICATION_X_NZB = create("application/x-nzb", "nzb"); + public static final MediaType APPLICATION_X_OBJECT = create("application/x-object", "o"); + public static final MediaType APPLICATION_XOP_XML = create("application/xop+xml", "xop"); + public static final MediaType APPLICATION_X_OZ_APPLICATION = create("application/x-oz-application", "oza"); + public static final MediaType APPLICATION_X_PKCS12 = create("application/x-pkcs12", "p12", "pfx"); + public static final MediaType APPLICATION_X_PKCS7_CERTIFICATES = create("application/x-pkcs7-certificates", "p7b", + "SPC"); + public static final MediaType APPLICATION_X_PKCS7_CERTREQRESP = create("application/x-pkcs7-certreqresp", "p7r"); + public static final MediaType APPLICATION_X_PKCS7_CRL = create("application/x-pkcs7-crl", "crl"); + public static final MediaType APPLICATION_XPROC_XML = create("application/xproc+xml", "xpl"); + public static final MediaType APPLICATION_X_PYTHON_CODE = create("application/x-python-code", "pyc", "pyo"); + public static final MediaType APPLICATION_X_QGIS = create("application/x-qgis", "qgs", "shp", "shx"); + public static final MediaType APPLICATION_X_QUICKTIMEPLAYER = create("application/x-quicktimeplayer", "qtl"); + public static final MediaType APPLICATION_X_RAR_COMPRESSED = create("application/x-rar-compressed", "rar"); + public static final MediaType APPLICATION_X_RDP = create("application/x-rdp", "rdp"); + public static final MediaType APPLICATION_X_REDHAT_PACKAGE_MANAGER = create("application/x-redhat-package-manager", + "RPM"); + public static final MediaType APPLICATION_X_RESEARCH_INFO_SYSTEMS = create("application/x-research-info-systems", + "RIS"); + public static final MediaType APPLICATION_X_RUBY = create("application/x-ruby", "rb"); + public static final MediaType APPLICATION_X_SCILAB = create("application/x-scilab", "sci", "sce"); + public static final MediaType APPLICATION_X_SHAR = create("application/x-shar", "shar"); + public static final MediaType APPLICATION_X_SHOCKWAVE_FLASH = create("application/x-shockwave-flash", "swf", "swfl"); + public static final MediaType APPLICATION_X_SH_UTF8 = createUTF8("application/x-sh", "sh"); + public static final MediaType APPLICATION_X_SILVERLIGHT_APP = create("application/x-silverlight-app", "xap"); + public static final MediaType APPLICATION_X_SILVERLIGHT = create("application/x-silverlight", "scr"); + public static final MediaType APPLICATION_XSLT_XML_UTF8 = createUTF8("application/xslt+xml", "xslt"); + public static final MediaType APPLICATION_XSPF_XML_UTF8 = createUTF8("application/xspf+xml", "xspf"); + public static final MediaType APPLICATION_X_SQL_UTF8 = createUTF8("application/x-sql", "sql"); + public static final MediaType APPLICATION_X_STUFFIT = create("application/x-stuffit", "sit", "sitx"); + public static final MediaType APPLICATION_X_STUFFITX = create("application/x-stuffitx", "sitx"); + public static final MediaType APPLICATION_X_SUBRIP = create("application/x-subrip", "srt"); + public static final MediaType APPLICATION_X_SV4CPIO = create("application/x-sv4cpio", "sv4cpio"); + public static final MediaType APPLICATION_X_SV4CRC = create("application/x-sv4crc", "sv4crc"); + public static final MediaType APPLICATION_X_T3VM_IMAGE = create("application/x-t3vm-image", "t3"); + public static final MediaType APPLICATION_X_TADS = create("application/x-tads", "gam"); + public static final MediaType APPLICATION_X_TAR = create("application/x-tar", "tar"); + public static final MediaType APPLICATION_X_TCL = create("application/x-tcl", "tcl"); + public static final MediaType APPLICATION_X_TEX_GF = create("application/x-tex-gf", "gf"); + public static final MediaType APPLICATION_X_TEXINFO = create("application/x-texinfo", "texinfo", "texi"); + public static final MediaType APPLICATION_X_TEX_PK = create("application/x-tex-pk", "pk"); + public static final MediaType APPLICATION_X_TEX = create("application/x-tex", "tex"); + public static final MediaType APPLICATION_X_TEX_TFM = create("application/x-tex-tfm", "tfm"); + public static final MediaType APPLICATION_X_TGIF = create("application/x-tgif", "obj"); + public static final MediaType APPLICATION_X_TRASH = create("application/x-trash", "~", "%", "bak", "old", "sik"); + public static final MediaType APPLICATION_X_TROFF_MAN = create("application/x-troff-man", "man"); + public static final MediaType APPLICATION_X_TROFF_ME = create("application/x-troff-me", "me"); + public static final MediaType APPLICATION_X_TROFF_MS = create("application/x-troff-ms", "ms"); + public static final MediaType APPLICATION_X_TROFF = create("application/x-troff", "t", "tr", "roff"); + public static final MediaType APPLICATION_X_USTAR = create("application/x-ustar", "ustar"); + public static final MediaType APPLICATION_XV_XML = create("application/xv+xml", "mxml", "xhvml", "xvml", "xvm"); + public static final MediaType APPLICATION_X_WAIS_SOURCE = create("application/x-wais-source", "src"); + public static final MediaType APPLICATION_X_WINGZ = create("application/x-wingz", "wz"); + public static final MediaType APPLICATION_X_X509_CA_CERT = create("application/x-x509-ca-cert", "der", "crt"); + public static final MediaType APPLICATION_X_XCF = create("application/x-xcf", "xcf"); + public static final MediaType APPLICATION_X_XFIG = create("application/x-xfig", "fig"); + public static final MediaType APPLICATION_X_XLIFF_XML = create("application/x-xliff+xml", "xlf"); + public static final MediaType APPLICATION_X_XPINSTALL = create("application/x-xpinstall", "xpi"); + public static final MediaType APPLICATION_X_XZ = create("application/x-xz", "xz"); + public static final MediaType APPLICATION_X_ZMACHINE = create("application/x-zmachine", "z1", "z2", "z3", "z4", + "z5", "Z6", "Z7", "Z8"); + public static final MediaType APPLICATION_YANG = create("application/yang", "yang"); + public static final MediaType APPLICATION_YIN_XML = create("application/yin+xml", "yin"); + public static final MediaType APPLICATION_ZIP = create("application/zip", "zip"); + public static final MediaType AUDIO_ADPCM = create("audio/adpcm", "adp"); + public static final MediaType AUDIO_AMR = create("audio/amr", "amr"); + public static final MediaType AUDIO_AMR_WB = create("audio/amr-wb", "awb"); + public static final MediaType AUDIO_ANNODEX = create("audio/annodex", "axa"); + public static final MediaType AUDIO_BASIC = create("audio/basic", "au", "snd"); + public static final MediaType AUDIO_CSOUND = create("audio/csound", "csd", "orc", "sco"); + public static final MediaType AUDIO_FLAC = create("audio/flac", "flac"); + public static final MediaType AUDIO_MIDI = create("audio/midi", "mid", "midi", "kar", "rmi"); + public static final MediaType AUDIO_MP4 = create("audio/mp4", "mp4a"); + public static final MediaType AUDIO_MPEG = create("audio/mpeg", "mpga", "mpega", "mp2", "mp2a", "mp3", "m2a", + "m3a", "MP3", "M4A"); + public static final MediaType AUDIO_MPEGURL = create("audio/mpegurl", "m3u"); + public static final MediaType AUDIO_OGG = create("audio/ogg", "oga", "ogg", "spx"); + public static final MediaType AUDIO_PRS_SID = create("audio/prs.sid", "sid"); + public static final MediaType AUDIO_S3M = create("audio/s3m", "s3m"); + public static final MediaType AUDIO_SILK = create("audio/silk", "sil"); + public static final MediaType AUDIO_VND_DECE_AUDIO = create("audio/vnd.dece.audio", "uva", "uvva"); + public static final MediaType AUDIO_VND_DIGITAL_WINDS = create("audio/vnd.digital-winds", "eol"); + public static final MediaType AUDIO_VND_DRA = create("audio/vnd.dra", "dra"); + public static final MediaType AUDIO_VND_DTS = create("audio/vnd.dts", "dts"); + public static final MediaType AUDIO_VND_DTS_HD = create("audio/vnd.dts.hd", "dtshd"); + public static final MediaType AUDIO_VND_LUCENT_VOICE = create("audio/vnd.lucent.voice", "lvp"); + public static final MediaType AUDIO_VND_MS_PLAYREADY_MEDIA_PYA = create("audio/vnd.ms-playready.media.pya", "pya"); + public static final MediaType AUDIO_VND_NUERA_ECELP4800 = create("audio/vnd.nuera.ecelp4800", "ecelp4800"); + public static final MediaType AUDIO_VND_NUERA_ECELP7470 = create("audio/vnd.nuera.ecelp7470", "ecelp7470"); + public static final MediaType AUDIO_VND_NUERA_ECELP9600 = create("audio/vnd.nuera.ecelp9600", "ecelp9600"); + public static final MediaType AUDIO_VND_RIP = create("audio/vnd.rip", "rip"); + public static final MediaType AUDIO_WEBM = create("audio/webm", "weba"); + public static final MediaType AUDIO_X_AAC = create("audio/x-aac", "aac"); + public static final MediaType AUDIO_X_AIFF = create("audio/x-aiff", "aif", "aiff", "aifc"); + public static final MediaType AUDIO_X_CAF = create("audio/x-caf", "caf"); + public static final MediaType AUDIO_X_FLAC = create("audio/x-flac", "flac"); + public static final MediaType AUDIO_X_GSM = create("audio/x-gsm", "gsm"); + public static final MediaType AUDIO_X_MATROSKA = create("audio/x-matroska", "mka"); + public static final MediaType AUDIO_X_MPEGURL = create("audio/x-mpegurl", "m3u"); + public static final MediaType AUDIO_X_MS_WAX = create("audio/x-ms-wax", "wax"); + public static final MediaType AUDIO_X_MS_WMA = create("audio/x-ms-wma", "wma"); + public static final MediaType AUDIO_XM = create("audio/xm", "xm"); + public static final MediaType AUDIO_X_PN_REALAUDIO_PLUGIN = create("audio/x-pn-realaudio-plugin", "rmp"); + public static final MediaType AUDIO_X_PN_REALAUDIO = create("audio/x-pn-realaudio", "ra", "rm", "ram"); + public static final MediaType AUDIO_X_REALAUDIO = create("audio/x-realaudio", "ra"); + public static final MediaType AUDIO_X_SCPLS = create("audio/x-scpls", "pls"); + public static final MediaType AUDIO_X_SD2 = create("audio/x-sd2", "sd2"); + public static final MediaType AUDIO_X_WAV = create("audio/x-wav", "wav"); + public static final MediaType CHEMICAL_X_ALCHEMY = create("chemical/x-alchemy", "alc"); + public static final MediaType CHEMICAL_X_CACHE = create("chemical/x-cache", "cac", "cache"); + public static final MediaType CHEMICAL_X_CACHE_CSF = create("chemical/x-cache-csf", "csf"); + public static final MediaType CHEMICAL_X_CACTVS_BINARY = create("chemical/x-cactvs-binary", "cbin", "cascii", + "ctab"); + public static final MediaType CHEMICAL_X_CDX = create("chemical/x-cdx", "cdx"); + public static final MediaType CHEMICAL_X_CERIUS = create("chemical/x-cerius", "cer"); + public static final MediaType CHEMICAL_X_CHEM3D = create("chemical/x-chem3d", "c3d"); + public static final MediaType CHEMICAL_X_CHEMDRAW = create("chemical/x-chemdraw", "chm"); + public static final MediaType CHEMICAL_X_CIF = create("chemical/x-cif", "cif"); + public static final MediaType CHEMICAL_X_CMDF = create("chemical/x-cmdf", "cmdf"); + public static final MediaType CHEMICAL_X_CML = create("chemical/x-cml", "cml"); + public static final MediaType CHEMICAL_X_COMPASS = create("chemical/x-compass", "cpa"); + public static final MediaType CHEMICAL_X_CROSSFIRE = create("chemical/x-crossfire", "bsd"); + public static final MediaType CHEMICAL_X_CSML = create("chemical/x-csml", "csml", "csm"); + public static final MediaType CHEMICAL_X_CTX = create("chemical/x-ctx", "ctx"); + public static final MediaType CHEMICAL_X_CXF = create("chemical/x-cxf", "cxf", "cef"); + public static final MediaType CHEMICAL_X_DAYLIGHT_SMILES = create("chemical/x-daylight-smiles", "smi"); + public static final MediaType CHEMICAL_X_EMBL_DL_NUCLEOTIDE = create("chemical/x-embl-dl-nucleotide", "emb", "embl"); + public static final MediaType CHEMICAL_X_GALACTIC_SPC = create("chemical/x-galactic-spc", "spc"); + public static final MediaType CHEMICAL_X_GAMESS_INPUT = create("chemical/x-gamess-input", "inp", "gam", "gamin"); + public static final MediaType CHEMICAL_X_GAUSSIAN_CHECKPOINT = create("chemical/x-gaussian-checkpoint", "fch", + "fchk"); + public static final MediaType CHEMICAL_X_GAUSSIAN_CUBE = create("chemical/x-gaussian-cube", "cub"); + public static final MediaType CHEMICAL_X_GAUSSIAN_INPUT = create("chemical/x-gaussian-input", "gau", "gjc", "gjf"); + public static final MediaType CHEMICAL_X_GAUSSIAN_LOG = create("chemical/x-gaussian-log", "gal"); + public static final MediaType CHEMICAL_X_GCG8_SEQUENCE = create("chemical/x-gcg8-sequence", "gcg"); + public static final MediaType CHEMICAL_X_GENBANK = create("chemical/x-genbank", "gen"); + public static final MediaType CHEMICAL_X_HIN = create("chemical/x-hin", "hin"); + public static final MediaType CHEMICAL_X_ISOSTAR = create("chemical/x-isostar", "istr", "ist"); + public static final MediaType CHEMICAL_X_JCAMP_DX = create("chemical/x-jcamp-dx", "jdx", "dx"); + public static final MediaType CHEMICAL_X_KINEMAGE = create("chemical/x-kinemage", "kin"); + public static final MediaType CHEMICAL_X_MACMOLECULE = create("chemical/x-macmolecule", "mcm"); + public static final MediaType CHEMICAL_X_MACROMODEL_INPUT = create("chemical/x-macromodel-input", "mmd", "mmod"); + public static final MediaType CHEMICAL_X_MDL_MOLFILE = create("chemical/x-mdl-molfile", "mol"); + public static final MediaType CHEMICAL_X_MDL_RDFILE = create("chemical/x-mdl-rdfile", "rd"); + public static final MediaType CHEMICAL_X_MDL_RXNFILE = create("chemical/x-mdl-rxnfile", "rxn"); + public static final MediaType CHEMICAL_X_MDL_SDFILE = create("chemical/x-mdl-sdfile", "sd", "sdf"); + public static final MediaType CHEMICAL_X_MDL_TGF = create("chemical/x-mdl-tgf", "tgf"); + public static final MediaType CHEMICAL_X_MIF = create("chemical/x-mif", "mif"); + public static final MediaType CHEMICAL_X_MMCIF = create("chemical/x-mmcif", "mcif"); + public static final MediaType CHEMICAL_X_MOL2 = create("chemical/x-mol2", "mol2"); + public static final MediaType CHEMICAL_X_MOLCONN_Z = create("chemical/x-molconn-z", "b"); + public static final MediaType CHEMICAL_X_MOPAC_GRAPH = create("chemical/x-mopac-graph", "gpt"); + public static final MediaType CHEMICAL_X_MOPAC_INPUT = create("chemical/x-mopac-input", "mop", "mopcrt", "mpc", + "zmt"); + public static final MediaType CHEMICAL_X_MOPAC_OUT = create("chemical/x-mopac-out", "moo"); + public static final MediaType CHEMICAL_X_MOPAC_VIB = create("chemical/x-mopac-vib", "mvb"); + public static final MediaType CHEMICAL_X_NCBI_ASN1_ASCII = create("chemical/x-ncbi-asn1-ascii", "prt", "ent"); + public static final MediaType CHEMICAL_X_NCBI_ASN1 = create("chemical/x-ncbi-asn1", "asn"); + public static final MediaType CHEMICAL_X_NCBI_ASN1_BINARY = create("chemical/x-ncbi-asn1-binary", "val", "aso"); + public static final MediaType CHEMICAL_X_NCBI_ASN1_SPEC = create("chemical/x-ncbi-asn1-spec", "asn"); + public static final MediaType CHEMICAL_X_PDB = create("chemical/x-pdb", "pdb", "ent"); + public static final MediaType CHEMICAL_X_ROSDAL = create("chemical/x-rosdal", "ros"); + public static final MediaType CHEMICAL_X_SWISSPROT = create("chemical/x-swissprot", "sw"); + public static final MediaType CHEMICAL_X_VAMAS_ISO14976 = create("chemical/x-vamas-iso14976", "vms"); + public static final MediaType CHEMICAL_X_VMD = create("chemical/x-vmd", "vmd"); + public static final MediaType CHEMICAL_X_XTEL = create("chemical/x-xtel", "xtel"); + public static final MediaType CHEMICAL_X_XYZ = create("chemical/x-xyz", "xyz"); + public static final MediaType IMAGE_BMP = create("image/bmp", "bmp"); + public static final MediaType IMAGE_CGM = create("image/cgm", "cgm"); + public static final MediaType IMAGE_G3FAX = create("image/g3fax", "g3"); + public static final MediaType IMAGE_GIF = create("image/gif", "gif"); + public static final MediaType IMAGE_IEF = create("image/ief", "ief"); + public static final MediaType IMAGE_JPEG = create("image/jpeg", "jpeg", "jpg", "jpe"); + public static final MediaType IMAGE_KTX = create("image/ktx", "ktx"); + public static final MediaType IMAGE_PCX = create("image/pcx", "pcx"); + public static final MediaType IMAGE_PNG = create("image/png", "png"); + public static final MediaType IMAGE_PRS_BTIF = create("image/prs.btif", "btif"); + public static final MediaType IMAGE_SGI = create("image/sgi", "sgi"); + public static final MediaType IMAGE_SVG_XML = createUTF8("image/svg+xml", "svg", "svgz"); + public static final MediaType IMAGE_TIFF = create("image/tiff", "tiff", "tif"); + public static final MediaType IMAGE_VND_ADOBE_PHOTOSHOP = create("image/vnd.adobe.photoshop", "psd"); + public static final MediaType IMAGE_VND_DECE_GRAPHIC = create("image/vnd.dece.graphic", "uvi", "uvvi", "uvg", + "uvvg"); + public static final MediaType IMAGE_VND_DJVU = create("image/vnd.djvu", "djvu", "djv"); + public static final MediaType IMAGE_VND_DVB_SUBTITLE = create("image/vnd.dvb.subtitle", "sub"); + public static final MediaType IMAGE_VND_DWG = create("image/vnd.dwg", "dwg"); + public static final MediaType IMAGE_VND_DXF = create("image/vnd.dxf", "dxf"); + public static final MediaType IMAGE_VND_FASTBIDSHEET = create("image/vnd.fastbidsheet", "fbs"); + public static final MediaType IMAGE_VND_FPX = create("image/vnd.fpx", "fpx"); + public static final MediaType IMAGE_VND_FST = create("image/vnd.fst", "fst"); + public static final MediaType IMAGE_VND_FUJIXEROX_EDMICS_MMR = create("image/vnd.fujixerox.edmics-mmr", "mmr"); + public static final MediaType IMAGE_VND_FUJIXEROX_EDMICS_RLC = create("image/vnd.fujixerox.edmics-rlc", "rlc"); + public static final MediaType IMAGE_VND_MS_MODI = create("image/vnd.ms-modi", "mdi"); + public static final MediaType IMAGE_VND_MS_PHOTO = create("image/vnd.ms-photo", "wdp"); + public static final MediaType IMAGE_VND_NET_FPX = create("image/vnd.net-fpx", "npx"); + public static final MediaType IMAGE_VND_WAP_WBMP = create("image/vnd.wap.wbmp", "wbmp"); + public static final MediaType IMAGE_VND_XIFF = create("image/vnd.xiff", "xif"); + public static final MediaType IMAGE_WEBP = create("image/webp", "webp"); + public static final MediaType IMAGE_X_3DS = create("image/x-3ds", "3ds"); + public static final MediaType IMAGE_X_CANON_CR2 = create("image/x-canon-cr2", "cr2"); + public static final MediaType IMAGE_X_CANON_CRW = create("image/x-canon-crw", "crw"); + public static final MediaType IMAGE_X_CMU_RASTER = create("image/x-cmu-raster", "ras"); + public static final MediaType IMAGE_X_CMX = create("image/x-cmx", "cmx"); + public static final MediaType IMAGE_X_CORELDRAW = create("image/x-coreldraw", "cdr"); + public static final MediaType IMAGE_X_CORELDRAWPATTERN = create("image/x-coreldrawpattern", "pat"); + public static final MediaType IMAGE_X_CORELDRAWTEMPLATE = create("image/x-coreldrawtemplate", "cdt"); + public static final MediaType IMAGE_X_CORELPHOTOPAINT = create("image/x-corelphotopaint", "cpt"); + public static final MediaType IMAGE_X_EPSON_ERF = create("image/x-epson-erf", "erf"); + public static final MediaType IMAGE_X_FREEHAND = create("image/x-freehand", "fh", "fhc", "fh4", "fh5", "fh7"); + public static final MediaType IMAGE_X_ICON = create("image/x-icon", "ico"); + public static final MediaType IMAGE_X_JG = create("image/x-jg", "art"); + public static final MediaType IMAGE_X_JNG = create("image/x-jng", "jng"); + public static final MediaType IMAGE_X_MRSID_IMAGE = create("image/x-mrsid-image", "sid"); + public static final MediaType IMAGE_X_NIKON_NEF = create("image/x-nikon-nef", "nef"); + public static final MediaType IMAGE_X_OLYMPUS_ORF = create("image/x-olympus-orf", "orf"); + public static final MediaType IMAGE_X_PCX = create("image/x-pcx", "pcx"); + public static final MediaType IMAGE_X_PHOTOSHOP = create("image/x-photoshop", "psd"); + public static final MediaType IMAGE_X_PICT = create("image/x-pict", "pic", "pct"); + public static final MediaType IMAGE_X_PORTABLE_ANYMAP = create("image/x-portable-anymap", "pnm"); + public static final MediaType IMAGE_X_PORTABLE_BITMAP = create("image/x-portable-bitmap", "pbm"); + public static final MediaType IMAGE_X_PORTABLE_GRAYMAP = create("image/x-portable-graymap", "pgm"); + public static final MediaType IMAGE_X_PORTABLE_PIXMAP = create("image/x-portable-pixmap", "ppm"); + public static final MediaType IMAGE_X_RGB = create("image/x-rgb", "rgb"); + public static final MediaType IMAGE_X_TGA = create("image/x-tga", "tga"); + public static final MediaType IMAGE_X_XBITMAP = create("image/x-xbitmap", "xbm"); + public static final MediaType IMAGE_X_XPIXMAP = create("image/x-xpixmap", "xpm"); + public static final MediaType IMAGE_X_XWINDOWDUMP = create("image/x-xwindowdump", "xwd"); + public static final MediaType MESSAGE_RFC822 = create("message/rfc822", "eml", "mime"); + public static final MediaType MODEL_IGES = create("model/iges", "igs", "iges"); + public static final MediaType MODEL_MESH = create("model/mesh", "msh", "mesh", "silo"); + public static final MediaType MODEL_VND_COLLADA_XML = create("model/vnd.collada+xml", "dae"); + public static final MediaType MODEL_VND_DWF = create("model/vnd.dwf", "dwf"); + public static final MediaType MODEL_VND_GDL = create("model/vnd.gdl", "gdl"); + public static final MediaType MODEL_VND_GTW = create("model/vnd.gtw", "gtw"); + public static final MediaType MODEL_VND_MTS = create("model/vnd.mts", "mts"); + public static final MediaType MODEL_VND_VTU = create("model/vnd.vtu", "vtu"); + public static final MediaType MODEL_VRML = create("model/vrml", "wrl", "vrml"); + public static final MediaType MODEL_X3D_BINARY = create("model/x3d+binary", "x3db", "x3dbz"); + public static final MediaType MODEL_X3D_VRML = create("model/x3d+vrml", "x3dv", "x3dvz"); + public static final MediaType MODEL_X3D_XML = create("model/x3d+xml", "x3d", "x3dz"); + public static final MediaType TEXT_CACHE_MANIFEST = create("text/cache-manifest", "appcache", "manifest"); + public static final MediaType TEXT_CALENDAR = create("text/calendar", "ics", "icz", "ifb"); + public static final MediaType TEXT_CSS_UTF8 = createUTF8("text/css", "css"); + public static final MediaType TEXT_CSV_UTF8 = createUTF8("text/csv", "csv"); + public static final MediaType TEXT_H323 = create("text/h323", "323"); + public static final MediaType TEXT_HTML_UTF8 = createUTF8("text/html", "html", "htm", "shtml"); + public static final MediaType TEXT_IULS = create("text/iuls", "uls"); + public static final MediaType TEXT_MATHML = create("text/mathml", "mml"); + public static final MediaType TEXT_N3 = create("text/n3", "n3"); + public static final MediaType TEXT_PLAIN = create("text/plain"); + public static final MediaType TEXT_PLAIN_UTF8 = createUTF8("text/plain", "asc", "txt", "text", "conf", "def", + "pot", "brf", "LIST", "LOG", "IN"); + public static final MediaType TEXT_PRS_LINES_TAG = create("text/prs.lines.tag", "dsc"); + public static final MediaType TEXT_RICHTEXT = create("text/richtext", "rtx"); + public static final MediaType TEXT_SCRIPTLET = create("text/scriptlet", "sct", "wsc"); + public static final MediaType TEXT_SGML = create("text/sgml", "sgml", "sgm"); + public static final MediaType TEXT_TAB_SEPARATED_VALUES_UTF8 = createUTF8("text/tab-separated-values", "tsv"); + public static final MediaType TEXT_TEXMACS = create("text/texmacs", "tm"); + public static final MediaType TEXT_TROFF = create("text/troff", "t", "tr", "roff", "man", "me", "ms"); + public static final MediaType TEXT_TURTLE = create("text/turtle", "ttl"); + public static final MediaType TEXT_URI_LIST = create("text/uri-list", "uri", "uris", "urls"); + public static final MediaType TEXT_VCARD = create("text/vcard", "vcard"); + public static final MediaType TEXT_VND_CURL = create("text/vnd.curl", "curl"); + public static final MediaType TEXT_VND_CURL_DCURL = create("text/vnd.curl.dcurl", "dcurl"); + public static final MediaType TEXT_VND_CURL_MCURL = create("text/vnd.curl.mcurl", "mcurl"); + public static final MediaType TEXT_VND_CURL_SCURL = create("text/vnd.curl.scurl", "scurl"); + public static final MediaType TEXT_VND_DVB_SUBTITLE = create("text/vnd.dvb.subtitle", "sub"); + public static final MediaType TEXT_VND_FLY = create("text/vnd.fly", "fly"); + public static final MediaType TEXT_VND_FMI_FLEXSTOR = create("text/vnd.fmi.flexstor", "flx"); + public static final MediaType TEXT_VND_GRAPHVIZ = create("text/vnd.graphviz", "gv"); + public static final MediaType TEXT_VND_IN3D_3DML = create("text/vnd.in3d.3dml", "3dml"); + public static final MediaType TEXT_VND_IN3D_SPOT = create("text/vnd.in3d.spot", "spot"); + public static final MediaType TEXT_VND_SUN_J2ME_APP_DESCRIPTOR = create("text/vnd.sun.j2me.app-descriptor", "jad"); + public static final MediaType TEXT_VND_WAP_WMLSCRIPT = create("text/vnd.wap.wmlscript", "wmls"); + public static final MediaType TEXT_VND_WAP_WML = create("text/vnd.wap.wml", "wml"); + public static final MediaType TEXT_X_ASM_UTF8 = createUTF8("text/x-asm", "s", "asm"); + public static final MediaType TEXT_X_BIBTEX_UTF8 = createUTF8("text/x-bibtex", "bib"); + public static final MediaType TEXT_X_BOO_UTF8 = createUTF8("text/x-boo", "boo"); + public static final MediaType TEXT_X_C_UTF8 = createUTF8("text/x-c", "c", "cc", "cxx", "cpp", "h", "hh", "dic"); + public static final MediaType TEXT_X_CHDR_UTF8 = createUTF8("text/x-chdr", "h"); + public static final MediaType TEXT_X_C__HDR_UTF8 = createUTF8("text/x-c++hdr", "h++", "hpp", "hxx", "hh"); + public static final MediaType TEXT_X_COMPONENT_UTF8 = createUTF8("text/x-component", "htc"); + public static final MediaType TEXT_X_CSH_UTF8 = createUTF8("text/x-csh", "csh"); + public static final MediaType TEXT_X_CSRC_UTF8 = createUTF8("text/x-csrc", "c"); + public static final MediaType TEXT_X_C__SRC_UTF8 = createUTF8("text/x-c++src", "c++", "cpp", "cxx", "cc"); + public static final MediaType TEXT_X_DIFF_UTF8 = createUTF8("text/x-diff", "diff", "patch"); + public static final MediaType TEXT_X_DSRC_UTF8 = createUTF8("text/x-dsrc", "d"); + public static final MediaType TEXT_X_FORTRAN_UTF8 = createUTF8("text/x-fortran", "f", "for", "f77", "f90"); + public static final MediaType TEXT_X_HASKELL_UTF8 = createUTF8("text/x-haskell", "hs"); + public static final MediaType TEXT_X_JAVA_UTF8 = createUTF8("text/x-java", "java"); + public static final MediaType TEXT_X_JAVA_SOURCE_UTF8 = createUTF8("text/x-java-source", "java"); + public static final MediaType TEXT_X_LITERATE_HASKELL_UTF8 = createUTF8("text/x-literate-haskell", "lhs"); + public static final MediaType TEXT_X_MOC_UTF8 = createUTF8("text/x-moc", "moc"); + public static final MediaType TEXT_X_NFO_UTF8 = createUTF8("text/x-nfo", "nfo"); + public static final MediaType TEXT_X_OPML_UTF8 = createUTF8("text/x-opml", "opml"); + public static final MediaType TEXT_X_PASCAL_UTF8 = createUTF8("text/x-pascal", "p", "pas"); + public static final MediaType TEXT_X_PCS_GCD_UTF8 = createUTF8("text/x-pcs-gcd", "gcd"); + public static final MediaType TEXT_X_PERL_UTF8 = createUTF8("text/x-perl", "pl", "pm"); + public static final MediaType TEXT_X_PYTHON_UTF8 = createUTF8("text/x-python", "py"); + public static final MediaType TEXT_X_SCALA_UTF8 = createUTF8("text/x-scala", "scala"); + public static final MediaType TEXT_X_SETEXT_UTF8 = createUTF8("text/x-setext", "etx"); + public static final MediaType TEXT_X_SFV_UTF8 = createUTF8("text/x-sfv", "sfv"); + public static final MediaType TEXT_X_SH_UTF8 = createUTF8("text/x-sh", "sh"); + public static final MediaType TEXT_X_TCL_UTF8 = createUTF8("text/x-tcl", "tcl", "tk"); + public static final MediaType TEXT_X_TEX_UTF8 = createUTF8("text/x-tex", "tex", "ltx", "sty", "cls"); + public static final MediaType TEXT_X_UUENCODE_UTF8 = createUTF8("text/x-uuencode", "uu"); + public static final MediaType TEXT_X_VCALENDAR_UTF8 = createUTF8("text/x-vcalendar", "vcs"); + public static final MediaType TEXT_X_VCARD_UTF8 = createUTF8("text/x-vcard", "vcf"); + public static final MediaType VIDEO_3GPP2 = create("video/3gpp2", "3g2"); + public static final MediaType VIDEO_3GPP = create("video/3gpp", "3gp"); + public static final MediaType VIDEO_ANNODEX = create("video/annodex", "axv"); + public static final MediaType VIDEO_DL = create("video/dl", "dl"); + public static final MediaType VIDEO_DV = create("video/dv", "dif", "dv"); + public static final MediaType VIDEO_FLI = create("video/fli", "fli"); + public static final MediaType VIDEO_GL = create("video/gl", "gl"); + public static final MediaType VIDEO_H261 = create("video/h261", "h261"); + public static final MediaType VIDEO_H263 = create("video/h263", "h263"); + public static final MediaType VIDEO_H264 = create("video/h264", "h264"); + public static final MediaType VIDEO_JPEG = create("video/jpeg", "jpgv"); + public static final MediaType VIDEO_JPM = create("video/jpm", "jpm", "jpgm"); + public static final MediaType VIDEO_MJ2 = create("video/mj2", "mj2", "mjp2"); + public static final MediaType VIDEO_MP2T = create("video/mp2t", "ts"); + public static final MediaType VIDEO_MP4 = create("video/mp4", "mp4", "mp4v", "mpg4"); + public static final MediaType VIDEO_MPEG = create("video/mpeg", "mpeg", "mpg", "mpe", "m1v", "m2v"); + public static final MediaType VIDEO_OGG = create("video/ogg", "ogv"); + public static final MediaType VIDEO_QUICKTIME = create("video/quicktime", "qt", "mov"); + public static final MediaType VIDEO_VND_DECE_HD = create("video/vnd.dece.hd", "uvh", "uvvh"); + public static final MediaType VIDEO_VND_DECE_MOBILE = create("video/vnd.dece.mobile", "uvm", "uvvm"); + public static final MediaType VIDEO_VND_DECE_PD = create("video/vnd.dece.pd", "uvp", "uvvp"); + public static final MediaType VIDEO_VND_DECE_SD = create("video/vnd.dece.sd", "uvs", "uvvs"); + public static final MediaType VIDEO_VND_DECE_VIDEO = create("video/vnd.dece.video", "uvv", "uvvv"); + public static final MediaType VIDEO_VND_DVB_FILE = create("video/vnd.dvb.file", "dvb"); + public static final MediaType VIDEO_VND_FVT = create("video/vnd.fvt", "fvt"); + public static final MediaType VIDEO_VND_MPEGURL = create("video/vnd.mpegurl", "mxu", "m4u"); + public static final MediaType VIDEO_VND_MS_PLAYREADY_MEDIA_PYV = create("video/vnd.ms-playready.media.pyv", "pyv"); + public static final MediaType VIDEO_VND_UVVU_MP4 = create("video/vnd.uvvu.mp4", "uvu", "uvvu"); + public static final MediaType VIDEO_VND_VIVO = create("video/vnd.vivo", "viv"); + public static final MediaType VIDEO_WEBM = create("video/webm", "webm"); + public static final MediaType VIDEO_X_F4V = create("video/x-f4v", "f4v"); + public static final MediaType VIDEO_X_FLI = create("video/x-fli", "fli"); + public static final MediaType VIDEO_X_FLV = create("video/x-flv", "flv"); + public static final MediaType VIDEO_X_LA_ASF = create("video/x-la-asf", "lsf", "lsx"); + public static final MediaType VIDEO_X_M4V = create("video/x-m4v", "m4v"); + public static final MediaType VIDEO_X_MATROSKA = create("video/x-matroska", "mpv", "mkv", "mk3d", "mks"); + public static final MediaType VIDEO_X_MNG = create("video/x-mng", "mng"); + public static final MediaType VIDEO_X_MS_ASF = create("video/x-ms-asf", "asf", "asx"); + public static final MediaType VIDEO_X_MSVIDEO = create("video/x-msvideo", "avi"); + public static final MediaType VIDEO_X_MS_VOB = create("video/x-ms-vob", "vob"); + public static final MediaType VIDEO_X_MS_WMV = create("video/x-ms-wmv", "wmv"); + public static final MediaType VIDEO_X_MS_WM = create("video/x-ms-wm", "wm"); + public static final MediaType VIDEO_X_MS_WMX = create("video/x-ms-wmx", "wmx"); + public static final MediaType VIDEO_X_MS_WVX = create("video/x-ms-wvx", "wvx"); + public static final MediaType VIDEO_X_SGI_MOVIE = create("video/x-sgi-movie", "movie"); + public static final MediaType VIDEO_X_SMV = create("video/x-smv", "smv"); + public static final MediaType X_CONFERENCE_X_COOLTALK = create("x-conference/x-cooltalk", "ice"); + public static final MediaType X_EPOC_X_SISX_APP = create("x-epoc/x-sisx-app", "sisx"); + public static final MediaType X_WORLD_X_VRML = create("x-world/x-vrml", "vrm", "vrml", "wrl"); - /*******************************************************/ + /*******************************************************/ - public static final MediaType ANY = create("*/*"); - public static final MediaType TEXT_ANY = create("text/*"); - public static final MediaType APPLICATION_ANY = create("application/*"); - public static final MediaType IMAGE_ANY = create("image/*"); - public static final MediaType VIDEO_ANY = create("video/*"); - public static final MediaType AUDIO_ANY = create("audio/*"); + public static final MediaType HTML_UTF_8 = TEXT_HTML_UTF8; + public static final MediaType CSS_UTF_8 = TEXT_CSS_UTF8; + public static final MediaType CSV_UTF_8 = TEXT_CSV_UTF8; + public static final MediaType PLAIN_TEXT_UTF_8 = TEXT_PLAIN_UTF8; - /*******************************************************/ + public static final MediaType XHTML_XML_UTF8 = APPLICATION_XHTML_XML_UTF8; + public static final MediaType JAVASCRIPT_UTF8 = APPLICATION_JAVASCRIPT_UTF8; + public static final MediaType JSON = APPLICATION_JSON; + public static final MediaType XML_UTF_8 = APPLICATION_XML_UTF8; - public static final MediaType TEXT_YAML = create("text/yaml","yaml"); + public static final MediaType BINARY = APPLICATION_OCTET_STREAM; + public static final MediaType ZIP = APPLICATION_ZIP; + public static final MediaType PDF = APPLICATION_PDF; + public static final MediaType SWF = APPLICATION_X_SHOCKWAVE_FLASH; - public static final MediaType APPLICATION_ANDREW_INSET = create("application/andrew-inset", "ez"); - public static final MediaType APPLICATION_ANNODEX = create("application/annodex", "anx"); - public static final MediaType APPLICATION_APPLIXWARE = create("application/applixware", "aw"); - public static final MediaType APPLICATION_ATOMCAT_XML_UTF8 = createUTF8("application/atomcat+xml", "atomcat"); - public static final MediaType APPLICATION_ATOMSERV_XML_UTF8 = createUTF8("application/atomserv+xml", "atomsrv"); - public static final MediaType APPLICATION_ATOMSVC_XML_UTF8 = createUTF8("application/atomsvc+xml", "atomsvc"); - public static final MediaType APPLICATION_ATOM_XML_UTF8 = createUTF8("application/atom+xml", "atom"); - public static final MediaType APPLICATION_BBOLIN = create("application/bbolin", "lin"); - public static final MediaType APPLICATION_CAP = create("application/cap", "cap", "pcap"); - public static final MediaType APPLICATION_CCXML_XML = create("application/ccxml+xml", "ccxml"); - public static final MediaType APPLICATION_CDMI_CAPABILITY = create("application/cdmi-capability", "cdmia"); - public static final MediaType APPLICATION_CDMI_CONTAINER = create("application/cdmi-container", "cdmic"); - public static final MediaType APPLICATION_CDMI_DOMAIN = create("application/cdmi-domain", "cdmid"); - public static final MediaType APPLICATION_CDMI_OBJECT = create("application/cdmi-object", "cdmio"); - public static final MediaType APPLICATION_CDMI_QUEUE = create("application/cdmi-queue", "cdmiq"); - public static final MediaType APPLICATION_CU_SEEME = create("application/cu-seeme", "cu"); - public static final MediaType APPLICATION_DAVMOUNT_XML = create("application/davmount+xml", "davmount"); - public static final MediaType APPLICATION_DOCBOOK_XML = create("application/docbook+xml", "dbk"); - public static final MediaType APPLICATION_DSPTYPE = create("application/dsptype", "tsp"); - public static final MediaType APPLICATION_DSSC_DER = create("application/dssc+der", "dssc"); - public static final MediaType APPLICATION_DSSC_XML = create("application/dssc+xml", "xdssc"); - public static final MediaType APPLICATION_ECMASCRIPT_UTF8 = createUTF8("application/ecmascript", "ecma", "es"); - public static final MediaType APPLICATION_EMMA_XML = create("application/emma+xml", "emma"); - public static final MediaType APPLICATION_EPUB_ZIP = create("application/epub+zip", "epub"); - public static final MediaType APPLICATION_EXI = create("application/exi", "exi"); - public static final MediaType APPLICATION_FONT_TDPFR = create("application/font-tdpfr", "pfr"); - public static final MediaType APPLICATION_FUTURESPLASH = create("application/futuresplash", "spl"); - public static final MediaType APPLICATION_GML_XML = create("application/gml+xml", "gml"); - public static final MediaType APPLICATION_GPX_XML = create("application/gpx+xml", "gpx"); - public static final MediaType APPLICATION_GXF = create("application/gxf", "gxf"); - public static final MediaType APPLICATION_HTA = create("application/hta", "hta"); - public static final MediaType APPLICATION_HYPERSTUDIO = create("application/hyperstudio", "stk"); - public static final MediaType APPLICATION_INKML_XML = create("application/inkml+xml", "ink", "inkml"); - public static final MediaType APPLICATION_IPFIX = create("application/ipfix", "ipfix"); - public static final MediaType APPLICATION_JAVA_ARCHIVE = create("application/java-archive", "jar"); - public static final MediaType APPLICATION_JAVASCRIPT_UTF8 = createUTF8("application/javascript", "js"); - public static final MediaType APPLICATION_JAVA_SERIALIZED_OBJECT = create("application/java-serialized-object", - "ser"); - public static final MediaType APPLICATION_JAVA_VM = create("application/java-vm", "class"); - public static final MediaType APPLICATION_JSON = create("application/json", "json", "map"); - public static final MediaType APPLICATION_JSONML_JSON = create("application/jsonml+json", "jsonml"); - public static final MediaType APPLICATION_LOST_XML = create("application/lost+xml", "lostxml"); - public static final MediaType APPLICATION_M3G = create("application/m3g", "m3g"); - public static final MediaType APPLICATION_MAC_BINHEX40 = create("application/mac-binhex40", "hqx"); - public static final MediaType APPLICATION_MAC_COMPACTPRO = create("application/mac-compactpro", "cpt"); - public static final MediaType APPLICATION_MADS_XML = create("application/mads+xml", "mads"); - public static final MediaType APPLICATION_MARC = create("application/marc", "mrc"); - public static final MediaType APPLICATION_MARCXML_XML = create("application/marcxml+xml", "mrcx"); - public static final MediaType APPLICATION_MATHEMATICA = create("application/mathematica", "ma", "mb", "nb", "nbp"); - public static final MediaType APPLICATION_MATHML_XML = create("application/mathml+xml", "mathml"); - public static final MediaType APPLICATION_MBOX = create("application/mbox", "mbox"); - public static final MediaType APPLICATION_MEDIASERVERCONTROL_XML = create("application/mediaservercontrol+xml", - "MSCML"); - public static final MediaType APPLICATION_METALINK4_XML = create("application/metalink4+xml", "meta4"); - public static final MediaType APPLICATION_METALINK_XML = create("application/metalink+xml", "metalink"); - public static final MediaType APPLICATION_METS_XML = create("application/mets+xml", "mets"); - public static final MediaType APPLICATION_MODS_XML = create("application/mods+xml", "mods"); - public static final MediaType APPLICATION_MP21 = create("application/mp21", "m21", "mp21"); - public static final MediaType APPLICATION_MP4 = create("application/mp4", "mp4s"); - public static final MediaType APPLICATION_MSACCESS = create("application/msaccess", "mdb"); - public static final MediaType APPLICATION_MSWORD = create("application/msword", "doc", "dot"); - public static final MediaType APPLICATION_MXF = create("application/mxf", "mxf"); - public static final MediaType APPLICATION_OCTET_STREAM = create("application/octet-stream", "bin", "dms", "lrf", - "MAR", "SO", "DIST", "DISTZ", "PKG", "BPK", "DUMP", "ELC", "DEPLOY"); - public static final MediaType APPLICATION_ODA = create("application/oda", "oda"); - public static final MediaType APPLICATION_OEBPS_PACKAGE_XML = create("application/oebps-package+xml", "opf"); - public static final MediaType APPLICATION_OGG = create("application/ogg", "ogx"); - public static final MediaType APPLICATION_OMDOC_XML = create("application/omdoc+xml", "omdoc"); - public static final MediaType APPLICATION_ONENOTE = create("application/onenote", "one", "onetoc", "onetoc2", - "ONETMP", "ONEPKG"); - public static final MediaType APPLICATION_OXPS = create("application/oxps", "oxps"); - public static final MediaType APPLICATION_PATCH_OPS_ERROR_XML = create("application/patch-ops-error+xml", "xer"); - public static final MediaType APPLICATION_PDF = create("application/pdf", "pdf"); - public static final MediaType APPLICATION_PGP_ENCRYPTED = create("application/pgp-encrypted", "pgp"); - public static final MediaType APPLICATION_PGP_KEYS = create("application/pgp-keys", "key"); - public static final MediaType APPLICATION_PGP_SIGNATURE = create("application/pgp-signature", "asc", "pgp", "sig"); - public static final MediaType APPLICATION_PICS_RULES = create("application/pics-rules", "prf"); - public static final MediaType APPLICATION_PKCS10 = create("application/pkcs10", "p10"); - public static final MediaType APPLICATION_PKCS7_MIME = create("application/pkcs7-mime", "p7m", "p7c"); - public static final MediaType APPLICATION_PKCS7_SIGNATURE = create("application/pkcs7-signature", "p7s"); - public static final MediaType APPLICATION_PKCS8 = create("application/pkcs8", "p8"); - public static final MediaType APPLICATION_PKIX_ATTR_CERT = create("application/pkix-attr-cert", "ac"); - public static final MediaType APPLICATION_PKIX_CERT = create("application/pkix-cert", "cer"); - public static final MediaType APPLICATION_PKIXCMP = create("application/pkixcmp", "pki"); - public static final MediaType APPLICATION_PKIX_CRL = create("application/pkix-crl", "crl"); - public static final MediaType APPLICATION_PKIX_PKIPATH = create("application/pkix-pkipath", "pkipath"); - public static final MediaType APPLICATION_PLS_XML = create("application/pls+xml", "pls"); - public static final MediaType APPLICATION_POSTSCRIPT = create("application/postscript", "ps", "ai", "eps", "epsi", - "EPSF", "EPS2", "EPS3"); - public static final MediaType APPLICATION_PRS_CWW = create("application/prs.cww", "cww"); - public static final MediaType APPLICATION_PSKC_XML = create("application/pskc+xml", "pskcxml"); - public static final MediaType APPLICATION_RAR = create("application/rar", "rar"); - public static final MediaType APPLICATION_RDF_XML = create("application/rdf+xml", "rdf"); - public static final MediaType APPLICATION_REGINFO_XML = create("application/reginfo+xml", "rif"); - public static final MediaType APPLICATION_RELAX_NG_COMPACT_SYNTAX = create("application/relax-ng-compact-syntax", - "RNC"); - public static final MediaType APPLICATION_RESOURCE_LISTS_DIFF_XML = create("application/resource-lists-diff+xml", - "RLD"); - public static final MediaType APPLICATION_RESOURCE_LISTS_XML = create("application/resource-lists+xml", "rl"); - public static final MediaType APPLICATION_RLS_SERVICES_XML = create("application/rls-services+xml", "rs"); - public static final MediaType APPLICATION_RPKI_GHOSTBUSTERS = create("application/rpki-ghostbusters", "gbr"); - public static final MediaType APPLICATION_RPKI_MANIFEST = create("application/rpki-manifest", "mft"); - public static final MediaType APPLICATION_RPKI_ROA = create("application/rpki-roa", "roa"); - public static final MediaType APPLICATION_RSD_XML_UTF8 = createUTF8("application/rsd+xml", "rsd"); - public static final MediaType APPLICATION_RSS_XML_UTF8 = createUTF8("application/rss+xml", "rss"); - public static final MediaType APPLICATION_RTF = create("application/rtf", "rtf"); - public static final MediaType APPLICATION_SBML_XML = create("application/sbml+xml", "sbml"); - public static final MediaType APPLICATION_SCVP_CV_REQUEST = create("application/scvp-cv-request", "scq"); - public static final MediaType APPLICATION_SCVP_CV_RESPONSE = create("application/scvp-cv-response", "scs"); - public static final MediaType APPLICATION_SCVP_VP_REQUEST = create("application/scvp-vp-request", "spq"); - public static final MediaType APPLICATION_SCVP_VP_RESPONSE = create("application/scvp-vp-response", "spp"); - public static final MediaType APPLICATION_SDP = create("application/sdp", "sdp"); - public static final MediaType APPLICATION_SET_PAYMENT_INITIATION = create("application/set-payment-initiation", - "SETPAY"); - public static final MediaType APPLICATION_SET_REGISTRATION_INITIATION = create( - "APPLICATION/SET-REGISTRATION-INITIATION", "SETREG"); - public static final MediaType APPLICATION_SHF_XML = create("application/shf+xml", "shf"); - public static final MediaType APPLICATION_SLA = create("application/sla", "stl"); - public static final MediaType APPLICATION_SMIL = create("application/smil", "smi", "smil"); - public static final MediaType APPLICATION_SMIL_XML = create("application/smil+xml", "smi", "smil"); - public static final MediaType APPLICATION_SPARQL_QUERY = create("application/sparql-query", "rq"); - public static final MediaType APPLICATION_SPARQL_RESULTS_XML = create("application/sparql-results+xml", "srx"); - public static final MediaType APPLICATION_SRGS = create("application/srgs", "gram"); - public static final MediaType APPLICATION_SRGS_XML = create("application/srgs+xml", "grxml"); - public static final MediaType APPLICATION_SRU_XML = create("application/sru+xml", "sru"); - public static final MediaType APPLICATION_SSDL_XML = create("application/ssdl+xml", "ssdl"); - public static final MediaType APPLICATION_SSML_XML = create("application/ssml+xml", "ssml"); - public static final MediaType APPLICATION_TEI_XML = create("application/tei+xml", "tei", "teicorpus"); - public static final MediaType APPLICATION_THRAUD_XML = create("application/thraud+xml", "tfi"); - public static final MediaType APPLICATION_TIMESTAMPED_DATA = create("application/timestamped-data", "tsd"); - public static final MediaType APPLICATION_VND_3GPP2_TCAP = create("application/vnd.3gpp2.tcap", "tcap"); - public static final MediaType APPLICATION_VND_3GPP_PIC_BW_LARGE = create("application/vnd.3gpp.pic-bw-large", "plb"); - public static final MediaType APPLICATION_VND_3GPP_PIC_BW_SMALL = create("application/vnd.3gpp.pic-bw-small", "psb"); - public static final MediaType APPLICATION_VND_3GPP_PIC_BW_VAR = create("application/vnd.3gpp.pic-bw-var", "pvb"); - public static final MediaType APPLICATION_VND_3M_POST_IT_NOTES = create("application/vnd.3m.post-it-notes", "pwn"); - public static final MediaType APPLICATION_VND_ACCPAC_SIMPLY_ASO = create("application/vnd.accpac.simply.aso", "aso"); - public static final MediaType APPLICATION_VND_ACCPAC_SIMPLY_IMP = create("application/vnd.accpac.simply.imp", "imp"); - public static final MediaType APPLICATION_VND_ACUCOBOL = create("application/vnd.acucobol", "acu"); - public static final MediaType APPLICATION_VND_ACUCORP = create("application/vnd.acucorp", "atc", "acutc"); - public static final MediaType APPLICATION_VND_ADOBE_AIR_APPLICATION_INSTALLER_PACKAGE_ZIP = create( - "APPLICATION/VND.ADOBE.AIR-APPLICATION-INSTALLER-PACKAGE+ZIP", "AIR"); - public static final MediaType APPLICATION_VND_ADOBE_FORMSCENTRAL_FCDT = create( - "APPLICATION/VND.ADOBE.FORMSCENTRAL.FCDT", "FCDT"); - public static final MediaType APPLICATION_VND_ADOBE_FXP = create("application/vnd.adobe.fxp", "fxp", "fxpl"); - public static final MediaType APPLICATION_VND_ADOBE_XDP_XML = create("application/vnd.adobe.xdp+xml", "xdp"); - public static final MediaType APPLICATION_VND_ADOBE_XFDF = create("application/vnd.adobe.xfdf", "xfdf"); - public static final MediaType APPLICATION_VND_AHEAD_SPACE = create("application/vnd.ahead.space", "ahead"); - public static final MediaType APPLICATION_VND_AIRZIP_FILESECURE_AZF = create( - "application/vnd.airzip.filesecure.azf", "AZF"); - public static final MediaType APPLICATION_VND_AIRZIP_FILESECURE_AZS = create( - "application/vnd.airzip.filesecure.azs", "AZS"); - public static final MediaType APPLICATION_VND_AMAZON_EBOOK = create("application/vnd.amazon.ebook", "azw"); - public static final MediaType APPLICATION_VND_AMERICANDYNAMICS_ACC = create("application/vnd.americandynamics.acc", - "ACC"); - public static final MediaType APPLICATION_VND_AMIGA_AMI = create("application/vnd.amiga.ami", "ami"); - public static final MediaType APPLICATION_VND_ANDROID_PACKAGE_ARCHIVE = create( - "APPLICATION/VND.ANDROID.PACKAGE-ARCHIVE", "APK"); - public static final MediaType APPLICATION_VND_ANSER_WEB_CERTIFICATE_ISSUE_INITIATION = create( - "APPLICATION/VND.ANSER-WEB-CERTIFICATE-ISSUE-INITIATION", "CII"); - public static final MediaType APPLICATION_VND_ANSER_WEB_FUNDS_TRANSFER_INITIATION = create( - "APPLICATION/VND.ANSER-WEB-FUNDS-TRANSFER-INITIATION", "FTI"); - public static final MediaType APPLICATION_VND_ANTIX_GAME_COMPONENT = create("application/vnd.antix.game-component", - "ATX"); - public static final MediaType APPLICATION_VND_APPLE_INSTALLER_XML = create("application/vnd.apple.installer+xml", - "MPKG"); - public static final MediaType APPLICATION_VND_APPLE_MPEGURL = create("application/vnd.apple.mpegurl", "m3u8"); - public static final MediaType APPLICATION_VND_ARISTANETWORKS_SWI = create("application/vnd.aristanetworks.swi", - "swi"); - public static final MediaType APPLICATION_VND_ASTRAEA_SOFTWARE_IOTA = create( - "application/vnd.astraea-software.iota", "IOTA"); - public static final MediaType APPLICATION_VND_AUDIOGRAPH = create("application/vnd.audiograph", "aep"); - public static final MediaType APPLICATION_VND_BLUEICE_MULTIPASS = create("application/vnd.blueice.multipass", "mpm"); - public static final MediaType APPLICATION_VND_BMI = create("application/vnd.bmi", "bmi"); - public static final MediaType APPLICATION_VND_BUSINESSOBJECTS = create("application/vnd.businessobjects", "rep"); - public static final MediaType APPLICATION_VND_CHEMDRAW_XML = create("application/vnd.chemdraw+xml", "cdxml"); - public static final MediaType APPLICATION_VND_CHIPNUTS_KARAOKE_MMD = create("application/vnd.chipnuts.karaoke-mmd", - "MMD"); - public static final MediaType APPLICATION_VND_CINDERELLA = create("application/vnd.cinderella", "cdy"); - public static final MediaType APPLICATION_VND_CLAYMORE = create("application/vnd.claymore", "cla"); - public static final MediaType APPLICATION_VND_CLOANTO_RP9 = create("application/vnd.cloanto.rp9", "rp9"); - public static final MediaType APPLICATION_VND_CLONK_C4GROUP = create("application/vnd.clonk.c4group", "c4g", "c4d", - "C4F", "C4P", "C4U"); - public static final MediaType APPLICATION_VND_CLUETRUST_CARTOMOBILE_CONFIG = create( - "APPLICATION/VND.CLUETRUST.CARTOMOBILE-CONFIG", "C11AMC"); - public static final MediaType APPLICATION_VND_CLUETRUST_CARTOMOBILE_CONFIG_PKG = create( - "APPLICATION/VND.CLUETRUST.CARTOMOBILE-CONFIG-PKG", "C11AMZ"); - public static final MediaType APPLICATION_VND_COMMONSPACE = create("application/vnd.commonspace", "csp"); - public static final MediaType APPLICATION_VND_CONTACT_CMSG = create("application/vnd.contact.cmsg", "cdbcmsg"); - public static final MediaType APPLICATION_VND_COSMOCALLER = create("application/vnd.cosmocaller", "cmc"); - public static final MediaType APPLICATION_VND_CRICK_CLICKER = create("application/vnd.crick.clicker", "clkx"); - public static final MediaType APPLICATION_VND_CRICK_CLICKER_KEYBOARD = create( - "APPLICATION/VND.CRICK.CLICKER.KEYBOARD", "CLKK"); - public static final MediaType APPLICATION_VND_CRICK_CLICKER_PALETTE = create( - "application/vnd.crick.clicker.palette", "CLKP"); - public static final MediaType APPLICATION_VND_CRICK_CLICKER_TEMPLATE = create( - "APPLICATION/VND.CRICK.CLICKER.TEMPLATE", "CLKT"); - public static final MediaType APPLICATION_VND_CRICK_CLICKER_WORDBANK = create( - "APPLICATION/VND.CRICK.CLICKER.WORDBANK", "CLKW"); - public static final MediaType APPLICATION_VND_CRITICALTOOLS_WBS_XML = create( - "application/vnd.criticaltools.wbs+xml", "WBS"); - public static final MediaType APPLICATION_VND_CTC_POSML = create("application/vnd.ctc-posml", "pml"); - public static final MediaType APPLICATION_VND_CUPS_PPD = create("application/vnd.cups-ppd", "ppd"); - public static final MediaType APPLICATION_VND_CURL_CAR = create("application/vnd.curl.car", "car"); - public static final MediaType APPLICATION_VND_CURL_PCURL = create("application/vnd.curl.pcurl", "pcurl"); - public static final MediaType APPLICATION_VND_DART = create("application/vnd.dart", "dart"); - public static final MediaType APPLICATION_VND_DATA_VISION_RDZ = create("application/vnd.data-vision.rdz", "rdz"); - public static final MediaType APPLICATION_VND_DECE_DATA = create("application/vnd.dece.data", "uvf", "uvvf", "uvd", - "UVVD"); - public static final MediaType APPLICATION_VND_DECE_TTML_XML = create("application/vnd.dece.ttml+xml", "uvt", "uvvt"); - public static final MediaType APPLICATION_VND_DECE_UNSPECIFIED = create("application/vnd.dece.unspecified", "uvx", - "UVVX"); - public static final MediaType APPLICATION_VND_DECE_ZIP = create("application/vnd.dece.zip", "uvz", "uvvz"); - public static final MediaType APPLICATION_VND_DENOVO_FCSELAYOUT_LINK = create( - "APPLICATION/VND.DENOVO.FCSELAYOUT-LINK", "FE_LAUNCH"); - public static final MediaType APPLICATION_VND_DNA = create("application/vnd.dna", "dna"); - public static final MediaType APPLICATION_VND_DOLBY_MLP = create("application/vnd.dolby.mlp", "mlp"); - public static final MediaType APPLICATION_VND_DPGRAPH = create("application/vnd.dpgraph", "dpg"); - public static final MediaType APPLICATION_VND_DREAMFACTORY = create("application/vnd.dreamfactory", "dfac"); - public static final MediaType APPLICATION_VND_DS_KEYPOINT = create("application/vnd.ds-keypoint", "kpxx"); - public static final MediaType APPLICATION_VND_DVB_AIT = create("application/vnd.dvb.ait", "ait"); - public static final MediaType APPLICATION_VND_DVB_SERVICE = create("application/vnd.dvb.service", "svc"); - public static final MediaType APPLICATION_VND_DYNAGEO = create("application/vnd.dynageo", "geo"); - public static final MediaType APPLICATION_VND_ECOWIN_CHART = create("application/vnd.ecowin.chart", "mag"); - public static final MediaType APPLICATION_VND_ENLIVEN = create("application/vnd.enliven", "nml"); - public static final MediaType APPLICATION_VND_EPSON_ESF = create("application/vnd.epson.esf", "esf"); - public static final MediaType APPLICATION_VND_EPSON_MSF = create("application/vnd.epson.msf", "msf"); - public static final MediaType APPLICATION_VND_EPSON_QUICKANIME = create("application/vnd.epson.quickanime", "qam"); - public static final MediaType APPLICATION_VND_EPSON_SALT = create("application/vnd.epson.salt", "slt"); - public static final MediaType APPLICATION_VND_EPSON_SSF = create("application/vnd.epson.ssf", "ssf"); - public static final MediaType APPLICATION_VND_ESZIGNO3_XML = create("application/vnd.eszigno3+xml", "es3", "et3"); - public static final MediaType APPLICATION_VND_EZPIX_ALBUM = create("application/vnd.ezpix-album", "ez2"); - public static final MediaType APPLICATION_VND_EZPIX_PACKAGE = create("application/vnd.ezpix-package", "ez3"); - public static final MediaType APPLICATION_VND_FDF = create("application/vnd.fdf", "fdf"); - public static final MediaType APPLICATION_VND_FDSN_MSEED = create("application/vnd.fdsn.mseed", "mseed"); - public static final MediaType APPLICATION_VND_FDSN_SEED = create("application/vnd.fdsn.seed", "seed", "dataless"); - public static final MediaType APPLICATION_VND_FLOGRAPHIT = create("application/vnd.flographit", "gph"); - public static final MediaType APPLICATION_VND_FLUXTIME_CLIP = create("application/vnd.fluxtime.clip", "ftc"); - public static final MediaType APPLICATION_VND_FRAMEMAKER = create("application/vnd.framemaker", "fm", "frame", - "MAKER", "BOOK"); - public static final MediaType APPLICATION_VND_FROGANS_FNC = create("application/vnd.frogans.fnc", "fnc"); - public static final MediaType APPLICATION_VND_FROGANS_LTF = create("application/vnd.frogans.ltf", "ltf"); - public static final MediaType APPLICATION_VND_FSC_WEBLAUNCH = create("application/vnd.fsc.weblaunch", "fsc"); - public static final MediaType APPLICATION_VND_FUJITSU_OASYS2 = create("application/vnd.fujitsu.oasys2", "oa2"); - public static final MediaType APPLICATION_VND_FUJITSU_OASYS3 = create("application/vnd.fujitsu.oasys3", "oa3"); - public static final MediaType APPLICATION_VND_FUJITSU_OASYSGP = create("application/vnd.fujitsu.oasysgp", "fg5"); - public static final MediaType APPLICATION_VND_FUJITSU_OASYS = create("application/vnd.fujitsu.oasys", "oas"); - public static final MediaType APPLICATION_VND_FUJITSU_OASYSPRS = create("application/vnd.fujitsu.oasysprs", "bh2"); - public static final MediaType APPLICATION_VND_FUJIXEROX_DDD = create("application/vnd.fujixerox.ddd", "ddd"); - public static final MediaType APPLICATION_VND_FUJIXEROX_DOCUWORKS_BINDER = create( - "APPLICATION/VND.FUJIXEROX.DOCUWORKS.BINDER", "XBD"); - public static final MediaType APPLICATION_VND_FUJIXEROX_DOCUWORKS = create("application/vnd.fujixerox.docuworks", - "XDW"); - public static final MediaType APPLICATION_VND_FUZZYSHEET = create("application/vnd.fuzzysheet", "fzs"); - public static final MediaType APPLICATION_VND_GENOMATIX_TUXEDO = create("application/vnd.genomatix.tuxedo", "txd"); - public static final MediaType APPLICATION_VND_GEOGEBRA_FILE = create("application/vnd.geogebra.file", "ggb"); - public static final MediaType APPLICATION_VND_GEOGEBRA_TOOL = create("application/vnd.geogebra.tool", "ggt"); - public static final MediaType APPLICATION_VND_GEOMETRY_EXPLORER = create("application/vnd.geometry-explorer", - "gex", "GRE"); - public static final MediaType APPLICATION_VND_GEONEXT = create("application/vnd.geonext", "gxt"); - public static final MediaType APPLICATION_VND_GEOPLAN = create("application/vnd.geoplan", "g2w"); - public static final MediaType APPLICATION_VND_GEOSPACE = create("application/vnd.geospace", "g3w"); - public static final MediaType APPLICATION_VND_GMX = create("application/vnd.gmx", "gmx"); - public static final MediaType APPLICATION_VND_GOOGLE_EARTH_KML_XML = create("application/vnd.google-earth.kml+xml", - "KML"); - public static final MediaType APPLICATION_VND_GOOGLE_EARTH_KMZ = create("application/vnd.google-earth.kmz", "kmz"); - public static final MediaType APPLICATION_VND_GRAFEQ = create("application/vnd.grafeq", "gqf", "gqs"); - public static final MediaType APPLICATION_VND_GROOVE_ACCOUNT = create("application/vnd.groove-account", "gac"); - public static final MediaType APPLICATION_VND_GROOVE_HELP = create("application/vnd.groove-help", "ghf"); - public static final MediaType APPLICATION_VND_GROOVE_IDENTITY_MESSAGE = create( - "APPLICATION/VND.GROOVE-IDENTITY-MESSAGE", "GIM"); - public static final MediaType APPLICATION_VND_GROOVE_INJECTOR = create("application/vnd.groove-injector", "grv"); - public static final MediaType APPLICATION_VND_GROOVE_TOOL_MESSAGE = create("application/vnd.groove-tool-message", - "GTM"); - public static final MediaType APPLICATION_VND_GROOVE_TOOL_TEMPLATE = create("application/vnd.groove-tool-template", - "TPL"); - public static final MediaType APPLICATION_VND_GROOVE_VCARD = create("application/vnd.groove-vcard", "vcg"); - public static final MediaType APPLICATION_VND_HAL_XML = create("application/vnd.hal+xml", "hal"); - public static final MediaType APPLICATION_VND_HANDHELD_ENTERTAINMENT_XML = create( - "APPLICATION/VND.HANDHELD-ENTERTAINMENT+XML", "ZMM"); - public static final MediaType APPLICATION_VND_HBCI = create("application/vnd.hbci", "hbci"); - public static final MediaType APPLICATION_VND_HHE_LESSON_PLAYER = create("application/vnd.hhe.lesson-player", "les"); - public static final MediaType APPLICATION_VND_HP_HPGL = create("application/vnd.hp-hpgl", "hpgl"); - public static final MediaType APPLICATION_VND_HP_HPID = create("application/vnd.hp-hpid", "hpid"); - public static final MediaType APPLICATION_VND_HP_HPS = create("application/vnd.hp-hps", "hps"); - public static final MediaType APPLICATION_VND_HP_JLYT = create("application/vnd.hp-jlyt", "jlt"); - public static final MediaType APPLICATION_VND_HP_PCL = create("application/vnd.hp-pcl", "pcl"); - public static final MediaType APPLICATION_VND_HP_PCLXL = create("application/vnd.hp-pclxl", "pclxl"); - public static final MediaType APPLICATION_VND_HYDROSTATIX_SOF_DATA = create("application/vnd.hydrostatix.sof-data", - "SFD-HDSTX"); - public static final MediaType APPLICATION_VND_IBM_MINIPAY = create("application/vnd.ibm.minipay", "mpy"); - public static final MediaType APPLICATION_VND_IBM_MODCAP = create("application/vnd.ibm.modcap", "afp", "listafp", - "LIST3820"); - public static final MediaType APPLICATION_VND_IBM_RIGHTS_MANAGEMENT = create( - "application/vnd.ibm.rights-management", "IRM"); - public static final MediaType APPLICATION_VND_IBM_SECURE_CONTAINER = create("application/vnd.ibm.secure-container", - "SC"); - public static final MediaType APPLICATION_VND_ICCPROFILE = create("application/vnd.iccprofile", "icc", "icm"); - public static final MediaType APPLICATION_VND_IGLOADER = create("application/vnd.igloader", "igl"); - public static final MediaType APPLICATION_VND_IMMERVISION_IVP = create("application/vnd.immervision-ivp", "ivp"); - public static final MediaType APPLICATION_VND_IMMERVISION_IVU = create("application/vnd.immervision-ivu", "ivu"); - public static final MediaType APPLICATION_VND_INSORS_IGM = create("application/vnd.insors.igm", "igm"); - public static final MediaType APPLICATION_VND_INTERCON_FORMNET = create("application/vnd.intercon.formnet", "xpw", - "XPX"); - public static final MediaType APPLICATION_VND_INTERGEO = create("application/vnd.intergeo", "i2g"); - public static final MediaType APPLICATION_VND_INTU_QBO = create("application/vnd.intu.qbo", "qbo"); - public static final MediaType APPLICATION_VND_INTU_QFX = create("application/vnd.intu.qfx", "qfx"); - public static final MediaType APPLICATION_VND_IPUNPLUGGED_RCPROFILE = create( - "application/vnd.ipunplugged.rcprofile", "RCPROFILE"); - public static final MediaType APPLICATION_VND_IREPOSITORY_PACKAGE_XML = create( - "APPLICATION/VND.IREPOSITORY.PACKAGE+XML", "IRP"); - public static final MediaType APPLICATION_VND_ISAC_FCS = create("application/vnd.isac.fcs", "fcs"); - public static final MediaType APPLICATION_VND_IS_XPR = create("application/vnd.is-xpr", "xpr"); - public static final MediaType APPLICATION_VND_JAM = create("application/vnd.jam", "jam"); - public static final MediaType APPLICATION_VND_JCP_JAVAME_MIDLET_RMS = create( - "application/vnd.jcp.javame.midlet-rms", "RMS"); - public static final MediaType APPLICATION_VND_JISP = create("application/vnd.jisp", "jisp"); - public static final MediaType APPLICATION_VND_JOOST_JODA_ARCHIVE = create("application/vnd.joost.joda-archive", - "joda"); - public static final MediaType APPLICATION_VND_KAHOOTZ = create("application/vnd.kahootz", "ktz", "ktr"); - public static final MediaType APPLICATION_VND_KDE_KARBON = create("application/vnd.kde.karbon", "karbon"); - public static final MediaType APPLICATION_VND_KDE_KCHART = create("application/vnd.kde.kchart", "chrt"); - public static final MediaType APPLICATION_VND_KDE_KFORMULA = create("application/vnd.kde.kformula", "kfo"); - public static final MediaType APPLICATION_VND_KDE_KIVIO = create("application/vnd.kde.kivio", "flw"); - public static final MediaType APPLICATION_VND_KDE_KONTOUR = create("application/vnd.kde.kontour", "kon"); - public static final MediaType APPLICATION_VND_KDE_KPRESENTER = create("application/vnd.kde.kpresenter", "kpr", - "kpt"); - public static final MediaType APPLICATION_VND_KDE_KSPREAD = create("application/vnd.kde.kspread", "ksp"); - public static final MediaType APPLICATION_VND_KDE_KWORD = create("application/vnd.kde.kword", "kwd", "kwt"); - public static final MediaType APPLICATION_VND_KENAMEAAPP = create("application/vnd.kenameaapp", "htke"); - public static final MediaType APPLICATION_VND_KIDSPIRATION = create("application/vnd.kidspiration", "kia"); - public static final MediaType APPLICATION_VND_KINAR = create("application/vnd.kinar", "kne", "knp"); - public static final MediaType APPLICATION_VND_KOAN = create("application/vnd.koan", "skp", "skd", "skt", "skm"); - public static final MediaType APPLICATION_VND_KODAK_DESCRIPTOR = create("application/vnd.kodak-descriptor", "sse"); - public static final MediaType APPLICATION_VND_LAS_LAS_XML = create("application/vnd.las.las+xml", "lasxml"); - public static final MediaType APPLICATION_VND_LLAMAGRAPHICS_LIFE_BALANCE_DESKTOP = create( - "APPLICATION/VND.LLAMAGRAPHICS.LIFE-BALANCE.DESKTOP", "LBD"); - public static final MediaType APPLICATION_VND_LLAMAGRAPHICS_LIFE_BALANCE_EXCHANGE_XML = create( - "APPLICATION/VND.LLAMAGRAPHICS.LIFE-BALANCE.EXCHANGE+XML", "LBE"); - public static final MediaType APPLICATION_VND_LOTUS_1_2_3 = create("application/vnd.lotus-1-2-3", "123"); - public static final MediaType APPLICATION_VND_LOTUS_APPROACH = create("application/vnd.lotus-approach", "apr"); - public static final MediaType APPLICATION_VND_LOTUS_FREELANCE = create("application/vnd.lotus-freelance", "pre"); - public static final MediaType APPLICATION_VND_LOTUS_NOTES = create("application/vnd.lotus-notes", "nsf"); - public static final MediaType APPLICATION_VND_LOTUS_ORGANIZER = create("application/vnd.lotus-organizer", "org"); - public static final MediaType APPLICATION_VND_LOTUS_SCREENCAM = create("application/vnd.lotus-screencam", "scm"); - public static final MediaType APPLICATION_VND_LOTUS_WORDPRO = create("application/vnd.lotus-wordpro", "lwp"); - public static final MediaType APPLICATION_VND_MACPORTS_PORTPKG = create("application/vnd.macports.portpkg", - "portpkg"); - public static final MediaType APPLICATION_VND_MCD = create("application/vnd.mcd", "mcd"); - public static final MediaType APPLICATION_VND_MEDCALCDATA = create("application/vnd.medcalcdata", "mc1"); - public static final MediaType APPLICATION_VND_MEDIASTATION_CDKEY = create("application/vnd.mediastation.cdkey", - "CDKEY"); - public static final MediaType APPLICATION_VND_MFER = create("application/vnd.mfer", "mwf"); - public static final MediaType APPLICATION_VND_MFMP = create("application/vnd.mfmp", "mfm"); - public static final MediaType APPLICATION_VND_MICROGRAFX_FLO = create("application/vnd.micrografx.flo", "flo"); - public static final MediaType APPLICATION_VND_MICROGRAFX_IGX = create("application/vnd.micrografx.igx", "igx"); - public static final MediaType APPLICATION_VND_MIF = create("application/vnd.mif", "mif"); - public static final MediaType APPLICATION_VND_MOBIUS_DAF = create("application/vnd.mobius.daf", "daf"); - public static final MediaType APPLICATION_VND_MOBIUS_DIS = create("application/vnd.mobius.dis", "dis"); - public static final MediaType APPLICATION_VND_MOBIUS_MBK = create("application/vnd.mobius.mbk", "mbk"); - public static final MediaType APPLICATION_VND_MOBIUS_MQY = create("application/vnd.mobius.mqy", "mqy"); - public static final MediaType APPLICATION_VND_MOBIUS_MSL = create("application/vnd.mobius.msl", "msl"); - public static final MediaType APPLICATION_VND_MOBIUS_PLC = create("application/vnd.mobius.plc", "plc"); - public static final MediaType APPLICATION_VND_MOBIUS_TXF = create("application/vnd.mobius.txf", "txf"); - public static final MediaType APPLICATION_VND_MOPHUN_APPLICATION = create("application/vnd.mophun.application", - "mpn"); - public static final MediaType APPLICATION_VND_MOPHUN_CERTIFICATE = create("application/vnd.mophun.certificate", - "mpc"); - public static final MediaType APPLICATION_VND_MOZILLA_XUL_XML = create("application/vnd.mozilla.xul+xml", "xul"); - public static final MediaType APPLICATION_VND_MS_ARTGALRY = create("application/vnd.ms-artgalry", "cil"); - public static final MediaType APPLICATION_VND_MS_CAB_COMPRESSED = create("application/vnd.ms-cab-compressed", "cab"); - public static final MediaType APPLICATION_VND_MSEQ = create("application/vnd.mseq", "mseq"); - public static final MediaType APPLICATION_VND_MS_EXCEL_ADDIN_MACROENABLED_12 = create( - "APPLICATION/VND.MS-EXCEL.ADDIN.MACROENABLED.12", "XLAM"); - public static final MediaType APPLICATION_VND_MS_EXCEL_SHEET_BINARY_MACROENABLED_12 = create( - "APPLICATION/VND.MS-EXCEL.SHEET.BINARY.MACROENABLED.12", "XLSB"); - public static final MediaType APPLICATION_VND_MS_EXCEL_SHEET_MACROENABLED_12 = create( - "APPLICATION/VND.MS-EXCEL.SHEET.MACROENABLED.12", "XLSM"); - public static final MediaType APPLICATION_VND_MS_EXCEL_TEMPLATE_MACROENABLED_12 = create( - "APPLICATION/VND.MS-EXCEL.TEMPLATE.MACROENABLED.12", "XLTM"); - public static final MediaType APPLICATION_VND_MS_EXCEL = create("application/vnd.ms-excel", "xls", "xlm", "xla", - "XLB", "XLC", "XLT", "XLW"); - public static final MediaType APPLICATION_VND_MS_FONTOBJECT = create("application/vnd.ms-fontobject", "eot"); - public static final MediaType APPLICATION_VND_MS_HTMLHELP = create("application/vnd.ms-htmlhelp", "chm"); - public static final MediaType APPLICATION_VND_MS_IMS = create("application/vnd.ms-ims", "ims"); - public static final MediaType APPLICATION_VND_MS_LRM = create("application/vnd.ms-lrm", "lrm"); - public static final MediaType APPLICATION_VND_MS_OFFICETHEME = create("application/vnd.ms-officetheme", "thmx"); - public static final MediaType APPLICATION_VND_MS_PKI_SECCAT = create("application/vnd.ms-pki.seccat", "cat"); - public static final MediaType APPLICATION_VND_MS_PKI_STL = create("application/vnd.ms-pki.stl", "stl"); - public static final MediaType APPLICATION_VND_MS_POWERPOINT_ADDIN_MACROENABLED_12 = create( - "APPLICATION/VND.MS-POWERPOINT.ADDIN.MACROENABLED.12", "PPAM"); - public static final MediaType APPLICATION_VND_MS_POWERPOINT = create("application/vnd.ms-powerpoint", "ppt", "pps", - "POT"); - public static final MediaType APPLICATION_VND_MS_POWERPOINT_PRESENTATION_MACROENABLED_12 = create( - "APPLICATION/VND.MS-POWERPOINT.PRESENTATION.MACROENABLED.12", "PPTM"); - public static final MediaType APPLICATION_VND_MS_POWERPOINT_SLIDE_MACROENABLED_12 = create( - "APPLICATION/VND.MS-POWERPOINT.SLIDE.MACROENABLED.12", "SLDM"); - public static final MediaType APPLICATION_VND_MS_POWERPOINT_SLIDESHOW_MACROENABLED_12 = create( - "APPLICATION/VND.MS-POWERPOINT.SLIDESHOW.MACROENABLED.12", "PPSM"); - public static final MediaType APPLICATION_VND_MS_POWERPOINT_TEMPLATE_MACROENABLED_12 = create( - "APPLICATION/VND.MS-POWERPOINT.TEMPLATE.MACROENABLED.12", "POTM"); - public static final MediaType APPLICATION_VND_MS_PROJECT = create("application/vnd.ms-project", "mpp", "mpt"); - public static final MediaType APPLICATION_VND_MS_WORD_DOCUMENT_MACROENABLED_12 = create( - "APPLICATION/VND.MS-WORD.DOCUMENT.MACROENABLED.12", "DOCM"); - public static final MediaType APPLICATION_VND_MS_WORD_TEMPLATE_MACROENABLED_12 = create( - "APPLICATION/VND.MS-WORD.TEMPLATE.MACROENABLED.12", "DOTM"); - public static final MediaType APPLICATION_VND_MS_WORKS = create("application/vnd.ms-works", "wps", "wks", "wcm", - "wdb"); - public static final MediaType APPLICATION_VND_MS_WPL = create("application/vnd.ms-wpl", "wpl"); - public static final MediaType APPLICATION_VND_MS_XPSDOCUMENT = create("application/vnd.ms-xpsdocument", "xps"); - public static final MediaType APPLICATION_VND_MUSICIAN = create("application/vnd.musician", "mus"); - public static final MediaType APPLICATION_VND_MUVEE_STYLE = create("application/vnd.muvee.style", "msty"); - public static final MediaType APPLICATION_VND_MYNFC = create("application/vnd.mynfc", "taglet"); - public static final MediaType APPLICATION_VND_NEUROLANGUAGE_NLU = create("application/vnd.neurolanguage.nlu", "nlu"); - public static final MediaType APPLICATION_VND_NITF = create("application/vnd.nitf", "ntf", "nitf"); - public static final MediaType APPLICATION_VND_NOBLENET_DIRECTORY = create("application/vnd.noblenet-directory", - "nnd"); - public static final MediaType APPLICATION_VND_NOBLENET_SEALER = create("application/vnd.noblenet-sealer", "nns"); - public static final MediaType APPLICATION_VND_NOBLENET_WEB = create("application/vnd.noblenet-web", "nnw"); - public static final MediaType APPLICATION_VND_NOKIA_N_GAGE_DATA = create("application/vnd.nokia.n-gage.data", - "ngdat"); - public static final MediaType APPLICATION_VND_NOKIA_N_GAGE_SYMBIAN_INSTALL = create( - "APPLICATION/VND.NOKIA.N-GAGE.SYMBIAN.INSTALL", "N-GAGE"); - public static final MediaType APPLICATION_VND_NOKIA_RADIO_PRESET = create("application/vnd.nokia.radio-preset", - "rpst"); - public static final MediaType APPLICATION_VND_NOKIA_RADIO_PRESETS = create("application/vnd.nokia.radio-presets", - "RPSS"); - public static final MediaType APPLICATION_VND_NOVADIGM_EDM = create("application/vnd.novadigm.edm", "edm"); - public static final MediaType APPLICATION_VND_NOVADIGM_EDX = create("application/vnd.novadigm.edx", "edx"); - public static final MediaType APPLICATION_VND_NOVADIGM_EXT = create("application/vnd.novadigm.ext", "ext"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_CHART = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.CHART", "ODC"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_CHART_TEMPLATE = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.CHART-TEMPLATE", "OTC"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_DATABASE = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.DATABASE", "ODB"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_FORMULA = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.FORMULA", "ODF"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_FORMULA_TEMPLATE = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.FORMULA-TEMPLATE", "ODFT"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_GRAPHICS = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.GRAPHICS", "ODG"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_GRAPHICS_TEMPLATE = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.GRAPHICS-TEMPLATE", "OTG"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_IMAGE = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.IMAGE", "ODI"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_IMAGE_TEMPLATE = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.IMAGE-TEMPLATE", "OTI"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.PRESENTATION", "ODP"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.PRESENTATION-TEMPLATE", "OTP"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.SPREADSHEET", "ODS"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET_TEMPLATE = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.SPREADSHEET-TEMPLATE", "OTS"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT_MASTER = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.TEXT-MASTER", "ODM"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.TEXT", "ODT"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT_TEMPLATE = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.TEXT-TEMPLATE", "OTT"); - public static final MediaType APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT_WEB = create( - "APPLICATION/VND.OASIS.OPENDOCUMENT.TEXT-WEB", "OTH"); - public static final MediaType APPLICATION_VND_OLPC_SUGAR = create("application/vnd.olpc-sugar", "xo"); - public static final MediaType APPLICATION_VND_OMA_DD2_XML = create("application/vnd.oma.dd2+xml", "dd2"); - public static final MediaType APPLICATION_VND_OPENOFFICEORG_EXTENSION = create( - "APPLICATION/VND.OPENOFFICEORG.EXTENSION", "OXT"); - public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION = create( - "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.PRESENTATIONML.PRESENTATION", "PPTX"); - public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_SLIDESHOW = create( - "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.PRESENTATIONML.SLIDESHOW", "PPSX"); - public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_SLIDE = create( - "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.PRESENTATIONML.SLIDE", "SLDX"); - public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_TEMPLATE = create( - "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.PRESENTATIONML.TEMPLATE", "POTX"); - public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET = create( - "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.SPREADSHEETML.SHEET", "XLSX"); - public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_TEMPLATE = create( - "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.SPREADSHEETML.TEMPLATE", "XLTX"); - public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT = create( - "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.WORDPROCESSINGML.DOCUMENT", "DOCX"); - public static final MediaType APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_TEMPLATE = create( - "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.WORDPROCESSINGML.TEMPLATE", "DOTX"); - public static final MediaType APPLICATION_VND_OSGEO_MAPGUIDE_PACKAGE = create( - "APPLICATION/VND.OSGEO.MAPGUIDE.PACKAGE", "MGP"); - public static final MediaType APPLICATION_VND_OSGI_DP = create("application/vnd.osgi.dp", "dp"); - public static final MediaType APPLICATION_VND_OSGI_SUBSYSTEM = create("application/vnd.osgi.subsystem", "esa"); - public static final MediaType APPLICATION_VND_PALM = create("application/vnd.palm", "pdb", "pqa", "oprc"); - public static final MediaType APPLICATION_VND_PAWAAFILE = create("application/vnd.pawaafile", "paw"); - public static final MediaType APPLICATION_VND_PG_FORMAT = create("application/vnd.pg.format", "str"); - public static final MediaType APPLICATION_VND_PG_OSASLI = create("application/vnd.pg.osasli", "ei6"); - public static final MediaType APPLICATION_VND_PICSEL = create("application/vnd.picsel", "efif"); - public static final MediaType APPLICATION_VND_PMI_WIDGET = create("application/vnd.pmi.widget", "wg"); - public static final MediaType APPLICATION_VND_POCKETLEARN = create("application/vnd.pocketlearn", "plf"); - public static final MediaType APPLICATION_VND_POWERBUILDER6 = create("application/vnd.powerbuilder6", "pbd"); - public static final MediaType APPLICATION_VND_PREVIEWSYSTEMS_BOX = create("application/vnd.previewsystems.box", - "box"); - public static final MediaType APPLICATION_VND_PROTEUS_MAGAZINE = create("application/vnd.proteus.magazine", "mgz"); - public static final MediaType APPLICATION_VND_PUBLISHARE_DELTA_TREE = create( - "application/vnd.publishare-delta-tree", "QPS"); - public static final MediaType APPLICATION_VND_PVI_PTID1 = create("application/vnd.pvi.ptid1", "ptid"); - public static final MediaType APPLICATION_VND_QUARK_QUARKXPRESS = create("application/vnd.quark.quarkxpress", - "qxd", "QXT", "QWD", "QWT", "QXL", "QXB"); - public static final MediaType APPLICATION_VND_REALVNC_BED = create("application/vnd.realvnc.bed", "bed"); - public static final MediaType APPLICATION_VND_RECORDARE_MUSICXML = create("application/vnd.recordare.musicxml", - "mxl"); - public static final MediaType APPLICATION_VND_RECORDARE_MUSICXML_XML = create( - "APPLICATION/VND.RECORDARE.MUSICXML+XML", "MUSICXML"); - public static final MediaType APPLICATION_VND_RIG_CRYPTONOTE = create("application/vnd.rig.cryptonote", - "cryptonote"); - public static final MediaType APPLICATION_VND_RIM_COD = create("application/vnd.rim.cod", "cod"); - public static final MediaType APPLICATION_VND_RN_REALMEDIA = create("application/vnd.rn-realmedia", "rm"); - public static final MediaType APPLICATION_VND_RN_REALMEDIA_VBR = create("application/vnd.rn-realmedia-vbr", "rmvb"); - public static final MediaType APPLICATION_VND_ROUTE66_LINK66_XML = create("application/vnd.route66.link66+xml", - "LINK66"); - public static final MediaType APPLICATION_VND_SAILINGTRACKER_TRACK = create("application/vnd.sailingtracker.track", - "ST"); - public static final MediaType APPLICATION_VND_SEEMAIL = create("application/vnd.seemail", "see"); - public static final MediaType APPLICATION_VND_SEMA = create("application/vnd.sema", "sema"); - public static final MediaType APPLICATION_VND_SEMD = create("application/vnd.semd", "semd"); - public static final MediaType APPLICATION_VND_SEMF = create("application/vnd.semf", "semf"); - public static final MediaType APPLICATION_VND_SHANA_INFORMED_FORMDATA = create( - "APPLICATION/VND.SHANA.INFORMED.FORMDATA", "IFM"); - public static final MediaType APPLICATION_VND_SHANA_INFORMED_FORMTEMPLATE = create( - "APPLICATION/VND.SHANA.INFORMED.FORMTEMPLATE", "ITP"); - public static final MediaType APPLICATION_VND_SHANA_INFORMED_INTERCHANGE = create( - "APPLICATION/VND.SHANA.INFORMED.INTERCHANGE", "IIF"); - public static final MediaType APPLICATION_VND_SHANA_INFORMED_PACKAGE = create( - "APPLICATION/VND.SHANA.INFORMED.PACKAGE", "IPK"); - public static final MediaType APPLICATION_VND_SIMTECH_MINDMAPPER = create("application/vnd.simtech-mindmapper", - "twd", "TWDS"); - public static final MediaType APPLICATION_VND_SMAF = create("application/vnd.smaf", "mmf"); - public static final MediaType APPLICATION_VND_SMART_TEACHER = create("application/vnd.smart.teacher", "teacher"); - public static final MediaType APPLICATION_VND_SOLENT_SDKM_XML = create("application/vnd.solent.sdkm+xml", "sdkm", - "SDKD"); - public static final MediaType APPLICATION_VND_SPOTFIRE_DXP = create("application/vnd.spotfire.dxp", "dxp"); - public static final MediaType APPLICATION_VND_SPOTFIRE_SFS = create("application/vnd.spotfire.sfs", "sfs"); - public static final MediaType APPLICATION_VND_STARDIVISION_CALC = create("application/vnd.stardivision.calc", "sdc"); - public static final MediaType APPLICATION_VND_STARDIVISION_CHART = create("application/vnd.stardivision.chart", - "sds"); - public static final MediaType APPLICATION_VND_STARDIVISION_DRAW = create("application/vnd.stardivision.draw", "sda"); - public static final MediaType APPLICATION_VND_STARDIVISION_IMPRESS = create("application/vnd.stardivision.impress", - "SDD"); - public static final MediaType APPLICATION_VND_STARDIVISION_MATH = create("application/vnd.stardivision.math", - "smf", "SDF"); - public static final MediaType APPLICATION_VND_STARDIVISION_WRITER_GLOBAL = create( - "APPLICATION/VND.STARDIVISION.WRITER-GLOBAL", "SGL"); - public static final MediaType APPLICATION_VND_STARDIVISION_WRITER = create("application/vnd.stardivision.writer", - "SDW", "VOR"); - public static final MediaType APPLICATION_VND_STEPMANIA_PACKAGE = create("application/vnd.stepmania.package", - "smzip"); - public static final MediaType APPLICATION_VND_STEPMANIA_STEPCHART = create("application/vnd.stepmania.stepchart", - "sm"); - public static final MediaType APPLICATION_VND_SUN_XML_CALC = create("application/vnd.sun.xml.calc", "sxc"); - public static final MediaType APPLICATION_VND_SUN_XML_CALC_TEMPLATE = create( - "application/vnd.sun.xml.calc.template", "STC"); - public static final MediaType APPLICATION_VND_SUN_XML_DRAW = create("application/vnd.sun.xml.draw", "sxd"); - public static final MediaType APPLICATION_VND_SUN_XML_DRAW_TEMPLATE = create( - "application/vnd.sun.xml.draw.template", "STD"); - public static final MediaType APPLICATION_VND_SUN_XML_IMPRESS = create("application/vnd.sun.xml.impress", "sxi"); - public static final MediaType APPLICATION_VND_SUN_XML_IMPRESS_TEMPLATE = create( - "APPLICATION/VND.SUN.XML.IMPRESS.TEMPLATE", "STI"); - public static final MediaType APPLICATION_VND_SUN_XML_MATH = create("application/vnd.sun.xml.math", "sxm"); - public static final MediaType APPLICATION_VND_SUN_XML_WRITER_GLOBAL = create( - "application/vnd.sun.xml.writer.global", "SXG"); - public static final MediaType APPLICATION_VND_SUN_XML_WRITER = create("application/vnd.sun.xml.writer", "sxw"); - public static final MediaType APPLICATION_VND_SUN_XML_WRITER_TEMPLATE = create( - "APPLICATION/VND.SUN.XML.WRITER.TEMPLATE", "STW"); - public static final MediaType APPLICATION_VND_SUS_CALENDAR = create("application/vnd.sus-calendar", "sus", "susp"); - public static final MediaType APPLICATION_VND_SVD = create("application/vnd.svd", "svd"); - public static final MediaType APPLICATION_VND_SYMBIAN_INSTALL = create("application/vnd.symbian.install", "sis", - "SISX"); - public static final MediaType APPLICATION_VND_SYNCML_DM_WBXML = create("application/vnd.syncml.dm+wbxml", "bdm"); - public static final MediaType APPLICATION_VND_SYNCML_DM_XML = create("application/vnd.syncml.dm+xml", "xdm"); - public static final MediaType APPLICATION_VND_SYNCML_XML = create("application/vnd.syncml+xml", "xsm"); - public static final MediaType APPLICATION_VND_TAO_INTENT_MODULE_ARCHIVE = create( - "APPLICATION/VND.TAO.INTENT-MODULE-ARCHIVE", "TAO"); - public static final MediaType APPLICATION_VND_TCPDUMP_PCAP = create("application/vnd.tcpdump.pcap", "pcap", "cap", - "DMP"); - public static final MediaType APPLICATION_VND_TMOBILE_LIVETV = create("application/vnd.tmobile-livetv", "tmo"); - public static final MediaType APPLICATION_VND_TRID_TPT = create("application/vnd.trid.tpt", "tpt"); - public static final MediaType APPLICATION_VND_TRISCAPE_MXS = create("application/vnd.triscape.mxs", "mxs"); - public static final MediaType APPLICATION_VND_TRUEAPP = create("application/vnd.trueapp", "tra"); - public static final MediaType APPLICATION_VND_UFDL = create("application/vnd.ufdl", "ufd", "ufdl"); - public static final MediaType APPLICATION_VND_UIQ_THEME = create("application/vnd.uiq.theme", "utz"); - public static final MediaType APPLICATION_VND_UMAJIN = create("application/vnd.umajin", "umj"); - public static final MediaType APPLICATION_VND_UNITY = create("application/vnd.unity", "unityweb"); - public static final MediaType APPLICATION_VND_UOML_XML = create("application/vnd.uoml+xml", "uoml"); - public static final MediaType APPLICATION_VND_VCX = create("application/vnd.vcx", "vcx"); - public static final MediaType APPLICATION_VND_VISIONARY = create("application/vnd.visionary", "vis"); - public static final MediaType APPLICATION_VND_VISIO = create("application/vnd.visio", "vsd", "vst", "vss", "vsw"); - public static final MediaType APPLICATION_VND_VSF = create("application/vnd.vsf", "vsf"); - public static final MediaType APPLICATION_VND_WAP_WBXML = create("application/vnd.wap.wbxml", "wbxml"); - public static final MediaType APPLICATION_VND_WAP_WMLC = create("application/vnd.wap.wmlc", "wmlc"); - public static final MediaType APPLICATION_VND_WAP_WMLSCRIPTC = create("application/vnd.wap.wmlscriptc", "wmlsc"); - public static final MediaType APPLICATION_VND_WEBTURBO = create("application/vnd.webturbo", "wtb"); - public static final MediaType APPLICATION_VND_WOLFRAM_PLAYER = create("application/vnd.wolfram.player", "nbp"); - public static final MediaType APPLICATION_VND_WORDPERFECT5_1 = create("application/vnd.wordperfect5.1", "wp5"); - public static final MediaType APPLICATION_VND_WORDPERFECT = create("application/vnd.wordperfect", "wpd"); - public static final MediaType APPLICATION_VND_WQD = create("application/vnd.wqd", "wqd"); - public static final MediaType APPLICATION_VND_WT_STF = create("application/vnd.wt.stf", "stf"); - public static final MediaType APPLICATION_VND_XARA = create("application/vnd.xara", "xar"); - public static final MediaType APPLICATION_VND_XFDL = create("application/vnd.xfdl", "xfdl"); - public static final MediaType APPLICATION_VND_YAMAHA_HV_DIC = create("application/vnd.yamaha.hv-dic", "hvd"); - public static final MediaType APPLICATION_VND_YAMAHA_HV_SCRIPT = create("application/vnd.yamaha.hv-script", "hvs"); - public static final MediaType APPLICATION_VND_YAMAHA_HV_VOICE = create("application/vnd.yamaha.hv-voice", "hvp"); - public static final MediaType APPLICATION_VND_YAMAHA_OPENSCOREFORMAT = create( - "APPLICATION/VND.YAMAHA.OPENSCOREFORMAT", "OSF"); - public static final MediaType APPLICATION_VND_YAMAHA_OPENSCOREFORMAT_OSFPVG_XML = create( - "APPLICATION/VND.YAMAHA.OPENSCOREFORMAT.OSFPVG+XML", "OSFPVG"); - public static final MediaType APPLICATION_VND_YAMAHA_SMAF_AUDIO = create("application/vnd.yamaha.smaf-audio", "saf"); - public static final MediaType APPLICATION_VND_YAMAHA_SMAF_PHRASE = create("application/vnd.yamaha.smaf-phrase", - "spf"); - public static final MediaType APPLICATION_VND_YELLOWRIVER_CUSTOM_MENU = create( - "APPLICATION/VND.YELLOWRIVER-CUSTOM-MENU", "CMP"); - public static final MediaType APPLICATION_VND_ZUL = create("application/vnd.zul", "zir", "zirz"); - public static final MediaType APPLICATION_VND_ZZAZZ_DECK_XML = create("application/vnd.zzazz.deck+xml", "zaz"); - public static final MediaType APPLICATION_VOICEXML_XML = create("application/voicexml+xml", "vxml"); - public static final MediaType APPLICATION_WIDGET = create("application/widget", "wgt"); - public static final MediaType APPLICATION_WINHLP = create("application/winhlp", "hlp"); - public static final MediaType APPLICATION_WSDL_XML = create("application/wsdl+xml", "wsdl"); - public static final MediaType APPLICATION_WSPOLICY_XML = create("application/wspolicy+xml", "wspolicy"); - public static final MediaType APPLICATION_X_123 = create("application/x-123", "wk"); - public static final MediaType APPLICATION_X_7Z_COMPRESSED = create("application/x-7z-compressed", "7z"); - public static final MediaType APPLICATION_X_ABIWORD = create("application/x-abiword", "abw"); - public static final MediaType APPLICATION_X_ACE_COMPRESSED = create("application/x-ace-compressed", "ace"); - public static final MediaType APPLICATION_XAML_XML = create("application/xaml+xml", "xaml"); - public static final MediaType APPLICATION_X_APPLE_DISKIMAGE = create("application/x-apple-diskimage", "dmg"); - public static final MediaType APPLICATION_X_AUTHORWARE_BIN = create("application/x-authorware-bin", "aab", "x32", - "U32", "VOX"); - public static final MediaType APPLICATION_X_AUTHORWARE_MAP = create("application/x-authorware-map", "aam"); - public static final MediaType APPLICATION_X_AUTHORWARE_SEG = create("application/x-authorware-seg", "aas"); - public static final MediaType APPLICATION_X_BCPIO = create("application/x-bcpio", "bcpio"); - public static final MediaType APPLICATION_X_BITTORRENT = create("application/x-bittorrent", "torrent"); - public static final MediaType APPLICATION_X_BLORB = create("application/x-blorb", "blb", "blorb"); - public static final MediaType APPLICATION_X_BZIP2 = create("application/x-bzip2", "bz2", "boz"); - public static final MediaType APPLICATION_X_BZIP = create("application/x-bzip", "bz"); - public static final MediaType APPLICATION_X_CAB = create("application/x-cab", "cab"); - public static final MediaType APPLICATION_XCAP_DIFF_XML = create("application/xcap-diff+xml", "xdf"); - public static final MediaType APPLICATION_X_CBR = create("application/x-cbr", "cbr", "cba", "cbt", "cbz", "cb7"); - public static final MediaType APPLICATION_X_CBZ = create("application/x-cbz", "cbz"); - public static final MediaType APPLICATION_X_CDF = create("application/x-cdf", "cdf", "cda"); - public static final MediaType APPLICATION_X_CDLINK = create("application/x-cdlink", "vcd"); - public static final MediaType APPLICATION_X_CFS_COMPRESSED = create("application/x-cfs-compressed", "cfs"); - public static final MediaType APPLICATION_X_CHAT = create("application/x-chat", "chat"); - public static final MediaType APPLICATION_X_CHESS_PGN = create("application/x-chess-pgn", "pgn"); - public static final MediaType APPLICATION_X_COMSOL = create("application/x-comsol", "mph"); - public static final MediaType APPLICATION_X_CONFERENCE = create("application/x-conference", "nsc"); - public static final MediaType APPLICATION_X_CPIO = create("application/x-cpio", "cpio"); - public static final MediaType APPLICATION_X_CSH = create("application/x-csh", "csh"); - public static final MediaType APPLICATION_X_DEBIAN_PACKAGE = create("application/x-debian-package", "deb", "udeb"); - public static final MediaType APPLICATION_X_DGC_COMPRESSED = create("application/x-dgc-compressed", "dgc"); - public static final MediaType APPLICATION_X_DIRECTOR = create("application/x-director", "dir", "dcr", "dxr", "cst", - "CCT", "CXT", "W3D", "FGD", "SWA"); - public static final MediaType APPLICATION_X_DMS = create("application/x-dms", "dms"); - public static final MediaType APPLICATION_X_DOOM = create("application/x-doom", "wad"); - public static final MediaType APPLICATION_X_DTBNCX_XML = create("application/x-dtbncx+xml", "ncx"); - public static final MediaType APPLICATION_X_DTBOOK_XML = create("application/x-dtbook+xml", "dtb"); - public static final MediaType APPLICATION_X_DTBRESOURCE_XML = create("application/x-dtbresource+xml", "res"); - public static final MediaType APPLICATION_X_DVI = create("application/x-dvi", "dvi"); - public static final MediaType APPLICATION_XENC_XML = create("application/xenc+xml", "xenc"); - public static final MediaType APPLICATION_X_ENVOY = create("application/x-envoy", "evy"); - public static final MediaType APPLICATION_X_EVA = create("application/x-eva", "eva"); - public static final MediaType APPLICATION_X_FONT_BDF = create("application/x-font-bdf", "bdf"); - public static final MediaType APPLICATION_X_FONT_GHOSTSCRIPT = create("application/x-font-ghostscript", "gsf"); - public static final MediaType APPLICATION_X_FONT_LINUX_PSF = create("application/x-font-linux-psf", "psf"); - public static final MediaType APPLICATION_X_FONT_OTF = create("application/x-font-otf", "otf"); - public static final MediaType APPLICATION_X_FONT_PCF = create("application/x-font-pcf", "pcf"); - public static final MediaType APPLICATION_X_FONT = create("application/x-font", "pfa", "pfb", "gsf", "pcf", "pcf.z"); - public static final MediaType APPLICATION_X_FONT_SNF = create("application/x-font-snf", "snf"); - public static final MediaType APPLICATION_X_FONT_TTF = create("application/x-font-ttf", "ttf", "ttc"); - public static final MediaType APPLICATION_X_FONT_TYPE1 = create("application/x-font-type1", "pfa", "pfb", "pfm", - "afm"); - public static final MediaType APPLICATION_X_FONT_WOFF = create("application/x-font-woff", "woff", "woff2"); - public static final MediaType APPLICATION_X_FREEARC = create("application/x-freearc", "arc"); - public static final MediaType APPLICATION_X_FREEMIND = create("application/x-freemind", "mm"); - public static final MediaType APPLICATION_X_FUTURESPLASH = create("application/x-futuresplash", "spl"); - public static final MediaType APPLICATION_X_GANTTPROJECT = create("application/x-ganttproject", "gan"); - public static final MediaType APPLICATION_X_GCA_COMPRESSED = create("application/x-gca-compressed", "gca"); - public static final MediaType APPLICATION_X_GLULX = create("application/x-glulx", "ulx"); - public static final MediaType APPLICATION_X_GNUMERIC = create("application/x-gnumeric", "gnumeric"); - public static final MediaType APPLICATION_X_GO_SGF = create("application/x-go-sgf", "sgf"); - public static final MediaType APPLICATION_X_GRAMPS_XML = create("application/x-gramps-xml", "gramps"); - public static final MediaType APPLICATION_X_GRAPHING_CALCULATOR = create("application/x-graphing-calculator", "gcf"); - public static final MediaType APPLICATION_X_GTAR_COMPRESSED = create("application/x-gtar-compressed", "tgz", "taz"); - public static final MediaType APPLICATION_X_GTAR = create("application/x-gtar", "gtar"); - public static final MediaType APPLICATION_X_HDF = create("application/x-hdf", "hdf"); - public static final MediaType APPLICATION_XHTML_XML_UTF8 = createUTF8("application/xhtml+xml", "xhtml", "xht"); - public static final MediaType APPLICATION_X_HTTPD_ERUBY = create("application/x-httpd-eruby", "rhtml"); - public static final MediaType APPLICATION_X_HTTPD_PHP3 = create("application/x-httpd-php3", "php3"); - public static final MediaType APPLICATION_X_HTTPD_PHP3_PREPROCESSED = create( - "application/x-httpd-php3-preprocessed", "PHP3P"); - public static final MediaType APPLICATION_X_HTTPD_PHP4 = create("application/x-httpd-php4", "php4"); - public static final MediaType APPLICATION_X_HTTPD_PHP5 = create("application/x-httpd-php5", "php5"); - public static final MediaType APPLICATION_X_HTTPD_PHP = create("application/x-httpd-php", "phtml", "pht", "php"); - public static final MediaType APPLICATION_X_HTTPD_PHP_SOURCE = create("application/x-httpd-php-source", "phps"); - public static final MediaType APPLICATION_X_ICA = create("application/x-ica", "ica"); - public static final MediaType APPLICATION_X_INFO = create("application/x-info", "info"); - public static final MediaType APPLICATION_X_INSTALL_INSTRUCTIONS = create("application/x-install-instructions", - "INSTALL"); - public static final MediaType APPLICATION_X_INTERNET_SIGNUP = create("application/x-internet-signup", "ins", "isp"); - public static final MediaType APPLICATION_X_IPHONE = create("application/x-iphone", "iii"); - public static final MediaType APPLICATION_X_ISO9660_IMAGE = create("application/x-iso9660-image", "iso"); - public static final MediaType APPLICATION_X_JAM = create("application/x-jam", "jam"); - public static final MediaType APPLICATION_X_JAVA_JNLP_FILE = create("application/x-java-jnlp-file", "jnlp"); - public static final MediaType APPLICATION_X_JMOL = create("application/x-jmol", "jmz"); - public static final MediaType APPLICATION_X_KCHART = create("application/x-kchart", "chrt"); - public static final MediaType APPLICATION_X_KILLUSTRATOR = create("application/x-killustrator", "kil"); - public static final MediaType APPLICATION_X_KOAN = create("application/x-koan", "skp", "skd", "skt", "skm"); - public static final MediaType APPLICATION_X_KPRESENTER = create("application/x-kpresenter", "kpr", "kpt"); - public static final MediaType APPLICATION_X_KSPREAD = create("application/x-kspread", "ksp"); - public static final MediaType APPLICATION_X_KWORD = create("application/x-kword", "kwd", "kwt"); - public static final MediaType APPLICATION_X_LATEX = create("application/x-latex", "latex"); - public static final MediaType APPLICATION_X_LHA = create("application/x-lha", "lha"); - public static final MediaType APPLICATION_X_LYX = create("application/x-lyx", "lyx"); - public static final MediaType APPLICATION_X_LZH_COMPRESSED = create("application/x-lzh-compressed", "lzh", "lha"); - public static final MediaType APPLICATION_X_LZH = create("application/x-lzh", "lzh"); - public static final MediaType APPLICATION_X_LZX = create("application/x-lzx", "lzx"); - public static final MediaType APPLICATION_X_MAKER = create("application/x-maker", "frm", "maker", "frame", "fm", - "fb", "BOOK", "FBDOC"); - public static final MediaType APPLICATION_X_MIE = create("application/x-mie", "mie"); - public static final MediaType APPLICATION_X_MIF = create("application/x-mif", "mif"); - public static final MediaType APPLICATION_XML_DTD_UTF8 = createUTF8("application/xml-dtd", "dtd"); - public static final MediaType APPLICATION_XML = create("application/xml", "xml", "xsl", "xsd"); - public static final MediaType APPLICATION_XML_UTF8 = createUTF8("application/xml", "xml", "xsl", "xsd"); - public static final MediaType APPLICATION_X_MOBIPOCKET_EBOOK = create("application/x-mobipocket-ebook", "prc", - "mobi"); - public static final MediaType APPLICATION_X_MPEGURL = create("application/x-mpegurl", "m3u8"); - public static final MediaType APPLICATION_X_MSACCESS = create("application/x-msaccess", "mdb"); - public static final MediaType APPLICATION_X_MS_APPLICATION = create("application/x-ms-application", "application"); - public static final MediaType APPLICATION_X_MSBINDER = create("application/x-msbinder", "obd"); - public static final MediaType APPLICATION_X_MSCARDFILE = create("application/x-mscardfile", "crd"); - public static final MediaType APPLICATION_X_MSCLIP = create("application/x-msclip", "clp"); - public static final MediaType APPLICATION_X_MSDOS_PROGRAM = create("application/x-msdos-program", "com", "exe", - "bat", "DLL"); - public static final MediaType APPLICATION_X_MSDOWNLOAD = create("application/x-msdownload", "exe", "dll", "com", - "BAT", "MSI"); - public static final MediaType APPLICATION_X_MSI = create("application/x-msi", "msi"); - public static final MediaType APPLICATION_X_MSMEDIAVIEW = create("application/x-msmediaview", "mvb", "m13", "m14"); - public static final MediaType APPLICATION_X_MSMETAFILE = create("application/x-msmetafile", "wmf", "wmz", "emf", - "emz"); - public static final MediaType APPLICATION_X_MSMONEY = create("application/x-msmoney", "mny"); - public static final MediaType APPLICATION_X_MSPUBLISHER = create("application/x-mspublisher", "pub"); - public static final MediaType APPLICATION_X_MSSCHEDULE = create("application/x-msschedule", "scd"); - public static final MediaType APPLICATION_X_MS_SHORTCUT = create("application/x-ms-shortcut", "lnk"); - public static final MediaType APPLICATION_X_MSTERMINAL = create("application/x-msterminal", "trm"); - public static final MediaType APPLICATION_X_MS_WMD = create("application/x-ms-wmd", "wmd"); - public static final MediaType APPLICATION_X_MS_WMZ = create("application/x-ms-wmz", "wmz"); - public static final MediaType APPLICATION_X_MSWRITE = create("application/x-mswrite", "wri"); - public static final MediaType APPLICATION_X_MS_XBAP = create("application/x-ms-xbap", "xbap"); - public static final MediaType APPLICATION_X_NETCDF = create("application/x-netcdf", "nc", "cdf"); - public static final MediaType APPLICATION_X_NS_PROXY_AUTOCONFIG = create("application/x-ns-proxy-autoconfig", - "pac", "DAT"); - public static final MediaType APPLICATION_X_NWC = create("application/x-nwc", "nwc"); - public static final MediaType APPLICATION_X_NZB = create("application/x-nzb", "nzb"); - public static final MediaType APPLICATION_X_OBJECT = create("application/x-object", "o"); - public static final MediaType APPLICATION_XOP_XML = create("application/xop+xml", "xop"); - public static final MediaType APPLICATION_X_OZ_APPLICATION = create("application/x-oz-application", "oza"); - public static final MediaType APPLICATION_X_PKCS12 = create("application/x-pkcs12", "p12", "pfx"); - public static final MediaType APPLICATION_X_PKCS7_CERTIFICATES = create("application/x-pkcs7-certificates", "p7b", - "SPC"); - public static final MediaType APPLICATION_X_PKCS7_CERTREQRESP = create("application/x-pkcs7-certreqresp", "p7r"); - public static final MediaType APPLICATION_X_PKCS7_CRL = create("application/x-pkcs7-crl", "crl"); - public static final MediaType APPLICATION_XPROC_XML = create("application/xproc+xml", "xpl"); - public static final MediaType APPLICATION_X_PYTHON_CODE = create("application/x-python-code", "pyc", "pyo"); - public static final MediaType APPLICATION_X_QGIS = create("application/x-qgis", "qgs", "shp", "shx"); - public static final MediaType APPLICATION_X_QUICKTIMEPLAYER = create("application/x-quicktimeplayer", "qtl"); - public static final MediaType APPLICATION_X_RAR_COMPRESSED = create("application/x-rar-compressed", "rar"); - public static final MediaType APPLICATION_X_RDP = create("application/x-rdp", "rdp"); - public static final MediaType APPLICATION_X_REDHAT_PACKAGE_MANAGER = create("application/x-redhat-package-manager", - "RPM"); - public static final MediaType APPLICATION_X_RESEARCH_INFO_SYSTEMS = create("application/x-research-info-systems", - "RIS"); - public static final MediaType APPLICATION_X_RUBY = create("application/x-ruby", "rb"); - public static final MediaType APPLICATION_X_SCILAB = create("application/x-scilab", "sci", "sce"); - public static final MediaType APPLICATION_X_SHAR = create("application/x-shar", "shar"); - public static final MediaType APPLICATION_X_SHOCKWAVE_FLASH = create("application/x-shockwave-flash", "swf", "swfl"); - public static final MediaType APPLICATION_X_SH_UTF8 = createUTF8("application/x-sh", "sh"); - public static final MediaType APPLICATION_X_SILVERLIGHT_APP = create("application/x-silverlight-app", "xap"); - public static final MediaType APPLICATION_X_SILVERLIGHT = create("application/x-silverlight", "scr"); - public static final MediaType APPLICATION_XSLT_XML_UTF8 = createUTF8("application/xslt+xml", "xslt"); - public static final MediaType APPLICATION_XSPF_XML_UTF8 = createUTF8("application/xspf+xml", "xspf"); - public static final MediaType APPLICATION_X_SQL_UTF8 = createUTF8("application/x-sql", "sql"); - public static final MediaType APPLICATION_X_STUFFIT = create("application/x-stuffit", "sit", "sitx"); - public static final MediaType APPLICATION_X_STUFFITX = create("application/x-stuffitx", "sitx"); - public static final MediaType APPLICATION_X_SUBRIP = create("application/x-subrip", "srt"); - public static final MediaType APPLICATION_X_SV4CPIO = create("application/x-sv4cpio", "sv4cpio"); - public static final MediaType APPLICATION_X_SV4CRC = create("application/x-sv4crc", "sv4crc"); - public static final MediaType APPLICATION_X_T3VM_IMAGE = create("application/x-t3vm-image", "t3"); - public static final MediaType APPLICATION_X_TADS = create("application/x-tads", "gam"); - public static final MediaType APPLICATION_X_TAR = create("application/x-tar", "tar"); - public static final MediaType APPLICATION_X_TCL = create("application/x-tcl", "tcl"); - public static final MediaType APPLICATION_X_TEX_GF = create("application/x-tex-gf", "gf"); - public static final MediaType APPLICATION_X_TEXINFO = create("application/x-texinfo", "texinfo", "texi"); - public static final MediaType APPLICATION_X_TEX_PK = create("application/x-tex-pk", "pk"); - public static final MediaType APPLICATION_X_TEX = create("application/x-tex", "tex"); - public static final MediaType APPLICATION_X_TEX_TFM = create("application/x-tex-tfm", "tfm"); - public static final MediaType APPLICATION_X_TGIF = create("application/x-tgif", "obj"); - public static final MediaType APPLICATION_X_TRASH = create("application/x-trash", "~", "%", "bak", "old", "sik"); - public static final MediaType APPLICATION_X_TROFF_MAN = create("application/x-troff-man", "man"); - public static final MediaType APPLICATION_X_TROFF_ME = create("application/x-troff-me", "me"); - public static final MediaType APPLICATION_X_TROFF_MS = create("application/x-troff-ms", "ms"); - public static final MediaType APPLICATION_X_TROFF = create("application/x-troff", "t", "tr", "roff"); - public static final MediaType APPLICATION_X_USTAR = create("application/x-ustar", "ustar"); - public static final MediaType APPLICATION_XV_XML = create("application/xv+xml", "mxml", "xhvml", "xvml", "xvm"); - public static final MediaType APPLICATION_X_WAIS_SOURCE = create("application/x-wais-source", "src"); - public static final MediaType APPLICATION_X_WINGZ = create("application/x-wingz", "wz"); - public static final MediaType APPLICATION_X_X509_CA_CERT = create("application/x-x509-ca-cert", "der", "crt"); - public static final MediaType APPLICATION_X_XCF = create("application/x-xcf", "xcf"); - public static final MediaType APPLICATION_X_XFIG = create("application/x-xfig", "fig"); - public static final MediaType APPLICATION_X_XLIFF_XML = create("application/x-xliff+xml", "xlf"); - public static final MediaType APPLICATION_X_XPINSTALL = create("application/x-xpinstall", "xpi"); - public static final MediaType APPLICATION_X_XZ = create("application/x-xz", "xz"); - public static final MediaType APPLICATION_X_ZMACHINE = create("application/x-zmachine", "z1", "z2", "z3", "z4", - "z5", "Z6", "Z7", "Z8"); - public static final MediaType APPLICATION_YANG = create("application/yang", "yang"); - public static final MediaType APPLICATION_YIN_XML = create("application/yin+xml", "yin"); - public static final MediaType APPLICATION_ZIP = create("application/zip", "zip"); - public static final MediaType AUDIO_ADPCM = create("audio/adpcm", "adp"); - public static final MediaType AUDIO_AMR = create("audio/amr", "amr"); - public static final MediaType AUDIO_AMR_WB = create("audio/amr-wb", "awb"); - public static final MediaType AUDIO_ANNODEX = create("audio/annodex", "axa"); - public static final MediaType AUDIO_BASIC = create("audio/basic", "au", "snd"); - public static final MediaType AUDIO_CSOUND = create("audio/csound", "csd", "orc", "sco"); - public static final MediaType AUDIO_FLAC = create("audio/flac", "flac"); - public static final MediaType AUDIO_MIDI = create("audio/midi", "mid", "midi", "kar", "rmi"); - public static final MediaType AUDIO_MP4 = create("audio/mp4", "mp4a"); - public static final MediaType AUDIO_MPEG = create("audio/mpeg", "mpga", "mpega", "mp2", "mp2a", "mp3", "m2a", - "m3a", "MP3", "M4A"); - public static final MediaType AUDIO_MPEGURL = create("audio/mpegurl", "m3u"); - public static final MediaType AUDIO_OGG = create("audio/ogg", "oga", "ogg", "spx"); - public static final MediaType AUDIO_PRS_SID = create("audio/prs.sid", "sid"); - public static final MediaType AUDIO_S3M = create("audio/s3m", "s3m"); - public static final MediaType AUDIO_SILK = create("audio/silk", "sil"); - public static final MediaType AUDIO_VND_DECE_AUDIO = create("audio/vnd.dece.audio", "uva", "uvva"); - public static final MediaType AUDIO_VND_DIGITAL_WINDS = create("audio/vnd.digital-winds", "eol"); - public static final MediaType AUDIO_VND_DRA = create("audio/vnd.dra", "dra"); - public static final MediaType AUDIO_VND_DTS = create("audio/vnd.dts", "dts"); - public static final MediaType AUDIO_VND_DTS_HD = create("audio/vnd.dts.hd", "dtshd"); - public static final MediaType AUDIO_VND_LUCENT_VOICE = create("audio/vnd.lucent.voice", "lvp"); - public static final MediaType AUDIO_VND_MS_PLAYREADY_MEDIA_PYA = create("audio/vnd.ms-playready.media.pya", "pya"); - public static final MediaType AUDIO_VND_NUERA_ECELP4800 = create("audio/vnd.nuera.ecelp4800", "ecelp4800"); - public static final MediaType AUDIO_VND_NUERA_ECELP7470 = create("audio/vnd.nuera.ecelp7470", "ecelp7470"); - public static final MediaType AUDIO_VND_NUERA_ECELP9600 = create("audio/vnd.nuera.ecelp9600", "ecelp9600"); - public static final MediaType AUDIO_VND_RIP = create("audio/vnd.rip", "rip"); - public static final MediaType AUDIO_WEBM = create("audio/webm", "weba"); - public static final MediaType AUDIO_X_AAC = create("audio/x-aac", "aac"); - public static final MediaType AUDIO_X_AIFF = create("audio/x-aiff", "aif", "aiff", "aifc"); - public static final MediaType AUDIO_X_CAF = create("audio/x-caf", "caf"); - public static final MediaType AUDIO_X_FLAC = create("audio/x-flac", "flac"); - public static final MediaType AUDIO_X_GSM = create("audio/x-gsm", "gsm"); - public static final MediaType AUDIO_X_MATROSKA = create("audio/x-matroska", "mka"); - public static final MediaType AUDIO_X_MPEGURL = create("audio/x-mpegurl", "m3u"); - public static final MediaType AUDIO_X_MS_WAX = create("audio/x-ms-wax", "wax"); - public static final MediaType AUDIO_X_MS_WMA = create("audio/x-ms-wma", "wma"); - public static final MediaType AUDIO_XM = create("audio/xm", "xm"); - public static final MediaType AUDIO_X_PN_REALAUDIO_PLUGIN = create("audio/x-pn-realaudio-plugin", "rmp"); - public static final MediaType AUDIO_X_PN_REALAUDIO = create("audio/x-pn-realaudio", "ra", "rm", "ram"); - public static final MediaType AUDIO_X_REALAUDIO = create("audio/x-realaudio", "ra"); - public static final MediaType AUDIO_X_SCPLS = create("audio/x-scpls", "pls"); - public static final MediaType AUDIO_X_SD2 = create("audio/x-sd2", "sd2"); - public static final MediaType AUDIO_X_WAV = create("audio/x-wav", "wav"); - public static final MediaType CHEMICAL_X_ALCHEMY = create("chemical/x-alchemy", "alc"); - public static final MediaType CHEMICAL_X_CACHE = create("chemical/x-cache", "cac", "cache"); - public static final MediaType CHEMICAL_X_CACHE_CSF = create("chemical/x-cache-csf", "csf"); - public static final MediaType CHEMICAL_X_CACTVS_BINARY = create("chemical/x-cactvs-binary", "cbin", "cascii", - "ctab"); - public static final MediaType CHEMICAL_X_CDX = create("chemical/x-cdx", "cdx"); - public static final MediaType CHEMICAL_X_CERIUS = create("chemical/x-cerius", "cer"); - public static final MediaType CHEMICAL_X_CHEM3D = create("chemical/x-chem3d", "c3d"); - public static final MediaType CHEMICAL_X_CHEMDRAW = create("chemical/x-chemdraw", "chm"); - public static final MediaType CHEMICAL_X_CIF = create("chemical/x-cif", "cif"); - public static final MediaType CHEMICAL_X_CMDF = create("chemical/x-cmdf", "cmdf"); - public static final MediaType CHEMICAL_X_CML = create("chemical/x-cml", "cml"); - public static final MediaType CHEMICAL_X_COMPASS = create("chemical/x-compass", "cpa"); - public static final MediaType CHEMICAL_X_CROSSFIRE = create("chemical/x-crossfire", "bsd"); - public static final MediaType CHEMICAL_X_CSML = create("chemical/x-csml", "csml", "csm"); - public static final MediaType CHEMICAL_X_CTX = create("chemical/x-ctx", "ctx"); - public static final MediaType CHEMICAL_X_CXF = create("chemical/x-cxf", "cxf", "cef"); - public static final MediaType CHEMICAL_X_DAYLIGHT_SMILES = create("chemical/x-daylight-smiles", "smi"); - public static final MediaType CHEMICAL_X_EMBL_DL_NUCLEOTIDE = create("chemical/x-embl-dl-nucleotide", "emb", "embl"); - public static final MediaType CHEMICAL_X_GALACTIC_SPC = create("chemical/x-galactic-spc", "spc"); - public static final MediaType CHEMICAL_X_GAMESS_INPUT = create("chemical/x-gamess-input", "inp", "gam", "gamin"); - public static final MediaType CHEMICAL_X_GAUSSIAN_CHECKPOINT = create("chemical/x-gaussian-checkpoint", "fch", - "fchk"); - public static final MediaType CHEMICAL_X_GAUSSIAN_CUBE = create("chemical/x-gaussian-cube", "cub"); - public static final MediaType CHEMICAL_X_GAUSSIAN_INPUT = create("chemical/x-gaussian-input", "gau", "gjc", "gjf"); - public static final MediaType CHEMICAL_X_GAUSSIAN_LOG = create("chemical/x-gaussian-log", "gal"); - public static final MediaType CHEMICAL_X_GCG8_SEQUENCE = create("chemical/x-gcg8-sequence", "gcg"); - public static final MediaType CHEMICAL_X_GENBANK = create("chemical/x-genbank", "gen"); - public static final MediaType CHEMICAL_X_HIN = create("chemical/x-hin", "hin"); - public static final MediaType CHEMICAL_X_ISOSTAR = create("chemical/x-isostar", "istr", "ist"); - public static final MediaType CHEMICAL_X_JCAMP_DX = create("chemical/x-jcamp-dx", "jdx", "dx"); - public static final MediaType CHEMICAL_X_KINEMAGE = create("chemical/x-kinemage", "kin"); - public static final MediaType CHEMICAL_X_MACMOLECULE = create("chemical/x-macmolecule", "mcm"); - public static final MediaType CHEMICAL_X_MACROMODEL_INPUT = create("chemical/x-macromodel-input", "mmd", "mmod"); - public static final MediaType CHEMICAL_X_MDL_MOLFILE = create("chemical/x-mdl-molfile", "mol"); - public static final MediaType CHEMICAL_X_MDL_RDFILE = create("chemical/x-mdl-rdfile", "rd"); - public static final MediaType CHEMICAL_X_MDL_RXNFILE = create("chemical/x-mdl-rxnfile", "rxn"); - public static final MediaType CHEMICAL_X_MDL_SDFILE = create("chemical/x-mdl-sdfile", "sd", "sdf"); - public static final MediaType CHEMICAL_X_MDL_TGF = create("chemical/x-mdl-tgf", "tgf"); - public static final MediaType CHEMICAL_X_MIF = create("chemical/x-mif", "mif"); - public static final MediaType CHEMICAL_X_MMCIF = create("chemical/x-mmcif", "mcif"); - public static final MediaType CHEMICAL_X_MOL2 = create("chemical/x-mol2", "mol2"); - public static final MediaType CHEMICAL_X_MOLCONN_Z = create("chemical/x-molconn-z", "b"); - public static final MediaType CHEMICAL_X_MOPAC_GRAPH = create("chemical/x-mopac-graph", "gpt"); - public static final MediaType CHEMICAL_X_MOPAC_INPUT = create("chemical/x-mopac-input", "mop", "mopcrt", "mpc", - "zmt"); - public static final MediaType CHEMICAL_X_MOPAC_OUT = create("chemical/x-mopac-out", "moo"); - public static final MediaType CHEMICAL_X_MOPAC_VIB = create("chemical/x-mopac-vib", "mvb"); - public static final MediaType CHEMICAL_X_NCBI_ASN1_ASCII = create("chemical/x-ncbi-asn1-ascii", "prt", "ent"); - public static final MediaType CHEMICAL_X_NCBI_ASN1 = create("chemical/x-ncbi-asn1", "asn"); - public static final MediaType CHEMICAL_X_NCBI_ASN1_BINARY = create("chemical/x-ncbi-asn1-binary", "val", "aso"); - public static final MediaType CHEMICAL_X_NCBI_ASN1_SPEC = create("chemical/x-ncbi-asn1-spec", "asn"); - public static final MediaType CHEMICAL_X_PDB = create("chemical/x-pdb", "pdb", "ent"); - public static final MediaType CHEMICAL_X_ROSDAL = create("chemical/x-rosdal", "ros"); - public static final MediaType CHEMICAL_X_SWISSPROT = create("chemical/x-swissprot", "sw"); - public static final MediaType CHEMICAL_X_VAMAS_ISO14976 = create("chemical/x-vamas-iso14976", "vms"); - public static final MediaType CHEMICAL_X_VMD = create("chemical/x-vmd", "vmd"); - public static final MediaType CHEMICAL_X_XTEL = create("chemical/x-xtel", "xtel"); - public static final MediaType CHEMICAL_X_XYZ = create("chemical/x-xyz", "xyz"); - public static final MediaType IMAGE_BMP = create("image/bmp", "bmp"); - public static final MediaType IMAGE_CGM = create("image/cgm", "cgm"); - public static final MediaType IMAGE_G3FAX = create("image/g3fax", "g3"); - public static final MediaType IMAGE_GIF = create("image/gif", "gif"); - public static final MediaType IMAGE_IEF = create("image/ief", "ief"); - public static final MediaType IMAGE_JPEG = create("image/jpeg", "jpeg", "jpg", "jpe"); - public static final MediaType IMAGE_KTX = create("image/ktx", "ktx"); - public static final MediaType IMAGE_PCX = create("image/pcx", "pcx"); - public static final MediaType IMAGE_PNG = create("image/png", "png"); - public static final MediaType IMAGE_PRS_BTIF = create("image/prs.btif", "btif"); - public static final MediaType IMAGE_SGI = create("image/sgi", "sgi"); - public static final MediaType IMAGE_SVG_XML = createUTF8("image/svg+xml", "svg", "svgz"); - public static final MediaType IMAGE_TIFF = create("image/tiff", "tiff", "tif"); - public static final MediaType IMAGE_VND_ADOBE_PHOTOSHOP = create("image/vnd.adobe.photoshop", "psd"); - public static final MediaType IMAGE_VND_DECE_GRAPHIC = create("image/vnd.dece.graphic", "uvi", "uvvi", "uvg", - "uvvg"); - public static final MediaType IMAGE_VND_DJVU = create("image/vnd.djvu", "djvu", "djv"); - public static final MediaType IMAGE_VND_DVB_SUBTITLE = create("image/vnd.dvb.subtitle", "sub"); - public static final MediaType IMAGE_VND_DWG = create("image/vnd.dwg", "dwg"); - public static final MediaType IMAGE_VND_DXF = create("image/vnd.dxf", "dxf"); - public static final MediaType IMAGE_VND_FASTBIDSHEET = create("image/vnd.fastbidsheet", "fbs"); - public static final MediaType IMAGE_VND_FPX = create("image/vnd.fpx", "fpx"); - public static final MediaType IMAGE_VND_FST = create("image/vnd.fst", "fst"); - public static final MediaType IMAGE_VND_FUJIXEROX_EDMICS_MMR = create("image/vnd.fujixerox.edmics-mmr", "mmr"); - public static final MediaType IMAGE_VND_FUJIXEROX_EDMICS_RLC = create("image/vnd.fujixerox.edmics-rlc", "rlc"); - public static final MediaType IMAGE_VND_MS_MODI = create("image/vnd.ms-modi", "mdi"); - public static final MediaType IMAGE_VND_MS_PHOTO = create("image/vnd.ms-photo", "wdp"); - public static final MediaType IMAGE_VND_NET_FPX = create("image/vnd.net-fpx", "npx"); - public static final MediaType IMAGE_VND_WAP_WBMP = create("image/vnd.wap.wbmp", "wbmp"); - public static final MediaType IMAGE_VND_XIFF = create("image/vnd.xiff", "xif"); - public static final MediaType IMAGE_WEBP = create("image/webp", "webp"); - public static final MediaType IMAGE_X_3DS = create("image/x-3ds", "3ds"); - public static final MediaType IMAGE_X_CANON_CR2 = create("image/x-canon-cr2", "cr2"); - public static final MediaType IMAGE_X_CANON_CRW = create("image/x-canon-crw", "crw"); - public static final MediaType IMAGE_X_CMU_RASTER = create("image/x-cmu-raster", "ras"); - public static final MediaType IMAGE_X_CMX = create("image/x-cmx", "cmx"); - public static final MediaType IMAGE_X_CORELDRAW = create("image/x-coreldraw", "cdr"); - public static final MediaType IMAGE_X_CORELDRAWPATTERN = create("image/x-coreldrawpattern", "pat"); - public static final MediaType IMAGE_X_CORELDRAWTEMPLATE = create("image/x-coreldrawtemplate", "cdt"); - public static final MediaType IMAGE_X_CORELPHOTOPAINT = create("image/x-corelphotopaint", "cpt"); - public static final MediaType IMAGE_X_EPSON_ERF = create("image/x-epson-erf", "erf"); - public static final MediaType IMAGE_X_FREEHAND = create("image/x-freehand", "fh", "fhc", "fh4", "fh5", "fh7"); - public static final MediaType IMAGE_X_ICON = create("image/x-icon", "ico"); - public static final MediaType IMAGE_X_JG = create("image/x-jg", "art"); - public static final MediaType IMAGE_X_JNG = create("image/x-jng", "jng"); - public static final MediaType IMAGE_X_MRSID_IMAGE = create("image/x-mrsid-image", "sid"); - public static final MediaType IMAGE_X_NIKON_NEF = create("image/x-nikon-nef", "nef"); - public static final MediaType IMAGE_X_OLYMPUS_ORF = create("image/x-olympus-orf", "orf"); - public static final MediaType IMAGE_X_PCX = create("image/x-pcx", "pcx"); - public static final MediaType IMAGE_X_PHOTOSHOP = create("image/x-photoshop", "psd"); - public static final MediaType IMAGE_X_PICT = create("image/x-pict", "pic", "pct"); - public static final MediaType IMAGE_X_PORTABLE_ANYMAP = create("image/x-portable-anymap", "pnm"); - public static final MediaType IMAGE_X_PORTABLE_BITMAP = create("image/x-portable-bitmap", "pbm"); - public static final MediaType IMAGE_X_PORTABLE_GRAYMAP = create("image/x-portable-graymap", "pgm"); - public static final MediaType IMAGE_X_PORTABLE_PIXMAP = create("image/x-portable-pixmap", "ppm"); - public static final MediaType IMAGE_X_RGB = create("image/x-rgb", "rgb"); - public static final MediaType IMAGE_X_TGA = create("image/x-tga", "tga"); - public static final MediaType IMAGE_X_XBITMAP = create("image/x-xbitmap", "xbm"); - public static final MediaType IMAGE_X_XPIXMAP = create("image/x-xpixmap", "xpm"); - public static final MediaType IMAGE_X_XWINDOWDUMP = create("image/x-xwindowdump", "xwd"); - public static final MediaType MESSAGE_RFC822 = create("message/rfc822", "eml", "mime"); - public static final MediaType MODEL_IGES = create("model/iges", "igs", "iges"); - public static final MediaType MODEL_MESH = create("model/mesh", "msh", "mesh", "silo"); - public static final MediaType MODEL_VND_COLLADA_XML = create("model/vnd.collada+xml", "dae"); - public static final MediaType MODEL_VND_DWF = create("model/vnd.dwf", "dwf"); - public static final MediaType MODEL_VND_GDL = create("model/vnd.gdl", "gdl"); - public static final MediaType MODEL_VND_GTW = create("model/vnd.gtw", "gtw"); - public static final MediaType MODEL_VND_MTS = create("model/vnd.mts", "mts"); - public static final MediaType MODEL_VND_VTU = create("model/vnd.vtu", "vtu"); - public static final MediaType MODEL_VRML = create("model/vrml", "wrl", "vrml"); - public static final MediaType MODEL_X3D_BINARY = create("model/x3d+binary", "x3db", "x3dbz"); - public static final MediaType MODEL_X3D_VRML = create("model/x3d+vrml", "x3dv", "x3dvz"); - public static final MediaType MODEL_X3D_XML = create("model/x3d+xml", "x3d", "x3dz"); - public static final MediaType TEXT_CACHE_MANIFEST = create("text/cache-manifest", "appcache", "manifest"); - public static final MediaType TEXT_CALENDAR = create("text/calendar", "ics", "icz", "ifb"); - public static final MediaType TEXT_CSS_UTF8 = createUTF8("text/css", "css"); - public static final MediaType TEXT_CSV_UTF8 = createUTF8("text/csv", "csv"); - public static final MediaType TEXT_H323 = create("text/h323", "323"); - public static final MediaType TEXT_HTML_UTF8 = createUTF8("text/html", "html", "htm", "shtml"); - public static final MediaType TEXT_IULS = create("text/iuls", "uls"); - public static final MediaType TEXT_MATHML = create("text/mathml", "mml"); - public static final MediaType TEXT_N3 = create("text/n3", "n3"); - public static final MediaType TEXT_PLAIN = create("text/plain"); - public static final MediaType TEXT_PLAIN_UTF8 = createUTF8("text/plain", "asc", "txt", "text", "conf", "def", - "pot", "brf", "LIST", "LOG", "IN"); - public static final MediaType TEXT_PRS_LINES_TAG = create("text/prs.lines.tag", "dsc"); - public static final MediaType TEXT_RICHTEXT = create("text/richtext", "rtx"); - public static final MediaType TEXT_SCRIPTLET = create("text/scriptlet", "sct", "wsc"); - public static final MediaType TEXT_SGML = create("text/sgml", "sgml", "sgm"); - public static final MediaType TEXT_TAB_SEPARATED_VALUES_UTF8 = createUTF8("text/tab-separated-values", "tsv"); - public static final MediaType TEXT_TEXMACS = create("text/texmacs", "tm"); - public static final MediaType TEXT_TROFF = create("text/troff", "t", "tr", "roff", "man", "me", "ms"); - public static final MediaType TEXT_TURTLE = create("text/turtle", "ttl"); - public static final MediaType TEXT_URI_LIST = create("text/uri-list", "uri", "uris", "urls"); - public static final MediaType TEXT_VCARD = create("text/vcard", "vcard"); - public static final MediaType TEXT_VND_CURL = create("text/vnd.curl", "curl"); - public static final MediaType TEXT_VND_CURL_DCURL = create("text/vnd.curl.dcurl", "dcurl"); - public static final MediaType TEXT_VND_CURL_MCURL = create("text/vnd.curl.mcurl", "mcurl"); - public static final MediaType TEXT_VND_CURL_SCURL = create("text/vnd.curl.scurl", "scurl"); - public static final MediaType TEXT_VND_DVB_SUBTITLE = create("text/vnd.dvb.subtitle", "sub"); - public static final MediaType TEXT_VND_FLY = create("text/vnd.fly", "fly"); - public static final MediaType TEXT_VND_FMI_FLEXSTOR = create("text/vnd.fmi.flexstor", "flx"); - public static final MediaType TEXT_VND_GRAPHVIZ = create("text/vnd.graphviz", "gv"); - public static final MediaType TEXT_VND_IN3D_3DML = create("text/vnd.in3d.3dml", "3dml"); - public static final MediaType TEXT_VND_IN3D_SPOT = create("text/vnd.in3d.spot", "spot"); - public static final MediaType TEXT_VND_SUN_J2ME_APP_DESCRIPTOR = create("text/vnd.sun.j2me.app-descriptor", "jad"); - public static final MediaType TEXT_VND_WAP_WMLSCRIPT = create("text/vnd.wap.wmlscript", "wmls"); - public static final MediaType TEXT_VND_WAP_WML = create("text/vnd.wap.wml", "wml"); - public static final MediaType TEXT_X_ASM_UTF8 = createUTF8("text/x-asm", "s", "asm"); - public static final MediaType TEXT_X_BIBTEX_UTF8 = createUTF8("text/x-bibtex", "bib"); - public static final MediaType TEXT_X_BOO_UTF8 = createUTF8("text/x-boo", "boo"); - public static final MediaType TEXT_X_C_UTF8 = createUTF8("text/x-c", "c", "cc", "cxx", "cpp", "h", "hh", "dic"); - public static final MediaType TEXT_X_CHDR_UTF8 = createUTF8("text/x-chdr", "h"); - public static final MediaType TEXT_X_C__HDR_UTF8 = createUTF8("text/x-c++hdr", "h++", "hpp", "hxx", "hh"); - public static final MediaType TEXT_X_COMPONENT_UTF8 = createUTF8("text/x-component", "htc"); - public static final MediaType TEXT_X_CSH_UTF8 = createUTF8("text/x-csh", "csh"); - public static final MediaType TEXT_X_CSRC_UTF8 = createUTF8("text/x-csrc", "c"); - public static final MediaType TEXT_X_C__SRC_UTF8 = createUTF8("text/x-c++src", "c++", "cpp", "cxx", "cc"); - public static final MediaType TEXT_X_DIFF_UTF8 = createUTF8("text/x-diff", "diff", "patch"); - public static final MediaType TEXT_X_DSRC_UTF8 = createUTF8("text/x-dsrc", "d"); - public static final MediaType TEXT_X_FORTRAN_UTF8 = createUTF8("text/x-fortran", "f", "for", "f77", "f90"); - public static final MediaType TEXT_X_HASKELL_UTF8 = createUTF8("text/x-haskell", "hs"); - public static final MediaType TEXT_X_JAVA_UTF8 = createUTF8("text/x-java", "java"); - public static final MediaType TEXT_X_JAVA_SOURCE_UTF8 = createUTF8("text/x-java-source", "java"); - public static final MediaType TEXT_X_LITERATE_HASKELL_UTF8 = createUTF8("text/x-literate-haskell", "lhs"); - public static final MediaType TEXT_X_MOC_UTF8 = createUTF8("text/x-moc", "moc"); - public static final MediaType TEXT_X_NFO_UTF8 = createUTF8("text/x-nfo", "nfo"); - public static final MediaType TEXT_X_OPML_UTF8 = createUTF8("text/x-opml", "opml"); - public static final MediaType TEXT_X_PASCAL_UTF8 = createUTF8("text/x-pascal", "p", "pas"); - public static final MediaType TEXT_X_PCS_GCD_UTF8 = createUTF8("text/x-pcs-gcd", "gcd"); - public static final MediaType TEXT_X_PERL_UTF8 = createUTF8("text/x-perl", "pl", "pm"); - public static final MediaType TEXT_X_PYTHON_UTF8 = createUTF8("text/x-python", "py"); - public static final MediaType TEXT_X_SCALA_UTF8 = createUTF8("text/x-scala", "scala"); - public static final MediaType TEXT_X_SETEXT_UTF8 = createUTF8("text/x-setext", "etx"); - public static final MediaType TEXT_X_SFV_UTF8 = createUTF8("text/x-sfv", "sfv"); - public static final MediaType TEXT_X_SH_UTF8 = createUTF8("text/x-sh", "sh"); - public static final MediaType TEXT_X_TCL_UTF8 = createUTF8("text/x-tcl", "tcl", "tk"); - public static final MediaType TEXT_X_TEX_UTF8 = createUTF8("text/x-tex", "tex", "ltx", "sty", "cls"); - public static final MediaType TEXT_X_UUENCODE_UTF8 = createUTF8("text/x-uuencode", "uu"); - public static final MediaType TEXT_X_VCALENDAR_UTF8 = createUTF8("text/x-vcalendar", "vcs"); - public static final MediaType TEXT_X_VCARD_UTF8 = createUTF8("text/x-vcard", "vcf"); - public static final MediaType VIDEO_3GPP2 = create("video/3gpp2", "3g2"); - public static final MediaType VIDEO_3GPP = create("video/3gpp", "3gp"); - public static final MediaType VIDEO_ANNODEX = create("video/annodex", "axv"); - public static final MediaType VIDEO_DL = create("video/dl", "dl"); - public static final MediaType VIDEO_DV = create("video/dv", "dif", "dv"); - public static final MediaType VIDEO_FLI = create("video/fli", "fli"); - public static final MediaType VIDEO_GL = create("video/gl", "gl"); - public static final MediaType VIDEO_H261 = create("video/h261", "h261"); - public static final MediaType VIDEO_H263 = create("video/h263", "h263"); - public static final MediaType VIDEO_H264 = create("video/h264", "h264"); - public static final MediaType VIDEO_JPEG = create("video/jpeg", "jpgv"); - public static final MediaType VIDEO_JPM = create("video/jpm", "jpm", "jpgm"); - public static final MediaType VIDEO_MJ2 = create("video/mj2", "mj2", "mjp2"); - public static final MediaType VIDEO_MP2T = create("video/mp2t", "ts"); - public static final MediaType VIDEO_MP4 = create("video/mp4", "mp4", "mp4v", "mpg4"); - public static final MediaType VIDEO_MPEG = create("video/mpeg", "mpeg", "mpg", "mpe", "m1v", "m2v"); - public static final MediaType VIDEO_OGG = create("video/ogg", "ogv"); - public static final MediaType VIDEO_QUICKTIME = create("video/quicktime", "qt", "mov"); - public static final MediaType VIDEO_VND_DECE_HD = create("video/vnd.dece.hd", "uvh", "uvvh"); - public static final MediaType VIDEO_VND_DECE_MOBILE = create("video/vnd.dece.mobile", "uvm", "uvvm"); - public static final MediaType VIDEO_VND_DECE_PD = create("video/vnd.dece.pd", "uvp", "uvvp"); - public static final MediaType VIDEO_VND_DECE_SD = create("video/vnd.dece.sd", "uvs", "uvvs"); - public static final MediaType VIDEO_VND_DECE_VIDEO = create("video/vnd.dece.video", "uvv", "uvvv"); - public static final MediaType VIDEO_VND_DVB_FILE = create("video/vnd.dvb.file", "dvb"); - public static final MediaType VIDEO_VND_FVT = create("video/vnd.fvt", "fvt"); - public static final MediaType VIDEO_VND_MPEGURL = create("video/vnd.mpegurl", "mxu", "m4u"); - public static final MediaType VIDEO_VND_MS_PLAYREADY_MEDIA_PYV = create("video/vnd.ms-playready.media.pyv", "pyv"); - public static final MediaType VIDEO_VND_UVVU_MP4 = create("video/vnd.uvvu.mp4", "uvu", "uvvu"); - public static final MediaType VIDEO_VND_VIVO = create("video/vnd.vivo", "viv"); - public static final MediaType VIDEO_WEBM = create("video/webm", "webm"); - public static final MediaType VIDEO_X_F4V = create("video/x-f4v", "f4v"); - public static final MediaType VIDEO_X_FLI = create("video/x-fli", "fli"); - public static final MediaType VIDEO_X_FLV = create("video/x-flv", "flv"); - public static final MediaType VIDEO_X_LA_ASF = create("video/x-la-asf", "lsf", "lsx"); - public static final MediaType VIDEO_X_M4V = create("video/x-m4v", "m4v"); - public static final MediaType VIDEO_X_MATROSKA = create("video/x-matroska", "mpv", "mkv", "mk3d", "mks"); - public static final MediaType VIDEO_X_MNG = create("video/x-mng", "mng"); - public static final MediaType VIDEO_X_MS_ASF = create("video/x-ms-asf", "asf", "asx"); - public static final MediaType VIDEO_X_MSVIDEO = create("video/x-msvideo", "avi"); - public static final MediaType VIDEO_X_MS_VOB = create("video/x-ms-vob", "vob"); - public static final MediaType VIDEO_X_MS_WMV = create("video/x-ms-wmv", "wmv"); - public static final MediaType VIDEO_X_MS_WM = create("video/x-ms-wm", "wm"); - public static final MediaType VIDEO_X_MS_WMX = create("video/x-ms-wmx", "wmx"); - public static final MediaType VIDEO_X_MS_WVX = create("video/x-ms-wvx", "wvx"); - public static final MediaType VIDEO_X_SGI_MOVIE = create("video/x-sgi-movie", "movie"); - public static final MediaType VIDEO_X_SMV = create("video/x-smv", "smv"); - public static final MediaType X_CONFERENCE_X_COOLTALK = create("x-conference/x-cooltalk", "ice"); - public static final MediaType X_EPOC_X_SISX_APP = create("x-epoc/x-sisx-app", "sisx"); - public static final MediaType X_WORLD_X_VRML = create("x-world/x-vrml", "vrm", "vrml", "wrl"); + public static final MediaType JPEG = IMAGE_JPEG; + public static final MediaType PNG = IMAGE_PNG; + public static final MediaType BMP = IMAGE_BMP; + public static final MediaType GIF = IMAGE_GIF; + public static final MediaType SVG = IMAGE_SVG_XML; - /*******************************************************/ + public static final MediaType DEFAULT = MediaType.BINARY; - public static final MediaType HTML_UTF_8 = TEXT_HTML_UTF8; - public static final MediaType CSS_UTF_8 = TEXT_CSS_UTF8; - public static final MediaType CSV_UTF_8 = TEXT_CSV_UTF8; - public static final MediaType PLAIN_TEXT_UTF_8 = TEXT_PLAIN_UTF8; + /*******************************************************/ - public static final MediaType XHTML_XML_UTF8 = APPLICATION_XHTML_XML_UTF8; - public static final MediaType JAVASCRIPT_UTF8 = APPLICATION_JAVASCRIPT_UTF8; - public static final MediaType JSON = APPLICATION_JSON; - public static final MediaType XML_UTF_8 = APPLICATION_XML_UTF8; + public static synchronized MediaType create(String type, String... fileExtensisons) + { + return create(type, NO_ATTR, fileExtensisons); + } - public static final MediaType BINARY = APPLICATION_OCTET_STREAM; - public static final MediaType ZIP = APPLICATION_ZIP; - public static final MediaType PDF = APPLICATION_PDF; - public static final MediaType SWF = APPLICATION_X_SHOCKWAVE_FLASH; + public static synchronized MediaType create(String type, String[] attributes, String... fileExtensisons) + { + MediaType mt = new MediaType(type, attributes); - public static final MediaType JPEG = IMAGE_JPEG; - public static final MediaType PNG = IMAGE_PNG; - public static final MediaType BMP = IMAGE_BMP; - public static final MediaType GIF = IMAGE_GIF; - public static final MediaType SVG = IMAGE_SVG_XML; + for (String ext : fileExtensisons) { + FILE_EXTENSIONS.put(ext, mt); + } - public static final MediaType DEFAULT = MediaType.BINARY; + return mt; + } - /*******************************************************/ + public static synchronized MediaType createUTF8(String type, String... fileExtensisons) + { + return create(type, UTF8_ATTR, fileExtensisons); + } - public static synchronized MediaType create(String type, String... fileExtensisons) { - return create(type, NO_ATTR, fileExtensisons); - } + public static synchronized MediaType getByFileExtension(String fileExtension) + { + return FILE_EXTENSIONS.get(fileExtension); + } - public static synchronized MediaType create(String type, String[] attributes, String... fileExtensisons) { - MediaType mt = new MediaType(type, attributes); + public static synchronized MediaType getByFileName(String filename) + { + int dotPos = filename.lastIndexOf('.'); + if (dotPos >= 0) { + String ext = filename.substring(dotPos + 1); + return getByFileExtension(ext); + } else { + return MediaType.DEFAULT; + } + } - for (String ext : fileExtensisons) { - FILE_EXTENSIONS.put(ext, mt); - } + public String withCharset(String charset) + { + return charset != null ? String.format("%s; charset=%s", this.contentType, charset.toUpperCase()) : this.contentType; + } - return mt; - } + public static MediaType of(String contentType) + { + return new MediaType(contentType); + } - public static synchronized MediaType createUTF8(String type, String... fileExtensisons) { - return create(type, UTF8_ATTR, fileExtensisons); - } + private final byte[] bytes; - public static synchronized MediaType getByFileExtension(String fileExtension) { - return FILE_EXTENSIONS.get(fileExtension); - } + private final String contentType; - public static synchronized MediaType getByFileName(String filename) { - int dotPos = filename.lastIndexOf('.'); - if (dotPos >= 0) { - String ext = filename.substring(dotPos + 1); - return getByFileExtension(ext); - } else { - return MediaType.DEFAULT; - } - } - - public String withCharset(String charset) - { - return charset != null ? String.format("%s; charset=%s", this.contentType , charset.toUpperCase()) : this.contentType; - } - public static MediaType of(String contentType) { - return new MediaType(contentType); - } + private MediaType(String contentType) + { + this.bytes = contentType.getBytes(); + this.contentType = contentType; + } - private final byte[] bytes; - - private final String contentType; + private MediaType(String name, String[] attributes) + { + this.bytes = join(name, attributes).getBytes(); + this.contentType = new String(this.bytes); + } - private MediaType(String contentType) { - this.bytes = contentType.getBytes(); - this.contentType = contentType; - } + private String join(String name, String[] attributes) + { - private MediaType(String name, String[] attributes) { - this.bytes = join(name, attributes).getBytes(); - this.contentType = new String(this.bytes); + String attrs = Arrays.stream(attributes).collect(Collectors.joining(";")); - } + return attrs.isEmpty() ? name : name + "; " + attrs; + } - private String join(String name, String[] attributes) { - - String attrs = Arrays.stream(attributes).collect(Collectors.joining(";")); + public byte[] getBytes() + { + return bytes; + } - return attrs.isEmpty() ? name : name + "; " + attrs; - } + public String contentType() + { + return this.contentType; + } - public byte[] getBytes() { - return bytes; - } - - public String contentType() { - return this.contentType; - } + @Override + public String toString() + { + return this.contentType; + } - @Override - public String toString() { - return this.contentType; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(bytes); - return result; - } + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(bytes); + return result; + } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - MediaType other = (MediaType) obj; - if (!Arrays.equals(bytes, other.bytes)) - return false; - return true; - } + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MediaType other = (MediaType) obj; + if (!Arrays.equals(bytes, other.bytes)) + return false; + return true; + } - public String info() { - if (this == HTML_UTF_8) { - return "html"; - } + public String info() + { + if (this == HTML_UTF_8) { + return "html"; + } - if (this == JSON) { - return "json"; - } + if (this == JSON) { + return "json"; + } - if (this == PLAIN_TEXT_UTF_8) { - return "plain"; - } + if (this == PLAIN_TEXT_UTF_8) { + return "plain"; + } - if (this == BINARY) { - return "binary"; - } + if (this == BINARY) { + return "binary"; + } - return toString(); - } + return toString(); + } } diff --git a/core/src/main/java/io/sinistral/proteus/server/ServerRequest.java b/core/src/main/java/io/sinistral/proteus/server/ServerRequest.java index 56e4187..9f8a0e2 100644 --- a/core/src/main/java/io/sinistral/proteus/server/ServerRequest.java +++ b/core/src/main/java/io/sinistral/proteus/server/ServerRequest.java @@ -1,22 +1,9 @@ - /** * */ package io.sinistral.proteus.server; -import java.io.File; -import java.io.IOException; - -import java.net.InetSocketAddress; - -import java.nio.ByteBuffer; - -import java.util.Deque; -import java.util.Map; -import java.util.concurrent.Executor; - import io.sinistral.proteus.server.predicates.ServerPredicates; - import io.undertow.io.Receiver; import io.undertow.security.api.SecurityContext; import io.undertow.server.DefaultResponseListener; @@ -29,6 +16,14 @@ import io.undertow.util.FastConcurrentDirectDeque; import io.undertow.util.Headers; +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.util.Deque; +import java.util.Map; +import java.util.concurrent.Executor; + /** * * @author jbauer @@ -40,12 +35,12 @@ public class ServerRequest exchange.putAttachment(DefaultResponseListener.EXCEPTION, e); exchange.endExchange(); }; - + public static final AttachmentKey BYTE_BUFFER_KEY = AttachmentKey.create(ByteBuffer.class); - + protected static final String CHARSET = "UTF-8"; protected static final String TMP_DIR = System.getProperty("java.io.tmpdir"); - + public final HttpServerExchange exchange; protected final String path; protected FormData form; @@ -70,18 +65,12 @@ public ServerRequest(HttpServerExchange exchange) throws IOException this.contentType = exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE); this.accept = exchange.getRequestHeaders().getFirst(Headers.ACCEPT); - if (this.contentType != null) - { - if (ServerPredicates.URL_ENCODED_FORM_PREDICATE.resolve(exchange)) - { + if (this.contentType != null) { + if (ServerPredicates.URL_ENCODED_FORM_PREDICATE.resolve(exchange)) { this.parseEncodedForm(); - } - else if (ServerPredicates.MULTIPART_PREDICATE.resolve(exchange)) - { + } else if (ServerPredicates.MULTIPART_PREDICATE.resolve(exchange)) { this.parseMultipartForm(); - } - else if (exchange.getRequestContentLength() > 0) - { + } else if (exchange.getRequestContentLength() > 0) { this.extractBytes(); } } @@ -108,20 +97,18 @@ private void extractBytes() throws IOException ByteBuffer buffer = ByteBuffer.wrap(message); exchange.putAttachment(BYTE_BUFFER_KEY, buffer); - },ERROR_CALLBACK); + }, ERROR_CALLBACK); } private void extractFormParameters(final FormData formData) { - if (formData != null) - { - for (String key : formData) - { + if (formData != null) { + for (String key : formData) { final Deque formValues = formData.get(key); final Deque values = formValues.stream() - .filter(fv -> !fv.isFileItem()) - .map(FormData.FormValue::getValue) - .collect(java.util.stream.Collectors.toCollection(FastConcurrentDirectDeque::new)); + .filter(fv -> !fv.isFileItem()) + .map(FormData.FormValue::getValue) + .collect(java.util.stream.Collectors.toCollection(FastConcurrentDirectDeque::new)); exchange.getQueryParameters().put(key, values); } @@ -130,8 +117,7 @@ private void extractFormParameters(final FormData formData) public Deque files(final String name) { - if (this.form != null) - { + if (this.form != null) { return form.get(name); } @@ -150,7 +136,7 @@ private void parseEncodedForm() throws IOException final FormData formData = new FormEncodedDataDefinition().setDefaultEncoding(this.exchange.getRequestCharset()).create(exchange).parseBlocking(); this.exchange.putAttachment(FormDataParser.FORM_DATA, formData); - + extractFormParameters(formData); } @@ -160,12 +146,11 @@ private void parseMultipartForm() throws IOException final FormDataParser formDataParser = new MultiPartParserDefinition().setTempFileLocation(new File(TMP_DIR).toPath()).setDefaultEncoding(CHARSET).create(this.exchange); - if (formDataParser != null) - { + if (formDataParser != null) { final FormData formData = formDataParser.parseBlocking(); this.exchange.putAttachment(FormDataParser.FORM_DATA, formData); - + extractFormParameters(formData); } } @@ -236,45 +221,45 @@ public SecurityContext getSecurityContext() return exchange.getSecurityContext(); } - /** - * @return the exchange - */ - public HttpServerExchange getExchange() - { - return exchange; - } - - /** - * @return the path - */ - public String getPath() - { - return path; - } - - /** - * @return the contentType - */ - public String getContentType() - { - return contentType; - } - - /** - * @return the method - */ - public String getMethod() - { - return method; - } - - /** - * @return the accept - */ - public String getAccept() - { - return accept; - } + /** + * @return the exchange + */ + public HttpServerExchange getExchange() + { + return exchange; + } + + /** + * @return the path + */ + public String getPath() + { + return path; + } + + /** + * @return the contentType + */ + public String getContentType() + { + return contentType; + } + + /** + * @return the method + */ + public String getMethod() + { + return method; + } + + /** + * @return the accept + */ + public String getAccept() + { + return accept; + } } diff --git a/core/src/main/java/io/sinistral/proteus/server/ServerResponse.java b/core/src/main/java/io/sinistral/proteus/server/ServerResponse.java index 679f907..3f257cc 100644 --- a/core/src/main/java/io/sinistral/proteus/server/ServerResponse.java +++ b/core/src/main/java/io/sinistral/proteus/server/ServerResponse.java @@ -1,356 +1,339 @@ /** - * + * */ package io.sinistral.proteus.server; -import java.net.URI; -import java.nio.ByteBuffer; -import java.util.Date; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -import javax.ws.rs.core.Response; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.google.inject.Inject; - import io.sinistral.proteus.server.predicates.ServerPredicates; import io.undertow.io.IoCallback; import io.undertow.server.DefaultResponseListener; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.server.handlers.Cookie; -import io.undertow.util.HeaderMap; -import io.undertow.util.HeaderValues; -import io.undertow.util.Headers; -import io.undertow.util.HttpString; -import io.undertow.util.Methods; -import io.undertow.util.StatusCodes; +import io.undertow.util.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.core.Response; +import java.net.URI; +import java.nio.ByteBuffer; +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; /** * @author jbauer * Base server response. Friendlier interface to underlying exchange. * @TODO extend javax.ws.rs.core.Response - */ + */ public class ServerResponse { - private static Logger log = LoggerFactory.getLogger(ServerResponse.class.getCanonicalName()); - - @Inject - protected static XmlMapper XML_MAPPER; - - @Inject - protected static ObjectMapper OBJECT_MAPPER; - - protected ByteBuffer body; - - protected int status = StatusCodes.OK; - protected final HeaderMap headers = new HeaderMap(); - protected final Map cookies = new HashMap<>(); - protected String contentType = null; - protected T entity; - protected Throwable throwable; -// protected Class jsonContext; - protected HttpString method = null; - protected IoCallback ioCallback; - protected boolean hasCookies = false; - protected boolean hasHeaders = false; - protected boolean hasIoCallback = false; - protected boolean processXml = false; - protected boolean processJson = false; - protected boolean preprocessed = false; - protected String location = null; - - public ServerResponse() - { - - } - - public ByteBuffer getBody() - { - return body; - } - - public int getStatus() - { - return this.status; - } - - public Map getCookies() - { - return this.cookies; - } - - public HeaderMap getHeaders() - { - return this.headers; - } - - public ServerResponse addHeader(HttpString headerName, String headerValue) - { - this.headers.add(headerName, headerValue); - this.hasHeaders = true; - - return this; - } - - public ServerResponse addHeader(String headerString, String headerValue) - { - HttpString headerName = HttpString.tryFromString(headerString); - - this.headers.add(headerName, headerValue); - this.hasHeaders = true; - - return this; - } - - public ServerResponse setHeader(HttpString headerName, String headerValue) - { - this.headers.put(headerName, headerValue); - this.hasHeaders = true; - - return this; - } - - public ServerResponse setHeader(String headerString, String headerValue) - { - HttpString headerName = HttpString.tryFromString(headerString); - - this.headers.put(headerName, headerValue); - this.hasHeaders = true; - - return this; - } - - /** - * @return the contentType - */ - public String getContentType() - { - return contentType; - } - - /** - * @return the callback - */ - public IoCallback getIoCallback() - { - return ioCallback; - } - - /** - * @param ioCallback - * the ioCallback to set - */ - public void setIoCallback(IoCallback ioCallback) - { - this.ioCallback = ioCallback; - } - - /** - * @param body - * the body to set - */ - public void setBody(ByteBuffer body) - { - this.body = body; - } - - /** - * @param status - * the status to set - */ - public void setStatus(int status) - { - this.status = status; - } - - /** - * @param status - * the status to set - */ - public void setStatus(Response.Status status) - { - this.status = status.getStatusCode(); - } - - - - public ServerResponse body(ByteBuffer body) - { - this.body = body; - this.preprocessed = true; - return this; - } - - public ServerResponse body(String body) - { - return this.body(ByteBuffer.wrap(body.getBytes())); - } - - public ServerResponse entity(T entity) - { - this.entity = entity; - this.preprocessed = false; - - return this; - } - - public ServerResponse method(HttpString method) - { - this.method = method; - return this; - } - - public ServerResponse method(String method) - { - this.method = Methods.fromString(method); - return this; - } - - public ServerResponse lastModified(Date date) - { - this.headers.put(Headers.LAST_MODIFIED, date.getTime()); - return this; - } - - public ServerResponse contentLanguage(Locale locale) - { - this.headers.put(Headers.CONTENT_LANGUAGE, locale.toLanguageTag()); - return this; - } - - public ServerResponse contentLanguage(String language) - { - this.headers.put(Headers.CONTENT_LANGUAGE, language); - return this; - } - - public ServerResponse throwable(Throwable throwable) - { - this.throwable = throwable; - - if (this.status == StatusCodes.ACCEPTED) - { - return badRequest(throwable); - } - - return this; - } - - public ServerResponse status(Response.Status status) - { - this.status = status.getStatusCode(); - return this; + private static Logger log = LoggerFactory.getLogger(ServerResponse.class.getCanonicalName()); + + @Inject + protected static XmlMapper XML_MAPPER; + + @Inject + protected static ObjectMapper OBJECT_MAPPER; + + protected ByteBuffer body; + + protected int status = StatusCodes.OK; + protected final HeaderMap headers = new HeaderMap(); + protected final Map cookies = new HashMap<>(); + protected String contentType = null; + protected T entity; + protected Throwable throwable; + // protected Class jsonContext; + protected HttpString method = null; + protected IoCallback ioCallback; + protected boolean hasCookies = false; + protected boolean hasHeaders = false; + protected boolean hasIoCallback = false; + protected boolean processXml = false; + protected boolean processJson = false; + protected boolean preprocessed = false; + protected String location = null; + + public ServerResponse() + { + + } + + public ByteBuffer getBody() + { + return body; + } + + public int getStatus() + { + return this.status; + } + + public Map getCookies() + { + return this.cookies; + } + + public HeaderMap getHeaders() + { + return this.headers; + } + + public ServerResponse addHeader(HttpString headerName, String headerValue) + { + this.headers.add(headerName, headerValue); + this.hasHeaders = true; + + return this; + } + + public ServerResponse addHeader(String headerString, String headerValue) + { + HttpString headerName = HttpString.tryFromString(headerString); + + this.headers.add(headerName, headerValue); + this.hasHeaders = true; + + return this; + } + + public ServerResponse setHeader(HttpString headerName, String headerValue) + { + this.headers.put(headerName, headerValue); + this.hasHeaders = true; + + return this; + } + + public ServerResponse setHeader(String headerString, String headerValue) + { + HttpString headerName = HttpString.tryFromString(headerString); + + this.headers.put(headerName, headerValue); + this.hasHeaders = true; + + return this; + } + + /** + * @return the contentType + */ + public String getContentType() + { + return contentType; + } + + /** + * @return the callback + */ + public IoCallback getIoCallback() + { + return ioCallback; + } + + /** + * @param ioCallback + * the ioCallback to set + */ + public void setIoCallback(IoCallback ioCallback) + { + this.ioCallback = ioCallback; + } + + /** + * @param body + * the body to set + */ + public void setBody(ByteBuffer body) + { + this.body = body; + } + + /** + * @param status + * the status to set + */ + public void setStatus(int status) + { + this.status = status; + } + + /** + * @param status + * the status to set + */ + public void setStatus(Response.Status status) + { + this.status = status.getStatusCode(); + } + + + public ServerResponse body(ByteBuffer body) + { + this.body = body; + this.preprocessed = true; + return this; + } + + public ServerResponse body(String body) + { + return this.body(ByteBuffer.wrap(body.getBytes())); + } + + public ServerResponse entity(T entity) + { + this.entity = entity; + this.preprocessed = false; + + return this; + } + + public ServerResponse method(HttpString method) + { + this.method = method; + return this; + } + + public ServerResponse method(String method) + { + this.method = Methods.fromString(method); + return this; + } + + public ServerResponse lastModified(Date date) + { + this.headers.put(Headers.LAST_MODIFIED, date.getTime()); + return this; + } + + public ServerResponse contentLanguage(Locale locale) + { + this.headers.put(Headers.CONTENT_LANGUAGE, locale.toLanguageTag()); + return this; + } + + public ServerResponse contentLanguage(String language) + { + this.headers.put(Headers.CONTENT_LANGUAGE, language); + return this; + } + + public ServerResponse throwable(Throwable throwable) + { + this.throwable = throwable; + + if (this.status == StatusCodes.ACCEPTED) { + return badRequest(throwable); } - - public ServerResponse status(int status) - { - this.status = status; - return this; - } - - public ServerResponse header(HttpString headerName, String value) - { - this.headers.put(headerName, value); - this.hasHeaders = true; - return this; - } - - public ServerResponse cookie(String cookieName, Cookie cookie) - { - this.cookies.put(cookieName, cookie); - this.hasCookies = true; - return this; - } - - - /** - * @param contentType - * the contentType to set - */ - protected void setContentType(String contentType) - { - this.contentType = contentType; - - if (this.contentType.equals(javax.ws.rs.core.MediaType.APPLICATION_JSON)) - { - if (!this.preprocessed) - { - this.processJson = true; - } - } - else if (this.contentType.equals(javax.ws.rs.core.MediaType.APPLICATION_XML)) - { - if (!this.preprocessed) - { - this.processXml = true; - } - } - } - - public ServerResponse contentType(String contentType) - { - this.setContentType(contentType); - return this; - } - - - public ServerResponse contentType(javax.ws.rs.core.MediaType mediaType) - { - this.setContentType(mediaType.toString()); - return this; - } - - public ServerResponse contentType(MediaType mediaType) - { - this.setContentType(mediaType.contentType()); - return this; - } - - public ServerResponse applicationJson() - { - if (!this.preprocessed) - { - this.processJson = true; - } - this.contentType = javax.ws.rs.core.MediaType.APPLICATION_JSON; - return this; - } - - public ServerResponse textHtml() - { - this.contentType = javax.ws.rs.core.MediaType.TEXT_HTML; - return this; - } - - public ServerResponse applicationOctetStream() - { - this.contentType = javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM; - return this; - } - - public ServerResponse applicationXml() - { - if (!this.preprocessed) - { - this.processXml = true; - } - this.contentType = javax.ws.rs.core.MediaType.APPLICATION_XML; - return this; - } - - public ServerResponse textPlain() - { - this.contentType = javax.ws.rs.core.MediaType.TEXT_PLAIN; - return this; - } + + return this; + } + + public ServerResponse status(Response.Status status) + { + this.status = status.getStatusCode(); + return this; + } + + public ServerResponse status(int status) + { + this.status = status; + return this; + } + + public ServerResponse header(HttpString headerName, String value) + { + this.headers.put(headerName, value); + this.hasHeaders = true; + return this; + } + + public ServerResponse cookie(String cookieName, Cookie cookie) + { + this.cookies.put(cookieName, cookie); + this.hasCookies = true; + return this; + } + + + /** + * @param contentType + * the contentType to set + */ + protected void setContentType(String contentType) + { + this.contentType = contentType; + + if (this.contentType.equals(javax.ws.rs.core.MediaType.APPLICATION_JSON)) { + if (!this.preprocessed) { + this.processJson = true; + } + } else if (this.contentType.equals(javax.ws.rs.core.MediaType.APPLICATION_XML)) { + if (!this.preprocessed) { + this.processXml = true; + } + } + } + + public ServerResponse contentType(String contentType) + { + this.setContentType(contentType); + return this; + } + + + public ServerResponse contentType(javax.ws.rs.core.MediaType mediaType) + { + this.setContentType(mediaType.toString()); + return this; + } + + public ServerResponse contentType(MediaType mediaType) + { + this.setContentType(mediaType.contentType()); + return this; + } + + public ServerResponse applicationJson() + { + if (!this.preprocessed) { + this.processJson = true; + } + this.contentType = javax.ws.rs.core.MediaType.APPLICATION_JSON; + return this; + } + + public ServerResponse textHtml() + { + this.contentType = javax.ws.rs.core.MediaType.TEXT_HTML; + return this; + } + + public ServerResponse applicationOctetStream() + { + this.contentType = javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM; + return this; + } + + public ServerResponse applicationXml() + { + if (!this.preprocessed) { + this.processXml = true; + } + this.contentType = javax.ws.rs.core.MediaType.APPLICATION_XML; + return this; + } + + public ServerResponse textPlain() + { + this.contentType = javax.ws.rs.core.MediaType.TEXT_PLAIN; + return this; + } // public ServerResponse jsonContext(Class context) // { @@ -358,365 +341,332 @@ public ServerResponse textPlain() // return this; // } - public ServerResponse ok() - { - this.status = StatusCodes.OK; - return this; - } - - public ServerResponse redirect(String location) - { - this.location = location; - this.status = StatusCodes.FOUND; - return this; - } - - public ServerResponse redirect(String location, int status) - { - this.location = location; - this.status = status; - return this; - } - - public ServerResponse redirectPermanently(String location) - { - this.location = location; - this.status = StatusCodes.MOVED_PERMANENTLY; - return this; - } - - public ServerResponse found() - { - this.status = StatusCodes.FOUND; - return this; - } - - - public ServerResponse accepted() - { - this.status = StatusCodes.ACCEPTED; - return this; - } - - public ServerResponse badRequest() - { - this.status = StatusCodes.BAD_REQUEST; - return this; - } - - public ServerResponse badRequest(Throwable t) - { - this.throwable = t; - return this.badRequest(); - } - - public ServerResponse badRequest(String message) - { - return this.errorMessage(message).badRequest(); - } - - public ServerResponse internalServerError() - { - this.status = StatusCodes.INTERNAL_SERVER_ERROR; - return this; - } - - public ServerResponse internalServerError(Throwable t) - { - this.throwable = t; - return this.internalServerError(); - } - - public ServerResponse internalServerError(String message) - { - return this.errorMessage(message).internalServerError(); - } - - public ServerResponse created() - { - this.status = StatusCodes.CREATED; - return this; - } - - public ServerResponse created(String location) - { - this.status = StatusCodes.CREATED; - this.location = location; - return this; - } - - public ServerResponse created(URI uri) - { - this.status = StatusCodes.CREATED; - this.location = uri.toString(); - return this; - } - - public ServerResponse notModified() - { - this.status = StatusCodes.NOT_MODIFIED; - return this; - } - - - public ServerResponse notFound() - { - this.status = StatusCodes.NOT_FOUND; - return this; - } - - public ServerResponse notFound(Throwable t) - { - this.throwable = t; - return this.notFound(); - } - - public ServerResponse notFound(String message) - { - return this.errorMessage(message).notFound(); - } - - - public ServerResponse forbidden() - { - this.status = StatusCodes.FORBIDDEN; - return this; - } - - public ServerResponse forbidden(Throwable t) - { - this.throwable = t; - return this.forbidden(); - } - - public ServerResponse forbidden(String message) - { - return this.errorMessage(message).forbidden(); - } - - public ServerResponse noContent() - { - this.status = StatusCodes.NO_CONTENT; - return this; - } - - public ServerResponse noContent(Throwable t) - { - this.throwable = t; - return this.noContent(); - } - - - public ServerResponse noContent(String message) - { - return this.errorMessage(message).noContent(); - } - - public ServerResponse serviceUnavailable() - { - this.status = StatusCodes.SERVICE_UNAVAILABLE; - return this; - } - - public ServerResponse serviceUnavailable(Throwable t) - { - this.throwable = t; - return this.serviceUnavailable(); - } - - - public ServerResponse serviceUnavailable(String message) - { - return this.errorMessage(message).serviceUnavailable(); - } - - public ServerResponse unauthorized() - { - this.status = StatusCodes.UNAUTHORIZED; - return this; - } - - public ServerResponse unauthorized(Throwable t) - { - this.throwable = t; - return this.unauthorized(); - } - - - public ServerResponse unauthorized(String message) - { - return this.errorMessage(message).unauthorized(); - } - - public ServerResponse errorMessage(String message) - { - this.throwable = new Throwable(message); - return this; - } - - public ServerResponse withIoCallback(IoCallback ioCallback) - { - this.ioCallback = ioCallback; - this.hasIoCallback = ioCallback == null; - return this; - } - - public void send(final HttpServerExchange exchange) throws RuntimeException - { - send(null, exchange); - } - - public void send(final HttpHandler handler, final HttpServerExchange exchange) throws RuntimeException - { - - final boolean hasBody = this.body != null; - final boolean hasEntity = this.entity != null; - final boolean hasError = this.throwable != null; - - exchange.setStatusCode(this.status); - - - if (hasError) - { - exchange.putAttachment(DefaultResponseListener.EXCEPTION, throwable); - exchange.endExchange(); - return; - } - - if(this.location != null) - { - exchange.getResponseHeaders().put(Headers.LOCATION, this.location); - } - - if(this.status == StatusCodes.FOUND || this.status == StatusCodes.MOVED_PERMANENTLY || this.status == StatusCodes.TEMPORARY_REDIRECT || this.status == StatusCodes.SEE_OTHER || this.status == StatusCodes.PERMANENT_REDIRECT ) - { - if( (this.status == StatusCodes.FOUND || this.status == StatusCodes.MOVED_PERMANENTLY) && (this.method != null) ) - { - exchange.setRequestMethod(this.method); - } - - exchange.endExchange(); - return; - } - - if (this.contentType != null) - { - exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, this.contentType); - } - - - if (this.hasHeaders) - { - long itr = this.headers.fastIterateNonEmpty(); - - while (itr != -1L) - { - final HeaderValues values = this.headers.fiCurrent(itr); - - exchange.getResponseHeaders().putAll(values.getHeaderName(), values); - - itr = this.headers.fiNextNonEmpty(itr); - } - } - - if (this.hasCookies) - { - exchange.getResponseCookies().putAll(this.cookies); - } - - - - - else if (!this.processJson && !this.processXml) - { - if (ServerPredicates.ACCEPT_JSON_PREDICATE.resolve(exchange)) - { - this.applicationJson(); - exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, this.contentType); - } - else if (ServerPredicates.ACCEPT_XML_PREDICATE.resolve(exchange)) - { - this.applicationXml(); - exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, this.contentType); - } - else if (ServerPredicates.ACCEPT_TEXT_PREDICATE.resolve(exchange)) - { - this.textPlain(); - exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, this.contentType); - } - } - - - - if (hasBody) - { - if (!this.hasIoCallback) - { - exchange.getResponseSender().send(this.body); - } - else - { - exchange.getResponseSender().send(this.body, this.ioCallback); - } - } - else if (hasEntity) - { - try - { - if (this.processXml) - { - exchange.getResponseSender().send(ByteBuffer.wrap(XML_MAPPER.writeValueAsBytes(this.entity))); - } - else - { - - exchange.getResponseSender().send(ByteBuffer.wrap(OBJECT_MAPPER.writeValueAsBytes(this.entity))); - } - - } catch (Exception e) - { - log.error(e.getMessage() + " for entity " + this.entity, e); - - throw new IllegalArgumentException(e); - } - - } - else - { - exchange.endExchange(); - } - - } - - /** - * Creates builder to build {@link ServerResponse}. - * - * @return created builder - */ - public static ServerResponse response(Class clazz) - { - return new ServerResponse(); - } - - public static ServerResponse response(ByteBuffer body) - { - return new ServerResponse().body(body); - } - - public static ServerResponse response(String body) - { - return new ServerResponse().body(body); - } - - public static ServerResponse response(T entity) - { - return new ServerResponse().entity(entity); - } - - @SuppressWarnings("rawtypes") - public static ServerResponse response() - { - return new ServerResponse(); - } + public ServerResponse ok() + { + this.status = StatusCodes.OK; + return this; + } + + public ServerResponse redirect(String location) + { + this.location = location; + this.status = StatusCodes.FOUND; + return this; + } + + public ServerResponse redirect(String location, int status) + { + this.location = location; + this.status = status; + return this; + } + + public ServerResponse redirectPermanently(String location) + { + this.location = location; + this.status = StatusCodes.MOVED_PERMANENTLY; + return this; + } + + public ServerResponse found() + { + this.status = StatusCodes.FOUND; + return this; + } + + + public ServerResponse accepted() + { + this.status = StatusCodes.ACCEPTED; + return this; + } + + public ServerResponse badRequest() + { + this.status = StatusCodes.BAD_REQUEST; + return this; + } + + public ServerResponse badRequest(Throwable t) + { + this.throwable = t; + return this.badRequest(); + } + + public ServerResponse badRequest(String message) + { + return this.errorMessage(message).badRequest(); + } + + public ServerResponse internalServerError() + { + this.status = StatusCodes.INTERNAL_SERVER_ERROR; + return this; + } + + public ServerResponse internalServerError(Throwable t) + { + this.throwable = t; + return this.internalServerError(); + } + + public ServerResponse internalServerError(String message) + { + return this.errorMessage(message).internalServerError(); + } + + public ServerResponse created() + { + this.status = StatusCodes.CREATED; + return this; + } + + public ServerResponse created(String location) + { + this.status = StatusCodes.CREATED; + this.location = location; + return this; + } + + public ServerResponse created(URI uri) + { + this.status = StatusCodes.CREATED; + this.location = uri.toString(); + return this; + } + + public ServerResponse notModified() + { + this.status = StatusCodes.NOT_MODIFIED; + return this; + } + + + public ServerResponse notFound() + { + this.status = StatusCodes.NOT_FOUND; + return this; + } + + public ServerResponse notFound(Throwable t) + { + this.throwable = t; + return this.notFound(); + } + + public ServerResponse notFound(String message) + { + return this.errorMessage(message).notFound(); + } + + + public ServerResponse forbidden() + { + this.status = StatusCodes.FORBIDDEN; + return this; + } + + public ServerResponse forbidden(Throwable t) + { + this.throwable = t; + return this.forbidden(); + } + + public ServerResponse forbidden(String message) + { + return this.errorMessage(message).forbidden(); + } + + public ServerResponse noContent() + { + this.status = StatusCodes.NO_CONTENT; + return this; + } + + public ServerResponse noContent(Throwable t) + { + this.throwable = t; + return this.noContent(); + } + + + public ServerResponse noContent(String message) + { + return this.errorMessage(message).noContent(); + } + + public ServerResponse serviceUnavailable() + { + this.status = StatusCodes.SERVICE_UNAVAILABLE; + return this; + } + + public ServerResponse serviceUnavailable(Throwable t) + { + this.throwable = t; + return this.serviceUnavailable(); + } + + + public ServerResponse serviceUnavailable(String message) + { + return this.errorMessage(message).serviceUnavailable(); + } + + public ServerResponse unauthorized() + { + this.status = StatusCodes.UNAUTHORIZED; + return this; + } + + public ServerResponse unauthorized(Throwable t) + { + this.throwable = t; + return this.unauthorized(); + } + + + public ServerResponse unauthorized(String message) + { + return this.errorMessage(message).unauthorized(); + } + + public ServerResponse errorMessage(String message) + { + this.throwable = new Throwable(message); + return this; + } + + public ServerResponse withIoCallback(IoCallback ioCallback) + { + this.ioCallback = ioCallback; + this.hasIoCallback = ioCallback == null; + return this; + } + + public void send(final HttpServerExchange exchange) throws RuntimeException + { + send(null, exchange); + } + + public void send(final HttpHandler handler, final HttpServerExchange exchange) throws RuntimeException + { + + final boolean hasBody = this.body != null; + final boolean hasEntity = this.entity != null; + final boolean hasError = this.throwable != null; + + exchange.setStatusCode(this.status); + + + if (hasError) { + exchange.putAttachment(DefaultResponseListener.EXCEPTION, throwable); + exchange.endExchange(); + return; + } + + if (this.location != null) { + exchange.getResponseHeaders().put(Headers.LOCATION, this.location); + } + + if (this.status == StatusCodes.FOUND || this.status == StatusCodes.MOVED_PERMANENTLY || this.status == StatusCodes.TEMPORARY_REDIRECT || this.status == StatusCodes.SEE_OTHER || this.status == StatusCodes.PERMANENT_REDIRECT) { + if ((this.status == StatusCodes.FOUND || this.status == StatusCodes.MOVED_PERMANENTLY) && (this.method != null)) { + exchange.setRequestMethod(this.method); + } + + exchange.endExchange(); + return; + } + + if (this.contentType != null) { + exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, this.contentType); + } + + + if (this.hasHeaders) { + long itr = this.headers.fastIterateNonEmpty(); + + while (itr != -1L) { + final HeaderValues values = this.headers.fiCurrent(itr); + + exchange.getResponseHeaders().putAll(values.getHeaderName(), values); + + itr = this.headers.fiNextNonEmpty(itr); + } + } + + if (this.hasCookies) { + exchange.getResponseCookies().putAll(this.cookies); + } else if (!this.processJson && !this.processXml) { + if (ServerPredicates.ACCEPT_JSON_PREDICATE.resolve(exchange)) { + this.applicationJson(); + exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, this.contentType); + } else if (ServerPredicates.ACCEPT_XML_PREDICATE.resolve(exchange)) { + this.applicationXml(); + exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, this.contentType); + } else if (ServerPredicates.ACCEPT_TEXT_PREDICATE.resolve(exchange)) { + this.textPlain(); + exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, this.contentType); + } + } + + + if (hasBody) { + if (!this.hasIoCallback) { + exchange.getResponseSender().send(this.body); + } else { + exchange.getResponseSender().send(this.body, this.ioCallback); + } + } else if (hasEntity) { + try { + if (this.processXml) { + exchange.getResponseSender().send(ByteBuffer.wrap(XML_MAPPER.writeValueAsBytes(this.entity))); + } else { + + exchange.getResponseSender().send(ByteBuffer.wrap(OBJECT_MAPPER.writeValueAsBytes(this.entity))); + } + + } catch (Exception e) { + log.error(e.getMessage() + " for entity " + this.entity, e); + + throw new IllegalArgumentException(e); + } + + } else { + exchange.endExchange(); + } + + } + + /** + * Creates builder to build {@link ServerResponse}. + * + * @return created builder + */ + public static ServerResponse response(Class clazz) + { + return new ServerResponse(); + } + + public static ServerResponse response(ByteBuffer body) + { + return new ServerResponse().body(body); + } + + public static ServerResponse response(String body) + { + return new ServerResponse().body(body); + } + + public static ServerResponse response(T entity) + { + return new ServerResponse().entity(entity); + } + + @SuppressWarnings("rawtypes") + public static ServerResponse response() + { + return new ServerResponse(); + } } diff --git a/core/src/main/java/io/sinistral/proteus/server/endpoints/EndpointInfo.java b/core/src/main/java/io/sinistral/proteus/server/endpoints/EndpointInfo.java index d0e71f9..94eae04 100644 --- a/core/src/main/java/io/sinistral/proteus/server/endpoints/EndpointInfo.java +++ b/core/src/main/java/io/sinistral/proteus/server/endpoints/EndpointInfo.java @@ -1,4 +1,3 @@ - /** * */ @@ -44,111 +43,96 @@ public static Builder builder() public int compareTo(EndpointInfo other) { - int result = this.pathTemplate.compareTo(other.pathTemplate); - - if(result != 0) - { - return result; - } - - result = this.controllerName.compareTo(other.controllerName); - - if(result != 0) - { - return result; - } - - result = this.controllerMethod.compareTo(other.controllerMethod); - - if(result != 0) - { - return result; - } - - return this.method.compareTo(other.method); - + int result = this.pathTemplate.compareTo(other.pathTemplate); + + if (result != 0) { + return result; + } + + result = this.controllerName.compareTo(other.controllerName); + + if (result != 0) { + return result; + } + + result = this.controllerMethod.compareTo(other.controllerMethod); + + if (result != 0) { + return result; + } + + return this.method.compareTo(other.method); + + } + + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((consumes == null) ? 0 : consumes.hashCode()); + result = prime * result + ((controllerMethod == null) ? 0 : controllerMethod.hashCode()); + result = prime * result + ((controllerName == null) ? 0 : controllerName.hashCode()); + result = prime * result + ((method == null) ? 0 : method.hashCode()); + result = prime * result + ((pathTemplate == null) ? 0 : pathTemplate.hashCode()); + result = prime * result + ((produces == null) ? 0 : produces.hashCode()); + return result; } - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((consumes == null) ? 0 : consumes.hashCode()); - result = prime * result + ((controllerMethod == null) ? 0 : controllerMethod.hashCode()); - result = prime * result + ((controllerName == null) ? 0 : controllerName.hashCode()); - result = prime * result + ((method == null) ? 0 : method.hashCode()); - result = prime * result + ((pathTemplate == null) ? 0 : pathTemplate.hashCode()); - result = prime * result + ((produces == null) ? 0 : produces.hashCode()); - return result; - } - - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - EndpointInfo other = (EndpointInfo) obj; - if (consumes == null) - { - if (other.consumes != null) - return false; - } - else if (!consumes.equals(other.consumes)) - return false; - if (controllerMethod == null) - { - if (other.controllerMethod != null) - return false; - } - else if (!controllerMethod.equals(other.controllerMethod)) - return false; - if (controllerName == null) - { - if (other.controllerName != null) - return false; - } - else if (!controllerName.equals(other.controllerName)) - return false; - if (method == null) - { - if (other.method != null) - return false; - } - else if (!method.equals(other.method)) - return false; - if (pathTemplate == null) - { - if (other.pathTemplate != null) - return false; - } - else if (!pathTemplate.equals(other.pathTemplate)) - return false; - if (produces == null) - { - if (other.produces != null) - return false; - } - else if (!produces.equals(other.produces)) - return false; - return true; - } - - @Override + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + EndpointInfo other = (EndpointInfo) obj; + if (consumes == null) { + if (other.consumes != null) + return false; + } else if (!consumes.equals(other.consumes)) + return false; + if (controllerMethod == null) { + if (other.controllerMethod != null) + return false; + } else if (!controllerMethod.equals(other.controllerMethod)) + return false; + if (controllerName == null) { + if (other.controllerName != null) + return false; + } else if (!controllerName.equals(other.controllerName)) + return false; + if (method == null) { + if (other.method != null) + return false; + } else if (!method.equals(other.method)) + return false; + if (pathTemplate == null) { + if (other.pathTemplate != null) + return false; + } else if (!pathTemplate.equals(other.pathTemplate)) + return false; + if (produces == null) { + if (other.produces != null) + return false; + } else if (!produces.equals(other.produces)) + return false; + return true; + } + + @Override public String toString() { return String.format("\t%-8s %-40s %-26s %-26s %s", - this.method, - this.pathTemplate, - "[" + this.consumes + "]", - "[" + this.produces + "]", - "(" + this.controllerName + "." + this.controllerMethod + ")"); + this.method, + this.pathTemplate, + "[" + this.consumes + "]", + "[" + this.produces + "]", + "(" + this.controllerName + "." + this.controllerMethod + ")"); } /** @@ -198,8 +182,7 @@ public void setControllerName(String controllerName) { this.controllerName = controllerName; - if (this.controllerName == null) - { + if (this.controllerName == null) { this.controllerName = ""; } } diff --git a/core/src/main/java/io/sinistral/proteus/server/exceptions/ServerException.java b/core/src/main/java/io/sinistral/proteus/server/exceptions/ServerException.java index ec41118..f98a5d0 100644 --- a/core/src/main/java/io/sinistral/proteus/server/exceptions/ServerException.java +++ b/core/src/main/java/io/sinistral/proteus/server/exceptions/ServerException.java @@ -1,4 +1,3 @@ - /** * */ @@ -16,7 +15,7 @@ public class ServerException extends Exception * */ private static final long serialVersionUID = 8360356916374374408L; - + private Integer status = 500; public ServerException(int status) diff --git a/core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java b/core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java index 002096e..36d5d18 100644 --- a/core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java +++ b/core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java @@ -51,14 +51,16 @@ * annotation (i.e. javax.ws.rs.GET) * @author jbauer */ -public class HandlerGenerator { +public class HandlerGenerator +{ static Logger log = LoggerFactory.getLogger(HandlerGenerator.class.getCanonicalName()); private static final Pattern TYPE_NAME_PATTERN = Pattern.compile("(java\\.util\\.[A-Za-z]+)<([^>]+)", Pattern.DOTALL | Pattern.UNIX_LINES); private static final Pattern CONCURRENT_TYPE_NAME_PATTERN = Pattern.compile("(java\\.util\\.concurrent\\.[A-Za-z]+)<([^>]+)", Pattern.DOTALL | Pattern.UNIX_LINES); - public enum StatementParameterType { + public enum StatementParameterType + { STRING, LITERAL, TYPE, RAW } @@ -94,7 +96,8 @@ public enum StatementParameterType { * @param controllerClass * the class handlers will be generated from this class */ - public HandlerGenerator(String packageName, Class controllerClass) { + public HandlerGenerator(String packageName, Class controllerClass) + { this.packageName = packageName; this.controllerClass = controllerClass; this.className = controllerClass.getSimpleName() + "RouteSupplier"; @@ -104,7 +107,8 @@ public HandlerGenerator(String packageName, Class controllerClass) { * Compiles the generated source into a new {@link Class} * @return a new {@code Supplier} class */ - public Class> compileClass() { + public Class> compileClass() + { try { this.generateRoutes(); @@ -121,7 +125,8 @@ public Class> compileClass() { /** * Generates the routing Java source code */ - protected void generateRoutes() { + protected void generateRoutes() + { try { // Optional typeLevelWrapAnnotation = Optional.ofNullable(controllerClass.getAnnotation(io.sinistral.proteus.annotations.Chain.class)); @@ -218,7 +223,8 @@ protected void generateRoutes() { } } - protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class clazz) { + protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class clazz) + { ClassName httpHandlerClass = ClassName.get("io.undertow.server", "HttpHandler"); String controllerName = clazz.getSimpleName().toLowerCase() + "Controller"; @@ -260,7 +266,8 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla if (handler.equals(TypeHandler.BeanListValueOfType) || handler.equals(TypeHandler.BeanListFromStringType) || handler.equals(TypeHandler.OptionalBeanListValueOfType) - || handler.equals(TypeHandler.OptionalBeanListFromStringType)) { + || handler.equals(TypeHandler.OptionalBeanListFromStringType)) + { parameterizedLiteralsNameMap.put(p.getParameterizedType(), HandlerGenerator.typeReferenceNameForParameterizedType(p.getParameterizedType())); } } @@ -467,7 +474,8 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla //The handler for these two inputs types is blocking, so we set the flag if (endpointInfo.getConsumes().contains(FormEncodedDataDefinition.APPLICATION_X_WWW_FORM_URLENCODED) - || endpointInfo.getConsumes().contains(MultiPartParserDefinition.MULTIPART_FORM_DATA)) { + || endpointInfo.getConsumes().contains(MultiPartParserDefinition.MULTIPART_FORM_DATA)) + { isBlocking = true; } @@ -482,7 +490,7 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla TypeSpec.Builder handlerClassBuilder = TypeSpec.anonymousClassBuilder("").addSuperinterface(httpHandlerClass); - /** + /** * @TODO * Rewrite with lambdas or method references. * @@ -504,7 +512,8 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla if (p.getParameterizedType().equals(ServerRequest.class) || p.getParameterizedType().equals(HttpServerExchange.class) - || p.getParameterizedType().equals(HttpHandler.class)) { + || p.getParameterizedType().equals(HttpHandler.class)) + { continue; } @@ -631,7 +640,8 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla } else if (t.equals(TypeHandler.QueryOptionalListFromStringType) || t.equals(TypeHandler.QueryOptionalListValueOfType) || t.equals(TypeHandler.QueryOptionalSetValueOfType) - || t.equals(TypeHandler.QueryOptionalSetFromStringType)) { + || t.equals(TypeHandler.QueryOptionalSetFromStringType)) + { ParameterizedType pType = (ParameterizedType) type; if (type instanceof ParameterizedType) { @@ -681,7 +691,8 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla if (!m.getReturnType().toString().equalsIgnoreCase("void")) { if (m.getReturnType().getTypeName().contains("java.util.concurrent.CompletionStage") - || m.getReturnType().getTypeName().contains("java.util.concurrent.CompletableFuture")) { + || m.getReturnType().getTypeName().contains("java.util.concurrent.CompletableFuture")) + { Type futureType = m.getGenericReturnType(); functionBlockBuilder.add("$T $L = $L.$L($L);", futureType, "response", controllerName, m.getName(), controllerMethodArgs); @@ -698,7 +709,8 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla methodBuilder.addStatement("$L.send(this,$L)", "response", "exchange"); } else if (m.getReturnType().getTypeName().contains("java.util.concurrent.CompletionStage") - || m.getReturnType().getTypeName().contains("java.util.concurrent.CompletableFuture")) { + || m.getReturnType().getTypeName().contains("java.util.concurrent.CompletableFuture")) + { String postProcess = "."; if (!producesContentType.contains(",")) { @@ -742,8 +754,7 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla } - if(isBlocking) - { + if (isBlocking) { methodBuilder.endControlFlow(); } @@ -772,23 +783,21 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla Annotation[] annotations = clazz.getAnnotations(); - Annotation securityRequirementAnnotation = Arrays.stream(annotations).filter( a -> a.getClass().getName().contains("SecurityRequirement") ).findFirst().orElse(null); + Annotation securityRequirementAnnotation = Arrays.stream(annotations).filter(a -> a.getClass().getName().contains("SecurityRequirement")).findFirst().orElse(null); if (securityRequirementAnnotation != null) { if (securityRequirementAnnotation != null) { - try - { + try { Field nameField = securityRequirementAnnotation.getClass().getField("name"); - if(nameField != null) { + if (nameField != null) { Object securityRequirement = nameField.get(securityRequirementAnnotation); securityDefinitions.add(securityRequirement.toString()); } - } catch( Exception e ) - { + } catch (Exception e) { log.warn("No name field on security requirement"); } @@ -862,7 +871,8 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla /** * @return the packageName */ - public String getPackageName() { + public String getPackageName() + { return packageName; } @@ -870,14 +880,16 @@ public String getPackageName() { * @param packageName * the packageName to set */ - public void setPackageName(String packageName) { + public void setPackageName(String packageName) + { this.packageName = packageName; } /** * @return the className */ - public String getClassName() { + public String getClassName() + { return className; } @@ -885,11 +897,13 @@ public String getClassName() { * @param className * the className to set */ - public void setClassName(String className) { + public void setClassName(String className) + { this.className = className; } - protected static ArrayList getClassNamesFromPackage(String packageName) throws Exception { + protected static ArrayList getClassNamesFromPackage(String packageName) throws Exception + { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); URL packageURL; ArrayList names = new ArrayList<>(); @@ -918,7 +932,8 @@ protected static ArrayList getClassNamesFromPackage(String packageName) return names; } - protected static Set> getApiClasses(String basePath, Predicate pathPredicate) { + protected static Set> getApiClasses(String basePath, Predicate pathPredicate) + { Reflections ref = new Reflections(basePath); Stream> stream = ref.getTypesAnnotatedWith(Path.class).stream(); @@ -938,7 +953,8 @@ protected static Set> getApiClasses(String basePath, Predicate } - protected static Type extractErasedType(Type type) { + protected static Type extractErasedType(Type type) + { String typeName = type.getTypeName(); Matcher matcher = TYPE_NAME_PATTERN.matcher(typeName); @@ -986,7 +1002,8 @@ protected static Type extractErasedType(Type type) { return null; } - protected static String typeReferenceNameForParameterizedType(Type type) { + protected static String typeReferenceNameForParameterizedType(Type type) + { String typeName = type.getTypeName(); @@ -1054,7 +1071,8 @@ protected static String typeReferenceNameForParameterizedType(Type type) { return typeName; } - protected static String typeReferenceNameForType(Type type) { + protected static String typeReferenceNameForType(Type type) + { String typeName = type.getTypeName(); String[] erasedParts = typeName.split("\\."); @@ -1072,7 +1090,8 @@ protected static String typeReferenceNameForType(Type type) { return typeName; } - protected static String generateFieldName(String name) { + protected static String generateFieldName(String name) + { String[] parts = name.split("\\."); StringBuilder sb = new StringBuilder(); @@ -1090,7 +1109,8 @@ protected static String generateFieldName(String name) { return sb.toString(); } - protected static void generateTypeReference(MethodSpec.Builder builder, Type type, String name) { + protected static void generateTypeReference(MethodSpec.Builder builder, Type type, String name) + { builder.addCode( CodeBlock @@ -1098,17 +1118,20 @@ protected static void generateTypeReference(MethodSpec.Builder builder, Type typ } - protected static void generateParameterReference(MethodSpec.Builder builder, Class clazz) { + protected static void generateParameterReference(MethodSpec.Builder builder, Class clazz) + { builder.addCode(CodeBlock.of("\n\nType $LType = $T.", clazz, clazz)); } - protected static boolean hasValueOfMethod(Class clazz) { + protected static boolean hasValueOfMethod(Class clazz) + { return Arrays.stream(clazz.getMethods()).anyMatch(m -> m.getName().equals("valueOf")); } - protected static boolean hasFromStringMethod(Class clazz) { + protected static boolean hasFromStringMethod(Class clazz) + { return Arrays.stream(clazz.getMethods()).anyMatch(m -> m.getName().equals("fromString")); } diff --git a/core/src/main/java/io/sinistral/proteus/server/handlers/ProteusHandler.java b/core/src/main/java/io/sinistral/proteus/server/handlers/ProteusHandler.java index 307ecd1..1fa2c23 100644 --- a/core/src/main/java/io/sinistral/proteus/server/handlers/ProteusHandler.java +++ b/core/src/main/java/io/sinistral/proteus/server/handlers/ProteusHandler.java @@ -1,27 +1,20 @@ - /** * */ package io.sinistral.proteus.server.handlers; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.CopyOnWriteArrayList; - import io.undertow.Handlers; import io.undertow.predicate.Predicate; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.server.handlers.ResponseCodeHandler; import io.undertow.server.handlers.cache.LRUCache; -import io.undertow.util.CopyOnWriteMap; -import io.undertow.util.HttpString; -import io.undertow.util.Methods; -import io.undertow.util.PathMatcher; -import io.undertow.util.PathTemplate; -import io.undertow.util.PathTemplateMatch; -import io.undertow.util.PathTemplateMatcher; +import io.undertow.util.*; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.CopyOnWriteArrayList; /** * @author jbauer @@ -61,12 +54,9 @@ public ProteusHandler(final HttpHandler defaultHandler) public ProteusHandler(int cacheSize) { - if (cacheSize > 0) - { + if (cacheSize > 0) { cache = new LRUCache<>(cacheSize, -1, true); - } - else - { + } else { cache = null; } } @@ -82,20 +72,17 @@ public synchronized ProteusHandler add(HttpString method, String template, HttpH { PathTemplateMatcher matcher = matches.get(method); - if (matcher == null) - { + if (matcher == null) { matches.put(method, matcher = new PathTemplateMatcher<>()); } RoutingMatch res = matcher.get(template); - if (res == null) - { + if (res == null) { matcher.add(template, res = new RoutingMatch()); } - if (allMethodsMatcher.get(template) == null) - { + if (allMethodsMatcher.get(template) == null) { allMethodsMatcher.add(template, res); } @@ -113,20 +100,17 @@ public synchronized ProteusHandler add(HttpString method, String template, Predi { PathTemplateMatcher matcher = matches.get(method); - if (matcher == null) - { + if (matcher == null) { matches.put(method, matcher = new PathTemplateMatcher<>()); } RoutingMatch res = matcher.get(template); - if (res == null) - { + if (res == null) { matcher.add(template, res = new RoutingMatch()); } - if (allMethodsMatcher.get(template) == null) - { + if (allMethodsMatcher.get(template) == null) { allMethodsMatcher.add(template, res); } @@ -142,13 +126,11 @@ public synchronized ProteusHandler add(final String method, final String templat public synchronized ProteusHandler addAll(ProteusHandler routingHandler) { - for (Entry> entry : routingHandler.getMatches().entrySet()) - { + for (Entry> entry : routingHandler.getMatches().entrySet()) { HttpString method = entry.getKey(); PathTemplateMatcher matcher = matches.get(method); - if (matcher == null) - { + if (matcher == null) { matches.put(method, matcher = new PathTemplateMatcher<>()); } @@ -156,10 +138,8 @@ public synchronized ProteusHandler addAll(ProteusHandler routingHandler) // If we use allMethodsMatcher.addAll() we can have duplicate // PathTemplates which we want to ignore here so it does not crash. - for (PathTemplate template : entry.getValue().getPathTemplates()) - { - if (allMethodsMatcher.get(template.getTemplateString()) == null) - { + for (PathTemplate template : entry.getValue().getPathTemplates()) { + if (allMethodsMatcher.get(template.getTemplateString()) == null) { allMethodsMatcher.add(template, new RoutingMatch()); } } @@ -227,8 +207,7 @@ public synchronized ProteusHandler delete(final String template, Predicate predi private void handleNoMatch(final HttpServerExchange exchange) throws Exception { // if invalidMethodHandler is null we fail fast without matching with allMethodsMatcher - if ((invalidMethodHandler != null) && (allMethodsMatcher.match(exchange.getRelativePath()) != null)) - { + if ((invalidMethodHandler != null) && (allMethodsMatcher.match(exchange.getRelativePath()) != null)) { invalidMethodHandler.handleRequest(exchange); return; @@ -243,38 +222,31 @@ public void handleRequest(HttpServerExchange exchange) throws Exception PathMatcher.PathMatch match = null; boolean hit = false; - if (cache != null) - { + if (cache != null) { match = cache.get(exchange.getRelativePath()); hit = true; } - if (match == null) - { + if (match == null) { match = pathMatcher.match(exchange.getRelativePath()); } - if (match.getValue() == null) - { + if (match.getValue() == null) { handleRouterRequest(exchange); return; } - if (hit) - { + if (hit) { cache.add(exchange.getRelativePath(), match); } exchange.setRelativePath(match.getRemaining()); - if (exchange.getResolvedPath().isEmpty()) - { + if (exchange.getResolvedPath().isEmpty()) { // first path handler, we can just use the matched part exchange.setResolvedPath(match.getMatched()); - } - else - { + } else { // already something in the resolved path String sb = exchange.getResolvedPath() + @@ -289,8 +261,7 @@ public void handleRouterRequest(HttpServerExchange exchange) throws Exception { PathTemplateMatcher matcher = matches.get(exchange.getRequestMethod()); - if (matcher == null) - { + if (matcher == null) { handleNoMatch(exchange); return; @@ -298,8 +269,7 @@ public void handleRouterRequest(HttpServerExchange exchange) throws Exception PathTemplateMatcher.PathMatchResult match = matcher.match(exchange.getRelativePath()); - if (match == null) - { + if (match == null) { handleNoMatch(exchange); return; @@ -307,27 +277,21 @@ public void handleRouterRequest(HttpServerExchange exchange) throws Exception exchange.putAttachment(PathTemplateMatch.ATTACHMENT_KEY, match); - for (Entry entry : match.getParameters().entrySet()) - { + for (Entry entry : match.getParameters().entrySet()) { exchange.addQueryParam(entry.getKey(), entry.getValue()); } - for (HandlerHolder handler : match.getValue().predicatedHandlers) - { - if (handler.predicate.resolve(exchange)) - { + for (HandlerHolder handler : match.getValue().predicatedHandlers) { + if (handler.predicate.resolve(exchange)) { handler.handler.handleRequest(exchange); return; } } - if (match.getValue().defaultHandler != null) - { + if (match.getValue().defaultHandler != null) { match.getValue().defaultHandler.handleRequest(exchange); - } - else - { + } else { fallbackHandler.handleRequest(exchange); } } @@ -378,8 +342,7 @@ public ProteusHandler remove(HttpString method, String path) { PathTemplateMatcher handler = matches.get(method); - if (handler != null) - { + if (handler != null) { handler.remove(path); } diff --git a/core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultHttpHandler.java b/core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultHttpHandler.java index ef7403b..7825f29 100644 --- a/core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultHttpHandler.java +++ b/core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultHttpHandler.java @@ -1,16 +1,10 @@ - /** * */ package io.sinistral.proteus.server.handlers; -import java.util.Map; -import java.util.stream.Collectors; - import com.google.inject.Inject; - import com.typesafe.config.Config; - import io.undertow.server.DefaultResponseListener; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; @@ -19,16 +13,19 @@ import io.undertow.util.HeaderValues; import io.undertow.util.HttpString; +import java.util.Map; +import java.util.stream.Collectors; + /** * @author jbauer */ public class ServerDefaultHttpHandler implements HttpHandler { protected final HeaderMap headers = new HeaderMap(); - + @Inject(optional = true) protected DefaultResponseListener defaultResponseListener; - + @Inject protected volatile RoutingHandler next; @@ -38,8 +35,7 @@ public ServerDefaultHttpHandler(Config config) Config globalHeaders = config.getConfig("globalHeaders"); Map globalHeaderParameters = globalHeaders.entrySet().stream().collect(Collectors.toMap(e -> HttpString.tryFromString(e.getKey()), e -> e.getValue().unwrapped() + "")); - for (Map.Entry e : globalHeaderParameters.entrySet()) - { + for (Map.Entry e : globalHeaderParameters.entrySet()) { headers.add(e.getKey(), e.getValue()); } } @@ -51,15 +47,13 @@ public ServerDefaultHttpHandler(Config config) @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { - if (this.defaultResponseListener != null) - { + if (this.defaultResponseListener != null) { exchange.addDefaultResponseListener(defaultResponseListener); } long fiGlobal = this.headers.fastIterateNonEmpty(); - while (fiGlobal != -1) - { + while (fiGlobal != -1) { final HeaderValues headerValues = headers.fiCurrent(fiGlobal); exchange.getResponseHeaders().addAll(headerValues.getHeaderName(), headerValues); diff --git a/core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java b/core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java index e5d8efd..ca2ab51 100644 --- a/core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java +++ b/core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java @@ -1,36 +1,29 @@ - /** * */ package io.sinistral.proteus.server.handlers; -import java.io.PrintWriter; -import java.io.StringWriter; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.ws.rs.core.MediaType; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper; - import com.google.inject.Inject; import com.google.inject.Singleton; - import io.sinistral.proteus.server.predicates.ServerPredicates; - import io.undertow.server.DefaultResponseListener; import io.undertow.server.HttpServerExchange; import io.undertow.util.Headers; import io.undertow.util.StatusCodes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.core.MediaType; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * @author jbauer @@ -40,31 +33,28 @@ public class ServerDefaultResponseListener implements DefaultResponseListener { private static Logger log = LoggerFactory.getLogger(ServerDefaultResponseListener.class.getCanonicalName()); - + @Inject protected XmlMapper xmlMapper; - + @Inject protected ObjectMapper objectMapper; @Override public boolean handleDefaultResponse(HttpServerExchange exchange) { - if (!exchange.isResponseChannelAvailable()) - { + if (!exchange.isResponseChannelAvailable()) { return false; } final int statusCode = exchange.getStatusCode(); - if (statusCode >= 400) - { + if (statusCode >= 400) { final Map errorMap = new HashMap<>(); final String path = exchange.getRelativePath(); Throwable throwable = exchange.getAttachment(DefaultResponseListener.EXCEPTION); - if (throwable == null) - { + if (throwable == null) { final String reason = StatusCodes.getReason(statusCode); throwable = new Exception(reason); @@ -74,13 +64,11 @@ public boolean handleDefaultResponse(HttpServerExchange exchange) errorMap.put("message", throwable.getMessage()); errorMap.put("path", path); errorMap.put("code", Integer.toString(statusCode)); - + log.error("\n\tmessage: " + throwable.getMessage() + "\n\tpath: " + path, throwable); - if (throwable.getStackTrace() != null) - { - if (throwable.getStackTrace().length > 0) - { + if (throwable.getStackTrace() != null) { + if (throwable.getStackTrace().length > 0) { errorMap.put("className", throwable.getStackTrace()[0].getClassName()); } @@ -98,13 +86,11 @@ public boolean handleDefaultResponse(HttpServerExchange exchange) } } - if (throwable instanceof IllegalArgumentException) - { + if (throwable instanceof IllegalArgumentException) { exchange.setStatusCode(StatusCodes.BAD_REQUEST); } - if (ServerPredicates.ACCEPT_XML_EXCLUSIVE_PREDICATE.resolve(exchange)) - { + if (ServerPredicates.ACCEPT_XML_EXCLUSIVE_PREDICATE.resolve(exchange)) { try { final String xmlBody = xmlMapper.writeValueAsString(errorMap); @@ -116,9 +102,7 @@ public boolean handleDefaultResponse(HttpServerExchange exchange) } catch (JsonProcessingException e) { log.warn("Unable to create XML from error..."); } - } - else - { + } else { String jsonBody; try { diff --git a/core/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java b/core/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java index 3f02e49..1b76a3d 100644 --- a/core/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java +++ b/core/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java @@ -1,4 +1,3 @@ - /** * */ @@ -6,12 +5,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper; - -import com.google.common.collect.ImmutableMap; import com.google.inject.Inject; - import io.sinistral.proteus.server.predicates.ServerPredicates; - import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.util.Headers; @@ -37,26 +32,19 @@ public void handleRequest(HttpServerExchange exchange) throws Exception final String responseBody; final String reason = StatusCodes.getReason(statusCode); - if (ServerPredicates.ACCEPT_JSON_PREDICATE.resolve(exchange)) - { + if (ServerPredicates.ACCEPT_JSON_PREDICATE.resolve(exchange)) { responseBody = objectMapper.writeValueAsString(new Message(statusCode, reason)); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, javax.ws.rs.core.MediaType.APPLICATION_JSON); - } - else if (ServerPredicates.ACCEPT_XML_PREDICATE.resolve(exchange)) - { + } else if (ServerPredicates.ACCEPT_XML_PREDICATE.resolve(exchange)) { responseBody = xmlMapper.writeValueAsString(new Message(statusCode, reason)); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, javax.ws.rs.core.MediaType.APPLICATION_XML); - } - else if (ServerPredicates.ACCEPT_HTML_PREDICATE.resolve(exchange)) - { + } else if (ServerPredicates.ACCEPT_HTML_PREDICATE.resolve(exchange)) { responseBody = "Error" + statusCode + " - " + reason + ""; exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, javax.ws.rs.core.MediaType.TEXT_HTML); - } - else - { + } else { responseBody = statusCode + " - " + reason; exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, javax.ws.rs.core.MediaType.TEXT_PLAIN); diff --git a/core/src/main/java/io/sinistral/proteus/server/handlers/TypeHandler.java b/core/src/main/java/io/sinistral/proteus/server/handlers/TypeHandler.java index 426d767..a9290d9 100644 --- a/core/src/main/java/io/sinistral/proteus/server/handlers/TypeHandler.java +++ b/core/src/main/java/io/sinistral/proteus/server/handlers/TypeHandler.java @@ -1,639 +1,483 @@ /** - * + * */ package io.sinistral.proteus.server.handlers; +import com.squareup.javapoet.MethodSpec; +import io.sinistral.proteus.server.handlers.HandlerGenerator.StatementParameterType; + +import javax.ws.rs.*; import java.lang.reflect.Parameter; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Arrays; import java.util.Optional; -import javax.ws.rs.BeanParam; -import javax.ws.rs.CookieParam; -import javax.ws.rs.FormParam; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; +/** + * Enum that assists in code generation for different method parameter types + */ -import com.squareup.javapoet.MethodSpec; -import io.sinistral.proteus.server.handlers.HandlerGenerator.StatementParameterType; +public enum TypeHandler +{ + + LongType("Long $L = $T.longValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + IntegerType("Integer $L = $T.integerValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + StringType("String $L = $T.string(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + BooleanType("Boolean $L = $T.booleanValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + FilePathType("$T $L = $T.filePath(exchange,$S)", true, java.nio.file.Path.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + AnyType("$T $L = $T.any(exchange)", true, com.fasterxml.jackson.databind.JsonNode.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class), + JsonNodeType("$T $L = $T.jsonNode(exchange)", true, com.fasterxml.jackson.databind.JsonNode.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class), + ModelType("$T $L = io.sinistral.proteus.server.Extractors.model(exchange,$L)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.LITERAL), + + // EnumType("$T $L = $T.enumValue(exchange,$T.class,$S)", true, + // StatementParameterType.TYPE, + // StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.class, + // StatementParameterType.TYPE, StatementParameterType.STRING), + + FileType("$T $L = $T.file(exchange,$S)", true, java.io.File.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + + ByteBufferType("$T $L = $T.byteBuffer(exchange,$S)", true, java.nio.ByteBuffer.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + DateType("$T $L = $T.date(exchange,$S)", false, java.util.Date.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + ZonedDateTimeType("$T $L = $T.zonedDateTime(exchange,$S)", false, java.time.ZonedDateTime.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + OffsetDateTimeType("$T $L = $T.offsetDateTime(exchange,$S)", false, java.time.OffsetDateTime.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + + InstantType("$T $L = $T.instant(exchange,$S)", false, java.time.Instant.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + + FloatType("Integer $L = $T.floatValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + DoubleType("Integer $L = $T.doubleValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + + ValueOfType("$T $L = $T.valueOf($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), + FromStringType("$T $L = $T.fromString($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - /** - * Enum that assists in code generation for different method parameter types - */ - - - public enum TypeHandler - { - - LongType("Long $L = $T.longValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - IntegerType("Integer $L = $T.integerValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - StringType("String $L = $T.string(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - BooleanType("Boolean $L = $T.booleanValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - FilePathType("$T $L = $T.filePath(exchange,$S)", true, java.nio.file.Path.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - AnyType("$T $L = $T.any(exchange)", true, com.fasterxml.jackson.databind.JsonNode.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class), - JsonNodeType("$T $L = $T.jsonNode(exchange)", true, com.fasterxml.jackson.databind.JsonNode.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class), - ModelType("$T $L = io.sinistral.proteus.server.Extractors.model(exchange,$L)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.LITERAL), - - // EnumType("$T $L = $T.enumValue(exchange,$T.class,$S)", true, - // StatementParameterType.TYPE, - // StatementParameterType.LITERAL,io.sinistral.proteus.server.Extractors.class, - // StatementParameterType.TYPE, StatementParameterType.STRING), - - FileType("$T $L = $T.file(exchange,$S)", true, java.io.File.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - - ByteBufferType("$T $L = $T.byteBuffer(exchange,$S)", true, java.nio.ByteBuffer.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - DateType("$T $L = $T.date(exchange,$S)", false, java.util.Date.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - ZonedDateTimeType("$T $L = $T.zonedDateTime(exchange,$S)", false, java.time.ZonedDateTime.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - OffsetDateTimeType("$T $L = $T.offsetDateTime(exchange,$S)", false, java.time.OffsetDateTime.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - - InstantType("$T $L = $T.instant(exchange,$S)", false, java.time.Instant.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - - FloatType("Integer $L = $T.floatValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - DoubleType("Integer $L = $T.doubleValue(exchange,$S)", false, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - - ValueOfType("$T $L = $T.valueOf($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - FromStringType("$T $L = $T.fromString($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.class, StatementParameterType.STRING), - - QueryListValueOfType("$T<$T> $L = exchange.getQueryParameters().get($S).stream().map($T::valueOf).collect(java.util.stream.Collectors.toList())", false, java.util.List.class, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), - QueryListFromStringType("$T<$T> $L = exchange.getQueryParameters().get($S).stream().map($T::fromString).collect(java.util.stream.Collectors.toList())", false, java.util.List.class, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), - - QuerySetValueOfType("$T<$T> $L = exchange.getQueryParameters().get($S).stream().map($T::valueOf).collect(java.util.stream.Collectors.toSet())", false, java.util.Set.class, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), - QuerySetFromStringType("$T<$T> $L = exchange.getQueryParameters().get($S).stream().map($T::fromString).collect(java.util.stream.Collectors.toSet())", false, java.util.Set.class, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), - - // BeanListValueOfType("$T<$T> $L = - // $T.string(exchange,$S).map($T::valueOf).collect(java.util.stream.Collectors.toList())", - // true, java.util.List.class, StatementParameterType.RAW, - // StatementParameterType.LITERAL, - // io.sinistral.proteus.server.Extractors.class, - // StatementParameterType.LITERAL, StatementParameterType.RAW), - BeanListValueOfType("$T $L = io.sinistral.proteus.server.Extractors.model(exchange,$L)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.LITERAL), - BeanListFromStringType("$T $L = io.sinistral.proteus.server.Extractors.model(exchange,$L)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.LITERAL), - - HeaderValueOfType("$T $L = $T.valueOf($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.Header.class, StatementParameterType.STRING), - HeaderFromStringType("$T $L = $T.fromString($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.Header.class, StatementParameterType.STRING), - HeaderStringType("$T $L = $T.string(exchange,$S)", false, String.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Header.class, StatementParameterType.STRING), - - OptionalHeaderValueOfType("$T<$T> $L = $T.string(exchange,$S).map($T::valueOf)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), - OptionalHeaderFromStringType("$T<$T> $L = $T.string(exchange,$S).map($T::fromString)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), - OptionalHeaderStringType("$T<$T> $L = $T.string(exchange,$S)", false, Optional.class, String.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING), - - QueryOptionalListValueOfType("$T $L = java.util.Optional.ofNullable(exchange.getQueryParameters().get($S)).map(java.util.Deque::stream).map( p -> p.map($T::valueOf).collect(java.util.stream.Collectors.toList()))", false, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), - QueryOptionalListFromStringType("$T $L = java.util.Optional.ofNullable(exchange.getQueryParameters().get($S)).map(java.util.Deque::stream).map( p -> p.map($T::fromString).collect(java.util.stream.Collectors.toList()))", false, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), - - QueryOptionalSetValueOfType("$T $L = java.util.Optional.ofNullable(exchange.getQueryParameters().get($S)).map(java.util.Deque::stream).map( p -> p.map($T::valueOf).collect(java.util.stream.Collectors.toSet()))", false, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), - QueryOptionalSetFromStringType("$T $L = java.util.Optional.ofNullable(exchange.getQueryParameters().get($S)).map(java.util.Deque::stream).map( p -> p.map($T::fromString).collect(java.util.stream.Collectors.toSet()))", false, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), - - OptionalBeanListValueOfType("java.util.Optional<$L> $L = $T.model(exchange,$L)", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.LITERAL), - OptionalBeanListFromStringType("java.util.Optional<$L> $L = $T.model(exchange,$L)", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.LITERAL), - - OptionalJsonNodeType("$T<$T> $L = $T.jsonNode(exchange)", true, Optional.class, com.fasterxml.jackson.databind.JsonNode.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class), - OptionalAnyType("$T<$T> $L = $T.any(exchange)", true, Optional.class, com.fasterxml.jackson.databind.JsonNode.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class), - OptionalStringType("$T $L = $T.string(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalLongType("$T $L = $T.longValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalIntegerType("$T $L = $T.integerValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalBooleanType("$T $L = $T.booleanValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalFilePathType("$T<$T> $L = $T.filePath(exchange,$S)", true, Optional.class, java.nio.file.Path.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - - OptionalByteBufferType("$T<$T> $L = $T.byteBuffer(exchange,$S)", true, Optional.class, java.nio.ByteBuffer.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - - OptionalFileType("$T<$T> $L = $T.file(exchange,$S)", true, Optional.class, java.io.File.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - - OptionalFloatType("$T $L = $T.floatValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalDoubleType("$T $L = $T.doubleValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - - OptionalDateType("$T<$T> $L = $T.date(exchange,$S)", false, Optional.class, java.util.Date.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalInstantType("$T<$T> $L = $T.instant(exchange,$S)", false, Optional.class, java.time.Instant.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalZonedDateTimeType("$T<$T> $L = $T.zonedDateTime(exchange,$S)", false, Optional.class, java.time.ZonedDateTime.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - OptionalOffsetDateTimeType("$T<$T> $L = $T.offsetDateTime(exchange,$S)", false, Optional.class, java.time.OffsetDateTime.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), - - OptionalModelType("java.util.Optional<$L> $L = $T.model(exchange,$L)", false, StatementParameterType.LITERAL, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.LITERAL), - - OptionalValueOfType("$T<$T> $L = $T.string(exchange,$S).map($T::valueOf)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), - OptionalFromStringType("$T<$T> $L = $T.string(exchange,$S).map($T::fromString)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), - - // OptionalEnumType("$T $L = $T.enumValue(exchange,$T.class,$S)", true, - // StatementParameterType.TYPE, StatementParameterType.LITERAL, - // io.sinistral.proteus.server.Extractors.Optional.class, - // StatementParameterType.RAW, StatementParameterType.STRING), - - ; - - public boolean isBlocking() - { - return this.isBlocking; - } - - public String statement() - { - return this.statement; - } - - /** - * The template statement for the - * {@link com.squareup.javapoet.MethodSpec.Builder} to use - */ - final String statement; - - /** - * If the TypeReference requires the - * {@link io.undertow.server.HttpHandler} to block - */ - final private boolean isBlocking; - - /** - * An {@code Object} array that is passed to the {@code statement} - */ - final private Object[] parameterTypes; - - TypeHandler(String statement, boolean isBlocking, Object... types) - { - this.statement = statement; - this.isBlocking = isBlocking; - this.parameterTypes = types; - } - - /** - * Helper function to bind values to a - * {@link com.squareup.javapoet.MethodSpec.Builder} - * @param builder - * @param parameter - * @param handler - * @throws Exception - */ - public static void addStatement(MethodSpec.Builder builder, Parameter parameter, TypeHandler handler) throws Exception - { - Object[] args = new Object[handler.parameterTypes.length]; - - - for (int i = 0; i < handler.parameterTypes.length; i++) - { - if (handler.parameterTypes[i] instanceof StatementParameterType) - { - String pName = parameter.getName(); - - if (parameter.isAnnotationPresent(QueryParam.class)) - { - QueryParam qp = parameter.getAnnotation(QueryParam.class); - pName = qp.value(); - } - else if (parameter.isAnnotationPresent(HeaderParam.class)) - { - HeaderParam hp = parameter.getAnnotation(HeaderParam.class); - pName = hp.value(); - } - else if (parameter.isAnnotationPresent(PathParam.class)) - { - PathParam pp = parameter.getAnnotation(PathParam.class); - pName = pp.value(); - } - else if (parameter.isAnnotationPresent(CookieParam.class)) - { - CookieParam cp = parameter.getAnnotation(CookieParam.class); - pName = cp.value(); - } - else if (parameter.isAnnotationPresent(FormParam.class)) - { - FormParam fp = parameter.getAnnotation(FormParam.class); - pName = fp.value(); - } - - StatementParameterType pType = (StatementParameterType) handler.parameterTypes[i]; - switch (pType) - { - case LITERAL: - args[i] = parameter.getName(); - break; - case STRING: - args[i] = pName; - break; - case TYPE: - args[i] = parameter.getParameterizedType(); - break; - case RAW: - { - Type type = parameter.getParameterizedType(); - type = HandlerGenerator.extractErasedType(type); - args[i] = type; - break; - } - default: - break; - } - } - else if (handler.parameterTypes[i] instanceof Class) - { - Class clazz = (Class) handler.parameterTypes[i]; - - args[i] = clazz; - - } - } - - if (handler.equals(BeanListValueOfType)) - { - HandlerGenerator.log.debug(parameter.getName() + " " + Arrays.toString(args) + " " + handler); - } - - builder.addStatement(handler.statement, args); - } - - /** - * Helper function to bind a {@link Parameter} to a - * {@link com.squareup.javapoet.MethodSpec.Builder} - * @param builder - * @param parameter - * @throws Exception - */ - public static void addStatement(MethodSpec.Builder builder, Parameter parameter) throws Exception - { - BeanParam beanParam = parameter.getAnnotation(BeanParam.class); - - boolean isBeanParameter = beanParam != null; - - TypeHandler handler = TypeHandler.forType(parameter.getParameterizedType(), isBeanParameter); + QueryListValueOfType("$T<$T> $L = exchange.getQueryParameters().get($S).stream().map($T::valueOf).collect(java.util.stream.Collectors.toList())", false, java.util.List.class, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), + QueryListFromStringType("$T<$T> $L = exchange.getQueryParameters().get($S).stream().map($T::fromString).collect(java.util.stream.Collectors.toList())", false, java.util.List.class, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), + + QuerySetValueOfType("$T<$T> $L = exchange.getQueryParameters().get($S).stream().map($T::valueOf).collect(java.util.stream.Collectors.toSet())", false, java.util.Set.class, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), + QuerySetFromStringType("$T<$T> $L = exchange.getQueryParameters().get($S).stream().map($T::fromString).collect(java.util.stream.Collectors.toSet())", false, java.util.Set.class, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), + + // BeanListValueOfType("$T<$T> $L = + // $T.string(exchange,$S).map($T::valueOf).collect(java.util.stream.Collectors.toList())", + // true, java.util.List.class, StatementParameterType.RAW, + // StatementParameterType.LITERAL, + // io.sinistral.proteus.server.Extractors.class, + // StatementParameterType.LITERAL, StatementParameterType.RAW), + BeanListValueOfType("$T $L = io.sinistral.proteus.server.Extractors.model(exchange,$L)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.LITERAL), + BeanListFromStringType("$T $L = io.sinistral.proteus.server.Extractors.model(exchange,$L)", true, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.LITERAL), + + HeaderValueOfType("$T $L = $T.valueOf($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.Header.class, StatementParameterType.STRING), + HeaderFromStringType("$T $L = $T.fromString($T.string(exchange,$S))", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, StatementParameterType.TYPE, io.sinistral.proteus.server.Extractors.Header.class, StatementParameterType.STRING), + HeaderStringType("$T $L = $T.string(exchange,$S)", false, String.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Header.class, StatementParameterType.STRING), + + OptionalHeaderValueOfType("$T<$T> $L = $T.string(exchange,$S).map($T::valueOf)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), + OptionalHeaderFromStringType("$T<$T> $L = $T.string(exchange,$S).map($T::fromString)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), + OptionalHeaderStringType("$T<$T> $L = $T.string(exchange,$S)", false, Optional.class, String.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Header.Optional.class, StatementParameterType.STRING), + + QueryOptionalListValueOfType("$T $L = java.util.Optional.ofNullable(exchange.getQueryParameters().get($S)).map(java.util.Deque::stream).map( p -> p.map($T::valueOf).collect(java.util.stream.Collectors.toList()))", false, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), + QueryOptionalListFromStringType("$T $L = java.util.Optional.ofNullable(exchange.getQueryParameters().get($S)).map(java.util.Deque::stream).map( p -> p.map($T::fromString).collect(java.util.stream.Collectors.toList()))", false, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), + + QueryOptionalSetValueOfType("$T $L = java.util.Optional.ofNullable(exchange.getQueryParameters().get($S)).map(java.util.Deque::stream).map( p -> p.map($T::valueOf).collect(java.util.stream.Collectors.toSet()))", false, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), + QueryOptionalSetFromStringType("$T $L = java.util.Optional.ofNullable(exchange.getQueryParameters().get($S)).map(java.util.Deque::stream).map( p -> p.map($T::fromString).collect(java.util.stream.Collectors.toSet()))", false, StatementParameterType.RAW, StatementParameterType.LITERAL, StatementParameterType.STRING, StatementParameterType.RAW), + + OptionalBeanListValueOfType("java.util.Optional<$L> $L = $T.model(exchange,$L)", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.LITERAL), + OptionalBeanListFromStringType("java.util.Optional<$L> $L = $T.model(exchange,$L)", false, StatementParameterType.TYPE, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.LITERAL), + + OptionalJsonNodeType("$T<$T> $L = $T.jsonNode(exchange)", true, Optional.class, com.fasterxml.jackson.databind.JsonNode.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class), + OptionalAnyType("$T<$T> $L = $T.any(exchange)", true, Optional.class, com.fasterxml.jackson.databind.JsonNode.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class), + OptionalStringType("$T $L = $T.string(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalLongType("$T $L = $T.longValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalIntegerType("$T $L = $T.integerValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalBooleanType("$T $L = $T.booleanValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalFilePathType("$T<$T> $L = $T.filePath(exchange,$S)", true, Optional.class, java.nio.file.Path.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + + OptionalByteBufferType("$T<$T> $L = $T.byteBuffer(exchange,$S)", true, Optional.class, java.nio.ByteBuffer.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + + OptionalFileType("$T<$T> $L = $T.file(exchange,$S)", true, Optional.class, java.io.File.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + + OptionalFloatType("$T $L = $T.floatValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalDoubleType("$T $L = $T.doubleValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + + OptionalDateType("$T<$T> $L = $T.date(exchange,$S)", false, Optional.class, java.util.Date.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalInstantType("$T<$T> $L = $T.instant(exchange,$S)", false, Optional.class, java.time.Instant.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalZonedDateTimeType("$T<$T> $L = $T.zonedDateTime(exchange,$S)", false, Optional.class, java.time.ZonedDateTime.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + OptionalOffsetDateTimeType("$T<$T> $L = $T.offsetDateTime(exchange,$S)", false, Optional.class, java.time.OffsetDateTime.class, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING), + + OptionalModelType("java.util.Optional<$L> $L = $T.model(exchange,$L)", false, StatementParameterType.LITERAL, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.LITERAL), + + OptionalValueOfType("$T<$T> $L = $T.string(exchange,$S).map($T::valueOf)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), + OptionalFromStringType("$T<$T> $L = $T.string(exchange,$S).map($T::fromString)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL, io.sinistral.proteus.server.Extractors.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW), + + // OptionalEnumType("$T $L = $T.enumValue(exchange,$T.class,$S)", true, + // StatementParameterType.TYPE, StatementParameterType.LITERAL, + // io.sinistral.proteus.server.Extractors.Optional.class, + // StatementParameterType.RAW, StatementParameterType.STRING), + + ; + + public boolean isBlocking() + { + return this.isBlocking; + } + + public String statement() + { + return this.statement; + } + + /** + * The template statement for the + * {@link com.squareup.javapoet.MethodSpec.Builder} to use + */ + final String statement; + + /** + * If the TypeReference requires the + * {@link io.undertow.server.HttpHandler} to block + */ + final private boolean isBlocking; + + /** + * An {@code Object} array that is passed to the {@code statement} + */ + final private Object[] parameterTypes; + + TypeHandler(String statement, boolean isBlocking, Object... types) + { + this.statement = statement; + this.isBlocking = isBlocking; + this.parameterTypes = types; + } + + /** + * Helper function to bind values to a + * {@link com.squareup.javapoet.MethodSpec.Builder} + * @param builder + * @param parameter + * @param handler + * @throws Exception + */ + public static void addStatement(MethodSpec.Builder builder, Parameter parameter, TypeHandler handler) throws Exception + { + Object[] args = new Object[handler.parameterTypes.length]; + + + for (int i = 0; i < handler.parameterTypes.length; i++) { + if (handler.parameterTypes[i] instanceof StatementParameterType) { + String pName = parameter.getName(); + + if (parameter.isAnnotationPresent(QueryParam.class)) { + QueryParam qp = parameter.getAnnotation(QueryParam.class); + pName = qp.value(); + } else if (parameter.isAnnotationPresent(HeaderParam.class)) { + HeaderParam hp = parameter.getAnnotation(HeaderParam.class); + pName = hp.value(); + } else if (parameter.isAnnotationPresent(PathParam.class)) { + PathParam pp = parameter.getAnnotation(PathParam.class); + pName = pp.value(); + } else if (parameter.isAnnotationPresent(CookieParam.class)) { + CookieParam cp = parameter.getAnnotation(CookieParam.class); + pName = cp.value(); + } else if (parameter.isAnnotationPresent(FormParam.class)) { + FormParam fp = parameter.getAnnotation(FormParam.class); + pName = fp.value(); + } + + StatementParameterType pType = (StatementParameterType) handler.parameterTypes[i]; + switch (pType) { + case LITERAL: + args[i] = parameter.getName(); + break; + case STRING: + args[i] = pName; + break; + case TYPE: + args[i] = parameter.getParameterizedType(); + break; + case RAW: { + Type type = parameter.getParameterizedType(); + type = HandlerGenerator.extractErasedType(type); + args[i] = type; + break; + } + default: + break; + } + } else if (handler.parameterTypes[i] instanceof Class) { + Class clazz = (Class) handler.parameterTypes[i]; + + args[i] = clazz; + + } + } + + if (handler.equals(BeanListValueOfType)) { + HandlerGenerator.log.debug(parameter.getName() + " " + Arrays.toString(args) + " " + handler); + } + + builder.addStatement(handler.statement, args); + } + + /** + * Helper function to bind a {@link Parameter} to a + * {@link com.squareup.javapoet.MethodSpec.Builder} + * @param builder + * @param parameter + * @throws Exception + */ + public static void addStatement(MethodSpec.Builder builder, Parameter parameter) throws Exception + { + BeanParam beanParam = parameter.getAnnotation(BeanParam.class); + + boolean isBeanParameter = beanParam != null; + + TypeHandler handler = TypeHandler.forType(parameter.getParameterizedType(), isBeanParameter); // if(handler.equals(TypeHandler.ModelType)) // { // HandlerGenerator.log.warn("found modeltype for " + parameter.getParameterizedType()); // } - addStatement(builder, parameter, handler); - - } - - public static TypeHandler forType(Type type) - { - return forType(type, false); - } - - /** - * Lookup the TypeHandler for a {@link Type} - */ - public static TypeHandler forType(Type type, Boolean isBeanParam) - { - - boolean hasValueOf = false; - boolean hasFromString = false; - boolean isOptional = type.getTypeName().contains("java.util.Optional"); - boolean isArray = type.getTypeName().contains("java.util.List"); - boolean isSet = type.getTypeName().contains("java.util.Set"); - boolean isMap = type.getTypeName().contains("java.util.Map"); - - if (!isOptional && !isArray && !isSet) - { - try - { - Class clazz = Class.forName(type.getTypeName()); - - hasValueOf = HandlerGenerator.hasValueOfMethod(clazz); - - hasFromString = HandlerGenerator.hasFromStringMethod(clazz); - - } catch (Exception e) - { - HandlerGenerator.log.error(e.getMessage(), e); - } - } - - if (isArray && !isOptional) - { - try - { - Class erasedType = (Class) HandlerGenerator.extractErasedType(type); - - if (HandlerGenerator.hasValueOfMethod(erasedType)) - { - if (!isBeanParam) - { - return QueryListValueOfType; - - } - else - { - return BeanListValueOfType; - } - } - else if (HandlerGenerator.hasFromStringMethod(erasedType)) - { - if (!isBeanParam) - { - return QueryListFromStringType; - - } - else - { - return BeanListFromStringType; - } - } - else - { - return ModelType; - } - - } catch (Exception e) - { - HandlerGenerator.log.error(e.getMessage(), e); - - } - } - if (isSet && !isOptional) - { - try - { - Class erasedType = (Class) HandlerGenerator.extractErasedType(type); - - if (HandlerGenerator.hasValueOfMethod(erasedType)) - { - if (!isBeanParam) - { - return QuerySetValueOfType; - - } - else - { - return BeanListValueOfType; - } - } - else if (HandlerGenerator.hasFromStringMethod(erasedType)) - { - if (!isBeanParam) - { - return QuerySetFromStringType; - - } - else - { - return BeanListFromStringType; - } - } - else - { - return ModelType; - } - - } catch (Exception e) - { - HandlerGenerator.log.error(e.getMessage(), e); - - } - } - else if (isArray && isOptional) - { - try - { - - if (type instanceof ParameterizedType) - { - ParameterizedType pType = (ParameterizedType) type; - type = pType.getActualTypeArguments()[0]; - } - - Class erasedType = (Class) HandlerGenerator.extractErasedType(type); - - if (HandlerGenerator.hasValueOfMethod(erasedType)) - { - if (!isBeanParam) - { - return QueryOptionalListValueOfType; - - } - else - { - return OptionalBeanListValueOfType; - } - - } - else if (HandlerGenerator.hasFromStringMethod(erasedType)) - { - if (!isBeanParam) - { - return QueryOptionalListFromStringType; - - } - else - { - return OptionalBeanListFromStringType; - } - } - else - { - return ModelType; - } - - } catch (Exception e) - { - HandlerGenerator.log.error(e.getMessage(), e); - - } - } - else if (isSet && isOptional) - { - try - { - - if (type instanceof ParameterizedType) - { - ParameterizedType pType = (ParameterizedType) type; - type = pType.getActualTypeArguments()[0]; - } - - Class erasedType = (Class) HandlerGenerator.extractErasedType(type); - - if (HandlerGenerator.hasValueOfMethod(erasedType)) - { - if (!isBeanParam) - { - return QueryOptionalSetValueOfType; - - } - else - { - return OptionalBeanListValueOfType; - } - - } - else if (HandlerGenerator.hasFromStringMethod(erasedType)) - { - if (!isBeanParam) - { - return QueryOptionalSetFromStringType; - - } - else - { - return OptionalBeanListFromStringType; - } - } - else - { - return ModelType; - } - - } catch (Exception e) - { - HandlerGenerator.log.error(e.getMessage(), e); - - } - } - - // log.debug("type: " + type.getTypeName() + " valueOf: " + - // hasValueOf + " fromString: " + hasFromString); - - if (type.equals(Long.class)) - { - return LongType; - } - else if (type.equals(Integer.class)) - { - return IntegerType; - } - else if (type.equals(Float.class)) - { - return FloatType; - } - else if (type.equals(Double.class)) - { - return DoubleType; - } - else if (type.equals(java.nio.ByteBuffer.class)) - { - return ByteBufferType; - } - else if (type.equals(Boolean.class)) - { - return BooleanType; - } - else if (type.equals(String.class)) - { - return StringType; - } - else if (type.equals(java.nio.file.Path.class)) - { - return FilePathType; - } - else if (type.equals(java.io.File.class)) - { - return FileType; - } - else if (type.equals(java.time.Instant.class)) - { - return InstantType; - } - else if (type.equals(java.util.Date.class)) - { - return DateType; - } - else if (type.equals(java.time.ZonedDateTime.class)) - { - return ZonedDateTimeType; - } - else if (type.equals(java.time.OffsetDateTime.class)) - { - return OffsetDateTimeType; - } - else if (type.equals(com.fasterxml.jackson.databind.JsonNode.class)) - { - return AnyType; - } - else if (type.equals(com.fasterxml.jackson.databind.JsonNode.class)) - { - return JsonNodeType; - } - else if (isOptional) - { - if (type.getTypeName().contains("java.lang.Long")) - { - return OptionalLongType; - } - else if (type.getTypeName().contains("java.lang.String")) - { - return OptionalStringType; - } - else if (type.getTypeName().contains("java.util.Date")) - { - return OptionalDateType; - } - else if (type.getTypeName().contains("java.time.OffsetDateTime")) - { - return OptionalOffsetDateTimeType; - } - else if (type.getTypeName().contains("java.time.Instant")) - { - return OptionalInstantType; - } - else if (type.getTypeName().contains("java.time.ZonedDateTime")) - { - return ZonedDateTimeType; - } - else if (type.getTypeName().contains("java.lang.Boolean")) - { - return OptionalBooleanType; - } - else if (type.getTypeName().contains("java.lang.Float")) - { - return OptionalFloatType; - } - else if (type.getTypeName().contains("java.lang.Double")) - { - return OptionalDoubleType; - } - else if (type.getTypeName().contains("java.lang.Integer")) - { - return OptionalIntegerType; - } - else if (type.getTypeName().contains("java.nio.file.Path")) - { - return OptionalFilePathType; - } - else if (type.getTypeName().contains("java.nio.ByteBuffer")) - { - return OptionalByteBufferType; - } - else if (type.getTypeName().contains("java.io.File")) - { - return OptionalFileType; - } - else - { - try - { - - Class erasedType = (Class) HandlerGenerator.extractErasedType(type); - - if (HandlerGenerator.hasValueOfMethod(erasedType)) - { - return OptionalValueOfType; - - } - else if (HandlerGenerator.hasFromStringMethod(erasedType)) - { - return OptionalFromStringType; - - } - - } catch (Exception e) - { - HandlerGenerator.log.error("error : " + e.getMessage(), e); - return OptionalStringType; - } - - return OptionalStringType; - } - } - - else if (hasValueOf) - { - return ValueOfType; - } - else if (hasFromString) - { - return FromStringType; - } - else - { - return ModelType; - } - } - } \ No newline at end of file + addStatement(builder, parameter, handler); + + } + + public static TypeHandler forType(Type type) + { + return forType(type, false); + } + + /** + * Lookup the TypeHandler for a {@link Type} + */ + public static TypeHandler forType(Type type, Boolean isBeanParam) + { + + boolean hasValueOf = false; + boolean hasFromString = false; + boolean isOptional = type.getTypeName().contains("java.util.Optional"); + boolean isArray = type.getTypeName().contains("java.util.List"); + boolean isSet = type.getTypeName().contains("java.util.Set"); + boolean isMap = type.getTypeName().contains("java.util.Map"); + + if (!isOptional && !isArray && !isSet) { + try { + Class clazz = Class.forName(type.getTypeName()); + + hasValueOf = HandlerGenerator.hasValueOfMethod(clazz); + + hasFromString = HandlerGenerator.hasFromStringMethod(clazz); + + } catch (Exception e) { + HandlerGenerator.log.error(e.getMessage(), e); + } + } + + if (isArray && !isOptional) { + try { + Class erasedType = (Class) HandlerGenerator.extractErasedType(type); + + if (HandlerGenerator.hasValueOfMethod(erasedType)) { + if (!isBeanParam) { + return QueryListValueOfType; + + } else { + return BeanListValueOfType; + } + } else if (HandlerGenerator.hasFromStringMethod(erasedType)) { + if (!isBeanParam) { + return QueryListFromStringType; + + } else { + return BeanListFromStringType; + } + } else { + return ModelType; + } + + } catch (Exception e) { + HandlerGenerator.log.error(e.getMessage(), e); + + } + } + if (isSet && !isOptional) { + try { + Class erasedType = (Class) HandlerGenerator.extractErasedType(type); + + if (HandlerGenerator.hasValueOfMethod(erasedType)) { + if (!isBeanParam) { + return QuerySetValueOfType; + + } else { + return BeanListValueOfType; + } + } else if (HandlerGenerator.hasFromStringMethod(erasedType)) { + if (!isBeanParam) { + return QuerySetFromStringType; + + } else { + return BeanListFromStringType; + } + } else { + return ModelType; + } + + } catch (Exception e) { + HandlerGenerator.log.error(e.getMessage(), e); + + } + } else if (isArray && isOptional) { + try { + + if (type instanceof ParameterizedType) { + ParameterizedType pType = (ParameterizedType) type; + type = pType.getActualTypeArguments()[0]; + } + + Class erasedType = (Class) HandlerGenerator.extractErasedType(type); + + if (HandlerGenerator.hasValueOfMethod(erasedType)) { + if (!isBeanParam) { + return QueryOptionalListValueOfType; + + } else { + return OptionalBeanListValueOfType; + } + + } else if (HandlerGenerator.hasFromStringMethod(erasedType)) { + if (!isBeanParam) { + return QueryOptionalListFromStringType; + + } else { + return OptionalBeanListFromStringType; + } + } else { + return ModelType; + } + + } catch (Exception e) { + HandlerGenerator.log.error(e.getMessage(), e); + + } + } else if (isSet && isOptional) { + try { + + if (type instanceof ParameterizedType) { + ParameterizedType pType = (ParameterizedType) type; + type = pType.getActualTypeArguments()[0]; + } + + Class erasedType = (Class) HandlerGenerator.extractErasedType(type); + + if (HandlerGenerator.hasValueOfMethod(erasedType)) { + if (!isBeanParam) { + return QueryOptionalSetValueOfType; + + } else { + return OptionalBeanListValueOfType; + } + + } else if (HandlerGenerator.hasFromStringMethod(erasedType)) { + if (!isBeanParam) { + return QueryOptionalSetFromStringType; + + } else { + return OptionalBeanListFromStringType; + } + } else { + return ModelType; + } + + } catch (Exception e) { + HandlerGenerator.log.error(e.getMessage(), e); + + } + } + + // log.debug("type: " + type.getTypeName() + " valueOf: " + + // hasValueOf + " fromString: " + hasFromString); + + if (type.equals(Long.class)) { + return LongType; + } else if (type.equals(Integer.class)) { + return IntegerType; + } else if (type.equals(Float.class)) { + return FloatType; + } else if (type.equals(Double.class)) { + return DoubleType; + } else if (type.equals(java.nio.ByteBuffer.class)) { + return ByteBufferType; + } else if (type.equals(Boolean.class)) { + return BooleanType; + } else if (type.equals(String.class)) { + return StringType; + } else if (type.equals(java.nio.file.Path.class)) { + return FilePathType; + } else if (type.equals(java.io.File.class)) { + return FileType; + } else if (type.equals(java.time.Instant.class)) { + return InstantType; + } else if (type.equals(java.util.Date.class)) { + return DateType; + } else if (type.equals(java.time.ZonedDateTime.class)) { + return ZonedDateTimeType; + } else if (type.equals(java.time.OffsetDateTime.class)) { + return OffsetDateTimeType; + } else if (type.equals(com.fasterxml.jackson.databind.JsonNode.class)) { + return AnyType; + } else if (type.equals(com.fasterxml.jackson.databind.JsonNode.class)) { + return JsonNodeType; + } else if (isOptional) { + if (type.getTypeName().contains("java.lang.Long")) { + return OptionalLongType; + } else if (type.getTypeName().contains("java.lang.String")) { + return OptionalStringType; + } else if (type.getTypeName().contains("java.util.Date")) { + return OptionalDateType; + } else if (type.getTypeName().contains("java.time.OffsetDateTime")) { + return OptionalOffsetDateTimeType; + } else if (type.getTypeName().contains("java.time.Instant")) { + return OptionalInstantType; + } else if (type.getTypeName().contains("java.time.ZonedDateTime")) { + return ZonedDateTimeType; + } else if (type.getTypeName().contains("java.lang.Boolean")) { + return OptionalBooleanType; + } else if (type.getTypeName().contains("java.lang.Float")) { + return OptionalFloatType; + } else if (type.getTypeName().contains("java.lang.Double")) { + return OptionalDoubleType; + } else if (type.getTypeName().contains("java.lang.Integer")) { + return OptionalIntegerType; + } else if (type.getTypeName().contains("java.nio.file.Path")) { + return OptionalFilePathType; + } else if (type.getTypeName().contains("java.nio.ByteBuffer")) { + return OptionalByteBufferType; + } else if (type.getTypeName().contains("java.io.File")) { + return OptionalFileType; + } else { + try { + + Class erasedType = (Class) HandlerGenerator.extractErasedType(type); + + if (HandlerGenerator.hasValueOfMethod(erasedType)) { + return OptionalValueOfType; + + } else if (HandlerGenerator.hasFromStringMethod(erasedType)) { + return OptionalFromStringType; + + } + + } catch (Exception e) { + HandlerGenerator.log.error("error : " + e.getMessage(), e); + return OptionalStringType; + } + + return OptionalStringType; + } + } else if (hasValueOf) { + return ValueOfType; + } else if (hasFromString) { + return FromStringType; + } else { + return ModelType; + } + } +} \ No newline at end of file diff --git a/core/src/main/java/io/sinistral/proteus/server/predicates/MaxRequestContentLengthPredicate.java b/core/src/main/java/io/sinistral/proteus/server/predicates/MaxRequestContentLengthPredicate.java index 1c28d23..25821a1 100644 --- a/core/src/main/java/io/sinistral/proteus/server/predicates/MaxRequestContentLengthPredicate.java +++ b/core/src/main/java/io/sinistral/proteus/server/predicates/MaxRequestContentLengthPredicate.java @@ -1,18 +1,17 @@ - /** * */ package io.sinistral.proteus.server.predicates; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - import io.undertow.predicate.Predicate; import io.undertow.predicate.PredicateBuilder; import io.undertow.server.HttpServerExchange; import io.undertow.util.Headers; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + /** * @author jbauer * @@ -31,8 +30,7 @@ public boolean resolve(final HttpServerExchange value) { final String length = value.getRequestHeaders().getFirst(Headers.CONTENT_LENGTH); - if (length == null) - { + if (length == null) { return false; } diff --git a/core/src/main/java/io/sinistral/proteus/server/predicates/ServerPredicates.java b/core/src/main/java/io/sinistral/proteus/server/predicates/ServerPredicates.java index 787966c..ece2a1a 100644 --- a/core/src/main/java/io/sinistral/proteus/server/predicates/ServerPredicates.java +++ b/core/src/main/java/io/sinistral/proteus/server/predicates/ServerPredicates.java @@ -1,13 +1,9 @@ - /** * */ package io.sinistral.proteus.server.predicates; -import java.util.Collections; - import io.sinistral.proteus.server.MediaType; - import io.undertow.attribute.ExchangeAttributes; import io.undertow.predicate.Predicate; import io.undertow.predicate.Predicates; @@ -15,6 +11,8 @@ import io.undertow.server.handlers.form.MultiPartParserDefinition; import io.undertow.util.Headers; +import java.util.Collections; + /** * @author jbauer * @@ -38,8 +36,8 @@ public class ServerPredicates public static final Predicate MAX_CONTENT_SIZE_PREDICATE = new MaxRequestContentLengthPredicate.Builder().build(Collections.singletonMap("value", 0L)); public static final Predicate STRING_BODY_PREDICATE = Predicates.and(Predicates.or(JSON_PREDICATE, XML_PREDICATE), MAX_CONTENT_SIZE_PREDICATE); public static final Predicate MULTIPART_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE), - MediaType.APPLICATION_OCTET_STREAM.contentType(), - MultiPartParserDefinition.MULTIPART_FORM_DATA); + MediaType.APPLICATION_OCTET_STREAM.contentType(), + MultiPartParserDefinition.MULTIPART_FORM_DATA); public static final Predicate URL_ENCODED_FORM_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE), FormEncodedDataDefinition.APPLICATION_X_WWW_FORM_URLENCODED); } diff --git a/core/src/main/java/io/sinistral/proteus/server/security/MapIdentityManager.java b/core/src/main/java/io/sinistral/proteus/server/security/MapIdentityManager.java index e786f96..78fd286 100644 --- a/core/src/main/java/io/sinistral/proteus/server/security/MapIdentityManager.java +++ b/core/src/main/java/io/sinistral/proteus/server/security/MapIdentityManager.java @@ -1,21 +1,19 @@ - /** * */ package io.sinistral.proteus.server.security; -import java.security.Principal; +import io.undertow.security.idm.Account; +import io.undertow.security.idm.Credential; +import io.undertow.security.idm.IdentityManager; +import io.undertow.security.idm.PasswordCredential; +import java.security.Principal; import java.util.Arrays; import java.util.Collections; import java.util.Map; import java.util.Set; -import io.undertow.security.idm.Account; -import io.undertow.security.idm.Credential; -import io.undertow.security.idm.IdentityManager; -import io.undertow.security.idm.PasswordCredential; - /** * @author jbauer */ @@ -47,8 +45,7 @@ public Account verify(String id, Credential credential) { Account account = getAccount(id); - if ((account != null) && verifyCredential(account, credential)) - { + if ((account != null) && verifyCredential(account, credential)) { return account; } @@ -57,8 +54,7 @@ public Account verify(String id, Credential credential) private boolean verifyCredential(Account account, Credential credential) { - if (credential instanceof PasswordCredential) - { + if (credential instanceof PasswordCredential) { char[] password = ((PasswordCredential) credential).getPassword(); char[] expectedPassword = identities.get(account.getPrincipal().getName()); @@ -70,8 +66,7 @@ private boolean verifyCredential(Account account, Credential credential) private Account getAccount(final String id) { - if (identities.containsKey(id)) - { + if (identities.containsKey(id)) { return new UserAccount(id); } diff --git a/core/src/main/java/io/sinistral/proteus/services/AssetsService.java b/core/src/main/java/io/sinistral/proteus/services/AssetsService.java index 3dbdcbb..a15cde8 100644 --- a/core/src/main/java/io/sinistral/proteus/services/AssetsService.java +++ b/core/src/main/java/io/sinistral/proteus/services/AssetsService.java @@ -1,25 +1,22 @@ package io.sinistral.proteus.services; -import java.nio.file.Paths; - -import java.util.Set; -import java.util.function.Supplier; - import com.google.inject.Inject; import com.google.inject.name.Named; - import com.typesafe.config.Config; - import io.sinistral.proteus.server.endpoints.EndpointInfo; - import io.undertow.predicate.TruePredicate; import io.undertow.server.RoutingHandler; import io.undertow.server.handlers.resource.FileResourceManager; import io.undertow.server.handlers.resource.ResourceHandler; import io.undertow.util.Methods; +import java.nio.file.Paths; +import java.util.Set; +import java.util.function.Supplier; + /** * A service for serving static assets from a directory. + * * @author jbauer */ public class AssetsService extends BaseService implements Supplier @@ -56,19 +53,19 @@ public RoutingHandler get() final FileResourceManager fileResourceManager = new FileResourceManager(Paths.get(assetsDirectoryName).toFile()); router.add(Methods.GET, - assetsPath + "/*", - io.undertow.Handlers.rewrite("regex('" + assetsPath + "/(.*)')", - "/$1", - getClass().getClassLoader(), - new ResourceHandler(fileResourceManager).setCachable(TruePredicate.instance()).setCacheTime(assetsCacheTime))); - + assetsPath + "/*", + io.undertow.Handlers.rewrite("regex('" + assetsPath + "/(.*)')", + "/$1", + getClass().getClassLoader(), + new ResourceHandler(fileResourceManager).setCachable(TruePredicate.instance()).setCacheTime(assetsCacheTime))); + this.registeredEndpoints.add(EndpointInfo.builder() - .withConsumes("*/*") - .withProduces("*/*") - .withPathTemplate(assetsPath) - .withControllerName(this.getClass().getSimpleName()) - .withMethod(Methods.GET) - .build()); + .withConsumes("*/*") + .withProduces("*/*") + .withPathTemplate(assetsPath) + .withControllerName(this.getClass().getSimpleName()) + .withMethod(Methods.GET) + .build()); return router; } diff --git a/core/src/main/java/io/sinistral/proteus/services/BaseService.java b/core/src/main/java/io/sinistral/proteus/services/BaseService.java index 6481e94..7f98cf0 100644 --- a/core/src/main/java/io/sinistral/proteus/services/BaseService.java +++ b/core/src/main/java/io/sinistral/proteus/services/BaseService.java @@ -1,19 +1,17 @@ - package io.sinistral.proteus.services; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.google.common.util.concurrent.AbstractIdleService; import com.google.inject.Binder; import com.google.inject.Inject; import com.google.inject.Module; import com.google.inject.Singleton; - import com.typesafe.config.Config; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * An abstract base class for a Proteus service. + * * @author jbauer */ @Singleton @@ -36,7 +34,8 @@ public BaseService() * @see com.google.inject.Module#configure(com.google.inject.Binder) */ @Override - public void configure(Binder binder) { + public void configure(Binder binder) + { } diff --git a/core/src/main/java/io/sinistral/proteus/utilities/SecurityOps.java b/core/src/main/java/io/sinistral/proteus/utilities/SecurityOps.java index 7c5c625..c6d2fff 100644 --- a/core/src/main/java/io/sinistral/proteus/utilities/SecurityOps.java +++ b/core/src/main/java/io/sinistral/proteus/utilities/SecurityOps.java @@ -1,37 +1,15 @@ - /** * */ package io.sinistral.proteus.utilities; -import java.io.ByteArrayOutputStream; +import javax.net.ssl.*; import java.io.File; -import java.io.IOException; import java.io.InputStream; - -import java.net.URL; - import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; - import java.security.KeyStore; -import java.util.jar.JarFile; -import java.util.zip.ZipInputStream; - -import javax.net.ssl.KeyManager; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; - -import org.apache.commons.io.FileUtils; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * @author jbauer */ @@ -68,17 +46,13 @@ public static KeyStore loadKeyStore(String name, String password) throws Excepti File storeFile = new File(name); InputStream stream = null; - if (!storeFile.exists()) - { + if (!storeFile.exists()) { stream = SecurityOps.class.getResourceAsStream("/" + name); - } - else - { + } else { stream = Files.newInputStream(Paths.get(name)); } - if (stream == null) - { + if (stream == null) { throw new RuntimeException("Could not load keystore"); } diff --git a/core/src/main/java/io/sinistral/proteus/utilities/TablePrinter.java b/core/src/main/java/io/sinistral/proteus/utilities/TablePrinter.java index cfcfe06..03fe52c 100644 --- a/core/src/main/java/io/sinistral/proteus/utilities/TablePrinter.java +++ b/core/src/main/java/io/sinistral/proteus/utilities/TablePrinter.java @@ -1,4 +1,3 @@ - /** * */ @@ -22,8 +21,7 @@ public TablePrinter(List headersIn, List> content) this.headers = headersIn; this.maxLength = new ArrayList(); - for (int i = 0; i < headers.size(); i++) - { + for (int i = 0; i < headers.size(); i++) { maxLength.add(headers.get(i).length()); } @@ -39,15 +37,12 @@ public String toString() String padder = ""; String rowSeperator = ""; - for (int i = 0; i < 4; i++) - { + for (int i = 0; i < 4; i++) { padder += " "; } - for (int i = 0; i < maxLength.size(); i++) - { - for (int j = 0; j < maxLength.get(i) + (TABLEPADDING * 2); j++) - { + for (int i = 0; i < maxLength.size(); i++) { + for (int j = 0; j < maxLength.get(i) + (TABLEPADDING * 2); j++) { rowSeparatorBuilder.append("-"); } } @@ -56,13 +51,11 @@ public String toString() sb.append("\n"); - for (int i = 0; i < headers.size(); i++) - { + for (int i = 0; i < headers.size(); i++) { sb.append(padder); sb.append(headers.get(i)); - for (int k = 0; k < (maxLength.get(i) - headers.get(i).length()); k++) - { + for (int k = 0; k < (maxLength.get(i) - headers.get(i).length()); k++) { sb.append(" "); } @@ -73,17 +66,14 @@ public String toString() sb.append(rowSeperator); sb.append("\n"); - for (int i = 0; i < table.size(); i++) - { + for (int i = 0; i < table.size(); i++) { List tempRow = table.get(i); - for (int j = 0; j < tempRow.size(); j++) - { + for (int j = 0; j < tempRow.size(); j++) { sb.append(padder); sb.append(tempRow.get(j)); - for (int k = 0; k < (maxLength.get(j) - tempRow.get(j).length()); k++) - { + for (int k = 0; k < (maxLength.get(j) - tempRow.get(j).length()); k++) { sb.append(" "); } @@ -104,10 +94,8 @@ public void updateField(int row, int col, String input) private void updateMaxColumnLength(int col) { - for (int i = 0; i < table.size(); i++) - { - if (table.get(i).get(col).length() > maxLength.get(col)) - { + for (int i = 0; i < table.size(); i++) { + if (table.get(i).get(col).length() > maxLength.get(col)) { maxLength.set(col, table.get(i).get(col).length()); } } @@ -115,14 +103,11 @@ private void updateMaxColumnLength(int col) private void updateMaxLengths() { - for (int i = 0; i < table.size(); i++) - { + for (int i = 0; i < table.size(); i++) { List temp = table.get(i); - for (int j = 0; j < temp.size(); j++) - { - if (temp.get(j).length() > maxLength.get(j)) - { + for (int j = 0; j < temp.size(); j++) { + if (temp.get(j).length() > maxLength.get(j)) { maxLength.set(j, temp.get(j).length()); } } diff --git a/core/src/main/resources/io/sinistral/proteus/proteus-logo.svg b/core/src/main/resources/io/sinistral/proteus/proteus-logo.svg new file mode 100644 index 0000000..ab4ad7b --- /dev/null +++ b/core/src/main/resources/io/sinistral/proteus/proteus-logo.svg @@ -0,0 +1,17 @@ + + + + + proteus + + + + + + + + + +