HTML Parser Home Page

org.htmlparser.util
Class LinkProcessor

java.lang.Object
  extended byorg.htmlparser.util.LinkProcessor
All Implemented Interfaces:
Serializable

public class LinkProcessor
extends Object
implements Serializable

Processor class for links, is present basically as a utility class.

See Also:
Serialized Form

Constructor Summary
LinkProcessor()
          Create an HTMLLinkProcessor.
 
Method Summary
 URL constructUrl(String link, String base)
           
 String extract(String link, String base)
          Create an absolute URL from a possibly relative link and a base URL.
static String fixSpaces(String url)
          Turn spaces into %20.
 String getBaseUrl()
          Returns the baseUrl.
static boolean isURL(String resourceLocn)
          Check if a resource is a valid URL.
static String removeLastSlash(String baseUrl)
           
 void setBaseUrl(String baseUrl)
          Sets the baseUrl.
 String stripQuotes(String string)
          Remove double or single quotes from the string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkProcessor

public LinkProcessor()
Create an HTMLLinkProcessor.

Method Detail

extract

public String extract(String link,
                      String base)
Create an absolute URL from a possibly relative link and a base URL.

Parameters:
link - The reslative portion of a URL.
base - The base URL unless overridden by the current baseURL property.
Returns:
The fully qualified URL or the original link if a failure occured.

stripQuotes

public String stripQuotes(String string)
Remove double or single quotes from the string.


constructUrl

public URL constructUrl(String link,
                        String base)
                 throws MalformedURLException
Throws:
MalformedURLException

fixSpaces

public static String fixSpaces(String url)
Turn spaces into %20.

Parameters:
url - The url containing spaces.
Returns:
The URL with spaces as %20 sequences.

isURL

public static boolean isURL(String resourceLocn)
Check if a resource is a valid URL.

Parameters:
resourceLocn - The resource to test.
Returns:
true if the resource is a valid URL.

getBaseUrl

public String getBaseUrl()
Returns the baseUrl.

Returns:
String

setBaseUrl

public void setBaseUrl(String baseUrl)
Sets the baseUrl.

Parameters:
baseUrl - The baseUrl to set

removeLastSlash

public static String removeLastSlash(String baseUrl)

© 2004 Somik Raha
Mar 14, 2004

HTML Parser is an open source library released under LGPL.
SourceForge.net