/** * Constructor. * * @param clientDispatcher * The client HTTP dispatcher. */ public Service(Uniform clientDispatcher) { super(new MediaType("***")); this.clientDispatcher = clientDispatcher; }
SparqlResultFormat(final String mimeType) { mediaType = new MediaType(mimeType); }
SparqlResultFormat(final String mimeType) { mediaType = new MediaType(mimeType); }
/** * Returns a media type from an Atom type attribute. * * @param type * The Atom type attribute. * @return The media type. */ private MediaType getMediaType(String type) { MediaType result = null; if (type == null) { // No type defined } else if (type.equals("text")) { result = MediaType.TEXT_PLAIN; } else if (type.equals("html")) { result = MediaType.TEXT_HTML; } else if (type.equals("xhtml")) { result = MediaType.APPLICATION_XHTML; } else { result = new MediaType(type); } return result; }
/** * Returns a media type from an Atom type attribute. * * @param type * The Atom type attribute. * @return The media type. */ private MediaType getMediaType(String type) { MediaType result = null; if (type == null) { // No type defined } else if (type.equals("text")) { result = MediaType.TEXT_PLAIN; } else if (type.equals("html")) { result = MediaType.TEXT_HTML; } else if (type.equals("xhtml")) { result = MediaType.APPLICATION_XHTML_XML; } else { result = new MediaType(type); } return result; }
/** * Returns a media type from an Atom type attribute. * * @param type * The Atom type attribute. * @return The media type. */ private MediaType getMediaType(String type) { MediaType result = null; if (type == null) { // No type defined } else if (type.equals("text")) { result = MediaType.TEXT_PLAIN; } else if (type.equals("html")) { result = MediaType.TEXT_HTML; } else if (type.equals("xhtml")) { result = MediaType.APPLICATION_XHTML; } else { result = new MediaType(type); } return result; }
/** * Constructor. * * @param clientDispatcher * The client HTTP dispatcher. */ public Service(Client clientDispatcher) { super(new MediaType("***")); setNamespaceAware(true); this.clientDispatcher = clientDispatcher; }
/** * Constructor. * * @param clientDispatcher * The client HTTP dispatcher. */ public Service(Client clientDispatcher) { super(new MediaType("***")); setNamespaceAware(true); this.clientDispatcher = clientDispatcher; }
/** * Returns a media type from an Atom type attribute. * * @param type * The Atom type attribute. * @return The media type. */ private MediaType getMediaType(String type) { MediaType result = null; if (type == null) { // No type defined } else if (type.equals("text")) { result = MediaType.TEXT_PLAIN; } else if (type.equals("html")) { result = MediaType.TEXT_HTML; } else if (type.equals("xhtml")) { result = MediaType.APPLICATION_XHTML; } else { result = new MediaType(type); } return result; }
/** * Returns a media type from an Atom type attribute. * * @param type * The Atom type attribute. * @return The media type. */ private MediaType getMediaType(String type) { MediaType result = null; if (type == null) { // No type defined } else if (type.equals("text")) { result = MediaType.TEXT_PLAIN; } else if (type.equals("html")) { result = MediaType.TEXT_HTML; } else if (type.equals("xhtml")) { result = MediaType.APPLICATION_XHTML; } else { result = new MediaType(type); } return result; }
/** * Returns the media type associated to a name. If an existing constant * exists then it is returned, otherwise a new instance is created. * * @param name * The name. * @return The associated media type. */ public static MediaType valueOf(String name) { MediaType result = null; if ((name != null) && !name.equals("")) { result = getTypes().get(name); if (result == null) { result = new MediaType(name); } } return result; }
/** * Returns the media type associated to a name. If an existing constant * exists then it is returned, otherwise a new instance is created. * * @param name * The name. * @return The associated media type. */ public static MediaType valueOf(String name) { MediaType result = null; if ((name != null) && !name.equals("")) { result = getTypes().get(name); if (result == null) { result = new MediaType(name); } } return result; }
/** * Creates a content type. * * @param mediaType * The media type name. * @param parameters * The parameters parsed. * @return The content type. */ private ContentType createContentType(StringBuilder mediaType, Series<Parameter> parameters) { // Attempt to extract the character set CharacterSet characterSet = null; if (parameters != null) { String charSet = parameters.getFirstValue("charset"); if (charSet != null) { parameters.removeAll("charset"); characterSet = new CharacterSet(charSet); } return new ContentType(new MediaType(mediaType.toString(), parameters), characterSet); } return new ContentType(new MediaType(mediaType.toString()), null); }
/** * Register a media type as a known type that can later be retrieved using * {@link #valueOf(String)}. If the type already exists, the existing type * is returned, otherwise a new instance is created. * * @param name * The name. * @param description * The description. * @return The registered media type */ public static synchronized MediaType register(String name, String description) { if (!getTypes().containsKey(name)) { final MediaType type = new MediaType(name, description); getTypes().put(name, type); } return getTypes().get(name); }
/** * Returns the media type associated to a name. If an existing constant * exists then it is returned, otherwise a new instance is created. * * @param name * The name. * @return The associated media type. */ public static MediaType valueOf(String name) { MediaType result = null; if (!StringUtils.isNullOrEmpty(name)) { result = getTypes().get(name); if (result == null) { result = new MediaType(name); } } return result; }
/** * Register a media type as a known type that can later be retrieved using * {@link #valueOf(String)}. If the type already exists, the existing type * is returned, otherwise a new instance is created. * * @param name * The name. * @param description * The description. * @return The registered media type */ public static synchronized MediaType register(String name, String description) { if (!getTypes().containsKey(name)) { final MediaType type = new MediaType(name, description); getTypes().put(name, type); } return getTypes().get(name); }
/** * Register a media type as a known type that can later be retrieved using * {@link #valueOf(String)}. If the type already exists, the existing type * is returned, otherwise a new instance is created. * * @param name * The name. * @param description * The description. * @return The registered media type */ public static synchronized MediaType register(String name, String description) { if (!getTypes().containsKey(name)) { final MediaType type = new MediaType(name, description); getTypes().put(name, type); } return getTypes().get(name); }
/** * Creates the media type of a multipart form which must include the used * boundary. * * @param boundary * The multipart boundary. * @return The multipart media type. */ private static MediaType createMultipartMediaType(String boundary) { Series<Parameter> params = new Series<Parameter>(Parameter.class); params.add("boundary", boundary); MediaType result = new MediaType( MediaType.MULTIPART_FORM_DATA.getName(), params); return result; }
private void doGet(Request request, Response response) { String filename = (String) request.getAttributes().get("filename"); InputStream is = ByteStreamerRestlet.class.getResourceAsStream(filename); if(is == null) { response.setStatus(Status.CLIENT_ERROR_NOT_FOUND); return; } response.setStatus(Status.SUCCESS_OK); String[] filenameParts = filename.split("\\."); String extension = filenameParts[filenameParts.length - 1]; MimeType mime = null; try { mime = MimeType.createFromExtension(extension); } catch (MimeException e) { response.setStatus(Status.SERVER_ERROR_INTERNAL); response.setEntity("Unable to create MimeType for " + extension); return; } ByteRepresentation imgRep = new ByteRepresentation(new MediaType(mime.getMimeType()), is); response.setEntity(imgRep); }
/** * Convert a JAX-RS MediaType to a Restlet MediaType. * * @param jaxRsMediaType * @return the converted MediaType */ public static org.restlet.data.MediaType toRestletMediaType(MediaType jaxRsMediaType) { if (jaxRsMediaType == null) { return null; } final Series<Parameter> parameters = toRestletSeries(jaxRsMediaType.getParameters()); final String name = jaxRsMediaType.getType() + "/" + jaxRsMediaType.getSubtype(); return new org.restlet.data.MediaType(name, parameters); }