biweekly.io.text
Class ICalRawWriter

java.lang.Object
  extended by biweekly.io.text.ICalRawWriter
All Implemented Interfaces:
Closeable

public class ICalRawWriter
extends Object
implements Closeable

Writes data to an iCalendar data stream.

Author:
Michael Angstadt
Specification Reference:
RFC 5545

Nested Class Summary
static interface ICalRawWriter.ParameterValueChangedListener
          Allows you to respond to when a parameter's value is changed due to it containing invalid characters.
 
Constructor Summary
ICalRawWriter(Writer writer)
          Creates an iCalendar raw writer using the standard folding scheme and newline sequence.
ICalRawWriter(Writer writer, FoldingScheme foldingScheme)
          Creates an iCalendar raw writer using the standard newline sequence.
ICalRawWriter(Writer writer, FoldingScheme foldingScheme, String newline)
          Creates an iCalendar raw writer.
 
Method Summary
 void close()
          Closes the underlying Writer object.
 FoldingScheme getFoldingScheme()
          Gets the rules for how each line is folded.
 String getNewline()
          Gets the newline sequence that is used to separate lines.
 ICalRawWriter.ParameterValueChangedListener getParameterValueChangedListener()
          Gets the listener which will be invoked when a parameter's value is changed due to containing invalid characters.
 boolean isCaretEncodingEnabled()
           Gets whether the writer will apply circumflex accent encoding on parameter values (disabled by default).
 void setCaretEncodingEnabled(boolean enable)
           Sets whether the writer will apply circumflex accent encoding on parameter values (disabled by default).
 void setParameterValueChangedListener(ICalRawWriter.ParameterValueChangedListener parameterValueChangedListener)
          Sets the listener which will be invoked when a parameter's value is changed due to containing invalid characters.
 void writeBeginComponent(String componentName)
          Writes a property marking the beginning of a component (in other words, writes a "BEGIN:NAME" property).
 void writeEndComponent(String componentName)
          Writes a property marking the end of a component (in other words, writes a "END:NAME" property).
 void writeProperty(String propertyName, ICalParameters parameters, String value)
          Writes a property to the iCalendar data stream.
 void writeProperty(String propertyName, String value)
          Writes a property to the iCalendar data stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ICalRawWriter

public ICalRawWriter(Writer writer)
Creates an iCalendar raw writer using the standard folding scheme and newline sequence.

Parameters:
writer - the writer to the data stream

ICalRawWriter

public ICalRawWriter(Writer writer,
                     FoldingScheme foldingScheme)
Creates an iCalendar raw writer using the standard newline sequence.

Parameters:
writer - the writer to the data stream
foldingScheme - the folding scheme to use or null not to fold at all

ICalRawWriter

public ICalRawWriter(Writer writer,
                     FoldingScheme foldingScheme,
                     String newline)
Creates an iCalendar raw writer.

Parameters:
writer - the writer to the data stream
foldingScheme - the folding scheme to use or null not to fold at all
newline - the newline sequence to use
Method Detail

isCaretEncodingEnabled

public boolean isCaretEncodingEnabled()

Gets whether the writer will apply circumflex accent encoding on parameter values (disabled by default). This escaping mechanism allows for newlines and double quotes to be included in parameter values.

When disabled, the writer will replace newlines with spaces and double quotes with single quotes.

Character Replacement
(when disabled)
Replacement
(when enabled)
" ' ^'
newline space ^n
^ ^ ^^

Example:

 GEO;X-ADDRESS="Pittsburgh Pirates^n115 Federal St^nPitt
  sburgh, PA 15212":40.446816;80.00566
 

Returns:
true if circumflex accent encoding is enabled, false if not
Specification Reference:
RFC 6868

setCaretEncodingEnabled

public void setCaretEncodingEnabled(boolean enable)

Sets whether the writer will apply circumflex accent encoding on parameter values (disabled by default). This escaping mechanism allows for newlines and double quotes to be included in parameter values.

When disabled, the writer will replace newlines with spaces and double quotes with single quotes.

Character Replacement
(when disabled)
Replacement
(when enabled)
" ' ^'
newline space ^n
^ ^ ^^

Example:

 GEO;X-ADDRESS="Pittsburgh Pirates^n115 Federal St^nPitt
  sburgh, PA 15212":40.446816;80.00566
 

Parameters:
enable - true to use circumflex accent encoding, false not to
Specification Reference:
RFC 6868

getNewline

public String getNewline()
Gets the newline sequence that is used to separate lines.

Returns:
the newline sequence

getParameterValueChangedListener

public ICalRawWriter.ParameterValueChangedListener getParameterValueChangedListener()
Gets the listener which will be invoked when a parameter's value is changed due to containing invalid characters.

Returns:
the listener or null if not set

setParameterValueChangedListener

public void setParameterValueChangedListener(ICalRawWriter.ParameterValueChangedListener parameterValueChangedListener)
Sets the listener which will be invoked when a parameter's value is changed due to containing invalid characters.

Parameters:
parameterValueChangedListener - the listener or null to remove

getFoldingScheme

public FoldingScheme getFoldingScheme()
Gets the rules for how each line is folded.

Returns:
the folding scheme or null if the lines are not folded

writeBeginComponent

public void writeBeginComponent(String componentName)
                         throws IOException
Writes a property marking the beginning of a component (in other words, writes a "BEGIN:NAME" property).

Parameters:
componentName - the component name (e.g. "VEVENT")
Throws:
IOException - if there's an I/O problem

writeEndComponent

public void writeEndComponent(String componentName)
                       throws IOException
Writes a property marking the end of a component (in other words, writes a "END:NAME" property).

Parameters:
componentName - the component name (e.g. "VEVENT")
Throws:
IOException - if there's an I/O problem

writeProperty

public void writeProperty(String propertyName,
                          String value)
                   throws IOException
Writes a property to the iCalendar data stream.

Parameters:
propertyName - the property name (e.g. "VERSION")
value - the property value (e.g. "2.0")
Throws:
IllegalArgumentException - if the property name contains invalid characters
IOException - if there's an I/O problem

writeProperty

public void writeProperty(String propertyName,
                          ICalParameters parameters,
                          String value)
                   throws IOException
Writes a property to the iCalendar data stream.

Parameters:
propertyName - the property name (e.g. "VERSION")
parameters - the property parameters
value - the property value (e.g. "2.0")
Throws:
IllegalArgumentException - if the property name contains invalid characters
IOException - if there's an I/O problem

close

public void close()
           throws IOException
Closes the underlying Writer object.

Specified by:
close in interface Closeable
Throws:
IOException


Copyright © 2013 Michael Angstadt. All Rights Reserved.