Class Image
- java.lang.Object
-
- org.schabi.newpipe.extractor.Image
-
- All Implemented Interfaces:
java.io.Serializable
public final class Image extends java.lang.Object implements java.io.Serializable
Class representing images in the extractor.An image has four properties: its URL, its height, its width and its estimated quality level.
Depending of the services, the height, the width or both properties may be not known. Implementations must use the relevant unknown constants in this case (
HEIGHT_UNKNOWN
andWIDTH_UNKNOWN
), to ensure properly the lack of knowledge of one or both of these properties to extractor clients.They should also respect the ranges defined in the estimated image resolution levels as much as possible, to ensure consistency to extractor clients.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Image.ResolutionLevel
The estimated resolution level of anImage
.
-
Field Summary
Fields Modifier and Type Field Description static int
HEIGHT_UNKNOWN
Constant representing that the height of anImage
is unknown.static int
WIDTH_UNKNOWN
Constant representing that the width of anImage
is unknown.
-
Constructor Summary
Constructors Constructor Description Image(java.lang.String url, int height, int width, Image.ResolutionLevel estimatedResolutionLevel)
Construct anImage
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Image.ResolutionLevel
getEstimatedResolutionLevel()
Get the estimated resolution level of this image.int
getHeight()
Get the height of thisImage
.java.lang.String
getUrl()
Get the URL of thisImage
.int
getWidth()
Get the width of thisImage
.java.lang.String
toString()
Get a string representation of thisImage
instance.
-
-
-
Field Detail
-
HEIGHT_UNKNOWN
public static final int HEIGHT_UNKNOWN
Constant representing that the height of anImage
is unknown.- See Also:
- Constant Field Values
-
WIDTH_UNKNOWN
public static final int WIDTH_UNKNOWN
Constant representing that the width of anImage
is unknown.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Image
public Image(@Nonnull java.lang.String url, int height, int width, @Nonnull Image.ResolutionLevel estimatedResolutionLevel) throws java.lang.NullPointerException
Construct anImage
instance.- Parameters:
url
- the URL to the image, which should be not null or emptyheight
- the image's heightwidth
- the image's widthestimatedResolutionLevel
- the image's estimated resolution level, which must not be null- Throws:
java.lang.NullPointerException
- ifestimatedResolutionLevel
is null
-
-
Method Detail
-
getUrl
@Nonnull public java.lang.String getUrl()
Get the URL of thisImage
.- Returns:
- the
Image
's URL.
-
getHeight
public int getHeight()
Get the height of thisImage
.If it is unknown,
HEIGHT_UNKNOWN
is returned instead.- Returns:
- the
Image
's height orHEIGHT_UNKNOWN
-
getWidth
public int getWidth()
Get the width of thisImage
.If it is unknown,
WIDTH_UNKNOWN
is returned instead.- Returns:
- the
Image
's width orWIDTH_UNKNOWN
-
getEstimatedResolutionLevel
@Nonnull public Image.ResolutionLevel getEstimatedResolutionLevel()
Get the estimated resolution level of this image.If it is unknown,
Image.ResolutionLevel.UNKNOWN
is returned instead.- Returns:
- the estimated resolution level, which is never
null
- See Also:
Image.ResolutionLevel
-
toString
@Nonnull public java.lang.String toString()
Get a string representation of thisImage
instance.The representation will be in the following format, where
url
,height
,width
andestimatedResolutionLevel
represent the corresponding properties:
Image {url=url, height='height, width=width, estimatedResolutionLevel=estimatedResolutionLevel}'
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of this
Image
instance
-
-