Package net.fortuna.ical4j.util
Class Calendars
- java.lang.Object
-
- net.fortuna.ical4j.util.Calendars
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getContentType(Calendar calendar, Charset charset)
Returns an appropriate MIME Content-Type for the specified calendar object.static Uid
getUid(Calendar calendar)
Returns a unique identifier as specified by components in the provided calendar.static Calendar
load(String filename)
Loads a calendar from the specified file.static Calendar
load(URL url)
Loads a calendar from the specified URL.static Calendar
merge(Calendar c1, Calendar c2)
Merge all properties and components from two specified calendars into one instance.static Calendar[]
split(Calendar calendar)
Splits a calendar object into distinct calendar objects for unique identifers (UID).static Calendar
wrap(CalendarComponent... component)
Wraps a component in a calendar.
-
-
-
Method Detail
-
load
public static Calendar load(String filename) throws IOException, ParserException
Loads a calendar from the specified file.- Parameters:
filename
- the name of the file from which to load calendar data- Returns:
- returns a new calendar instance initialised from the specified file
- Throws:
IOException
- occurs when there is an error reading the specified fileParserException
- occurs when the data in the specified file is invalid
-
load
public static Calendar load(URL url) throws IOException, ParserException
Loads a calendar from the specified URL.- Parameters:
url
- the URL from which to load calendar data- Returns:
- returns a new calendar instance initialised from the specified URL
- Throws:
IOException
- occurs when there is an error reading from the specified URLParserException
- occurs when the data in the specified URL is invalid
-
merge
public static Calendar merge(Calendar c1, Calendar c2)
Merge all properties and components from two specified calendars into one instance. Note that the merge process is not very sophisticated, and may result in invalid calendar data (e.g. multiple properties of a type that should only be specified once).- Parameters:
c1
- the first calendar to mergec2
- the second calendar to merge- Returns:
- a Calendar instance containing all properties and components from both of the specified calendars
-
wrap
public static Calendar wrap(CalendarComponent... component)
Wraps a component in a calendar.- Parameters:
component
- the component to wrap with a calendar- Returns:
- a calendar containing the specified component
-
split
public static Calendar[] split(Calendar calendar)
Splits a calendar object into distinct calendar objects for unique identifers (UID).- Parameters:
calendar
- a calendar instance- Returns:
- an array of calendar objects
-
getUid
public static Uid getUid(Calendar calendar) throws ConstraintViolationException
Returns a unique identifier as specified by components in the provided calendar.- Parameters:
calendar
- a calendar instance- Returns:
- the UID property
- Throws:
ConstraintViolationException
- if zero or more than one unique identifer is found in the specified calendar
-
-