net.sourceforge.esw.collection
Class URLTransducerAdapter

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

public class URLTransducerAdapter
extends ATransducerAdapter
implements ITransducer

Performs Transduction to or against a URL.

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 IIOTransducer instance provides stream-based access for stream-based ITransducer implementors. It abstracts out the setting and getting of the streams, or the readers and the writers, into this interface.

This implementation of the URLTransducerAdapter delegates all get and put method invocations to the contained IIOTransducer instance. Also, this URLTransducerAdapter instance provides convenience methods to transduce to or against a URL.

Example:

    IMetaCollection meta = MetaFactory.createMetaCollection();
    IIOTransducer transducer = createIOTransducer() // for whatever
                                                    // IIOTransducer instance
                                                    // you need to use.
    URLTransducerAdapter adapter = new URLTransducerAdapter( getURLStream(), // the URL data
                                                             transducer );
    meta.setTransducer( adapter ); // Notice it is the Adapter set on the
                                   // IMetaCollectsion instance!
    try {
      meta.get();
    }
    catch ( TransducerException te ) {
      te.printStackTrace(); // in case something went wrong.
    }
 

See Also:
Serialized Form

Field Summary
protected  java.lang.String url
          The URL for the data this URLTransducerAdapter instance will transduce.
 
Fields inherited from class net.sourceforge.esw.collection.ATransducerAdapter
ioTransducer
 
Constructor Summary
URLTransducerAdapter()
          Creates a new URLTransducerAdapter instance.
URLTransducerAdapter(IIOTransducer aIIOTransducer)
          Creates a new URLTransducerAdapter instance, delegating ITransducer implemented method invocations to the specified IIOTransducer instance.
URLTransducerAdapter(java.lang.String aURL)
          Creates a new URLTransducerAdapter instance with the specified URL.
URLTransducerAdapter(java.lang.String aURL, IIOTransducer aIIOTransducer)
          Creates a new URLTransducerAdapter instance with the specified URL and IIOTransducer instance to which to delegate ITransducer implemented method invocations.
 
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 getURL()
          Returns the URL for this URLTransducerAdapter instance.
 void put(IMetaCollection aCollection)
          Puts the referenced IMetaCollection instance's data into the data source represented by this ITransducer instance.
 void setURL(java.lang.String aURL)
          Sets the name of the URL this URLTransducerAdapter instance will transduce against.
 
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
 
Methods inherited from interface net.sourceforge.esw.collection.ITransducer
getContextFactory, setContextFactory
 

Field Detail

url

protected java.lang.String url
The URL for the data this URLTransducerAdapter instance will transduce.
Constructor Detail

URLTransducerAdapter

public URLTransducerAdapter()
Creates a new URLTransducerAdapter instance.

URLTransducerAdapter

public URLTransducerAdapter(java.lang.String aURL)
Creates a new URLTransducerAdapter instance with the specified URL.
Parameters:
aURL - the String representing the URL this URLTransducerAdapter instance will transduce against.

URLTransducerAdapter

public URLTransducerAdapter(IIOTransducer aIIOTransducer)
Creates a new URLTransducerAdapter instance, delegating ITransducer implemented method invocations to the specified IIOTransducer instance.
Parameters:
aIIOTransducer - the IIOTransducer instance to which to delegate.

URLTransducerAdapter

public URLTransducerAdapter(java.lang.String aURL,
                            IIOTransducer aIIOTransducer)
Creates a new URLTransducerAdapter instance with the specified URL and IIOTransducer instance to which to delegate ITransducer implemented method invocations.
Parameters:
aURL - the String representing the URL this URLTransducerAdapter instance will transduce against.
aIIOTransducer - the IIOTransducer instance to which to delegate.
Method Detail

setURL

public void setURL(java.lang.String aURL)
Sets the name of the URL this URLTransducerAdapter instance will transduce against.
Parameters:
aURL - the String representing the URL this URLTransducerAdapter instance will transduce against.
See Also:
getURL()

getURL

public java.lang.String getURL()
Returns the URL for this URLTransducerAdapter instance.
See Also:
setURL( 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 previously specified URL and sets the Reader instance on the previously specified IIOTransducer instance, then calls get on the IIOTransducer instance.

Specified by:
get in interface ITransducer
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 from the URL and sets the Writer instance on the previously specified IIOTransducer instance, then calls get on the IIOTransducer instance.

Specified by:
put in interface ITransducer
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.