本文整理汇总了Java中com.day.cq.dam.api.Asset.getRenditions方法的典型用法代码示例。如果您正苦于以下问题:Java Asset.getRenditions方法的具体用法?Java Asset.getRenditions怎么用?Java Asset.getRenditions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.day.cq.dam.api.Asset
的用法示例。
在下文中一共展示了Asset.getRenditions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRendition
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
/**
* Gets the rendition which matches against the constructor's Regex pattern.
* <p>
* If no matches are made and an Original exists, returns the Original.
* <p>
* If no matches are made and an Original doesn't exist, return the first Rendition.
*
* @param asset Asset whose Renditions will be selected.
* @return The first rendition whose name matches the supplied pattern (via constructor).
*/
@Override
public final Rendition getRendition(final Asset asset) {
final List<Rendition> renditions = asset.getRenditions();
final Pattern p = getPattern();
boolean hasOriginal = asset.getOriginal() != null;
boolean hasRenditions = renditions.size() > 0;
for (final Rendition rendition : renditions) {
final Matcher m = p.matcher(rendition.getName());
if (m.find()) {
return rendition;
}
}
if (hasOriginal) {
return asset.getOriginal();
} else if (hasRenditions) {
return renditions.get(0);
} else {
return null;
}
}
示例2: getRenditionsWithExistingRenditionsIsNotEmpty
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
@Test
public void getRenditionsWithExistingRenditionsIsNotEmpty() throws Exception {
Asset target = anAsset("/libs/quatico/base/templates/backend/thumbnail.png");
List<Rendition> actual = target.getRenditions();
assertFalse(actual.isEmpty());
}
示例3: getAWebRendition
import com.day.cq.dam.api.Asset; //导入方法依赖的package包/类
/**
* Given an {@link Asset}, this method will return the first web {@link Rendition} it finds in the asset's renditions list.
*
* @param asset the asset for which to retrieve the web rendition
* @return the rendition, if found, {@code null} otherwise
*/
private Rendition getAWebRendition(Asset asset) {
List<Rendition> renditions = asset.getRenditions();
for (Rendition rendition : renditions) {
if (rendition.getName().startsWith(DamConstants.PREFIX_ASSET_WEB)) {
return rendition;
}
}
return null;
}