@Override public void setMediaType(MediaType mediaType) { getWrappedRepresentation().setMediaType(mediaType); }
ClientResource cr = new ClientResource("..."); Representation entity = ...; entity.setMediaType(MediaType.APPLICATION_JSON); cr.setEntity(entity);
jsRequest.endObject(); Representation rep = new JsonRepresentation(jsRequest); rep.setMediaType(MediaType.APPLICATION_JSON); ClientResource clientResource = new ClientResource(uri);
@Get public Representation represent() { // Modification date (Fri, 17 Apr 2012 10:10:10 GMT) unchanged. Calendar cal = new GregorianCalendar(2012, 4, 17, 10, 10, 10); Representation result = new StringRepresentation("<a href=" + getReference() + ">" + System.currentTimeMillis() + "</a>"); result.setMediaType(MediaType.TEXT_HTML); result.setModificationDate(cal.getTime()); // Expiration date (Fri, 17 Apr 2012 13:10:10 GMT) unchanged. cal.roll(Calendar.HOUR, 3); result.setExpirationDate(cal.getTime()); // Setting E-Tag result.setTag(new Tag("xyz123")); // Setting a cache directive getResponse().getCacheDirectives().add(CacheDirective.publicInfo()); return result; }
.getCharacterSet()); resultRepresentation .setMediaType(representation.getMediaType()); resultRepresentation .setEncodings(representation.getEncodings());
/** * Transforms a source XML representation by applying an XSLT transform * sheet to it. * * @param source * The source XML representation. * @return The generated result representation. */ public Representation transform(Representation source) { final Representation result = new TransformRepresentation(getContext(), source, getTransformSheet()); if (this.resultLanguages != null) { result.getLanguages().addAll(getResultLanguages()); } result.setCharacterSet(getResultCharacterSet()); if (this.resultEncodings != null) { result.getEncodings().addAll(getResultEncodings()); } result.setMediaType(getResultMediaType()); return result; }
/** * Transforms a source XML representation by applying an XSLT transform * sheet to it. * * @param source * The source XML representation. * @return The generated result representation. */ public Representation transform(Representation source) { final Representation result = new TransformRepresentation(getContext(), source, getTransformSheet()); if (this.resultLanguages != null) { result.getLanguages().addAll(getResultLanguages()); } result.setCharacterSet(getResultCharacterSet()); if (this.resultEncodings != null) { result.getEncodings().addAll(getResultEncodings()); } result.setMediaType(getResultMediaType()); return result; }
representation = new TransformRepresentation( Context.getCurrent(), this, xslRep); representation.setMediaType(MediaType.TEXT_HTML); } catch (IOException e) { Context.getCurrent()
representation.setMediaType(MediaType.APPLICATION_JSON);
representation.setMediaType(MediaType.APPLICATION_JSON);
representation.setMediaType(MediaType.APPLICATION_JSON);
if ((target.getMediaType() != null) && target.getMediaType().isConcrete()) { result.setMediaType(target.getMediaType()); } else if (resource != null) { result.setMediaType(resource.getMetadataService() .getDefaultMediaType()); } else { result.setMediaType(MediaType.APPLICATION_OCTET_STREAM);
representation.setMediaType(MediaType.APPLICATION_JSON);
representation.setMediaType(MediaType.APPLICATION_JSON);
resultRepresentation.setMediaType(source.getMediaType()); resultRepresentation.getEncodings().addAll( source.getEncodings());
@Override public Representation toRepresentation(Object object, Variant targetVariant, UniformResource resource) throws IOException { Representation result = null; if (object instanceof Document) { result = new DomRepresentation(targetVariant == null ? null : targetVariant.getMediaType(), (Document) object); } if ((result != null) && (targetVariant != null)) { // Copy the variant metadata result.setCharacterSet(targetVariant.getCharacterSet()); result.setMediaType(targetVariant.getMediaType()); result.setEncodings(targetVariant.getEncodings()); result.setLanguages(targetVariant.getLanguages()); } return result; } }
/** * Constructor from a variant. * * @param variant * The variant to copy. * @param modificationDate * The modification date. * @param tag * The tag. */ public Representation(Variant variant, Date modificationDate, Tag tag) { setCharacterSet(variant.getCharacterSet()); setEncodings(variant.getEncodings()); setLocationRef(variant.getLocationRef()); setLanguages(variant.getLanguages()); setMediaType(variant.getMediaType()); setModificationDate(modificationDate); setTag(tag); }
HeaderConstants.HEADER_CONTENT_TYPE)) { ContentType contentType = new ContentType(header.getValue()); result.setMediaType(contentType.getMediaType()); result.setCharacterSet(contentType.getCharacterSet()); } else if (header.getName().equalsIgnoreCase(
if (HEADER_CONTENT_TYPE.equalsIgnoreCase(header.getName())) { ContentType contentType = new ContentType(header.getValue()); result.setMediaType(contentType.getMediaType());
repr.setMediaType(Converter .getMediaTypeWithoutParams(jaxRsResponseMediaType)); } else { // entity == null repr = new EmptyRepresentation(); repr.setMediaType(determineMediaType(jaxRsResponseMediaType, resourceMethod, entityClass, genericReturnType));