com.mucommander.file
Class DefaultSchemeHandler

java.lang.Object
  extended by com.mucommander.file.DefaultSchemeHandler
All Implemented Interfaces:
SchemeHandler

public class DefaultSchemeHandler
extends java.lang.Object
implements SchemeHandler

This class provides a default SchemeHandler implementation. The no-arg constructor creates an instance with default values that suit most schemes. This is how the default URL handler returned by FileURL.getDefaultHandler() is created.
The multi-arg constructor allows to create a scheme handler with specific values.

The getRealm(FileURL) implementation returns a URL with the same scheme and host (if any) as the specified URL, and a path set to "/". This behavior can be modified by overridding getRealm.

Author:
Maxence Bernard
See Also:
FileURL.getDefaultHandler(), SchemeHandler

Field Summary
protected  int authenticationType
           
protected  Credentials guestCredentials
           
protected  SchemeParser parser
           
protected  java.lang.String pathSeparator
           
protected  int standardPort
           
 
Constructor Summary
DefaultSchemeHandler()
          Creates a DefaultSchemeHandler with default values that suit most schemes: the parser is a DefaultSchemeParser instance created with the no-arg constructor the scheme's standard port is -1 the scheme's path separator is "/" authentication type is AuthenticationTypes.NO_AUTHENTICATION guest credentials are null
DefaultSchemeHandler(SchemeParser parser, int standardPort, java.lang.String pathSeparator, int authenticationType, Credentials guestCredentials)
          Creates a DefaultSchemeHandler with the specified values.
 
Method Summary
 int getAuthenticationType()
          Returns the authentication type that was passed to the constructor.
 Credentials getGuestCredentials()
          Returns the set of guest credentials that was passed to the constructor.
 SchemeParser getParser()
          Returns the parser that was passed to the constructor.
 java.lang.String getPathSeparator()
          Returns the path separator that was passed to the constructor.
 FileURL getRealm(FileURL location)
          Returns a URL with the same scheme, host and port (if any) as the specified URL, and a path set to "/".
 int getStandardPort()
          Returns the standard port that was passed to the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

protected SchemeParser parser

standardPort

protected int standardPort

pathSeparator

protected java.lang.String pathSeparator

authenticationType

protected int authenticationType

guestCredentials

protected Credentials guestCredentials
Constructor Detail

DefaultSchemeHandler

public DefaultSchemeHandler()
Creates a DefaultSchemeHandler with default values that suit most schemes:


DefaultSchemeHandler

public DefaultSchemeHandler(SchemeParser parser,
                            int standardPort,
                            java.lang.String pathSeparator,
                            int authenticationType,
                            Credentials guestCredentials)
Creates a DefaultSchemeHandler with the specified values.

Parameters:
parser - the parser that takes care of parsing URL strings and turning them into FileURL
standardPort - the scheme's standard port, -1 for none
pathSeparator - the scheme's path separator, cannot be null
authenticationType - the type of authentication used by the scheme's file protocol
guestCredentials - the scheme's guest credentials, null for none
Method Detail

getParser

public SchemeParser getParser()
Returns the parser that was passed to the constructor.

Specified by:
getParser in interface SchemeHandler
Returns:
the parser that was passed to the constructor

getAuthenticationType

public int getAuthenticationType()
Returns the authentication type that was passed to the constructor.

Specified by:
getAuthenticationType in interface SchemeHandler
Returns:
the authentication type that was passed to the constructor

getGuestCredentials

public Credentials getGuestCredentials()
Returns the set of guest credentials that was passed to the constructor.

Specified by:
getGuestCredentials in interface SchemeHandler
Returns:
the set of guest credentials that was passed to the constructor

getPathSeparator

public java.lang.String getPathSeparator()
Returns the path separator that was passed to the constructor.

Specified by:
getPathSeparator in interface SchemeHandler
Returns:
the path separator that was passed to the constructor

getStandardPort

public int getStandardPort()
Returns the standard port that was passed to the constructor.

Specified by:
getStandardPort in interface SchemeHandler
Returns:
the standard port that was passed to the constructor

getRealm

public FileURL getRealm(FileURL location)
Returns a URL with the same scheme, host and port (if any) as the specified URL, and a path set to "/". The login, password, query and fragment parts of the returned URL are always null. For example, when called with http://www.mucommander.com:8080/path/to/file?query¶m=value, this method returns http://www.mucommander.com:8080/.

Specified by:
getRealm in interface SchemeHandler
Parameters:
location - the location for which to return the authentication realm
Returns:
the authentication realm of the specified location


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard