Search this API

y.util
Class WrappedObjectDataProvider

java.lang.Object
  extended by y.util.WrappedObjectDataProvider
All Implemented Interfaces:
DataProvider

public class WrappedObjectDataProvider
extends java.lang.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 data provider will be queried.

 

Constructor Summary
WrappedObjectDataProvider(DataProvider wrapper, DataProvider provider)
          Creates a new instance of WrappedDataProvider.
WrappedObjectDataProvider(DataProvider wrapper, Graph graph, java.lang.Object dataProviderKey)
          Creates a new instance of WrappedDataProvider.
 
Method Summary
 void dispose()
          Disposes previously allocated data structures.
 java.lang.Object get(java.lang.Object dataHolder)
          Returns an object value associated with the given data holder.
 boolean getBool(java.lang.Object dataHolder)
          Returns a boolean value associated with the given data holder.
 DataMap getDataMapView()
          Returns a DataMap that can be used to read and write values.
 double getDouble(java.lang.Object dataHolder)
          Returns a double value associated with the given data holder.
 int getInt(java.lang.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, java.lang.Object dataProviderKey)
          Performs the wrapping, the given DataProvider will be unregistered from the graph and replaced with this instance.
static WrappedObjectDataProvider wrapUsingEdgeMap(Graph graph, java.lang.Object dataProviderKey)
          Creates a new instance of WrappedDataProvider.
static WrappedObjectDataProvider wrapUsingNodeMap(Graph graph, java.lang.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 data provider which will be wrapped by the first one

WrappedObjectDataProvider

public WrappedObjectDataProvider(DataProvider wrapper,
                                 Graph graph,
                                 java.lang.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 data provider
graph - the graph which will be registered with the data providers
dataProviderKey - the key used for registering
Method Detail

getDataMapView

public DataMap getDataMapView()
Returns a DataMap that can be used to read and write values.

Returns:
a DataMap that can be used to read values from the provider and wrapper and to write values to the wrapper.

wrapUsingEdgeMap

public static WrappedObjectDataProvider wrapUsingEdgeMap(Graph graph,
                                                         java.lang.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 DataProvider instance. This can be undone by calling unwrap()

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

wrapUsingNodeMap

public static WrappedObjectDataProvider wrapUsingNodeMap(Graph graph,
                                                         java.lang.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 DataProvider instance. This can be undone by calling unwrap()

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

wrap

public void wrap(Graph g,
                 java.lang.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 data providers
dataProviderKey - the key used for registering

unwrap

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


get

public java.lang.Object get(java.lang.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(java.lang.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(java.lang.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(java.lang.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 data structures. 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-2021,
yWorks GmbH.
All rights reserved.