de.smartics.properties.config.transfer.templatestream
Class StreamPropertySink

Package class diagram package StreamPropertySink
java.lang.Object
  extended by de.smartics.properties.config.transfer.templatestream.StreamPropertySink
All Implemented Interfaces:
PropertySink

public final class StreamPropertySink
     
     
extends Object
implements PropertySink

Writes properties to a folder.


Constructor Summary
StreamPropertySink(String template, PrintWriter stream, ValueEscaper escaper)
          Convenience constructor using a default table descriptor with no wrappers.
StreamPropertySink(TableDescriptor descriptor, String template, PrintWriter stream, ValueEscaper escaper)
          Convenience constructor with no wrappers.
StreamPropertySink(TableDescriptor descriptor, Wrapper documentWrapper, Wrapper lineWrapper, String template, PrintWriter stream, ValueEscaper escaper)
          Default constructor.
 
Method Summary
 void clear()
          Removes all information from the sink.
 void close()
          Closes the sink.
 void write(Iterable<PropertyProvider> providers)
          Writes the property definitions provided by the given providers.
 void write(PropertyProvider provider)
          Writes the property definitions provided by the given provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamPropertySink

public StreamPropertySink(String template,
                          PrintWriter stream,
                          ValueEscaper escaper)
                   throws NullPointerException,
                          IllegalArgumentException
Convenience constructor using a default table descriptor with no wrappers.

The stream is closed by calling close() by the client.

Parameters:
template - the template to apply on each property.
stream - the stream to write to.
escaper - the escaper for config key, property name and value.
Throws:
NullPointerException - if template or stream is null.
IllegalArgumentException - if template is blank.

StreamPropertySink

public StreamPropertySink(TableDescriptor descriptor,
                          String template,
                          PrintWriter stream,
                          ValueEscaper escaper)
                   throws NullPointerException,
                          IllegalArgumentException
Convenience constructor with no wrappers.

The stream is closed by calling close() by the client.

Parameters:
descriptor - the descriptor for table and column names to store property values.
template - the template to apply on each property.
stream - the stream to write to.
escaper - the escaper for config key, property name and value.
Throws:
NullPointerException - if template or stream is null.
IllegalArgumentException - if template is blank.

StreamPropertySink

public StreamPropertySink(TableDescriptor descriptor,
                          Wrapper documentWrapper,
                          Wrapper lineWrapper,
                          String template,
                          PrintWriter stream,
                          ValueEscaper escaper)
                   throws NullPointerException,
                          IllegalArgumentException
Default constructor.

The stream is closed by calling close() by the client.

Parameters:
descriptor - the descriptor for table and column names to store property values.
documentWrapper - the introduction to write to the stream at the start.
lineWrapper - the text to write to the stream at the end before closing the stream.
template - the template to apply on each property.
stream - the stream to write to.
escaper - the escaper for config key, property name and value.
Throws:
NullPointerException - if template , stream , or is null.
IllegalArgumentException - if template is blank.
Method Detail

clear

public void clear()
           throws TransferException
Removes all information from the sink.

This implementation is a no-op since a stream cannot be cleared.

Specified by:
clear in interface PropertySink
Throws:
TransferException - on any problem clearing the sink.

write

public void write(PropertyProvider provider)
           throws TransferException
Description copied from interface: PropertySink
Writes the property definitions provided by the given provider.

It is assumed that the writing is transactional. If it is not, the implementation should document that it isn't.

Specified by:
write in interface PropertySink
Parameters:
provider - the provider of property definitions.
Throws:
TransferException - on any problem writing the definitions to this sink.

write

public void write(Iterable<PropertyProvider> providers)
           throws TransferException
Description copied from interface: PropertySink
Writes the property definitions provided by the given providers.

It is assumed that the writing is transactional. If it is not, the implementation should document that it isn't.

Specified by:
write in interface PropertySink
Parameters:
providers - the list of providers to add their property definitions.
Throws:
TransferException - on any problem writing property definitions to this sink.

close

public void close()
           throws TransferException
Closes the sink. No more writing to the sink will be allowed after the sink is closed.

This is a no-op.

Specified by:
close in interface PropertySink
Throws:
TransferException - on any problem closing the sink.


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.