/** * Indicates if some fresh content is available, without having to actually * call one of the content manipulation method like getStream() that would * actually consume it. This is especially useful for transient * representation whose content can only be accessed once and also when the * size of the representation is not known in advance. * * @return True if some fresh content is available. */ public boolean isAvailable() { return (getSize() != 0) && this.available; }
@Override public long getContentLength() { return entity.getSize(); }
@Override public long getSize() { return getWrappedRepresentation().getSize(); }
/** * Returns the size effectively available. This returns the same value as * {@link #getSize()} if no range is defined, otherwise it returns the size * of the range using {@link Range#getSize()}. * * @return The available size. */ public long getAvailableSize() { if (getRange() == null) { return getSize(); } else if (getRange().getSize() != Range.SIZE_MAX) { return getRange().getSize(); } else if (getSize() != Representation.UNKNOWN_SIZE) { if (getRange().getIndex() != Range.INDEX_LAST) { return getSize() - getRange().getIndex(); } else { return getSize(); } } return Representation.UNKNOWN_SIZE; }
/** * Indicates if a content is available and can be sent. Several conditions * must be met: the content must exists and have some available data. * * @return True if a content is available and can be sent. */ public boolean isEntityAvailable() { return (getEntity() != null) && (getEntity().getSize() != 0) && getEntity().isAvailable(); }