/** * Get the media type of the entity. * * @return the media type or {@code null} if not specified (e.g. there's no * message entity). */ public MediaType getMediaType() { return singleHeader(HttpHeaders.CONTENT_TYPE, MediaType.class, MediaType::valueOf, false); }
/** * Get the media type of the entity. * * @return the media type or {@code null} if not specified (e.g. there's no * message entity). */ public MediaType getMediaType() { return singleHeader(HttpHeaders.CONTENT_TYPE, MediaType.class, MediaType::valueOf, false); }
/** * Get the location. * * @return the location URI, otherwise {@code null} if not present. */ public URI getLocation() { return singleHeader(HttpHeaders.LOCATION, URI.class, new Function<String, URI>() { @Override public URI apply(String value) { try { return value == null ? null : URI.create(value); } catch (IllegalArgumentException ex) { throw new ProcessingException(ex); } } }, false); }
/** * Get the last modified date. * * @return the last modified date, otherwise {@code null} if not present. */ public Date getLastModified() { return singleHeader(HttpHeaders.LAST_MODIFIED, Date.class, new Function<String, Date>() { @Override public Date apply(String input) { try { return HttpHeaderReader.readDate(input); } catch (ParseException e) { throw new ProcessingException(e); } } }, false); }
/** * Get the entity tag. * * @return the entity tag, otherwise {@code null} if not present. */ public EntityTag getEntityTag() { return singleHeader(HttpHeaders.ETAG, EntityTag.class, new Function<String, EntityTag>() { @Override public EntityTag apply(String value) { try { return value == null ? null : EntityTag.valueOf(value); } catch (IllegalArgumentException ex) { throw new ProcessingException(ex); } } }, false); }
/** * Get the location. * * @return the location URI, otherwise {@code null} if not present. */ public URI getLocation() { return singleHeader(HttpHeaders.LOCATION, URI.class, new Function<String, URI>() { @Override public URI apply(String value) { try { return value == null ? null : URI.create(value); } catch (IllegalArgumentException ex) { throw new ProcessingException(ex); } } }, false); }
/** * Get the last modified date. * * @return the last modified date, otherwise {@code null} if not present. */ public Date getLastModified() { return singleHeader(HttpHeaders.LAST_MODIFIED, Date.class, new Function<String, Date>() { @Override public Date apply(String input) { try { return HttpHeaderReader.readDate(input); } catch (ParseException e) { throw new ProcessingException(e); } } }, false); }
/** * Get the entity tag. * * @return the entity tag, otherwise {@code null} if not present. */ public EntityTag getEntityTag() { return singleHeader(HttpHeaders.ETAG, EntityTag.class, new Function<String, EntityTag>() { @Override public EntityTag apply(String value) { try { return value == null ? null : EntityTag.valueOf(value); } catch (IllegalArgumentException ex) { throw new ProcessingException(ex); } } }, false); }
/** * Get Content-Length value. * * @return Content-Length as a positive long if present and valid number, {@code -1} if negative number. * @throws ProcessingException when {@link Long#parseLong(String)} throws {@link NumberFormatException}. */ public long getLengthLong() { return singleHeader(HttpHeaders.CONTENT_LENGTH, Long.class, input -> { try { if (input != null && !input.isEmpty()) { long l = Long.parseLong(input); if (l >= 0) { return l; } } return -1L; } catch (NumberFormatException ex) { throw new ProcessingException(ex); } }, true); }
/** * Get Content-Length value. * * @return Content-Length as a positive long if present and valid number, {@code -1} if negative number. * @throws ProcessingException when {@link Long#parseLong(String)} throws {@link NumberFormatException}. */ public long getLengthLong() { return singleHeader(HttpHeaders.CONTENT_LENGTH, Long.class, input -> { try { if (input != null && !input.isEmpty()) { long l = Long.parseLong(input); if (l >= 0) { return l; } } return -1L; } catch (NumberFormatException ex) { throw new ProcessingException(ex); } }, true); }
/** * Get Content-Length value. * <p> * <B>Note</B>: {@link #getLengthLong() getLengthLong()} * should be preferred over this method, since it returns a {@code long} * instead and is therefore more portable.</P> * * @return Content-Length as a postive integer if present and valid number, {@code -1} if negative number. * @throws ProcessingException when {@link Integer#parseInt(String)} (String)} throws {@link NumberFormatException}. */ public int getLength() { return singleHeader(HttpHeaders.CONTENT_LENGTH, Integer.class, input -> { try { if (input != null && !input.isEmpty()) { int i = Integer.parseInt(input); if (i >= 0) { return i; } } return -1; } catch (NumberFormatException ex) { throw new ProcessingException(ex); } }, true); }
/** * Get Content-Length value. * <p> * <B>Note</B>: {@link #getLengthLong() getLengthLong()} * should be preferred over this method, since it returns a {@code long} * instead and is therefore more portable.</P> * * @return Content-Length as a postive integer if present and valid number, {@code -1} if negative number. * @throws ProcessingException when {@link Integer#parseInt(String)} (String)} throws {@link NumberFormatException}. */ public int getLength() { return singleHeader(HttpHeaders.CONTENT_LENGTH, Integer.class, input -> { try { if (input != null && !input.isEmpty()) { int i = Integer.parseInt(input); if (i >= 0) { return i; } } return -1; } catch (NumberFormatException ex) { throw new ProcessingException(ex); } }, true); }
/** * Get message date. * * @return the message date, otherwise {@code null} if not present. */ public Date getDate() { return singleHeader(HttpHeaders.DATE, Date.class, input -> { try { return HttpHeaderReader.readDate(input); } catch (ParseException e) { throw new ProcessingException(e); } }, false); }
/** * Get message date. * * @return the message date, otherwise {@code null} if not present. */ public Date getDate() { return singleHeader(HttpHeaders.DATE, Date.class, input -> { try { return HttpHeaderReader.readDate(input); } catch (ParseException e) { throw new ProcessingException(e); } }, false); }
/** * Get the language of the entity. * * @return the language of the entity or {@code null} if not specified */ public Locale getLanguage() { return singleHeader(HttpHeaders.CONTENT_LANGUAGE, Locale.class, input -> { try { return new LanguageTag(input).getAsLocale(); } catch (ParseException e) { throw new ProcessingException(e); } }, false); }
/** * Get the language of the entity. * * @return the language of the entity or {@code null} if not specified */ public Locale getLanguage() { return singleHeader(HttpHeaders.CONTENT_LANGUAGE, Locale.class, input -> { try { return new LanguageTag(input).getAsLocale(); } catch (ParseException e) { throw new ProcessingException(e); } }, false); }
/** * Get the media type of the entity. * * @return the media type or {@code null} if not specified (e.g. there's no * message entity). */ public MediaType getMediaType() { return singleHeader(HttpHeaders.CONTENT_TYPE, MediaType.class, MediaType::valueOf, false); }
/** * Get the media type of the entity. * * @return the media type or {@code null} if not specified (e.g. there's no * message entity). */ public MediaType getMediaType() { return singleHeader(HttpHeaders.CONTENT_TYPE, MediaType.class, MediaType::valueOf, false); }
/** * Get message date. * * @return the message date, otherwise {@code null} if not present. */ public Date getDate() { return singleHeader(HttpHeaders.DATE, Date.class, input -> { try { return HttpHeaderReader.readDate(input); } catch (ParseException e) { throw new ProcessingException(e); } }, false); }
/** * Get the language of the entity. * * @return the language of the entity or {@code null} if not specified */ public Locale getLanguage() { return singleHeader(HttpHeaders.CONTENT_LANGUAGE, Locale.class, input -> { try { return new LanguageTag(input).getAsLocale(); } catch (ParseException e) { throw new ProcessingException(e); } }, false); }