Package io.wcm.handler.media.format
Class MediaFormat
- java.lang.Object
-
- io.wcm.handler.media.format.MediaFormat
-
- All Implemented Interfaces:
java.lang.Comparable<MediaFormat>
@ProviderType public final class MediaFormat extends java.lang.Object implements java.lang.Comparable<MediaFormat>
Media format.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(MediaFormat o)booleanequals(java.lang.Object pObj)@Nullable java.lang.StringgetDescription()longgetEffectiveMaxHeight()longgetEffectiveMaxWidth()longgetEffectiveMinHeight()longgetEffectiveMinWidth()java.lang.String[]getExtensions()longgetFileSizeMax()longgetHeight()@NotNull java.lang.StringgetLabel()longgetMaxHeight()longgetMaxWidth()DimensiongetMinDimension()Get minimum dimensions for media format.longgetMinHeight()longgetMinWidth()longgetMinWidthHeight()@NotNull java.lang.StringgetName()org.apache.sling.api.resource.ValueMapgetProperties()longgetRanking()doublegetRatio()Returns the ratio defined in the media format definition.java.lang.StringgetRatioDisplayString()Return display string for defined ratio.doublegetRatioHeightAsDouble()doublegetRatioWidthAsDouble()java.lang.StringgetRenditionGroup()longgetWidth()inthashCode()booleanhasRatio()booleanisDownload()booleanisFixedDimension()Checks if the media format has a fixed width and height defined, and no min/max constraints.booleanisFixedHeight()Checks if the media format has a fixed height defined, and no min/max constraints.booleanisFixedWidth()Checks if the media format has a fixed width defined, and no min/max constraints.booleanisImage()booleanisInternal()java.lang.StringtoString()
-
-
-
Method Detail
-
getName
@NotNull public @NotNull java.lang.String getName()
- Returns:
- Media format name
-
getLabel
@NotNull public @NotNull java.lang.String getLabel()
- Returns:
- Media format label
-
getDescription
@Nullable public @Nullable java.lang.String getDescription()
- Returns:
- Media format description
-
getWidth
public long getWidth()
- Returns:
- Image width (px)
-
getMinWidth
public long getMinWidth()
- Returns:
- Min. image width (px)
-
getMaxWidth
public long getMaxWidth()
- Returns:
- Max. image width (px)
-
getHeight
public long getHeight()
- Returns:
- Image height (px)
-
getMinHeight
public long getMinHeight()
- Returns:
- Min. image height (px)
-
getMaxHeight
public long getMaxHeight()
- Returns:
- Max. image height (px)
-
getMinWidthHeight
public long getMinWidthHeight()
- Returns:
- Min. width/height (px) - the longest edge is checked. Cannot be combined with other width/height restrictions.
-
getRatioWidthAsDouble
public double getRatioWidthAsDouble()
- Returns:
- Ration width (px)
-
getRatioHeightAsDouble
public double getRatioHeightAsDouble()
- Returns:
- Ration height (px)
-
getRatio
public double getRatio()
Returns the ratio defined in the media format definition. If no ratio is defined an the media format has a fixed width/height it is calculated automatically. Otherwise 0 is returned.- Returns:
- Ratio
-
getRatioDisplayString
public java.lang.String getRatioDisplayString()
Return display string for defined ratio.- Returns:
- Display string or null if media format has no ratio.
-
hasRatio
public boolean hasRatio()
- Returns:
- true if the media format has ratio (calculated for fixed dimensions or defined in media format)
-
getFileSizeMax
public long getFileSizeMax()
- Returns:
- Max. file size (bytes)
-
getExtensions
public java.lang.String[] getExtensions()
- Returns:
- Allowed file extensions
-
getRenditionGroup
public java.lang.String getRenditionGroup()
- Returns:
- Rendition group id
-
isDownload
public boolean isDownload()
- Returns:
- Media assets with this format should be downloaded and not displayed directly
-
isInternal
public boolean isInternal()
- Returns:
- For internal use only (not displayed for user)
-
getRanking
public long getRanking()
- Returns:
- Ranking for auto-detection. Lowest value = highest priority.
-
isImage
public boolean isImage()
- Returns:
- Whether the format allows at least one image extension
-
isFixedWidth
public boolean isFixedWidth()
Checks if the media format has a fixed width defined, and no min/max constraints.- Returns:
- If the media format has a fixed dimension.
-
isFixedHeight
public boolean isFixedHeight()
Checks if the media format has a fixed height defined, and no min/max constraints.- Returns:
- If the media format has a fixed dimension.
-
isFixedDimension
public boolean isFixedDimension()
Checks if the media format has a fixed width and height defined, and no min/max constraints.- Returns:
- If the media format has a fixed dimension.
-
getEffectiveMinWidth
public long getEffectiveMinWidth()
- Returns:
- Effective min. image width (px). Takes widthMin and width into account.
-
getEffectiveMaxWidth
public long getEffectiveMaxWidth()
- Returns:
- Effective max. image width (px). Takes widthMax and width into account.
-
getEffectiveMinHeight
public long getEffectiveMinHeight()
- Returns:
- Effective min. image height (px). Takes heightMin and height into account.
-
getEffectiveMaxHeight
public long getEffectiveMaxHeight()
- Returns:
- Effective max. image height (px). Takes heightMax and height into account.
-
getMinDimension
public Dimension getMinDimension()
Get minimum dimensions for media format. If only width or height is defined the missing dimensions is calculated from the ratio. If no ratio defined either only width or height dimension is returned. If neither width or height are defined null is returned.- Returns:
- Min. dimensions or null
-
getProperties
public org.apache.sling.api.resource.ValueMap getProperties()
- Returns:
- Custom properties that my be used by application-specific markup builders or processors.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- User-friendly combined title of current media format name and dimension.
-
equals
public boolean equals(java.lang.Object pObj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(MediaFormat o)
- Specified by:
compareToin interfacejava.lang.Comparable<MediaFormat>
-
-