com.alee.utils
Class WebUtils

java.lang.Object
  extended by com.alee.utils.WebUtils

public final class WebUtils
extends java.lang.Object

This class provides a set of utilities to work with URLs and email addresses.

Author:
Mikle Garin

Constructor Summary
WebUtils()
           
 
Method Summary
static void browseSite(java.lang.String address)
          Opens site in default system web-browser
static void browseSiteSafely(java.lang.String address)
          Opens site in default system web-browser safely
static java.lang.String decodeUrl(java.lang.String url)
          Returns decoded url path.
static java.lang.String encodeUrl(java.lang.String url)
          Returns encoded url path.
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getUrlParameters(java.lang.String url)
          Returns url query parameters.
static java.lang.String normalizeUrl(java.lang.String url)
          Returns normalized url path.
static void openFile(java.io.File file)
          Opens file in appropriate system application
static void openFileSafely(java.io.File file)
          Opens file in appropriate system application safely
static void shareOnFb(java.lang.String address)
          Opens system default web-browser with Facebook share page.
static void shareOnTwitter(java.lang.String address)
          Opens system default web-browser with Twitter share page.
static void shareOnVk(java.lang.String address)
          Opens system default web-browser with VKontakte share page.
static void writeEmail(java.lang.String email)
          Opens system mail agent to compose a new letter
static void writeEmail(java.lang.String email, java.lang.String subject, java.lang.String body)
          Opens system mail agent to compose a new letter
static void writeEmailSafely(java.lang.String email)
          Opens system mail agent to compose a new letter safely
static void writeEmailSafely(java.lang.String email, java.lang.String subject, java.lang.String body)
          Opens system mail agent to compose a new letter safely
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebUtils

public WebUtils()
Method Detail

normalizeUrl

public static java.lang.String normalizeUrl(java.lang.String url)
Returns normalized url path.

Parameters:
url - the url to normalize
Returns:
normalized url

getUrlParameters

public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getUrlParameters(java.lang.String url)
Returns url query parameters.

Parameters:
url - the url to parse
Returns:
parameters map

encodeUrl

public static java.lang.String encodeUrl(java.lang.String url)
Returns encoded url path.

Parameters:
url - the url to encode
Returns:
encoded url

decodeUrl

public static java.lang.String decodeUrl(java.lang.String url)
Returns decoded url path.

Parameters:
url - the url to decode
Returns:
decoded url

shareOnTwitter

public static void shareOnTwitter(java.lang.String address)
Opens system default web-browser with Twitter share page.

Parameters:
address - the address to share

shareOnVk

public static void shareOnVk(java.lang.String address)
Opens system default web-browser with VKontakte share page.

Parameters:
address - the address to share

shareOnFb

public static void shareOnFb(java.lang.String address)
Opens system default web-browser with Facebook share page.

Parameters:
address - the address to share

browseSiteSafely

public static void browseSiteSafely(java.lang.String address)
Opens site in default system web-browser safely

Parameters:
address - the address to open

browseSite

public static void browseSite(java.lang.String address)
                       throws java.net.URISyntaxException,
                              java.io.IOException
Opens site in default system web-browser

Parameters:
address - the address to open
Throws:
java.net.URISyntaxException
java.io.IOException

openFileSafely

public static void openFileSafely(java.io.File file)
Opens file in appropriate system application safely

Parameters:
file - the file to open

openFile

public static void openFile(java.io.File file)
                     throws java.io.IOException
Opens file in appropriate system application

Parameters:
file - the file to open
Throws:
java.io.IOException

writeEmailSafely

public static void writeEmailSafely(java.lang.String email)
Opens system mail agent to compose a new letter safely

Parameters:
email - the destination email address

writeEmail

public static void writeEmail(java.lang.String email)
                       throws java.net.URISyntaxException,
                              java.io.IOException
Opens system mail agent to compose a new letter

Parameters:
email - the destination email address
Throws:
java.net.URISyntaxException
java.io.IOException

writeEmailSafely

public static void writeEmailSafely(java.lang.String email,
                                    java.lang.String subject,
                                    java.lang.String body)
Opens system mail agent to compose a new letter safely

Parameters:
email - the destination email address
subject - letter subject
body - letter text

writeEmail

public static void writeEmail(java.lang.String email,
                              java.lang.String subject,
                              java.lang.String body)
                       throws java.net.URISyntaxException,
                              java.io.IOException
Opens system mail agent to compose a new letter

Parameters:
email - the destination email address
subject - letter subject
body - letter text
Throws:
java.net.URISyntaxException
java.io.IOException