Search in sources :

Example 1 with Method

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();
}
Also used : PropertyList(net.fortuna.ical4j.model.PropertyList) StringWriter(java.io.StringWriter) VFreeBusy(net.fortuna.ical4j.model.component.VFreeBusy) BwCalendar(org.bedework.calfacade.BwCalendar) Calendar(net.fortuna.ical4j.model.Calendar) Method(net.fortuna.ical4j.model.property.Method) CalendarOutputter(net.fortuna.ical4j.data.CalendarOutputter) ProdId(net.fortuna.ical4j.model.property.ProdId) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) Writer(java.io.Writer) StringWriter(java.io.StringWriter)

Example 2 with Method

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;
}
Also used : PropertyList(net.fortuna.ical4j.model.PropertyList) BwCalendar(org.bedework.calfacade.BwCalendar) Calendar(net.fortuna.ical4j.model.Calendar) Method(net.fortuna.ical4j.model.property.Method) ProdId(net.fortuna.ical4j.model.property.ProdId)

Example 3 with Method

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);
    }
}
Also used : Method(net.fortuna.ical4j.model.property.Method) ProdId(net.fortuna.ical4j.model.property.ProdId) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

Method (net.fortuna.ical4j.model.property.Method)3 ProdId (net.fortuna.ical4j.model.property.ProdId)3 Calendar (net.fortuna.ical4j.model.Calendar)2 PropertyList (net.fortuna.ical4j.model.PropertyList)2 BwCalendar (org.bedework.calfacade.BwCalendar)2 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)2 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 CalendarOutputter (net.fortuna.ical4j.data.CalendarOutputter)1 VFreeBusy (net.fortuna.ical4j.model.component.VFreeBusy)1