public String toIcal() {
        StringBuilder buf = new StringBuilder();
        buf.append(this.getName());
        if (hasExtParams()) {
            for (Map.Entry<String, String> param : getExtParams().entrySet()) {
                String k = param.getKey(),
                        v = param.getValue();
                if (ICAL_SPECIALS.matcher(v).find()) {
                    v = "\"" + v + "\"";
                }
                buf.append(';').append(k).append('=').append(v);
            }
        }
        buf.append(":FREQ=").append(freq);
        if (null != wkst) {
            buf.append(";WKST=").append(wkst.toString());
        }
        if (null != this.until) {
            buf.append(";UNTIL=").append(until);
            if (until instanceof TimeValue) {
                buf.append('Z');
            }
        }
        if (count != 0) {
            buf.append(";COUNT=").append(count);
        }
        if (interval != 0) {
            buf.append(";INTERVAL=").append(interval);
        }
        if (0 != byYearDay.length) {
            buf.append(";BYYEARDAY=");
            writeIntList(byYearDay, buf);
        }
        if (0 != byMonth.length) {
            buf.append(";BYMONTH=");
            writeIntList(byMonth, buf);
        }
        if (0 != byMonthDay.length) {
            buf.append(";BYMONTHDAY=");
            writeIntList(byMonthDay, buf);
        }
        if (0 != byWeekNo.length) {
            buf.append(";BYWEEKNO=");
            writeIntList(byWeekNo, buf);
        }
        if (!byDay.isEmpty()) {
            buf.append(";BYDAY=");
            boolean first = true;
            for (WeekdayNum day : this.byDay) {
                if (!first) {
                    buf.append(',');
                } else {
                    first = false;
                }
                buf.append(day);
            }
        }
        if (0 != byHour.length) {
            buf.append(";BYHOUR=");
            writeIntList(byHour, buf);
        }
        if (0 != byMinute.length) {
            buf.append(";BYMINUTE=");
            writeIntList(byMinute, buf);
        }
        if (0 != bySecond.length) {
            buf.append(";BYSECOND=");
            writeIntList(bySecond, buf);
        }
        if (0 != bySetPos.length) {
            buf.append(";BYSETPOS=");
            writeIntList(bySetPos, buf);
        }
        return buf.toString();
    }
public String toIcal ( ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( this . getName ( ) ) ; if ( hasExtParams ( ) ) { for ( Map . Entry < String , String > param : getExtParams ( ) . entrySet ( ) ) { String k = param . getKey ( ) , v = param . getValue ( ) ; if ( ICAL_SPECIALS . matcher ( v ) . find ( ) ) { v = "\"" + v + "\"" ; } buf . append ( ';' ) . append ( k ) . append ( '=' ) . append ( v ) ; } } buf . append ( ":FREQ=" ) . append ( freq ) ; if ( null != wkst ) { buf . append ( ";WKST=" ) . append ( wkst . toString ( ) ) ; } if ( null != this . until ) { buf . append ( ";UNTIL=" ) . append ( until ) ; if ( until instanceof TimeValue ) { buf . append ( 'Z' ) ; } } if ( count != 0 ) { buf . append ( ";COUNT=" ) . append ( count ) ; } if ( interval != 0 ) { buf . append ( ";INTERVAL=" ) . append ( interval ) ; } if ( 0 != byYearDay . length ) { buf . append ( ";BYYEARDAY=" ) ; writeIntList ( byYearDay , buf ) ; } if ( 0 != byMonth . length ) { buf . append ( ";BYMONTH=" ) ; writeIntList ( byMonth , buf ) ; } if ( 0 != byMonthDay . length ) { buf . append ( ";BYMONTHDAY=" ) ; writeIntList ( byMonthDay , buf ) ; } if ( 0 != byWeekNo . length ) { buf . append ( ";BYWEEKNO=" ) ; writeIntList ( byWeekNo , buf ) ; } if ( ! byDay . isEmpty ( ) ) { buf . append ( ";BYDAY=" ) ; boolean first = true ; for ( WeekdayNum day : this . byDay ) { if ( ! first ) { buf . append ( ',' ) ; } else { first = false ; } buf . append ( day ) ; } } if ( 0 != byHour . length ) { buf . append ( ";BYHOUR=" ) ; writeIntList ( byHour , buf ) ; } if ( 0 != byMinute . length ) { buf . append ( ";BYMINUTE=" ) ; writeIntList ( byMinute , buf ) ; } if ( 0 != bySecond . length ) { buf . append ( ";BYSECOND=" ) ; writeIntList ( bySecond , buf ) ; } if ( 0 != bySetPos . length ) { buf . append ( ";BYSETPOS=" ) ; writeIntList ( bySetPos , buf ) ; } return buf . toString ( ) ; }
formats as an *unfolded* RFC 2445 content line.