public abstract class ICalComponent extends Object
Modifier and Type | Field and Description |
---|---|
protected ListMultimap<Class<? extends ICalComponent>,ICalComponent> |
components |
protected ListMultimap<Class<? extends ICalProperty>,ICalProperty> |
properties |
Constructor and Description |
---|
ICalComponent() |
Modifier and Type | Method and Description |
---|---|
void |
addComponent(ICalComponent component)
Adds a sub-component to this component.
|
RawComponent |
addExperimentalComponent(String name)
Adds an experimental sub-component to this component.
|
RawProperty |
addExperimentalProperty(String name,
ICalDataType dataType,
String value)
Adds an experimental property to this component.
|
RawProperty |
addExperimentalProperty(String name,
String value)
Adds an experimental property to this component.
|
void |
addProperty(ICalProperty property)
Adds a property to this component.
|
protected void |
checkOptionalCardinality(List<Warning> warnings,
Class<? extends ICalProperty>... classes)
Utility method for validating that there is no more than one instance of
each of the given properties.
|
protected void |
checkRequiredCardinality(List<Warning> warnings,
Class<? extends ICalProperty>... classes)
Utility method for validating that there is exactly one instance of each
of the given properties.
|
protected void |
checkStatus(List<Warning> warnings,
Status... allowed)
Utility method for validating the
Status property of a component. |
<T extends ICalComponent> |
getComponent(Class<T> clazz)
Gets the first component of a given class.
|
ListMultimap<Class<? extends ICalComponent>,ICalComponent> |
getComponents()
Gets all the sub-components associated with this component.
|
<T extends ICalComponent> |
getComponents(Class<T> clazz)
Gets all components of a given class.
|
RawComponent |
getExperimentalComponent(String name)
Gets the first experimental sub-component with a given name.
|
List<RawComponent> |
getExperimentalComponents()
Gets all experimental sub-components associated with this component.
|
List<RawComponent> |
getExperimentalComponents(String name)
Gets all experimental sub-component with a given name.
|
List<RawProperty> |
getExperimentalProperties()
Gets all experimental properties associated with this component.
|
List<RawProperty> |
getExperimentalProperties(String name)
Gets all experimental properties with a given name.
|
RawProperty |
getExperimentalProperty(String name)
Gets the first experimental property with a given name.
|
ListMultimap<Class<? extends ICalProperty>,ICalProperty> |
getProperties()
Gets all the properties associated with this component.
|
<T extends ICalProperty> |
getProperties(Class<T> clazz)
Gets all properties of a given class.
|
<T extends ICalProperty> |
getProperty(Class<T> clazz)
Gets the first property of a given class.
|
void |
removeComponents(Class<? extends ICalComponent> clazz)
Removes components from the iCalendar object.
|
void |
removeExperimentalComponents(String name)
Removes all experimental sub-components that have the given name.
|
void |
removeExperimentalProperty(String name)
Removes all experimental properties that have the given name.
|
void |
removeProperties(Class<? extends ICalProperty> clazz)
Removes properties from the iCalendar object.
|
<T extends ICalComponent> |
setComponent(Class<T> clazz,
T component)
Replaces all components of a given class with the given component.
|
void |
setComponent(ICalComponent component)
Replaces all components of a given class with the given component.
|
RawComponent |
setExperimentalComponents(String name)
Adds an experimental sub-component to this component, removing all
existing components that have the same name.
|
RawProperty |
setExperimentalProperty(String name,
ICalDataType dataType,
String value)
Adds an experimental property to this component, removing all existing
properties that have the same name.
|
RawProperty |
setExperimentalProperty(String name,
String value)
Adds an experimental property to this component, removing all existing
properties that have the same name.
|
<T extends ICalProperty> |
setProperty(Class<T> clazz,
T property)
Replaces all existing properties of the given class with a single
property instance.
|
void |
setProperty(ICalProperty property)
Replaces all existing properties of the given class with a single
property instance.
|
List<ValidationWarnings.WarningsGroup> |
validate(List<ICalComponent> hierarchy,
ICalVersion version)
Checks the component for data consistency problems or deviations from the
spec.
|
protected void |
validate(List<ICalComponent> components,
ICalVersion version,
List<Warning> warnings)
Checks the component for data consistency problems or deviations from the
spec.
|
protected final ListMultimap<Class<? extends ICalComponent>,ICalComponent> components
protected final ListMultimap<Class<? extends ICalProperty>,ICalProperty> properties
public ICalComponent()
public <T extends ICalProperty> T getProperty(Class<T> clazz)
clazz
- the property classpublic <T extends ICalProperty> List<T> getProperties(Class<T> clazz)
clazz
- the property classpublic ListMultimap<Class<? extends ICalProperty>,ICalProperty> getProperties()
public void addProperty(ICalProperty property)
property
- the property to addpublic void setProperty(ICalProperty property)
property
- the property (must not be null)public <T extends ICalProperty> void setProperty(Class<T> clazz, T property)
clazz
- the property class (e.g. "DateStart.class")property
- the property or null to removepublic void removeProperties(Class<? extends ICalProperty> clazz)
clazz
- the class of the properties to remove (e.g.
"DateStart.class")public void removeComponents(Class<? extends ICalComponent> clazz)
clazz
- the class of the components to remove (e.g. "VEvent.class")public RawProperty getExperimentalProperty(String name)
name
- the property name (e.g. "X-ALT-DESC")public List<RawProperty> getExperimentalProperties(String name)
name
- the property name (e.g. "X-ALT-DESC")public List<RawProperty> getExperimentalProperties()
public RawProperty addExperimentalProperty(String name, String value)
name
- the property name (e.g. "X-ALT-DESC")value
- the property valuepublic RawProperty addExperimentalProperty(String name, ICalDataType dataType, String value)
name
- the property name (e.g. "X-ALT-DESC")dataType
- the property's data type (e.g. "text") or null if unknownvalue
- the property valuepublic RawProperty setExperimentalProperty(String name, String value)
name
- the property name (e.g. "X-ALT-DESC")value
- the property valuepublic RawProperty setExperimentalProperty(String name, ICalDataType dataType, String value)
name
- the property name (e.g. "X-ALT-DESC")dataType
- the property's data type (e.g. "text") or null if unknownvalue
- the property valuepublic void removeExperimentalProperty(String name)
name
- the component name (e.g. "X-ALT-DESC")public <T extends ICalComponent> T getComponent(Class<T> clazz)
clazz
- the component classpublic <T extends ICalComponent> List<T> getComponents(Class<T> clazz)
clazz
- the component classpublic ListMultimap<Class<? extends ICalComponent>,ICalComponent> getComponents()
public void addComponent(ICalComponent component)
component
- the component to addpublic void setComponent(ICalComponent component)
component
- the component (must not be null)public <T extends ICalComponent> void setComponent(Class<T> clazz, T component)
clazz
- the component's classcomponent
- the component or null to removepublic RawComponent getExperimentalComponent(String name)
name
- the component name (e.g. "X-PARTY")public List<RawComponent> getExperimentalComponents(String name)
name
- the component name (e.g. "X-PARTY")public List<RawComponent> getExperimentalComponents()
public RawComponent addExperimentalComponent(String name)
name
- the component name (e.g. "X-PARTY")public RawComponent setExperimentalComponents(String name)
name
- the component name (e.g. "X-PARTY")public void removeExperimentalComponents(String name)
name
- the component name (e.g. "X-PARTY")public final List<ValidationWarnings.WarningsGroup> validate(List<ICalComponent> hierarchy, ICalVersion version)
hierarchy
- the hierarchy of components that the component belongs
toversion
- the version to validate againstICalendar.validate(biweekly.ICalVersion)
protected void validate(List<ICalComponent> components, ICalVersion version, List<Warning> warnings)
Checks the component for data consistency problems or deviations from the spec.
This method should be overridden by child classes that wish to provide validation logic. The default implementation of this method does nothing.
components
- the hierarchy of components that the component belongs
toversion
- the version to validate againstwarnings
- the list to add the warnings toprotected void checkRequiredCardinality(List<Warning> warnings, Class<? extends ICalProperty>... classes)
warnings
- the list to add the warnings toclasses
- the properties to checkprotected void checkOptionalCardinality(List<Warning> warnings, Class<? extends ICalProperty>... classes)
warnings
- the list to add the warnings toclasses
- the properties to checkprotected void checkStatus(List<Warning> warnings, Status... allowed)
Status
property of a component.warnings
- the list to add the warnings toallowed
- the valid statusesCopyright © 2013-2015 Michael Angstadt. All Rights Reserved.