public class ICalWriter extends Object implements Closeable, Flushable
Writes ICalendar
objects to an iCalendar data stream.
Example:
List<ICalendar> icals = ... OutputStream out = ... ICalWriter icalWriter = new ICalWriter(out); for (ICalendar ical : icals){ icalWriter.write(ical); } icalWriter.close();
Constructor and Description |
---|
ICalWriter(File file)
Creates an iCalendar writer that writes to a file.
|
ICalWriter(File file,
boolean append)
Creates an iCalendar writer that writes to a file.
|
ICalWriter(File file,
boolean append,
FoldingScheme foldingScheme)
Creates an iCalendar writer that writes to a file.
|
ICalWriter(File file,
boolean append,
FoldingScheme foldingScheme,
String newline)
Creates an iCalendar writer that writes to a file.
|
ICalWriter(OutputStream outputStream)
Creates an iCalendar writer that writes to an output stream.
|
ICalWriter(OutputStream outputStream,
FoldingScheme foldingScheme)
Creates an iCalendar writer that writes to an output stream.
|
ICalWriter(OutputStream outputStream,
FoldingScheme foldingScheme,
String newline)
Creates an iCalendar writer that writes to an output stream.
|
ICalWriter(Writer writer)
Creates an iCalendar writer that writes to a writer.
|
ICalWriter(Writer writer,
FoldingScheme foldingScheme)
Creates an iCalendar writer that writes to a writer.
|
ICalWriter(Writer writer,
FoldingScheme foldingScheme,
String newline)
Creates an iCalendar writer that writes to a writer.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying
Writer object. |
void |
flush()
Flushes the stream.
|
FoldingScheme |
getFoldingScheme()
Gets the rules for how each line is folded.
|
String |
getNewline()
Gets the newline sequence that is used to separate lines.
|
ScribeIndex |
getScribeIndex()
Gets the object that manages the component/property scribes.
|
boolean |
isCaretEncodingEnabled()
Gets whether the writer will apply circumflex accent encoding on
parameter values (disabled by default).
|
void |
registerScribe(ICalComponentScribe<? extends ICalComponent> scribe)
Registers an experimental component scribe.
|
void |
registerScribe(ICalPropertyScribe<? extends ICalProperty> scribe)
Registers an experimental property scribe.
|
void |
setCaretEncodingEnabled(boolean enable)
Sets whether the writer will apply circumflex accent encoding on
parameter values (disabled by default).
|
void |
setScribeIndex(ScribeIndex scribe)
Sets the object that manages the component/property scribes.
|
void |
write(ICalendar ical)
Writes an iCalendar object to the data stream.
|
public ICalWriter(OutputStream outputStream)
outputStream
- the output stream to write topublic ICalWriter(OutputStream outputStream, FoldingScheme foldingScheme)
outputStream
- the output stream to write tofoldingScheme
- the folding scheme to use or null not to fold at allpublic ICalWriter(OutputStream outputStream, FoldingScheme foldingScheme, String newline)
outputStream
- the output stream to write tofoldingScheme
- the folding scheme to use or null not to fold at allnewline
- the newline sequence to usepublic ICalWriter(File file) throws FileNotFoundException
file
- the file to write toFileNotFoundException
- if the file cannot be written topublic ICalWriter(File file, boolean append) throws FileNotFoundException
file
- the file to write toappend
- true to append to the end of the file, false to overwrite
itFileNotFoundException
- if the file cannot be written topublic ICalWriter(File file, boolean append, FoldingScheme foldingScheme) throws FileNotFoundException
file
- the file to write toappend
- true to append to the end of the file, false to overwrite
itfoldingScheme
- the folding scheme to use or null not to fold at allFileNotFoundException
- if the file cannot be written topublic ICalWriter(File file, boolean append, FoldingScheme foldingScheme, String newline) throws FileNotFoundException
file
- the file to write toappend
- true to append to the end of the file, false to overwrite
itfoldingScheme
- the folding scheme to use or null not to fold at allnewline
- the newline sequence to useFileNotFoundException
- if the file cannot be written topublic ICalWriter(Writer writer)
writer
- the writer to the data streampublic ICalWriter(Writer writer, FoldingScheme foldingScheme)
writer
- the writer to the data streamfoldingScheme
- the folding scheme to use or null not to fold at allpublic ICalWriter(Writer writer, FoldingScheme foldingScheme, String newline)
writer
- the writer to the data streamfoldingScheme
- the folding scheme to use or null not to fold at allnewline
- the newline sequence to usepublic 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.
ICalRawWriter.isCaretEncodingEnabled()
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.
enable
- true to use circumflex accent encoding, false not toICalRawWriter.setCaretEncodingEnabled(boolean)
public String getNewline()
public FoldingScheme getFoldingScheme()
public void registerScribe(ICalPropertyScribe<? extends ICalProperty> scribe)
Registers an experimental property scribe. Can also be used to override the scribe of a standard property (such as DTSTART). Calling this method is the same as calling:
getScribeIndex().register(scribe)
.
scribe
- the scribe to registerpublic void registerScribe(ICalComponentScribe<? extends ICalComponent> scribe)
Registers an experimental component scribe. Can also be used to override the scribe of a standard component (such as VEVENT). Calling this method is the same as calling:
getScribeIndex().register(scribe)
.
scribe
- the scribe to registerpublic ScribeIndex getScribeIndex()
public void setScribeIndex(ScribeIndex scribe)
scribe
- the scribe indexpublic void write(ICalendar ical) throws IOException
ical
- the iCalendar object to writeIllegalArgumentException
- if the scribe class for a component or
property object cannot be found (only happens when an experimental
property/component scribe is not registered with the
registerScribe
method.)IOException
- if there's a problem writing to the data streampublic void flush() throws IOException
flush
in interface Flushable
IOException
- if there's a problem flushing the streampublic void close() throws IOException
Writer
object.close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2013-2014 Michael Angstadt. All Rights Reserved.