org.apache.commons.feedparser.locate
Class ResourceExpander

java.lang.Object
  |
  +--org.apache.commons.feedparser.locate.ResourceExpander

public class ResourceExpander
extends java.lang.Object

Version:
$Id: ResourceExpander.java 159217 2005-03-27 23:47:14Z burton $

Field Summary
protected static java.util.regex.Pattern schemePattern
          A regexp to determine if a URL has a scheme, such as "http://foo.com".
 
Constructor Summary
ResourceExpander()
           
 
Method Summary
static java.lang.String expand(java.lang.String resource, java.lang.String link)
          Expand a link relavant to the current site.
static java.lang.String getBase(java.lang.String resource)
          Get the base of this URL.
static java.lang.String getDomain(java.lang.String resource)
          Given a URL get the domain name.
static java.lang.String getSite(java.lang.String resource)
          Get the site for this resource.
static boolean hasScheme(java.lang.String resource)
          Determines if the given resource has a scheme.
static boolean isExpanded(java.lang.String resource)
          Return true if the given link is ALREADY relativized..
static boolean isValidScheme(java.lang.String resource)
          Return true if this is an valid scheme and should be expanded.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schemePattern

protected static java.util.regex.Pattern schemePattern
A regexp to determine if a URL has a scheme, such as "http://foo.com".

Constructor Detail

ResourceExpander

public ResourceExpander()
Method Detail

expand

public static java.lang.String expand(java.lang.String resource,
                                      java.lang.String link)
Expand a link relavant to the current site. This takes care of links such as /foo.html -> http://site.com/base/foo.html foo.html -> http://site.com/base/foo.html Links should *always* be expanded before they are used. This is because if we use the URL http://site.com/base then we don't know if it's a directory or a file. http://site.com/base/ would be a directory. Note that all resource URLs will have correct trailing slashes. If the URL does not end with / then it is a file URL and not a directory.

Parameters:
resource - The absolute base URL that will be used to expand the link, such as "http://www.codinginparadise.org".
link - The link to possibly expand, such as "/index.rdf" or "http://www.somehost.com/somepage.html".

isExpanded

public static boolean isExpanded(java.lang.String resource)
Return true if the given link is ALREADY relativized..


isValidScheme

public static boolean isValidScheme(java.lang.String resource)
Return true if this is an valid scheme and should be expanded.


hasScheme

public static boolean hasScheme(java.lang.String resource)
Determines if the given resource has a scheme. (i.e. does it start with "http://foo.com" or does it just have "foo.com").


getSite

public static java.lang.String getSite(java.lang.String resource)
Get the site for this resource. For example: http://www.foo.com/directory/index.html we will return http://www.foo.com for file: URLs we return file://


getDomain

public static java.lang.String getDomain(java.lang.String resource)
Given a URL get the domain name.


getBase

public static java.lang.String getBase(java.lang.String resource)
Get the base of this URL. For example if we are given: http://www.foo.com/directory/index.html we will return http://www.foo.com/directory


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
java.lang.Exception


Copyright © 2004-2006 Apache Software Foundation. All Rights Reserved.