Class LocatorWrapper
- java.lang.Object
-
- net.sf.jguiraffe.locators.LocatorWrapper
-
- All Implemented Interfaces:
Locator
public class LocatorWrapper extends Object implements Locator
A wrapper implementation for locators.
Most concrete
Locator
implementations in this package cannot be extended. (They do not have public constructors, instances can only be created through static factory methods.) If a customLocator
implementation is to be created that can benefit from an existing locator, composition can be used instead of inheritance. To simplify this, this wrapper class is introduced.LocatorWrapper
is an implementation of theLocator
interface that is based on an underlyingLocator
object. All methods are implemented to delegate to this wrapped object. This way inheritance can be emulated by implementing desired functionality before or after delegating to the wrappedLocator
(or skipping the call to this object at all).- Version:
- $Id: LocatorWrapper.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description LocatorWrapper(Locator wrapped)
Creates a new instance ofLocatorWrapper
and initializes it with the given wrapped locator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description File
getFile()
Returns the file this locator points to.InputStream
getInputStream()
Returns the input stream this locator points to.URL
getURL()
Returns the URL this locator points to.Locator
getWrappedLocator()
Returns the wrappedLocator
.
-
-
-
Constructor Detail
-
LocatorWrapper
public LocatorWrapper(Locator wrapped)
Creates a new instance ofLocatorWrapper
and initializes it with the given wrapped locator. Per default, all methods of this class delegate to this object. It must not be null.- Parameters:
wrapped
- the wrapped locator (must not be null)- Throws:
IllegalArgumentException
- if the wrapped locator is null
-
-
Method Detail
-
getWrappedLocator
public Locator getWrappedLocator()
Returns the wrappedLocator
. This is the object this instance will delegate to.- Returns:
- the wrapped
Locator
-
getFile
public File getFile()
Returns the file this locator points to. This implementation delegates to the wrappedLocator
.
-
getInputStream
public InputStream getInputStream() throws IOException
Returns the input stream this locator points to. This implementation delegates to the wrappedLocator
.- Specified by:
getInputStream
in interfaceLocator
- Returns:
- the input stream
- Throws:
IOException
- if an error occurs
-
-