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
Locatorimplementations in this package cannot be extended. (They do not have public constructors, instances can only be created through static factory methods.) If a customLocatorimplementation 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.LocatorWrapperis an implementation of theLocatorinterface that is based on an underlyingLocatorobject. 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 ofLocatorWrapperand initializes it with the given wrapped locator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FilegetFile()Returns the file this locator points to.InputStreamgetInputStream()Returns the input stream this locator points to.URLgetURL()Returns the URL this locator points to.LocatorgetWrappedLocator()Returns the wrappedLocator.
-
-
-
Constructor Detail
-
LocatorWrapper
public LocatorWrapper(Locator wrapped)
Creates a new instance ofLocatorWrapperand 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:
getInputStreamin interfaceLocator- Returns:
- the input stream
- Throws:
IOException- if an error occurs
-
-