public class PrefixRenditionPicker extends java.lang.Object implements RenditionPicker
RenditionPicker
that picks the first rendition found which name
starts with a given prefix.Constructor and Description |
---|
PrefixRenditionPicker(java.lang.String startsWith)
Picks the first rendition found which name starts with the given prefix.
|
PrefixRenditionPicker(java.lang.String prefix,
boolean returnOriginal)
Picks the first rendition found which name starts with the given prefix.
|
Modifier and Type | Method and Description |
---|---|
Rendition |
getRendition(Asset asset)
Returns the desired rendition
Rendition if existing, otherwise null . |
Rendition |
getRendition(java.util.Iterator<Rendition> renditions) |
public PrefixRenditionPicker(java.lang.String startsWith)
null
will be returned.startsWith
- the name prefix to matchpublic PrefixRenditionPicker(java.lang.String prefix, boolean returnOriginal)
null
).prefix
- the name prefix to matchreturnOriginal
- if true, will return the original rendition if no matching
rendition was found, otherwise the picker will return
null
public Rendition getRendition(Asset asset)
RenditionPicker
Rendition
if existing, otherwise null
.
Implementations are free to decide which rendition is chosen when this method is called.
The rendition shall be searched for within the given Asset
.
Example implementation:
... public Resource getRendition(Asset asset) { // 1. try to get a web enabled rendition List<Resource> renditions = asset.getRenditions(); for (Resource rendition: renditions) { if (Text.getName(rendition.getPath()).startsWith("cq5dam.web.")) { return rendition; } } // 2. return current rendition return asset.getCurrentOriginal(); } ...
getRendition
in interface RenditionPicker
asset
- The Asset
within which to search the rendition.null
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"