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;
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.Reader;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ICS Buffered Reader.
|
2009-12-20 05:51:02 -05:00
|
|
|
* Read events by line, handle multiple line elements
|
2009-01-04 09:21:50 -05:00
|
|
|
*/
|
|
|
|
public class ICSBufferedReader extends BufferedReader {
|
|
|
|
protected String nextLine;
|
2009-02-24 06:53:02 -05:00
|
|
|
protected final StringBuilder currentLine = new StringBuilder(75);
|
2009-01-04 09:21:50 -05:00
|
|
|
|
2009-08-13 17:04:46 -04:00
|
|
|
/**
|
|
|
|
* Create an ICS reader on the provided reader
|
|
|
|
* @param in input reader
|
|
|
|
* @throws IOException on error
|
|
|
|
*/
|
2009-01-04 09:21:50 -05:00
|
|
|
public ICSBufferedReader(Reader in) throws IOException {
|
|
|
|
super(in);
|
|
|
|
nextLine = super.readLine();
|
|
|
|
}
|
|
|
|
|
2009-08-13 17:04:46 -04:00
|
|
|
/**
|
|
|
|
* Read a line from input reader, unwrap long lines.
|
|
|
|
*/
|
2009-01-04 09:21:50 -05:00
|
|
|
@Override
|
|
|
|
public String readLine() throws IOException {
|
2009-04-29 18:54:05 -04:00
|
|
|
if (nextLine == null) {
|
2009-01-09 17:41:10 -05:00
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
currentLine.setLength(0);
|
|
|
|
currentLine.append(nextLine);
|
2009-01-04 09:21:50 -05:00
|
|
|
nextLine = super.readLine();
|
2009-03-05 05:24:58 -05:00
|
|
|
while (nextLine != null && !(nextLine.length() == 0) && nextLine.charAt(0) == ' ') {
|
2009-01-09 17:41:10 -05:00
|
|
|
currentLine.append(nextLine.substring(1));
|
|
|
|
nextLine = super.readLine();
|
|
|
|
}
|
|
|
|
return currentLine.toString();
|
2009-01-04 09:21:50 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|