y.util
Class WrappedObjectDataProvider

java.lang.Object
  |
  +--y.util.WrappedObjectDataProvider
All Implemented Interfaces:
DataProvider

public class WrappedObjectDataProvider
extends Object
implements DataProvider

This class can be used to wrap a given DataProvider with another one. It is intended to work with DataProviders providing Objects only. Whenever data is not found in the decorating DataProvider (known as the wrapper). The underlying dataprovider will be queried.


Constructor Summary
WrappedObjectDataProvider(DataProvider wrapper, DataProvider provider)
          Creates a new instance of WrappedDataProvider.
WrappedObjectDataProvider(DataProvider wrapper, Graph graph, Object dataProviderKey)
          Creates a new instance of WrappedDataProvider.
 
Method Summary
 void dispose()
          Disposes previously allocated datastructures.
 Object get(Object dataHolder)
          Returns an object value associated with the given data holder.
 boolean getBool(Object dataHolder)
          Returns a boolean value associated with the given data holder.
 double getDouble(Object dataHolder)
          Returns a double value associated with the given data holder.
 int getInt(Object dataHolder)
          Returns an integer value associated with the given data holder.
 DataProvider getWrappedProvider()
          Gets the underlying wrapped DataProvider.
 DataProvider getWrappingProvider()
          Gets the wrapping DataProvider instance.
 void unwrap()
          Undoes a previous wrap() operation.
 void wrap(Graph g, Object dataProviderKey)
          Performs the wrapping, the given DataProvider will be unregistered from the graph and replaced with this instance.
static WrappedObjectDataProvider wrapUsingEdgeMap(Graph graph, Object dataProviderKey)
          Creates a new instance of WrappedDataProvider.
static WrappedObjectDataProvider wrapUsingNodeMap(Graph graph, Object dataProviderKey)
          Creates a new instance of WrappedDataProvider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WrappedObjectDataProvider

public WrappedObjectDataProvider(DataProvider wrapper,
                                 DataProvider provider)
Creates a new instance of WrappedDataProvider. This instance will delegate queries to the wrapper first. Unsatisfied requests will be delegated to the original second provider.

Parameters:
wrapper - The DataProvider instance which will be queried first
provider - the dataprovider which will be wrapped by the first one

WrappedObjectDataProvider

public WrappedObjectDataProvider(DataProvider wrapper,
                                 Graph graph,
                                 Object dataProviderKey)
Creates a new instance of WrappedDataProvider. This instance will delegate queries to the wrapper first. Unsatisfied requests will be delegated to the original provider. This method wraps the currently registered DataProvider with this. This can be undone by calling unwrap()

Parameters:
wrapper - the wrapping dataprovider
graph - the graph which will be registered with the dataproviders
dataProviderKey - the key used for registering
Method Detail

wrapUsingEdgeMap

public static WrappedObjectDataProvider wrapUsingEdgeMap(Graph graph,
                                                         Object dataProviderKey)
Creates a new instance of WrappedDataProvider. This instance will delegate queries to a newly created EdgeMap wrapper first. Unsatisfied requests will be delegated to the original provider. This method wraps the currently registered DataProvider with the returned DataProvier instance. This can be undone by calling unwrap()

Parameters:
graph - the graph which will be registered with the dataproviders
dataProviderKey - the key used for registering and wrapping

wrapUsingNodeMap

public static WrappedObjectDataProvider wrapUsingNodeMap(Graph graph,
                                                         Object dataProviderKey)
Creates a new instance of WrappedDataProvider. This instance will delegate queries to a newly created NodeMap wrapper first. Unsatisfied requests will be delegated to the original provider. This method wraps the currently registered DataProvider with the returned DataProvier instance. This can be undone by calling unwrap()

Parameters:
graph - the graph which will be registered with the dataproviders
dataProviderKey - the key used for registering and wrapping

wrap

public void wrap(Graph g,
                 Object dataProviderKey)
Performs the wrapping, the given DataProvider will be unregistered from the graph and replaced with this instance.

Parameters:
g - the graph which will be registered with the dataproviders
dataProviderKey - the key used for registering

unwrap

public void unwrap()
Undoes a previous wrap() operation.


get

public Object get(Object dataHolder)
Description copied from interface: DataProvider
Returns an object value associated with the given data holder. This method may throw an UnsupportedOperationException.

Specified by:
get in interface DataProvider

getBool

public boolean getBool(Object dataHolder)
Description copied from interface: DataProvider
Returns a boolean value associated with the given data holder. This method may throw an UnsupportedOperationException.

Specified by:
getBool in interface DataProvider

getDouble

public double getDouble(Object dataHolder)
Description copied from interface: DataProvider
Returns a double value associated with the given data holder. This method may throw an UnsupportedOperationException.

Specified by:
getDouble in interface DataProvider

getInt

public int getInt(Object dataHolder)
Description copied from interface: DataProvider
Returns an integer value associated with the given data holder. This method may throw an UnsupportedOperationException.

Specified by:
getInt in interface DataProvider

getWrappedProvider

public DataProvider getWrappedProvider()
Gets the underlying wrapped DataProvider.

Returns:
the wrapped DataProvider.

getWrappingProvider

public DataProvider getWrappingProvider()
Gets the wrapping DataProvider instance. This can safely be cast to a NodeMap or an EdgeMap respectively if the appropriate static factory methods have been used for the construction of this.

Returns:
the wrapping DataProvider.

dispose

public void dispose()
Disposes previously allocated datastructures. First a call to unwrap() is made. Then the wrappers are disposed from the graph if they are instances of NodeMaps or EdgeMaps respectively.


© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003