Package com.iizix.server.weblogos
Class WebLogos
java.lang.Object
com.iizix.server.weblogos.WebLogos
Class holding all Website logos together and requesting only the ones needed.
- Author:
- Christopher Mindus
- Field SummaryFields
- Constructor SummaryConstructors
- Method SummaryModifier and TypeMethodDescription- static String- fileNameToSite- (String fileName) Converts a logo file name into a potential Website name.Gets the file provider for logos that are persistent.- requestWebLogo- (String site) Requests a new logo for a Website.- static File- siteToFileName- (File root, String site) Gets the file name to use in the file provider for a Website logo.- static String- siteToFileName- (String site) Gets the file name to use in the file provider for a Website logo.- static String- siteToFileName- (String site, int width, int height, int quality) Gets the file name to use in the file provider for a Website logo.- static String- stringToSite- (String site) Converts an URL or email to a potential Website.- static String- urlToSite- (InternetAddress address) Converts an email address into a potential Website name.- static StringConverts a URL into a potential Website name.
- Field Details- DEBUGpublic static final boolean DEBUGThe debug flag.- See Also:
 
- FILE_EXTSSupported file extensions: ".png", ".jpg", ".jpeg", ".gif", ".bmp", ... (".svg" later on).
 
- Constructor Details- WebLogosConstructor. This constructor should NOT be called directly, it is handled from the Server itself.- Parameters:
- server- The server instance.
- Throws:
- IOException- If the COMMON_PERSISTENT file provider could not
- IllegalStateException- If constructor is called outside of the server itself.
 
 
- Method Details- siteToFileNameGets the file name to use in the file provider for a Website logo.- Parameters:
- site- The Website name, e.g. "oracle.com" or "www.oracle.com".
- width- The requested width of the image, range 10-1000.
- height- The requested height of the image, range 10-1000.
- quality- The quality of the image (0=pixel-perfect as PNG, otherwise 1-100 for JPG quality).
- Returns:
- File file name to use as below. File name ends with ".jpg" when qualityis 1-100, or ".png" whenqualityis zero (loss-less). "website-"+site.toLowerCase()+"-logo-"+width+'x'+height+".jpg".
- Throws:
- IllegalArgumentException- If- widthis not in range of 10-1000,- heightis not in range of 10-1000, or- qualityis not in range of 0-100.
 
- siteToFileNameGets the file name to use in the file provider for a Website logo.- Parameters:
- root- The root of the file provider that contains the Website logos. The lastest updated file will be returned with the file name supported.
- site- The Website name, e.g. "oracle.com" or "www.oracle.com".
- Returns:
- File use as "website-"+site.toLowerCase()+"-logo.[png|jpg|...]". The root will be searched for file names that matches the file extensions (.png, .jpg, ...). The one with the latest date is returned. If none is found, nullis returned. If a validfileis returned, it is canonical.
 
- siteToFileNameGets the file name to use in the file provider for a Website logo.- Parameters:
- site- The Website name, e.g. "oracle.com" or "www.oracle.com".
- Returns:
- File file name to use as "website-"+site.toLowerCase()+"-logo.[png|jpg|...]". The default is to return the "png" file extension, although that may not be the one actually used (it is very common though).
 
- fileNameToSiteConverts a logo file name into a potential Website name.- Parameters:
- fileName- The file name.
- Returns:
- The site name, or nullis doesn't follow the rule"website-"+site.toLowerCase()+"-logo.[png|jpg|...]".
 
- urlToSiteConverts a URL into a potential Website name.- Parameters:
- url- The URL.
- Returns:
- The site name, or nullit cannot be established properly. The protocol is not specified (http/https).
- Throws:
- MalformedURLException- If the address cannot be turned into a Website "URL".
 
- urlToSiteConverts an email address into a potential Website name.- Parameters:
- address- The mail address.
- Returns:
- The site name, or nullit cannot be established properly. The protocol is not specified (http/https).
- Throws:
- MalformedURLException- If the address cannot be turned into a Website "URL".
 
- stringToSiteConverts an URL or email to a potential Website.- Parameters:
- site- The string as a potential site.
- Returns:
- The Website name, never null. The protocol is not specified (http/https).
- Throws:
- MalformedURLException
 
- getFileProviderGets the file provider for logos that are persistent.- Returns:
- The file provider.
 
- requestWebLogoRequests a new logo for a Website. If already present, it will be returned directly, otherwise you might have to wait for it using the- WebLogo.waitForCompletion(Runnable)- Parameters:
- site- A URL string where the protocol will be stripped.
- Returns:
- The instance of a WebThumbnail.
- Throws:
- MalformedURLException- If the protocol in invalid.
- IllegalStateException- If the WebThumbs instance is disposed of or was not initialized with a proper API key.