use of net.fortuna.ical4j.model.property.Method in project bw-calendar-engine by Bedework.
the class IcalTranslator method toIcalString.
/**
* Make a new Calendar with the freebusy object
*
* @param methodType
* @param ent
* @return String representation
* @throws CalFacadeException
*/
public static String toIcalString(final int methodType, final BwEvent ent) throws CalFacadeException {
Calendar cal = new Calendar();
PropertyList pl = cal.getProperties();
pl.add(new ProdId(prodId));
pl.add(Version.VERSION_2_0);
if ((methodType > ScheduleMethods.methodTypeNone) && (methodType < ScheduleMethods.methodTypeUnknown)) {
pl.add(new Method(ScheduleMethods.methods[methodType]));
}
if (ent.getEntityType() == IcalDefs.entityTypeFreeAndBusy) {
VFreeBusy vfreeBusy = VFreeUtil.toVFreeBusy(ent);
cal.getComponents().add(vfreeBusy);
} else {
throw new CalFacadeException("Unexpected entity type");
}
CalendarOutputter co = new CalendarOutputter(false, 74);
Writer wtr = new StringWriter();
try {
co.output(cal, wtr);
} catch (Throwable t) {
throw new CalFacadeException(t);
}
return wtr.toString();
}
use of net.fortuna.ical4j.model.property.Method in project bw-calendar-engine by Bedework.
the class IcalTranslator method newIcal.
/* ====================================================================
* Translation methods
* ==================================================================== */
/**
* Make a new Calendar with default properties
*
* @param methodType
* @return Calendar
* @throws CalFacadeException
*/
public static Calendar newIcal(final int methodType) throws CalFacadeException {
Calendar cal = new Calendar();
PropertyList pl = cal.getProperties();
pl.add(new ProdId(prodId));
pl.add(Version.VERSION_2_0);
if ((methodType > ScheduleMethods.methodTypeNone) && (methodType < ScheduleMethods.methodTypeUnknown)) {
pl.add(new Method(ScheduleMethods.methods[methodType]));
}
return cal;
}
use of net.fortuna.ical4j.model.property.Method in project bw-calendar-engine by Bedework.
the class JcalHandler method calendarProps.
private static void calendarProps(final JsonGenerator jgen, final int methodType) throws CalFacadeException {
try {
jgen.writeString("vcalendar");
jgen.writeStartArray();
JsonProperty.addFields(jgen, new ProdId(IcalTranslator.prodId));
JsonProperty.addFields(jgen, Version.VERSION_2_0);
if ((methodType > ScheduleMethods.methodTypeNone) && (methodType < ScheduleMethods.methodTypeUnknown)) {
JsonProperty.addFields(jgen, new Method(ScheduleMethods.methods[methodType]));
}
jgen.writeEndArray();
} catch (final Throwable t) {
throw new CalFacadeException(t);
}
}
Aggregations