Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added properties and parameters defined in RFC7986
- Loading branch information
1 parent
93fb02c
commit ec15dda
Showing
19 changed files
with
899 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/groovy/net/fortuna/ical4j/model/parameter/ParameterFactoryWrapper.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package net.fortuna.ical4j.model.parameter | ||
|
||
import net.fortuna.ical4j.model.ParameterFactory | ||
|
||
class ParameterFactoryWrapper extends AbstractFactory { | ||
|
||
Class parameterClass | ||
|
||
ParameterFactory factory | ||
|
||
ParameterFactoryWrapper(Class paramClass, ParameterFactory factory) { | ||
this.parameterClass = paramClass | ||
this.factory = factory | ||
} | ||
|
||
@Override | ||
Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException { | ||
if (FactoryBuilderSupport.checkValueIsTypeNotString(value, name, parameterClass)) { | ||
return value | ||
} | ||
return factory.createParameter(value) | ||
} | ||
|
||
boolean isLeaf() { | ||
return true | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/groovy/net/fortuna/ical4j/model/property/PropertyFactoryWrapper.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package net.fortuna.ical4j.model.property | ||
|
||
import net.fortuna.ical4j.model.Parameter | ||
import net.fortuna.ical4j.model.ParameterList | ||
import net.fortuna.ical4j.model.PropertyFactory | ||
|
||
class PropertyFactoryWrapper extends AbstractFactory { | ||
|
||
Class propertyClass | ||
|
||
PropertyFactory factory | ||
|
||
PropertyFactoryWrapper(Class propClass, PropertyFactory factory) { | ||
this.propertyClass = propClass | ||
this.factory = factory | ||
} | ||
|
||
@Override | ||
Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException { | ||
if (FactoryBuilderSupport.checkValueIsTypeNotString(value, name, propertyClass)) { | ||
return value | ||
} | ||
ParameterList parameters = attributes.remove('parameters') | ||
if (parameters == null) { | ||
parameters = new ParameterList() | ||
} | ||
String propValue = attributes.remove('value') | ||
if (propValue != null) { | ||
return factory.createProperty(parameters, propValue) | ||
} | ||
else { | ||
return factory.createProperty(parameters, value) | ||
} | ||
} | ||
|
||
void setChild(FactoryBuilderSupport build, Object parent, Object child) { | ||
if (child instanceof Parameter) { | ||
parent.parameters.add(child) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/main/java/net/fortuna/ical4j/model/parameter/Display.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package net.fortuna.ical4j.model.parameter; | ||
|
||
import net.fortuna.ical4j.model.Content; | ||
import net.fortuna.ical4j.model.Parameter; | ||
import net.fortuna.ical4j.model.ParameterFactory; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
/** | ||
* <pre> | ||
* Parameter Name: DISPLAY | ||
* | ||
* Purpose: To specify different ways in which an image for a calendar | ||
* or component can be displayed. | ||
* | ||
* Format Definition: This property parameter is defined by the | ||
* following notation: | ||
* | ||
* displayparam = "DISPLAY" "=" displayval *("," displayval) | ||
* | ||
* displayval = ("BADGE" / ; image inline with the title of the | ||
* ; event | ||
* "GRAPHIC" / ; a full image replacement for the event | ||
* ; itself | ||
* "FULLSIZE / ; an image that is used to enhance the | ||
* ; event | ||
* "THUMBNAIL / ; a smaller variant of "FULLSIZE" to be | ||
* ; used when space for the image is | ||
* ; constrained | ||
* x-name / ; Experimental type | ||
* iana-token) ; Other IANA registered type | ||
* ; | ||
* ; Default is BADGE | ||
* | ||
* Description: This property parameter MAY be specified on "IMAGE" | ||
* properties. In the absence of this parameter, the value "BADGE" | ||
* MUST be used for the default behavior. The value determines how a | ||
* client ought to present an image supplied in iCalendar data to the | ||
* user. | ||
* | ||
* Values for this parameter are registered with IANA as per | ||
* Section 8.3. New values can be added to this registry following | ||
* the procedure outlined in Section 8.2.1 of [RFC5545]. | ||
* | ||
* Servers and clients MUST handle x-name and iana-token values they | ||
* don't recognize by not displaying any image at all. | ||
* | ||
* Example: | ||
* | ||
* IMAGE;VALUE=URI;DISPLAY=BADGE,THUMBNAIL,;FMTTYPE=image/png:http://exa | ||
* mple.com/images/weather-cloudy.png | ||
* </pre> | ||
*/ | ||
public class Display extends Parameter { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private static final String PARAMETER_NAME = "DISPLAY"; | ||
|
||
public enum Value { | ||
BADGE, GRAPHIC, FULLSIZE, THUMBNAIL; | ||
} | ||
|
||
private final String[] values; | ||
|
||
public Display(String value) { | ||
super(PARAMETER_NAME, new Factory()); | ||
String[] valueStrings = value.split(","); | ||
for (String valueString : valueStrings) { | ||
try { | ||
Value.valueOf(valueString); | ||
} catch (IllegalArgumentException iae) { | ||
if (!valueString.startsWith(Parameter.EXPERIMENTAL_PREFIX)) { | ||
throw iae; | ||
} | ||
} | ||
} | ||
this.values = valueStrings; | ||
} | ||
|
||
@Override | ||
public String getValue() { | ||
return StringUtils.join(values, ","); | ||
} | ||
|
||
public static class Factory extends Content.Factory implements ParameterFactory { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public Factory() { | ||
super(PARAMETER_NAME); | ||
} | ||
|
||
public Parameter createParameter(final String value) { | ||
return new Display(value); | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/main/java/net/fortuna/ical4j/model/parameter/Email.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package net.fortuna.ical4j.model.parameter; | ||
|
||
import net.fortuna.ical4j.model.Content; | ||
import net.fortuna.ical4j.model.Parameter; | ||
import net.fortuna.ical4j.model.ParameterFactory; | ||
|
||
import javax.mail.internet.AddressException; | ||
import javax.mail.internet.InternetAddress; | ||
|
||
/** | ||
* From specification: | ||
* | ||
* <pre> | ||
* Parameter Name: EMAIL | ||
* | ||
* Purpose: To specify an email address that is used to identify or | ||
* contact an organizer or attendee. | ||
* | ||
* Format Definition: This property parameter is defined by the | ||
* following notation: | ||
* | ||
* emailparam = "EMAIL" "=" param-value | ||
* | ||
* Description: This property parameter MAY be specified on "ORGANIZER" | ||
* or "ATTENDEE" properties. This property can be used in situations | ||
* where the calendar user address value of "ORGANIZER" and | ||
* "ATTENDEE" properties is not likely to be an identifier that | ||
* recipients of scheduling messages could use to match the calendar | ||
* user with, for example, an address book entry. The value of this | ||
* property is an email address that can easily be matched by | ||
* recipients. Recipients can also use this value as an alternative | ||
* means of contacting the calendar user via email. If a recipient's | ||
* calendar user agent allows the recipient to save contact | ||
* information based on the "ORGANIZER" or "ATTENDEE" properties, | ||
* those calendar user agents SHOULD use any "EMAIL" property | ||
* parameter value for the email address of the contact over any | ||
* mailto: calendar user address specified as the value of the | ||
* property. Calendar user agents SHOULD NOT include an "EMAIL" | ||
* property parameter when its value matches the calendar user | ||
* address specified as the value of the property. | ||
* | ||
* Example: | ||
* | ||
* ATTENDEE;CN=Cyrus Daboo;EMAIL=cyrus@example.com:mailto:opaque-toke | ||
* n-1234@example.com | ||
* </pre> | ||
*/ | ||
public class Email extends Parameter { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private static final String PARAMETER_NAME = "EMAIL"; | ||
|
||
private final InternetAddress address; | ||
|
||
public Email(String address) throws AddressException { | ||
super(PARAMETER_NAME, new Factory()); | ||
this.address = InternetAddress.parse(address)[0]; | ||
} | ||
|
||
@Override | ||
public String getValue() { | ||
return address.getAddress(); | ||
} | ||
|
||
public static class Factory extends Content.Factory implements ParameterFactory { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public Factory() { | ||
super(PARAMETER_NAME); | ||
} | ||
|
||
public Parameter createParameter(final String value) { | ||
try { | ||
return new Email(value); | ||
} catch (AddressException e) { | ||
throw new IllegalArgumentException(e); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.