org.apache.commons.vfs2.provider.url
Class UrlFileNameParser

java.lang.Object
  extended by org.apache.commons.vfs2.provider.AbstractFileNameParser
      extended by org.apache.commons.vfs2.provider.url.UrlFileNameParser
All Implemented Interfaces:
FileNameParser

public class UrlFileNameParser
extends AbstractFileNameParser

Implementation for any java.net.url based filesystem.
Composite of URLFilenameParser and GenericFilenameParser

Author:
Commons VFS team

Constructor Summary
UrlFileNameParser()
           
 
Method Summary
protected  int countSlashes(String filename)
          This method counts the slashes after the scheme.
 boolean encodeCharacter(char ch)
          Check if a character needs encoding (%nn).
protected  boolean isUrlBased(FileName base, String filename)
          Guess is the given filename is a url with host or not.
 FileName parseUri(VfsComponentContext context, FileName base, String filename)
          Parse a URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlFileNameParser

public UrlFileNameParser()
Method Detail

encodeCharacter

public boolean encodeCharacter(char ch)
Description copied from interface: FileNameParser
Check if a character needs encoding (%nn).

Specified by:
encodeCharacter in interface FileNameParser
Overrides:
encodeCharacter in class AbstractFileNameParser
Parameters:
ch - the character
Returns:
true if character should be encoded

parseUri

public FileName parseUri(VfsComponentContext context,
                         FileName base,
                         String filename)
                  throws FileSystemException
Parse a URI.

Parameters:
context - The component context.
base - The base FileName.
filename - The target file name.
Returns:
The FileName.
Throws:
FileSystemException - if an error occurs

isUrlBased

protected boolean isUrlBased(FileName base,
                             String filename)
Guess is the given filename is a url with host or not. VFS treats such urls differently.
A filename is url-based if the base is a URLFileName or there are only 2 slashes after the scheme.
e.g: http://host/path, file:/path/to/file, file:///path/to/file


countSlashes

protected int countSlashes(String filename)
This method counts the slashes after the scheme.

Parameters:
filename - The file name.
Returns:
number of slashes


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.