private Representation representRdfXml( final EntityState entity ) throws ResourceException { Representation representation = new WriterRepresentation( MediaType.APPLICATION_RDF_XML ) { @Override public void write( Writer writer ) throws IOException { try { Iterable<Statement> statements = entitySerializer.serialize( entity ); new RdfXmlSerializer().serialize( statements, writer ); } catch( RDFHandlerException e ) { throw new IOException( e ); } } }; representation.setCharacterSet( CharacterSet.UTF_8 ); return representation; }
Representation representation = new StringRepresentation(body, MediaType.TEXT_PLAIN); representation.setCharacterSet(CharacterSet.UTF_8); return representation;
@Override public void setCharacterSet(CharacterSet characterSet) { getWrappedRepresentation().setCharacterSet(characterSet); }
@Override public void handle(Request request, Response response) { super.handle(request, response); Optional.ofNullable(response.getEntity()) .ifPresent(r -> r.setCharacterSet(CharacterSet.UTF_8)); } }
private Representation representHtml() throws ResourceException { try { Stream<EntityReference> query = entityFinder.findEntities( EntityComposite.class, null, null, null, null, Collections.emptyMap() ); Representation representation = new WriterRepresentation( MediaType.TEXT_HTML ) { @Override public void write( Writer buf ) throws IOException { PrintWriter out = new PrintWriter( buf ); out.println( "<html><head><title>All entities</title></head><body><h1>All entities</h1><ul>" ); query.forEach( entity -> out.println( "<li><a href=\"" + getRequest().getResourceRef().clone().addSegment( entity.identity() + ".html" ) + "\">" + entity.identity() + "</a></li>" ) ); out.println( "</ul></body></html>" ); } }; representation.setCharacterSet( CharacterSet.UTF_8 ); return representation; } catch( EntityFinderException e ) { throw new ResourceException( e ); } }
private Representation entityHeaders( Representation representation, EntityState entityState ) { representation.setModificationDate( java.util.Date.from( entityState.lastModified() ) ); representation.setTag( new Tag( "" + entityState.version() ) ); representation.setCharacterSet( CharacterSet.UTF_8 ); representation.setLanguages( Collections.singletonList( Language.ENGLISH ) ); return representation; }
resultRepresentation.setCharacterSet(representation .getCharacterSet()); resultRepresentation
/** * 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; }
resultRepresentation.setCharacterSet(source .getCharacterSet()); resultRepresentation.setMediaType(source.getMediaType());
result.setCharacterSet(target.getCharacterSet());
@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); }
response.getEntity().setCharacterSet( CharacterSet.UTF_8 ); response.getEntity().setCharacterSet( CharacterSet.UTF_8 );
response.getEntity().setCharacterSet( CharacterSet.UTF_8 ); response.getEntity().setCharacterSet( CharacterSet.UTF_8 );
ContentType contentType = new ContentType(header.getValue()); result.setMediaType(contentType.getMediaType()); result.setCharacterSet(contentType.getCharacterSet()); } else if (header.getName().equalsIgnoreCase( HeaderConstants.HEADER_CONTENT_RANGE)) {
result.setCharacterSet(contentType.getCharacterSet());
rep.setCharacterSet( CharacterSet.UTF_8 ); response.setEntity( rep ); return true;
rep.setCharacterSet( CharacterSet.UTF_8 ); response.setEntity( rep ); return true;
Representation repr = (Representation) entity; repr.setCharacterSet(getSupportedCharSet(repr.getCharacterSet())); if (jaxRsResponseMediaType != null) { repr.setMediaType(Converter resourceMethod, entityClass, genericReturnType)); repr.setCharacterSet(getSupportedCharSet(httpResponseHeaders)); return repr;