Top Description Fields Constructors Methods
net.fortuna.ical4j.data

public Class HCalendarParser

extends Object
implements CalendarParser
Class Inheritance
All Implemented Interfaces
net.fortuna.ical4j.data.CalendarParser
Imports
net.fortuna.ical4j.model.*, net.fortuna.ical4j.model.parameter.Value, org.apache.commons.lang3.StringUtils, org.slf4j.Logger, .LoggerFactory, org.w3c.dom.*, org.xml.sax.InputSource, .SAXException, .SAXParseException, javax.xml.XMLConstants, javax.xml.parsers.DocumentBuilderFactory, .ParserConfigurationException, javax.xml.xpath.*, java.io.IOException, .InputStream, .Reader, java.text.ParseException, .SimpleDateFormat, java.util.ArrayList, .List

A CalendarParser that parses XHTML documents that include calendar data marked up with the hCalendar microformat.

The parser treats the entire document as a single "vcalendar" context, ignoring any vcalendar elements and adding all components in the document to a single generated calendar.

Since hCalendar does not include product information, the PRODID property is omitted from the generated calendar. The hCalendar profile is supposed to define the iCalendar version that it represents, but it does not, so version 2.0 is assumed.

Supported Components

This parser recognizes only "vevent" components.

Supported Properties

This parser recognizes the following properties:

hCalendar allows for some properties to be represented by nested microformat records, including hCard, adr and geo. This parser does not recognize these records. It simply accumulates the text content of any child elements of the property element and uses the resulting string as the property value.

Date and Date-Time Properties

hCalendar date-time values are formatted according to RFC 3339. There is no representation in this specification for time zone ids. All date-times are specified either in UTC or with an offset that can be used to convert the local time into UTC. Neither does hCal provide a reprsentation for floating date-times. Therefore, all date-time values produced by this parser are in UTC.

Some examples in the wild provide date and date-time values in iCalendar format rather than RFC 3339 format. Although not technically legal according to spec, these values are accepted. In this case, floating date-times are produced by the parser.

Supported Parameters

hCalendar does not define attributes, nested elements or other information elements representing parameter data. Therefore, this parser does not set any property parameters except as implied by property value data (e.g. VALUE=DATE-TIME or VALUE=DATE for date-time properties).

Field Summary

Modifier and TypeField and Description
private static final DocumentBuilderFactory
private static final SimpleDateFormat
private static final String
private static final SimpleDateFormat
private static final String
private static final Logger
private static final XPath
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression
private static final XPathExpression

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
private void
buildEvent(Element element, ContentHandler handler)

private void
buildProperty(Element element, String propName, ContentHandler handler)

private static String
className(String propName)

private static XPathExpression
private static Element
private static List<Element>
private static Node
private static NodeList
private static String
private static Date
icalDate(String original)
References Deprecated Date is deprecated or references (maybe indirectly) at least one deprecated element.

private static boolean
private static boolean
private static boolean
private static boolean
public void
parse(InputStream
an input stream from which to read iCalendar data
in
,
ContentHandler
the content handler to notify during parsing
handler
)

Implements net.fortuna.ical4j.data.CalendarParser.parse.

Parse the iCalendar data from the specified input stream.

public void
parse(Reader
a reader from which to read iCalendar data
in
,
ContentHandler
the content handler to notify during parsing
handler
)

Implements net.fortuna.ical4j.data.CalendarParser.parse.

Parse the iCalendar data from the specified reader.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUILDER_FACTORYback to summary
private static final DocumentBuilderFactory BUILDER_FACTORY
HCAL_DATE_FORMATback to summary
private static final SimpleDateFormat HCAL_DATE_FORMAT
HCAL_DATE_PATTERNback to summary
private static final String HCAL_DATE_PATTERN
HCAL_DATE_TIME_FORMATback to summary
private static final SimpleDateFormat HCAL_DATE_TIME_FORMAT
HCAL_DATE_TIME_PATTERNback to summary
private static final String HCAL_DATE_TIME_PATTERN
LOGback to summary
private static final Logger LOG
XPATHback to summary
private static final XPath XPATH
XPATH_ATTACHback to summary
private static final XPathExpression XPATH_ATTACH
XPATH_ATTENDEEback to summary
private static final XPathExpression XPATH_ATTENDEE
XPATH_CATEGORYback to summary
private static final XPathExpression XPATH_CATEGORY
XPATH_CLASSback to summary
private static final XPathExpression XPATH_CLASS
XPATH_CONTACTback to summary
private static final XPathExpression XPATH_CONTACT
XPATH_DESCRIPTIONback to summary
private static final XPathExpression XPATH_DESCRIPTION
XPATH_DTENDback to summary
private static final XPathExpression XPATH_DTEND
XPATH_DTSTAMPback to summary
private static final XPathExpression XPATH_DTSTAMP
XPATH_DTSTARTback to summary
private static final XPathExpression XPATH_DTSTART
XPATH_DURATIONback to summary
private static final XPathExpression XPATH_DURATION
XPATH_LAST_MODIFIEDback to summary
private static final XPathExpression XPATH_LAST_MODIFIED
XPATH_LOCATIONback to summary
private static final XPathExpression XPATH_LOCATION
XPATH_METHODback to summary
private static final XPathExpression XPATH_METHOD
XPATH_ORGANIZERback to summary
private static final XPathExpression XPATH_ORGANIZER
XPATH_SEQUENCEback to summary
private static final XPathExpression XPATH_SEQUENCE
XPATH_STATUSback to summary
private static final XPathExpression XPATH_STATUS
XPATH_SUMMARYback to summary
private static final XPathExpression XPATH_SUMMARY
XPATH_UIDback to summary
private static final XPathExpression XPATH_UID
XPATH_URLback to summary
private static final XPathExpression XPATH_URL
XPATH_VEVENTSback to summary
private static final XPathExpression XPATH_VEVENTS

Constructor Detail

HCalendarParserback to summary
public HCalendarParser()

Method Detail

buildCalendarback to summary
private void buildCalendar(Document d, ContentHandler handler) throws ParserException, IOException
buildEventback to summary
private void buildEvent(Element element, ContentHandler handler) throws ParserException
buildPropertyback to summary
private void buildProperty(Element element, String propName, ContentHandler handler) throws ParserException
classNameback to summary
private static String className(String propName)
compileExpressionback to summary
private static XPathExpression compileExpression(String expr)
findElementback to summary
private static Element findElement(XPathExpression expr, Object context) throws ParserException
findElementsback to summary
private static List<Element> findElements(XPathExpression expr, Object context) throws ParserException
findNodeback to summary
private static Node findNode(XPathExpression expr, Object context) throws ParserException
findNodesback to summary
private static NodeList findNodes(XPathExpression expr, Object context) throws ParserException
getTextContentback to summary
private static String getTextContent(Element element) throws ParserException
icalDateback to summary
private static Date icalDate(String original) throws ParseException

References Deprecated

Date is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

isDatePropertyback to summary
private static boolean isDateProperty(String name)
isHeaderElementback to summary
private static boolean isHeaderElement(String name)
isTextPropertyback to summary
private static boolean isTextProperty(String name)
isUrlPropertyback to summary
private static boolean isUrlProperty(String name)
parseback to summary
public void parse(InputStream in, ContentHandler handler) throws IOException, ParserException

Implements net.fortuna.ical4j.data.CalendarParser.parse.

Doc from net.fortuna.ical4j.data.CalendarParser.parse.

Parse the iCalendar data from the specified input stream.

Parameters
in:InputStream

an input stream from which to read iCalendar data

handler:ContentHandler

the content handler to notify during parsing

Annotations
@Override
Exceptions
IOException:
thrown when unable to read from the specified stream
ParserException:
thrown if an error occurs during parsing
parseback to summary
public void parse(Reader in, ContentHandler handler) throws IOException, ParserException

Implements net.fortuna.ical4j.data.CalendarParser.parse.

Doc from net.fortuna.ical4j.data.CalendarParser.parse.

Parse the iCalendar data from the specified reader.

Parameters
in:Reader

a reader from which to read iCalendar data

handler:ContentHandler

the content handler to notify during parsing

Annotations
@Override
Exceptions
IOException:
thrown when unable to read from the specified reader
ParserException:
thrown if an error occurs during parsing
parseback to summary
private void parse(InputSource in, ContentHandler handler) throws IOException, ParserException