net.sourceforge.esw.collection
Class FileTransducerAdapter

java.lang.Object
  |
  +--net.sourceforge.esw.collection.ATransducerAdapter
        |
        +--net.sourceforge.esw.collection.FileTransducerAdapter
All Implemented Interfaces:
ITransducer, java.io.Serializable

public class FileTransducerAdapter
extends ATransducerAdapter

Provides file based access to ITransducer implementors.

Performs Transduction between a specific data source and an IMetaCollection instance.

This transduction occurs both ways; put() takes data from the IMetaCollection instance to which this ITransducer instance is attached and places it into the data source represented by this ITransducer instance. The get() method takes data from the data source represented by this ITransducer instance and places it into the IMetaCollection instance to which this ITransducer instance is attached.

This FileTransducerAdapter instance provides get and set methods for the file name. It also delegates all get and put method invocations to the contained IIOTransducer instance.

Example:

    IMetaCollection meta = MetaFactory.createMetaCollection();
    IIOTransducer transducer = createIOTransducer() // for whatever
                                                    // IIOTransducer instance
                                                    // you need to use.
    FileTransducerAdapter adapter = new FileTransducerAdapter( "filename.txt",
                                                               transducer );
    meta.setTransducer( adapter ); // Notice: set the adapter on the
                                   // IMetaCollection instance
    try {
      meta.get();
    }
    catch ( TransducerException te ) {
      te.printStackTrace(); // in case something went wrong.
    }
 

See Also:
Serialized Form

Field Summary
protected  java.lang.String filename
          Name of the file represented by this FileTransducerAdapter instance.
 
Fields inherited from class net.sourceforge.esw.collection.ATransducerAdapter
ioTransducer
 
Constructor Summary
FileTransducerAdapter()
          Creates a new FileTransducerAdapter instance.
FileTransducerAdapter(IIOTransducer aIIOTransducer)
          Creates a new FileTransducerAdapter instance, delegating all get and put method invocations to the specified IIOTransducer instance.
FileTransducerAdapter(java.lang.String aFilename)
          Creates a new FileTransducerAdapter instance using the specified file name.
FileTransducerAdapter(java.lang.String aFilename, IIOTransducer aIIOTransducer)
          Creates a new FileTransducerAdapter instance with the specified filename, delegating all get and put method invocations to the specified IIOTransducer instance.
 
Method Summary
 void get(IMetaCollection aCollection)
          Gets the data source's data represented by this ITransducer instance into the referenced IMetaCollection instance.
 java.lang.String getFilename()
          Returns the name of the file for this FileTransducerAdapter instance.
 void put(IMetaCollection aCollection)
          Puts the referenced IMetaCollection instance's data into the data source represented by this ITransducer instance.
 void setFilename(java.lang.String aFileName)
          Sets the name of the file for this FileTransducerAdapter instance.
 
Methods inherited from class net.sourceforge.esw.collection.ATransducerAdapter
getContextFactory, getIOTranducer, setContextFactory, setIOTransducer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filename

protected java.lang.String filename
Name of the file represented by this FileTransducerAdapter instance.
Constructor Detail

FileTransducerAdapter

public FileTransducerAdapter()
Creates a new FileTransducerAdapter instance.

FileTransducerAdapter

public FileTransducerAdapter(java.lang.String aFilename)
Creates a new FileTransducerAdapter instance using the specified file name.
Parameters:
aFilename - the name of the file for this FileTransducerAdapter instance.

FileTransducerAdapter

public FileTransducerAdapter(IIOTransducer aIIOTransducer)
Creates a new FileTransducerAdapter instance, delegating all get and put method invocations to the specified IIOTransducer instance.
Parameters:
aIIOTransducer - the IIOTransducer instance to which to delegate.

FileTransducerAdapter

public FileTransducerAdapter(java.lang.String aFilename,
                             IIOTransducer aIIOTransducer)
Creates a new FileTransducerAdapter instance with the specified filename, delegating all get and put method invocations to the specified IIOTransducer instance.
Parameters:
aFilename - the name of the file for this FileTransducerAdapter instance.
aIIOTransducer - the IIOTransducer instance to which to delegate.
Method Detail

setFilename

public void setFilename(java.lang.String aFileName)
Sets the name of the file for this FileTransducerAdapter instance.
Parameters:
aFileName - the name of the file for this FileTransducerAdapter instance.
See Also:
getFilename()

getFilename

public java.lang.String getFilename()
Returns the name of the file for this FileTransducerAdapter instance.
See Also:
setFilename( String )

get

public void get(IMetaCollection aCollection)
         throws TransducerException
Gets the data source's data represented by this ITransducer instance into the referenced IMetaCollection instance.

This implementation creates a Reader instance on the file specified by the previously specified filename and sets the Reader instance on the previously specified IIOTransducer instance, then calls get on the IIOTransducer instance.

Overrides:
get in class ATransducerAdapter
Parameters:
aCollection - the IMetaCollection instance into which to read.
Throws:
TransducerException - if an error occurs during transduction.
See Also:
put( IMetaCollection )

put

public void put(IMetaCollection aCollection)
         throws TransducerException
Puts the referenced IMetaCollection instance's data into the data source represented by this ITransducer instance.

This implementation creates a Writer instance on the file specified by the previously specified filename and sets the Writer instance on the previously specified IIOTransducer instance, then calls get on the IIOTransducer instance.

Overrides:
put in class ATransducerAdapter
Parameters:
aCollection - the IMetaCollection instance from which to take data.
Throws:
TransducerException - if an error occurs during transduction.
See Also:
get( IMetaCollection )


Copyright 2002 Free Software Foundation. All Rights Reserved.