|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiweekly.io.xml.XCalDocument
public class XCalDocument
Represents an XML document that contains iCalendar objects ("xCal" standard). This class can be used to read and write xCal documents.
Examples:
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<icalendar xmlns=\"urn:ietf:params:xml:ns:icalendar-2.0\">" + "<vcalendar>" + "<properties>" + "<prodid><text>-//Example Inc.//Example Client//EN</text></prodid>" + "<version><text>2.0</text></version>" + "</properties>" + "<components>" + "<vevent>" + "<properties>" + "<dtstart><date-time>2013-06-27T13:00:00Z</date-time></dtstart>" + "<dtend><date-time>2013-06-27T15:00:00Z</date-time></dtend>" + "<summary><text>Team Meeting</text></summary>" + "</properties>" + "</vevent>" + "</components>" + "</vcalendar>" + "</icalendar>"; //parsing an existing xCal document XCalDocument xcal = new XCalDocument(xml); List<ICalendar> icals = xcal.parseAll(); //creating an empty xCal document XCalDocument xcal = new XCalDocument(); //ICalendar objects can be added at any time ICalendar ical = new ICalendar(); xcal.add(ical); //retrieving the raw XML DOM Document document = xcal.getDocument(); //call one of the "write()" methods to output the xCal document File file = new File("meeting.xml"); xcal.write(file);
Constructor Summary | |
---|---|
XCalDocument()
Creates an empty xCal document. |
|
XCalDocument(Document document)
Wraps an existing XML DOM object. |
|
XCalDocument(File file)
Parses an xCal document from a file. |
|
XCalDocument(InputStream in)
Parses an xCal document from an input stream. |
|
XCalDocument(Reader reader)
Parses an xCal document from a reader. |
|
XCalDocument(String xml)
Parses an xCal document from a string. |
Method Summary | |
---|---|
void |
add(ICalendar ical)
Adds an iCalendar object to the xCal document. |
Document |
getDocument()
Gets the raw XML DOM object. |
List<List<String>> |
getParseWarnings()
Gets the warnings from the last parse operation. |
List<ICalendar> |
parseAll()
Parses all the ICalendar objects from the xCal document. |
ICalendar |
parseFirst()
Parses the first ICalendar object from the xCal document. |
void |
registerMarshaller(ICalComponentMarshaller<? extends ICalComponent> marshaller)
Registers a marshaller for an experimental component. |
void |
registerMarshaller(ICalPropertyMarshaller<? extends ICalProperty> marshaller)
Registers a marshaller for an experimental property. |
void |
registerParameterDataType(String parameterName,
Value dataType)
Registers the data type of an experimental parameter. |
String |
toString()
|
String |
write()
Writes the xCal document to a string without pretty-printing it. |
void |
write(File file)
Writes the xCal document to a file without pretty-printing it. |
void |
write(File file,
int indent)
Writes the xCal document to a file and pretty-prints it. |
String |
write(int indent)
Writes the xCal document to a string and pretty-prints it. |
void |
write(OutputStream out)
Writes the xCal document to an output stream without pretty-printing it. |
void |
write(OutputStream out,
int indent)
Writes the xCal document to an output stream and pretty-prints it. |
void |
write(Writer writer)
Writes the xCal document to a writer without pretty-printing it. |
void |
write(Writer writer,
int indent)
Writes the xCal document to a writer and pretty-prints it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public XCalDocument(String xml) throws SAXException
xml
- the xCal document in the form of a string
SAXException
- if there's a problem parsing the XMLpublic XCalDocument(InputStream in) throws SAXException, IOException
in
- the input stream to read the the xCal document from
IOException
- if there's a problem reading from the input stream
SAXException
- if there's a problem parsing the XMLpublic XCalDocument(File file) throws SAXException, IOException
file
- the file containing the xCal document
IOException
- if there's a problem reading from the file
SAXException
- if there's a problem parsing the XMLpublic XCalDocument(Reader reader) throws SAXException, IOException
reader
- the reader to read the xCal document from
IOException
- if there's a problem reading from the reader
SAXException
- if there's a problem parsing the XMLpublic XCalDocument(Document document)
document
- the XML DOM that contains the xCal documentpublic XCalDocument()
Method Detail |
---|
public void registerMarshaller(ICalPropertyMarshaller<? extends ICalProperty> marshaller)
marshaller
- the marshaller to registerpublic void registerMarshaller(ICalComponentMarshaller<? extends ICalComponent> marshaller)
marshaller
- the marshaller to registerpublic void registerParameterDataType(String parameterName, Value dataType)
parameterName
- the parameter name (e.g. "x-foo")dataType
- the data type or null to removepublic Document getDocument()
public List<List<String>> getParseWarnings()
ICalendar
object has its own warnings list)parseAll()
,
parseFirst()
public List<ICalendar> parseAll()
ICalendar
objects from the xCal document.
public ICalendar parseFirst()
ICalendar
object from the xCal document.
public void add(ICalendar ical)
ICalendar
object to the XML DOM. This means that any changes that
are made to the ICalendar
object after calling this method will
NOT be applied to the xCal document.
ical
- the iCalendar object to add
IllegalArgumentExeption
- if the marshaller class for a component
or property object cannot be found (only happens when an experimental
property/component marshaller is not registered with the
registerMarshaller
method.)public String write()
public String write(int indent)
indent
- the number of indent spaces to use for pretty-printing
public void write(OutputStream out) throws TransformerException
out
- the output stream
TransformerException
- if there's a problem writing to the output
streampublic void write(OutputStream out, int indent) throws TransformerException
out
- the output streamindent
- the number of indent spaces to use for pretty-printing
TransformerException
- if there's a problem writing to the output
streampublic void write(File file) throws TransformerException, IOException
file
- the file
IOException
- if there's a problem writing to the file
TransformerException
- if there's a problem writing the XMLpublic void write(File file, int indent) throws TransformerException, IOException
file
- the file streamindent
- the number of indent spaces to use for pretty-printing
IOException
- if there's a problem writing to the file
TransformerException
- if there's a problem writing the XMLpublic void write(Writer writer) throws TransformerException
writer
- the writer
TransformerException
- if there's a problem writing to the writerpublic void write(Writer writer, int indent) throws TransformerException
writer
- the writerindent
- the number of indent spaces to use for pretty-printing
TransformerException
- if there's a problem writing to the writerpublic String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |