org.planx.xmlstore.stores
Class TranslatorXMLStore

java.lang.Object
  extended by org.planx.xmlstore.stores.TranslatorXMLStore
All Implemented Interfaces:
ExecXMLStore<ValueReference>, XMLStore<ValueReference>

public class TranslatorXMLStore
extends Object
implements ExecXMLStore<ValueReference>

A bridge between location independent and location dependent XMLStores. The TranslatorXMLStore translates the underlying XMLStores References to ValueReferences that are location independent. Only root nodes (i.e. ones that were at any point argument to the save method) are registered in the translation mapping. The store implements the ExecXMLStore interface, but it will throw UnsupportedOperationException if exec is invoked and the underlying XML Store does not implement the ExecXMLStore interface.

Author:
Thomas Ambus

Constructor Summary
TranslatorXMLStore(LocalXMLStore xmlstore)
           
 
Method Summary
 void close()
          The method is used to let the XMLStore properly commit all data to the underlying ressource, release resources, and so forth.
 ValueReference exec(ValueReference code, ValueReference args)
          Execute the code referenced by codeRef supplied with the argument reference by argsRef.
 NameServer<ValueReference> getNameServer()
          Returns a name server associated with this XML Store.
 Node load(ValueReference ref)
          Loads XML data identified by a reference.
 void release(ValueReference ref)
           
 void retain(ValueReference ref)
           
 ValueReference save(Node n)
          Saves the Node, gives it a ValueReference, and registers it in the local reference server.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TranslatorXMLStore

public TranslatorXMLStore(LocalXMLStore xmlstore)
                   throws IOException
Throws:
IOException
Method Detail

load

public Node load(ValueReference ref)
          throws IOException
Description copied from interface: XMLStore
Loads XML data identified by a reference. The returned value is semi-structured tree data, represented by a "root node" having 0 or more subtrees each represented by Nodes.

Specified by:
load in interface XMLStore<ValueReference>
Parameters:
ref - the Reference to the data
Returns:
node representing the loaded XML data
Throws:
IOException - if an error occurs during disk, network, etc access
UnknownReferenceException - if the data referenced is not stored in the XMLStore or the Reference is of a type not supported by the XMLStore

exec

public ValueReference exec(ValueReference code,
                           ValueReference args)
                    throws IOException,
                           ExecException,
                           UnsupportedOperationException
Description copied from interface: ExecXMLStore
Execute the code referenced by codeRef supplied with the argument reference by argsRef. Returns a reference to the result of the execution.

Specified by:
exec in interface ExecXMLStore<ValueReference>
Parameters:
code - the Reference to a binary node containing class code implementing StoredCode
args - reference to arguments
Returns:
a reference to the result
Throws:
IOException - if an error occurs during loading of code or arguments
ExecException
UnsupportedOperationException

save

public ValueReference save(Node n)
                    throws IOException
Saves the Node, gives it a ValueReference, and registers it in the local reference server.

Specified by:
save in interface XMLStore<ValueReference>
Parameters:
n - representing XML data in the form of semi-structured tree data
Returns:
a reference to the saved node/tree
Throws:
IOException - if an error occurs during disk, network, etc access

retain

public void retain(ValueReference ref)
            throws UnknownReferenceException
Throws:
UnknownReferenceException

release

public void release(ValueReference ref)
             throws UnknownReferenceException
Throws:
UnknownReferenceException

getNameServer

public NameServer<ValueReference> getNameServer()
Returns a name server associated with this XML Store. The returned name server only works for Node's saved in this particular XML Store.

Specified by:
getNameServer in interface XMLStore<ValueReference>

close

public void close()
           throws IOException
Description copied from interface: XMLStore
The method is used to let the XMLStore properly commit all data to the underlying ressource, release resources, and so forth. Once close has been issued on an XMLStore, the store is no longer available for handling requests. Any subsequent request to the store will result in an exception being thrown. An XMLStore implementation has to ensure that this happens.

Specified by:
close in interface XMLStore<ValueReference>
Throws:
IOException - if it is not possible to properly close the store

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2004-2005 Plan-X. All Rights Reserved.