/** * Constructor. * * @param jsonRepresentation * A source JSON representation to parse. */ public JsonRepresentation(Representation jsonRepresentation) throws IOException { super((jsonRepresentation == null) ? null : jsonRepresentation .getMediaType()); this.jsonRepresentation = jsonRepresentation; }
/** * Constructor. * * @param jsonRepresentation * A source JSON representation to parse. */ public JsonRepresentation(Representation jsonRepresentation) throws IOException { super((jsonRepresentation == null) ? null : jsonRepresentation .getMediaType()); this.jsonRepresentation = jsonRepresentation; }
/** * Constructor. * * @param xmlRepresentation * A source XML representation to parse. */ public SaxRepresentation(Representation xmlRepresentation) { super((xmlRepresentation == null) ? null : xmlRepresentation .getMediaType()); this.secureProcessing = XML_SECURE_PROCESSING; this.xmlRepresentation = xmlRepresentation; }
/** * Constructor. * * @param xmlRepresentation * A source XML representation to parse. */ public DomRepresentation(Representation xmlRepresentation) { super((xmlRepresentation == null) ? null : xmlRepresentation .getMediaType()); this.xmlRepresentation = xmlRepresentation; }
/** * Constructor. * * @param jsonRepresentation * A source JSON representation to parse. */ public JsonRepresentation(Representation jsonRepresentation) throws IOException { super((jsonRepresentation == null) ? null : jsonRepresentation .getMediaType()); this.jsonRepresentation = jsonRepresentation; }
@Post public void addPerson(Representation rep) { System.out.println(rep.getMediaType()); Request request = getRequest(); Response response = getResponse(); }
/** * Returns the wrapped representation's media type. * * @return The wrapped representation's media type. * @see ContentStream#getContentType() */ public String getContentType() { if (representation.getMediaType() != null) return representation.getMediaType().getName(); return null; }
public String getContentType() { return (entity.getMediaType() != null) ? entity .getMediaType().toString() : null; }
public Header getContentType() { return new BasicHeader( HeaderConstants.HEADER_CONTENT_TYPE, (entity .getMediaType() != null) ? entity .getMediaType().toString() : null); }
/** * Constructor. * * @param representation * The representation. */ public ContentType(Representation representation) { this(representation.getMediaType(), representation.getCharacterSet()); }
private boolean isMediaType(Representation entity, MediaType desiredType) { if (entity == null) { return false; } return desiredType.equals(entity.getMediaType(), true); }
@Override public MediaType getMediaType() { return getWrappedRepresentation().getMediaType(); }
/** * Constructor. * * @param xmlRepresentation * A source XML representation to parse. */ public DomRepresentation(Representation xmlRepresentation) { super((xmlRepresentation == null) ? null : xmlRepresentation .getMediaType()); this.setAvailable(xmlRepresentation.isAvailable()); this.xmlRepresentation = xmlRepresentation; }
/** * Writes the HTTP "Content-Type" header. * * @param representation * The related representation. * @return The HTTP "Content-Type" header. */ public static String writeHeader(Representation representation) { return writeHeader(representation.getMediaType(), representation.getCharacterSet()); }
/** * Returns the media type of the value representation. * * @return The media type of the value representation. */ public MediaType getMediaType() { return getValueRepresentation() == null ? null : getValueRepresentation().getMediaType(); }
/** * Constructor. * * @param xmlRepresentation * A source XML representation to parse. */ public DomRepresentation(Representation xmlRepresentation) { super((xmlRepresentation == null) ? null : xmlRepresentation.getMediaType()); this.setAvailable((xmlRepresentation == null) ? false : xmlRepresentation.isAvailable()); this.xmlRepresentation = xmlRepresentation; }
@Override public <T> float score(Representation source, Class<T> target, Resource resource) { for (Variant v : variants) { if (v.getMediaType().isCompatible(source.getMediaType())) { return .5F; } } return -1F; }
/** * Constructor. * * @param formRepresentation * The representation to parse. */ public FormDataSet(Representation formRepresentation) { this(); if ((formRepresentation != null) && MediaType.APPLICATION_WWW_FORM.equals(formRepresentation .getMediaType())) { FormUtils.parse(this.entries, formRepresentation); } }
@Override public void doError(Status errorStatus) { Representation representation = getResponse().getEntity(); if (representation.getMediaType().equals(MediaType.APPLICATION_JSON)) { // Do not throw an exception here. getLogger().fine("OAuth response is found."); // XXX: after #doError, the representation will disposed in // #handleInbound. return; } // ResourceException will be thrown. super.doError(errorStatus); }
@Override protected void afterHandle(Request request, Response response) { if (response.isEntityAvailable() && response.getEntity().getEncodings() .contains(Encoding.FREEMARKER)) { TemplateRepresentation representation = new TemplateRepresentation( response.getEntity(), this.configuration, response .getEntity().getMediaType()); representation.setDataModel(createDataModel(request, response)); response.setEntity(representation); } }