18 package org.turro.vcard.db;
20 import java.io.BufferedReader;
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.Vector;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import org.turro.elephant.context.ElephantContext;
28 import org.turro.vcard.VCard;
29 import org.turro.vcard.properties.Version;
37 private BufferedReader in;
38 private boolean endReached =
false;
44 }
catch (IOException ex) {
50 List<VCard> l =
new ArrayList<VCard>();
52 processLines(l, readNextVCard());
57 private void processLines(List<VCard> l, List<String> lines) {
64 private List<String> readNextVCard() {
65 Vector<String> v =
new Vector<String>();
67 boolean nextAppend =
false;
70 String s = in.readLine();
71 endReached = s ==
null;
73 if(s.equalsIgnoreCase(
"BEGIN:VCARD")) {
76 if(!v.isEmpty() && (nextAppend || s.startsWith(
" "))) {
77 String tmp = v.lastElement();
78 v.add(v.size() - 1, tmp +
" " + s.trim());
81 if(s.endsWith(
"\\n")) {
83 s = s.substring(0, s.length() - 1);
90 }
catch (IOException ex) {
91 Logger.getLogger(
VCardParser.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
static String logMsg(String msg)
void readLines(List< String > lines)
VCardParser(BufferedReader in)
List< VCard > getVCards()
static Version getInstance(List< String > lines)