2009-07-21 04:39:18 -04:00
|
|
|
/*
|
|
|
|
* DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
|
|
|
|
* Copyright (C) 2009 Mickael Guessant
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2009-01-04 09:21:50 -05:00
|
|
|
package davmail.exchange;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ICS String writer.
|
|
|
|
* split lines longer than 75 characters
|
|
|
|
*/
|
|
|
|
public class ICSBufferedWriter {
|
2009-02-24 06:53:02 -05:00
|
|
|
final StringBuilder buffer = new StringBuilder();
|
2009-01-04 09:21:50 -05:00
|
|
|
|
2009-11-02 17:56:08 -05:00
|
|
|
/**
|
|
|
|
* Write content to buffer, do not split lines.
|
|
|
|
*
|
|
|
|
* @param content ics content
|
|
|
|
*/
|
|
|
|
public void write(String content) {
|
|
|
|
if (content != null) {
|
|
|
|
buffer.append(content);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-13 17:04:46 -04:00
|
|
|
/**
|
|
|
|
* Write line to buffer, split lines at 75 characters.
|
2009-09-21 17:34:13 -04:00
|
|
|
*
|
2009-08-13 17:04:46 -04:00
|
|
|
* @param line ics event line
|
|
|
|
*/
|
2009-01-04 09:21:50 -05:00
|
|
|
public void writeLine(String line) {
|
|
|
|
if (line.length() > 75) {
|
|
|
|
buffer.append(line.substring(0, 75));
|
|
|
|
newLine();
|
|
|
|
buffer.append(' ');
|
|
|
|
writeLine(line.substring(75));
|
|
|
|
} else {
|
|
|
|
buffer.append(line);
|
2010-05-13 08:36:45 -04:00
|
|
|
newLine();
|
2009-01-04 09:21:50 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-16 09:30:36 -04:00
|
|
|
public void newLine() {
|
2009-01-04 09:21:50 -05:00
|
|
|
buffer.append((char) 13).append((char) 10);
|
|
|
|
}
|
|
|
|
|
2009-08-13 17:04:46 -04:00
|
|
|
/**
|
|
|
|
* Get buffer as String
|
2009-09-21 17:34:13 -04:00
|
|
|
*
|
2009-08-13 17:04:46 -04:00
|
|
|
* @return ICS content as String
|
|
|
|
*/
|
2009-01-04 09:21:50 -05:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2009-09-21 17:34:13 -04:00
|
|
|
return buffer.toString();
|
2009-01-04 09:21:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|