P-Grid v2.0a2 API Specification

p2p.storage
Class StorageFactory

java.lang.Object
  extended by p2p.storage.StorageFactory

public abstract class StorageFactory
extends Object

Abstract Factory (GoF) that defines the operations that create various objects of the Storage subsystem. It is recommended to instantiate such types only through a concrete implementation of this factory to avoid hard-coding direct references to them. This class provides static methods to find concrete factories using the reflection API to further decouple the subsystem from its client.

Version:
1.0.0
Author:
@author Roman Schmidt

Constructor Summary
StorageFactory()
           
 
Method Summary
abstract  DataItem createDataItem(Type type, Object data)
          Create a DataItem instance compatible with the Storage implementation.
abstract  Query createQuery(Type type, String queryString)
          Create a Query instance compatible with the Storage implementation.
abstract  Query createQuery(Type type, String lowerBound, String higherBound)
          Create a Query instance compatible with the Storage implementation.
abstract  Storage createStorage(P2P p2p)
          Create the concrete Storage implementation.
abstract  Type createType(String type)
          Creates a Type instance compatible with the Storage implementation.
abstract  void registerTypeHandler(Type type, TypeHandler handler)
          Registers a Type Handler instance for a given Type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StorageFactory

public StorageFactory()
Method Detail

createDataItem

public abstract DataItem createDataItem(Type type,
                                        Object data)
                                 throws NoSuchTypeException
Create a DataItem instance compatible with the Storage implementation.

Parameters:
type - the data item's type
data - the encapsulated data
Returns:
a DataItem instance
Throws:
NoSuchTypeException - if the provided Type is unknown.

createQuery

public abstract Query createQuery(Type type,
                                  String queryString)
                           throws NoSuchTypeException
Create a Query instance compatible with the Storage implementation.

Parameters:
type - the Type of items the query is for
queryString - the string object that defines the query
Returns:
a Query instance
Throws:
NoSuchTypeException - if the provided Type is unknown.

createQuery

public abstract Query createQuery(Type type,
                                  String lowerBound,
                                  String higherBound)
                           throws NoSuchTypeException
Create a Query instance compatible with the Storage implementation.

Parameters:
type - the Type of items the query is for
lowerBound - the string object that defines the lower bound of the query
higherBound - the string object that defines the higher bound of the query
Returns:
a Query instance
Throws:
NoSuchTypeException - if the provided Type is unknown.

createStorage

public abstract Storage createStorage(P2P p2p)
Create the concrete Storage implementation.

Parameters:
p2p - the P2P implementation.
Returns:
the Storage implementation.

createType

public abstract Type createType(String type)
Creates a Type instance compatible with the Storage implementation.

Parameters:
type - an application-specific type to encapsulate
Returns:
a Type instance

registerTypeHandler

public abstract void registerTypeHandler(Type type,
                                         TypeHandler handler)
                                  throws NoSuchTypeException
Registers a Type Handler instance for a given Type.

Parameters:
type - an application-specific type to encapsulate
handler - an application-specific type handler to encapsulate
Throws:
NoSuchTypeException - if the provided Type is unknown.

P-Grid v2.0a2 API Specification

This is open source software distributed under the terms of the GNU General Public License, a copy of which is included in the file LICENSE. If not you can find the GPL at http://www.gnu.org/copyleft/gpl.txt