gov.nist.nlpir.irf.proxy
Class PersistentObjectManager

java.lang.Object
  |
  +--gov.nist.nlpir.irf.proxy.PersistentObjectManager

public class PersistentObjectManager
extends java.lang.Object

This class manages the two kinds of objects that may be written to disk in a very short form: Proxies and Handles. Every kind of proxy that must be stored in files, plus every kind of handle that has to be stored in a file, must be registered with this class. This way, the PersistentObjectManager gives them a unique code which ensures an instance of the class will be possible to recreate. Before this class existed, codes had to be given by hand, forcing the IRF user to modify the equivalent class in the framework. Now, an application defining new types of proxies/handles just has to extend this class and registers the extra classes by simply calling addXClassName(), X being either Proxy or Handle, with the class name as a parameter.

Version:
$Revision: 1.3 $
Author:
This software was produced by NIST, an agency of the U.S. government, and by statute is not subject to copyright in the United States. Recipients of this software assume all responsibilities associated with its operation, modification and maintenance.

Field Summary
protected static java.util.Vector handleClassNameVector
          Contains classes that just need a code, and do not necessarily comply to a given class or interface.
protected static int handleClassNumber
          Size of the two previous vectors, used several times.
protected static java.util.Vector handleClassVector
          Contains the Class objects, in order to call isInstance() and newInstance().
protected static java.util.Vector proxyClassNameVector
          Contains the descendants of VirtualProxy class names.
protected static int proxyClassNumber
          Size of the two previous vectors, used several times.
protected static java.util.Vector proxyClassVector
          Contains the VirtualProxy children Class objects, in order to call isInstance() and newInstance().
private static java.lang.Class proxyCranfieldDocumentClass
          Working instance of ProxyDE...
private static java.lang.Class proxyDeDoubleClass
          Working instance of ProxyDE...
private static java.lang.Class proxyDeHtml_Class
          Working instance of ProxyDE...
private static java.lang.Class proxyDeIntegerClass
          Working instance of ProxyDE...
private static java.lang.Class proxyDePersonNameClass
          Working instance of ProxyDE...
private static java.lang.Class proxyDeStringClass
          Working instance of ProxyDE...
private static java.lang.Class proxyFbisDocumentClass
          Working instance of ProxyDE...
private static java.lang.Class proxyHciDocClass
          Working instance of ProxyDE...
private static java.lang.Class proxyIdxFeatWordInStringClass
           
private static java.lang.Class proxyIdxFeatWordInTextClass
           
private static java.lang.Class proxyIndexingFeatureClass
           
 
Constructor Summary
PersistentObjectManager()
           
 
Method Summary
static void addHandleClassName(java.lang.String handleClassName)
          Registers a new handle class with this manager.
static void addProxyClassName(java.lang.String proxyClassName)
          Registers a new proxy class with this manager.
static ProxyDataElem buildDE(BufferedRandomAccessFile braf)
          Returns a Proxy Data Element of the type associated with the value in the byte[] passed
static ProxyDocument buildDoc(BufferedRandomAccessFile braf)
          Builds a proxy IR document from serialized data in the specified file
static Handle buildHandle(BufferedRandomAccessFile braf)
           
static ProxyIndexingFeature buildIF(BufferedRandomAccessFile braf)
          This method builds an IndexingFeature from the BufferedRandomAccessFile used.
static VirtualProxy buildProxy(BufferedRandomAccessFile braf)
          Builds the proxy found in the given file at its current file pointer.
static void defaultInit()
           
static int getDE_Type(DataElem de)
          Returns a code indicating the type of the data element passed
static int getDocType(ProxyDocument ird)
          Returns a code indicating the type of proxy IR document passed
static int getHandleType(Handle handle)
          Returns a unique code for every kind of Handle that may be encountered.
static int getIF_Type(ProxyIndexingFeature IF)
          This method is a perfect candidate for a general ObjectProvider class that would centralize them.
private static int getProxyType(VirtualProxy theProxy)
          Returns the assigned code to the class of this proxy.
static void init()
          This method assigns a code to every class, and reorganizes the name vectors so that indexes of names in them match the given code.
protected static void personalizedInit(java.util.Vector proxyClassNames, java.util.Vector handleClassNames)
          This constructor allows to perfectly tune the classes managed, specifying all of them and not just using the default ones provided by the no argument constructor.
static void present()
          Presents the different codes assigned to the proxy/handle classes.
static Handle reflectiveBuildHandle(BufferedRandomAccessFile braf)
          Builds the handle which is supposed to be found in the given file at its current file pointer.
private static int reflectiveGetHandleType(Handle theHandle)
          Returns the code assigned to the class of the given handle.
static void reflectiveWriteHandle(Handle theHandle, BufferedRandomAccessFile braf)
          Writes the given handle in the given file where the file pointer is currently.
static void writeDE(ProxyDataElem theProxy, BufferedRandomAccessFile braf)
          Writes the given proxy in the given file.
static void writeDoc(ProxyDocument theProxy, BufferedRandomAccessFile braf)
          Writes the given proxy in the given file.
static void writeHandle(Handle handle, BufferedRandomAccessFile braf)
           
static void writeIF(ProxyIndexingFeature theProxy, BufferedRandomAccessFile braf)
          Writes the given proxy in the given file.
static void writeProxy(VirtualProxy theProxy, BufferedRandomAccessFile braf)
          Writes the given proxy in the given file.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

proxyClassNameVector

protected static java.util.Vector proxyClassNameVector
Contains the descendants of VirtualProxy class names.

proxyClassVector

protected static java.util.Vector proxyClassVector
Contains the VirtualProxy children Class objects, in order to call isInstance() and newInstance().

proxyClassNumber

protected static int proxyClassNumber
Size of the two previous vectors, used several times.

handleClassNameVector

protected static java.util.Vector handleClassNameVector
Contains classes that just need a code, and do not necessarily comply to a given class or interface.

handleClassVector

protected static java.util.Vector handleClassVector
Contains the Class objects, in order to call isInstance() and newInstance().

handleClassNumber

protected static int handleClassNumber
Size of the two previous vectors, used several times.

proxyDeHtml_Class

private static java.lang.Class proxyDeHtml_Class
Working instance of ProxyDE... class

proxyDeStringClass

private static java.lang.Class proxyDeStringClass
Working instance of ProxyDE... class

proxyDePersonNameClass

private static java.lang.Class proxyDePersonNameClass
Working instance of ProxyDE... class

proxyDeDoubleClass

private static java.lang.Class proxyDeDoubleClass
Working instance of ProxyDE... class

proxyDeIntegerClass

private static java.lang.Class proxyDeIntegerClass
Working instance of ProxyDE... class

proxyHciDocClass

private static java.lang.Class proxyHciDocClass
Working instance of ProxyDE... class

proxyFbisDocumentClass

private static java.lang.Class proxyFbisDocumentClass
Working instance of ProxyDE... class

proxyCranfieldDocumentClass

private static java.lang.Class proxyCranfieldDocumentClass
Working instance of ProxyDE... class

proxyIndexingFeatureClass

private static java.lang.Class proxyIndexingFeatureClass

proxyIdxFeatWordInStringClass

private static java.lang.Class proxyIdxFeatWordInStringClass

proxyIdxFeatWordInTextClass

private static java.lang.Class proxyIdxFeatWordInTextClass
Constructor Detail

PersistentObjectManager

public PersistentObjectManager()
Method Detail

personalizedInit

protected static void personalizedInit(java.util.Vector proxyClassNames,
                                       java.util.Vector handleClassNames)
This constructor allows to perfectly tune the classes managed, specifying all of them and not just using the default ones provided by the no argument constructor.

defaultInit

public static void defaultInit()

addProxyClassName

public static void addProxyClassName(java.lang.String proxyClassName)
Registers a new proxy class with this manager.
Parameters:
proxyClassName - The complete name of the proxy class to register

addHandleClassName

public static void addHandleClassName(java.lang.String handleClassName)
Registers a new handle class with this manager.
Parameters:
handleClassName - The complete name of the handle class to register

init

public static void init()
This method assigns a code to every class, and reorganizes the name vectors so that indexes of names in them match the given code.

writeProxy

public static void writeProxy(VirtualProxy theProxy,
                              BufferedRandomAccessFile braf)
                       throws java.io.IOException
Writes the given proxy in the given file. This class ensures that buildProxy() called at the same offset in the file will recreate this proxy.

getProxyType

private static int getProxyType(VirtualProxy theProxy)
Returns the assigned code to the class of this proxy.

buildProxy

public static VirtualProxy buildProxy(BufferedRandomAccessFile braf)
                               throws java.io.IOException
Builds the proxy found in the given file at its current file pointer.

reflectiveWriteHandle

public static void reflectiveWriteHandle(Handle theHandle,
                                         BufferedRandomAccessFile braf)
                                  throws java.io.IOException
Writes the given handle in the given file where the file pointer is currently.

reflectiveGetHandleType

private static int reflectiveGetHandleType(Handle theHandle)
Returns the code assigned to the class of the given handle. This code will allow the manager to know which type of handle it was when it has to rebuild one that was stored on disk.

reflectiveBuildHandle

public static Handle reflectiveBuildHandle(BufferedRandomAccessFile braf)
                                    throws java.io.IOException
Builds the handle which is supposed to be found in the given file at its current file pointer.

present

public static void present()
Presents the different codes assigned to the proxy/handle classes.

getDE_Type

public static int getDE_Type(DataElem de)
Returns a code indicating the type of the data element passed
Returns:
code

getDocType

public static int getDocType(ProxyDocument ird)
Returns a code indicating the type of proxy IR document passed
Returns:
document type code

writeDE

public static void writeDE(ProxyDataElem theProxy,
                           BufferedRandomAccessFile braf)
                    throws java.io.IOException
Writes the given proxy in the given file. This class ensures that buildProxy() called at the same offset in the file will recreate this proxy.

writeDoc

public static void writeDoc(ProxyDocument theProxy,
                            BufferedRandomAccessFile braf)
                     throws java.io.IOException
Writes the given proxy in the given file. This class ensures that buildProxy() called at the same offset in the file will recreate this proxy.

buildDE

public static ProxyDataElem buildDE(BufferedRandomAccessFile braf)
                             throws java.io.IOException
Returns a Proxy Data Element of the type associated with the value in the byte[] passed
Returns:
DataElem

buildDoc

public static ProxyDocument buildDoc(BufferedRandomAccessFile braf)
                              throws java.io.IOException
Builds a proxy IR document from serialized data in the specified file
Returns:
the deserialized proxy IR document

buildHandle

public static Handle buildHandle(BufferedRandomAccessFile braf)
                          throws java.io.IOException

getHandleType

public static int getHandleType(Handle handle)
Returns a unique code for every kind of Handle that may be encountered.
Parameters:
handle - Handle for which a code is to be returned
Returns:
the code for the specified handle

writeHandle

public static void writeHandle(Handle handle,
                               BufferedRandomAccessFile braf)
                        throws java.io.IOException

buildIF

public static ProxyIndexingFeature buildIF(BufferedRandomAccessFile braf)
                                    throws java.io.IOException
This method builds an IndexingFeature from the BufferedRandomAccessFile used. It reads the code assigned to the IF, and then creates the IF with the needed class.

writeIF

public static void writeIF(ProxyIndexingFeature theProxy,
                           BufferedRandomAccessFile braf)
                    throws java.io.IOException
Writes the given proxy in the given file. This class ensures that buildProxy() called at the same offset in the file will recreate this proxy.

getIF_Type

public static int getIF_Type(ProxyIndexingFeature IF)
This method is a perfect candidate for a general ObjectProvider class that would centralize them. Many different classes may want to store IndexingFeatures.
Returns:
an arbitrary code for the given IF. But this code will allow to completely rebuild the IF.