aQute.bnd.url
Class DefaultURLConnectionHandler

java.lang.Object
  extended by aQute.bnd.url.DefaultURLConnectionHandler
All Implemented Interfaces:
Plugin, RegistryPlugin, URLConnectionHandler, Report, Reporter
Direct Known Subclasses:
BasicAuthentication, BndAuthentication, ConnectionSettings, HttpsVerification

public class DefaultURLConnectionHandler
extends Object
implements URLConnectionHandler, Plugin, RegistryPlugin, Reporter

Base class for the URL Connection handlers. This class implements some convenient methods like the matching. In general you should subclass and implement handle(URLConnection). Be aware to call the matches(URLConnection) method to verify the plugin is applicable.


Nested Class Summary
 
Nested classes/interfaces inherited from interface aQute.service.reporter.Reporter
Reporter.SetLocation
 
Nested classes/interfaces inherited from interface aQute.service.reporter.Report
Report.Location
 
Field Summary
protected  Registry registry
           
 
Fields inherited from interface aQute.bnd.service.url.URLConnectionHandler
MATCH
 
Constructor Summary
DefaultURLConnectionHandler()
           
 
Method Summary
 Reporter.SetLocation error(String format, Object... args)
          Create an error.
 Reporter.SetLocation exception(Throwable t, String format, Object... args)
          Dedicated message for an exception.
 List<String> getErrors()
          Return the errors.
 Report.Location getLocation(String msg)
          Return the errors for the given error or warning.
 List<String> getWarnings()
          Return the warnings.
 void handle(URLConnection connection)
          Not doing anything is perfect ok
 boolean isOk()
          Check if this report has any relevant errors that should make the run associated with this report invalid.
 boolean isPedantic()
          The provider of the reporter wants pedantic reporting, meaning every possible warning should be reported.
 boolean matches(URL url)
          Verify if the URL matches one of our globs.
protected  boolean matches(URLConnection connection)
          Convenience method to make it easier to verify connections
 void progress(float progress, String format, Object... args)
          Create a warning.
 void setProperties(Map<String,String> map)
          Set the properties for this plugin.
 void setRegistry(Registry registry)
          We are a @link RegistryPlugin for convenience to our subclasses.
 void setReporter(Reporter processor)
          Set the current reporter.
 void trace(String format, Object... args)
          Create a warning.
 Reporter.SetLocation warning(String format, Object... args)
          Create a warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registry

protected Registry registry
Constructor Detail

DefaultURLConnectionHandler

public DefaultURLConnectionHandler()
Method Detail

handle

public void handle(URLConnection connection)
            throws Exception
Not doing anything is perfect ok

Specified by:
handle in interface URLConnectionHandler
Parameters:
connection - The connection to modify
Throws:
Exception

matches

public boolean matches(URL url)
Verify if the URL matches one of our globs. If there are no globs, we always return true.

Specified by:
matches in interface URLConnectionHandler
Parameters:
url - the url to match
Returns:
true if matched, false if not.

matches

protected boolean matches(URLConnection connection)
Convenience method to make it easier to verify connections

Parameters:
connection - The connection to match
Returns:
true if this connection should be handled.

setRegistry

public void setRegistry(Registry registry)
We are a @link RegistryPlugin for convenience to our subclasses.

Specified by:
setRegistry in interface RegistryPlugin

setProperties

public void setProperties(Map<String,String> map)
                   throws Exception
Set the properties for this plugin. Subclasses should call this method before they handle their own properties.

Specified by:
setProperties in interface Plugin
Parameters:
map - attributes and directives for this plugin's clause
Throws:
Exception

setReporter

public void setReporter(Reporter processor)
Description copied from interface: Plugin
Set the current reporter. This is called at init time. This plugin should report all errors and warnings to this reporter.

Specified by:
setReporter in interface Plugin

getWarnings

public List<String> getWarnings()
Description copied from interface: Report
Return the warnings. This list must not be changed and may be immutable.

Specified by:
getWarnings in interface Report
Returns:
the warnings

getErrors

public List<String> getErrors()
Description copied from interface: Report
Return the errors. This list must not be changed and may be immutable.

Specified by:
getErrors in interface Report
Returns:
the errors

getLocation

public Report.Location getLocation(String msg)
Description copied from interface: Report
Return the errors for the given error or warning. Can return null.

Specified by:
getLocation in interface Report
Parameters:
msg - The message
Returns:
null or the location of the message

isOk

public boolean isOk()
Description copied from interface: Report
Check if this report has any relevant errors that should make the run associated with this report invalid. I.e. if this returns false then the run should be disregarded.

Specified by:
isOk in interface Report
Returns:
true if this run should be disregarded due to errors

error

public Reporter.SetLocation error(String format,
                                  Object... args)
Description copied from interface: Reporter
Create an error. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.

Specified by:
error in interface Reporter
Parameters:
format - The format of the error
args - The arguments of the error
Returns:
a SetLocation to set the location

warning

public Reporter.SetLocation warning(String format,
                                    Object... args)
Description copied from interface: Reporter
Create a warning. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.

Specified by:
warning in interface Reporter
Parameters:
format - The format of the error
args - The arguments of the error
Returns:
a SetLocation to set the location

trace

public void trace(String format,
                  Object... args)
Description copied from interface: Reporter
Create a warning. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.

Specified by:
trace in interface Reporter
Parameters:
format - The format of the error
args - The arguments of the error

progress

public void progress(float progress,
                     String format,
                     Object... args)
Description copied from interface: Reporter
Create a warning. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.

Specified by:
progress in interface Reporter
Parameters:
progress - A value between 0 and 1 indicating the progress. 0 is starting and >=1 is done.
format - The format of the error
args - The arguments of the error

exception

public Reporter.SetLocation exception(Throwable t,
                                      String format,
                                      Object... args)
Description copied from interface: Reporter
Dedicated message for an exception.

Specified by:
exception in interface Reporter
Parameters:
t - The exception
args - The arguments

isPedantic

public boolean isPedantic()
Description copied from interface: Reporter
The provider of the reporter wants pedantic reporting, meaning every possible warning should be reported.

Specified by:
isPedantic in interface Reporter
Returns:
if this is a pedantic reporter.


Copyright © 2014 aQute SARL. All rights reserved.