ecologylab.net
Class ConnectionAdapter

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.net.ConnectionAdapter
All Implemented Interfaces:
ConnectionHelper

public class ConnectionAdapter
extends Debug
implements ConnectionHelper

Adapter class to make it easier to use ParsedURL.connect(). The only method that you need to implement is parseFilesWithSuffix(String suffix).

Author:
andruid

Constructor Summary
ConnectionAdapter()
           
 
Method Summary
 void badResult()
          Called at the end of processing, if it turns out that something went wrong while opening the connection.
 void displayStatus(java.lang.String message)
          Used to provid status feedback to the user.
 void handleFileDirectory(java.io.File file)
          When this method is called, you know the file is a directory.
 boolean parseFilesWithSuffix(java.lang.String suffix)
          Tells the connect() method that it should go ahead and create a PURLConnection for all files that it finds.
 boolean processRedirect(java.net.URL connectionURL)
          Shuffle referential models when a redirect is observed, if you like.
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectionAdapter

public ConnectionAdapter()
Method Detail

handleFileDirectory

public void handleFileDirectory(java.io.File file)
When this method is called, you know the file is a directory. This implementation does nothing. connect() will return null in this special case.

Specified by:
handleFileDirectory in interface ConnectionHelper
Parameters:
file -

badResult

public void badResult()
Called at the end of processing, if it turns out that something went wrong while opening the connection. This version does nothing.

Specified by:
badResult in interface ConnectionHelper

displayStatus

public void displayStatus(java.lang.String message)
Used to provid status feedback to the user. The default implementation prints the message to the console.

Specified by:
displayStatus in interface ConnectionHelper
Parameters:
message -

processRedirect

public boolean processRedirect(java.net.URL connectionURL)
                        throws java.lang.Exception
Shuffle referential models when a redirect is observed, if you like. The default implementation allows all re-directs and keeps track of nothing.

Specified by:
processRedirect in interface ConnectionHelper
Parameters:
connectionURL -
Returns:
true if the redirect is o.k., and we should continue processing the connect(). false if the redirect is unacceptable, and we should terminate processing.
Throws:
java.lang.Exception

parseFilesWithSuffix

public boolean parseFilesWithSuffix(java.lang.String suffix)
Tells the connect() method that it should go ahead and create a PURLConnection for all files that it finds.

Specified by:
parseFilesWithSuffix in interface ConnectionHelper
Parameters:
suffix -
Returns:
true